<pre>Hello everybody,<br>I try to use Pmw library -> ScrollListBox. If I take the example of the reference web site (see below, I just quote the minimal code to launch, I note by <----- the line which are not execute when I click)<br>
It works, except selectioncommand and dblclickcommand: associate function doesn't run when I click one or two time. <br>Could you have an idea about that ? Is it about my tried code ?<br><br>Thank,<br><br>Guilhem<br><br>
<br><br>from Tkinter import *<br>import Pmw<br>#from pymol import *<br><br>class Demo:<br> def __init__(self):<br> parent=Tk()<br> Pmw.initialise(parent)<br> # Create the ScrolledListBox.<br> self.box = Pmw.ScrolledListBox(parent,<br>
items=('Sydney', 'Melbourne', 'Brisbane'),<br> labelpos='nw',<br> label_text='Cities',<br> listbox_height = 6,<br> selectioncommand=self.selectionCommand,<br>
dblclickcommand=self.defCmd,<br> usehullsize = 1,<br> hull_width = 200,<br> hull_height = 200,<br> )<br><br> # Create a group widget to contain the scrollmode options.<br>
w = Pmw.Group(parent, tag_text='Scroll mode')<br> w.pack(side = 'bottom', padx = 5, pady = 5)<br><br> hmode = Pmw.OptionMenu(w.interior(),<br> labelpos = 'w',<br>
label_text = 'Horizontal:',<br> items = ['none', 'static', 'dynamic'],<br> command = self.sethscrollmode,<br> menubutton_width = 8,<br>
)<br> hmode.pack(side = 'top', padx = 5, pady = 5)<br> hmode.invoke('dynamic')<br><br> vmode = Pmw.OptionMenu(w.interior(),<br> labelpos = 'w',<br> label_text = 'Vertical:',<br>
items = ['none', 'static', 'dynamic'],<br> command = self.setvscrollmode,<br> menubutton_width = 8,<br> )<br> vmode.pack(side = 'top', padx = 5, pady = 5)<br>
vmode.invoke('dynamic')<br><br> buttonBox = Pmw.ButtonBox(parent)<br> buttonBox.pack(side = 'bottom')<br> buttonBox.add('yview', text = 'Show\nyview', command = self.showYView)<br>
buttonBox.add('scroll', text = 'Page\ndown', command = self.pageDown)<br> buttonBox.add('center', text = 'Center', command = self.centerPage)<br><br> # Pack this last so that the buttons do not get shrunk when<br>
# the window is resized.<br> self.box.pack(fill = 'both', expand = 1, padx = 5, pady = 5)<br><br> # Do this after packing the scrolled list box, so that the<br> # window does not resize as soon as it appears (because<br>
# alignlabels has to do an update_idletasks).<br> Pmw.alignlabels((hmode, vmode))<br><br> <br> def sethscrollmode(self, tag):<br> self.box.configure(hscrollmode = tag)<br><br> def setvscrollmode(self, tag):<br>
self.box.configure(vscrollmode = tag)<br><br> def selectionCommand(self):<br> print "toto" # <----------- doesn t run !!!<br> def defCmd(self):<br> print "toto2" # <----------- doen t run !!!<br>
<br> def showYView(self):<br> print self.box.yview()<br><br> def pageDown(self):<br> self.box.yview('scroll', 1, 'page')<br><br> def centerPage(self):<br> top, bottom = self.box.yview()<br>
size = bottom - top<br> middle = 0.5 - size / 2<br> self.box.yview('moveto', middle)<br><br><br>Demo()<br></pre>
<center><p align="center">
<br>
</p></center>