Hey there,
In the application I'm building, I'm using Python 2.5 to place a toolbar
from Matplotlib 0.98.5.2 in a Qt 4 environment. Now I'd like to modify the
toolbar to suit our needs. So, I've done the following:
> from PyQt4 import QtGui
> from matplotlib.backends.backend_qt4 import NavigationToolbar2QT
> from matplotlib.backend_bases import NavigationToolbar2
>
> class Toolbar(NavigationToolbar2QT) :
> def __init__(self , parent , canvas, coordinates=True) :
> self.canvas = canvas
> self.coordinates = coordinates
> QtGui.QWidget.__init__( self, parent )
> NavigationToolbar2.__init__( self, canvas )
>
I'd like to delete the configure subplots button, and add a new button in
it's place. However, I can't seem to find the configure subplots button, as
it is not listed in its method/object list. So, I had to use this crude
method:
> pushButtonCounter = -1
> for child in self.children():
> if str( type(child) ) == "<class
> 'PyQt4.QtGui.QToolButton'>":
> pushButtonCounter += 1
> if pushButtonCounter == 6:
> configuresubplots_button = child
>
Also, Python 2.5 crashes when trying to do certain things with the button:
> configuresubplots_button.deleteLater() # Crashes
> # Ugh, I forgot what other kinds of operations make Python
> crash... I
> think trying to connect and disconnect functions didn't go right... not
> sure though.
>
These things, however, do work (or at least don't make Python crash):
> configuresubplots_button.setEnabled(False) # Works
> configuresubplots_button.setHidden(True) # Does not work, but
> doesn't
> cause a crash, either.
> configuresubplots_button.setIcon(QtGui.QIcon('newicon.PNG')) #
> Works
> configuresubplots_button.setToolTip('Another tool tip') # Works
> configuresubplots_button.connect(child,
> QtCore.SIGNAL('clicked()'),
> self.new_fuction) # Works, though this should only be done after you
> instantiate this class in your GUI. So, you have to loop again to find the
> button to connect it.
>
So, in the end, I managed to change the configure_subplots button into the
button I want. However, such a method should not be necessary.
The question is whether I was doing something wrong, and if so, how I could
have done this differently?
My sincere thanks for your time and efforts!
Cheers,
Gert-Jan
--
View this message in context:
http://www.nabble.com/Qt4-backend-question-tp24110367p24110367.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users