> To: tutor@python.org > From: __pete...@web.de > Date: Sat, 12 Mar 2016 10:28:36 +0100 > Subject: Re: [Tutor] Pmw/Tkinter question > > Albert-Jan Roskam wrote: > > > Hello, > > > > Below is a slightly modified example about Pmw/Tkinter from > > http://pmw.sourceforge.net/doc/howtouse.html. I changed the geometry > > manager from 'pack' to 'grid', because I use that in all other parts of my > > program. The problem is, 'broccoli' won't display nicely under vege_menu. > > I want it to left-align, not center (I don't case that it's truncated). In > > plain Tkinter I could do "self.vege_menu.configure(anchor=Tkinter.W)" but > > this raises a KeyError in Pmw. > > I don't see an official way to to change the alignment, but looking into the > source there's > > class OptionMenu(Pmw.MegaWidget): > > def __init__(self, parent = None, **kw): > > [...] > self._menubutton = self.createcomponent('menubutton', > (), None, > Tkinter.Menubutton, (interior,), > borderwidth = 2, > indicatoron = 1, > relief = 'raised', > anchor = 'c', > highlightthickness = 2, > direction = 'flush', > takefocus = 1, > ) > > so if you don't mind touching _private attributes > > > self.vege_menu = Pmw.OptionMenu (parent, > > labelpos = 'w', > > label_text = 'Choose vegetable:', > > items = ('broccoli-broccoli-broccoli-broccoli', 'peas', > > 'carrots', 'pumpkin'), menubutton_width = 10, > > command = self._printOrder, > > ) > self.vege_menu._menubutton.config(anchor=Tkinter.W) > > > #self.vege_menu.pack(anchor = 'w', padx = 10, pady = 10) > > self.vege_menu.grid(row=1, column=0, sticky = 'w', padx = 10, pady > > = 10) > > should work.
Ahh, yes, that works! Thank you!! I should indeed have looked at the source myself. The Tk website is often informative, but not everything is exposed by Tkinter/Pmw. This is also the first time I tried Pmw. A lot less verbose than Tkinter, but it takes some time to learn the names/meaning of various parameters. They differ from the equivalent params in Tkinter and are often more descriptive, but pre-existing knowledge of Tkinter creates some "noise". Best wishes, Albert-Jan _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor