[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] Calling Custom Widget from Designer Code
From:       Phil Thompson <phil () riverbankcomputing ! com>
Date:       2008-01-30 19:39:47
Message-ID: 200801301939.47688.phil () riverbankcomputing ! com
[Download RAW message or body]

On Wednesday 30 January 2008, Clowers, Brian H wrote:
> So I'm stumped.  I've created a GUI in designer and have successfully
> added a matplotlib canvas to a mainwindow by promoting a custom widget
> class.  I've named the canvas "mpl_widget".  Now my problem is the
> following:  I would like to be able to be able to update and clear the
> matplotlib canvas but I cannot seem to access it when I building the
> GUI.  I've shown my problem below.  Basically I'd like to access the
> widget and by extension the normal functions associated with the
> matplotlib API.  Any ideas on how to make this work?  It would seem
> silly to have to define all of the specific functions to access the
> matplotlib API in the custom widget class.  Any help would be greatly
> appreciated.  (To run the attached example files you'll need matplotlib,
> numpy, and obviously PyQt4)
>
> Cheers,
>
> Brian
>
> class Main_Window(QMainWindow):
>     def __init__(self):
>         QMainWindow.__init__(self)
>         self.ui = Ui_MainWindow()
>         self.ui.setupUi(self)
>
>
>         x = N.arange(0,10, 0.2)
>         y = N.sin(x)
>         ###The Problem Area###
>         self.mpl_widget.ax.plot(x,y)
>         ######################
>
>  <<Subplot.py>>  <<ui_Subplot.py>>  <<mpl_custom_widget.py>>

mpl_widget is an attribute of self.ui, not self.

Phil
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic