PyTk cascaded radiobuttons, howto?
Using python 3.4.2. Tcl/tk example here is from /usr/share/tk8.5/demos/widget and .../menu.tcl. The way tcl/tk adds cascaded radiobuttons to a menu is like this: set m $w.menu.cascade $w.menu add cascade -label "Cascades" -menu $m -underline 0 $m add cascade -label "Radio buttons" -menu $w.menu.cascade.radio... set m $w.menu.cascade.radio $m add radio -label "Roman" -variable style... $m add radio -label "Italic" -variable style... ...and so on. My difficulty doing the same in PyTk is the following: When creating that uppermost cascade, you do something like menu.add_cascade(label = "Cascades") ...but there is no ability to save a usable reference to that top-level cascade. If I do so anyway and add a radiobutton to it, nothing appears, no errors either. What is the correct way to cascade radiobuttons from a cascaded menu in PyTk? ThanksNick -- https://mail.python.org/mailman/listinfo/python-list
Re: PyTk cascaded radiobuttons, howto?
This is of course using tkinter from python, PyTk is a misnomer. Python 3.4.2 wit tcl/tk 8.5 under CentOS 7. -- https://mail.python.org/mailman/listinfo/python-list
pygtk2 and colors
Morning- With python 2.7.5, pygtk 2.24, gtk 2.24: The following snippet successfully sets the line_width but not the foreground color, and I can't figure-out why. The color human-name and the result returned by gtk.gdk.color_parse are correct. Clues? Thanks. self.gc.set_line_attributes(myclass.board_line_width, gtk.gdk.LINE_SOLID, gtk.gdk.CAP_ROUND, gtk.gdk.JOIN_BEVEL) fg = gtk.gdk.color_parse(myclass.board_foreground) self.gc.set_foreground(fg) -- https://mail.python.org/mailman/listinfo/python-list
Re: pygtk2 and colors
On Tuesday, July 7, 2015 at 11:54:21 AM UTC-5, Cousin Stanley wrote: > You might try > > self.set_rgb_fg_color( fg ) Well thanks, that works. Yet set_rgb_bg_color() does not. And I notice that the example at the link you sent doesn't set the background color either. Do I have a color overlay or masking issue? I guess what bothers me is that this is such a basic thing, the reference doc is almost useless on the subject, the usual response is "look at this example", and each example does it differently than every other example. -- https://mail.python.org/mailman/listinfo/python-list
Re: pygtk2 and colors
On Tuesday, July 7, 2015 at 12:58:12 PM UTC-5, Chris Angelico wrote: > > Part of your confusion may be because "background" isn't necessarily > what you think it is. Indeed. Yet "foreground" _is_ what I think it is :-) I would argue that we have here a clumsy intrusion of OO inheritance into a context which doesn't consistently support it. I don't mind inheritance; I do mind clumsiness and inconsistency. -- https://mail.python.org/mailman/listinfo/python-list
Re: pygtk2 and colors
I may be phrasing this question improperly, but...If I need a canvas or canvas-like object, does GTK3/pygobject provide one? Or only GTK2/PyGTK? The answer seems to be "only GTK2/PyGTK" but the discussion I find online doesn't seem to have a clear answer. -- https://mail.python.org/mailman/listinfo/python-list
Re: beginners choice: wx or tk?
I've recently been facing the same question but with a new (probably simpler) app than your own. I've decided to re-implement what I have in tk, replacing GTK in the python code. I am no expert in either but I find tk to be more coherent at the API level and better documented. However Windows and Mac support is not necessarily an issue for me. -- https://mail.python.org/mailman/listinfo/python-list
tkinter resize question
Resizing a tkinter window which contains a frame which contains a button widget, will not change the current size of the window, frame or button as recorded in their height and width attributes (at least not if they are resizable). What is the correct way to detect their current size? -- https://mail.python.org/mailman/listinfo/python-list
Re: tkinter resize question
On Friday, July 17, 2015 at 1:53:19 PM UTC-5, nickge...@gmail.com wrote: > Resizing a tkinter window which contains a frame which contains a button > widget, will not change the current size of the window, frame or button as > recorded in their height and width attributes (at least not if they are > resizable). What is the correct way to detect their current size? Ok, partially answering my own question: The geometry of the window will change (win.geometry()), but the changes do not appear to "propagate" to the retrieved width/height of the child widgets, frames, etc. Or am I incorrect with this? -- https://mail.python.org/mailman/listinfo/python-list
Re: tkinter resize question
On Friday, July 17, 2015 at 2:52:56 PM UTC-5, Russell Owen wrote: > On 7/17/15 12:17 PM, nickgeova...@gmail.com wrote: > > On Friday, July 17, 2015 at 1:53:19 PM UTC-5, nickge...@gmail.com wrote: > >> Resizing a tkinter window which contains a frame which contains a button > >> widget, will not change the current size of the window, frame or button as > >> recorded in their height and width attributes (at least not if they are > >> resizable). What is the correct way to detect their current size? > > > > Ok, partially answering my own question: > > The geometry of the window will change (win.geometry()), but the changes do > > not appear to "propagate" to the retrieved width/height of the child > > widgets, frames, etc. Or am I incorrect with this? > > I'm not seeing it. If I try the following script I see that resizing the > widget does update frame.winfo_width() and winfo_height. (I also see > that the requested width and height are ignored; you can omit those). > > -- Russell > > > #!/usr/bin/env python > import Tkinter > root = Tkinter.Tk() > > frame = Tkinter.Frame(root, width=100, height=50) > frame.pack(expand=True, fill="both") > def doReport(*args): > print "frame actualwidth=%s, height=%s" % (frame.winfo_width(), > frame.winfo_height()) > print "frame requested width=%s, height=%s" % > (frame.winfo_reqwidth(), frame.winfo_reqheight()) > button = Tkinter.Button(frame, text="Report", command=doReport) > button.pack() > > root.mainloop() So my mistake was, rather than calling frame.winfo_height() or winfo_width() as you've done, instead checking frame["width"] and frame["height"]. Which retain their original values regardless of actual size AFAICS. If you do the same on the button, I think you'll find the same (non?)issue. I don't think I've seen the "winfo_optioname()" construct in the python-side doc. For example Sec 25.1.6.1 "Setting Options" in the tkinter chapter of the standard python Library Reference doesn't mention it or anything syntactically similar. I'm sure the usual disclaimer "see the tcl/tk docs" applies, but this seems more than a detail to me. Thanks for your help...Nick -- https://mail.python.org/mailman/listinfo/python-list
Re: tkinter resize question
On Friday, July 17, 2015 at 5:55:19 PM UTC-5, Terry Reedy wrote: > On 7/17/2015 2:53 PM, nickgeova...@gmail.com wrote: > > Resizing a tkinter window which contains a frame which contains a > > button widget, will not change the current size of the window, frame > > or button as recorded in their height and width attributes (at least > > not if they are resizable). > > Post the code and experiments performed that leads you to believe the above. It's really boring but here you are: [ngeo@localhost src]$ python3 Python 3.4.2 (default, Dec 20 2014, 13:53:33) [GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import tkinter >>> win=tkinter.Tk() >>> frame=tkinter.Frame(win, bg="blue", width=200, height=200) >>> butt1=tkinter.Button(fg="green", bg="black") >>> frame.grid() >>> butt1.grid() >>> butt1["width"] 0 >>> butt1["height"] 0 >>> win["width"] 0 >>> win["height"] 0 Needless to say the button has appeared and has non-zero size. > > What is the correct way to detect their current size? > > It is hard to fix code not posted. Just a question from first principles: Find a widget's current size. But the code example posted showed a working way to do the same thing. Unfortunately requiring a function call, and not in the doc online AFAICS butdoc is doc. > Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list