From ggpolo at gmail.com Thu Jan 1 04:34:48 2009 From: ggpolo at gmail.com (Guilherme Polo) Date: Thu, 1 Jan 2009 01:34:48 -0200 Subject: [Tkinter-discuss] TkTable changing the entry widgets In-Reply-To: <742958.82225.qm@web51904.mail.re2.yahoo.com> References: <742958.82225.qm@web51904.mail.re2.yahoo.com> Message-ID: On Wed, Dec 31, 2008 at 7:10 PM, Troy Taillefer wrote: > Hi all, > > I was wondering if anyone knew who to change the entry widgets in TkTable to > replace them with a custom entry widget like AutoCompletionEntry > http://tkinter.unpythonic.net/wiki/AutocompleteEntry or ValidatingEntry > http://tkinter.unpythonic.net/wiki/ValidateEntry. I would suggest embedding these widgets, and others, instead of trying to replace the default behaviour of a cell entry in tktable. Embedding is easy enough given your tktable python wrapper has the window commands wrapped: import Tkinter import tktable table = tktable.Table() table.window_configure("2,3", window=Tkinter.Entry()) table.pack() table.mainloop() I'm using Tkinter.Entry here, but you could just as well use this AutoCompleteEntry widget. This "2,3" is the cell index -- third row, fourth column. The wrapper I used there can be found at XXX (forgot the link, it is on http://tkinter.unpythonic.net/wiki but the wiki is inaccessible now) and also in tktable's cvs since about 1-2 month(s) ago (except that the one in cvs doesn't yet have the latest updates). > Also if anyone knows how > to enhance TkTable to do column sorting or point me to some good links it > would be greatly apreciated thanks. > It is a matter of reorganizing the ArrayVar associated to the table since tktable doesn't have a built-in sort yet. Have you tried doing anything like this ? > Troy -- -- Guilherme H. Polo Goncalves From ironwaist29 at yahoo.com Thu Jan 1 17:45:25 2009 From: ironwaist29 at yahoo.com (Troy Taillefer) Date: Thu, 1 Jan 2009 08:45:25 -0800 (PST) Subject: [Tkinter-discuss] http://tkinter.unpythonic.net/ is down / unrechable Message-ID: <124193.73092.qm@web51912.mail.re2.yahoo.com> Hi all, ? Just wanted to know did someone take http://tkinter.unpythonic.net/?down for maintainance ? I hope it will be back soon learning a lot about tkinter from it. ? Troy ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From ggpolo at gmail.com Thu Jan 1 20:15:29 2009 From: ggpolo at gmail.com (Guilherme Polo) Date: Thu, 1 Jan 2009 17:15:29 -0200 Subject: [Tkinter-discuss] http://tkinter.unpythonic.net/ is down / unrechable In-Reply-To: <124193.73092.qm@web51912.mail.re2.yahoo.com> References: <124193.73092.qm@web51912.mail.re2.yahoo.com> Message-ID: On Thu, Jan 1, 2009 at 2:45 PM, Troy Taillefer wrote: > Hi all, > > Just wanted to know did someone take http://tkinter.unpythonic.net/ down for > maintainance ? I hope it will be back soon learning a lot about tkinter from > it. > I just tried accessing it and it seems to be working now. -- -- Guilherme H. Polo Goncalves From ggpolo at gmail.com Thu Jan 1 23:02:23 2009 From: ggpolo at gmail.com (Guilherme Polo) Date: Thu, 1 Jan 2009 20:02:23 -0200 Subject: [Tkinter-discuss] TkTable changing the entry widgets In-Reply-To: References: <742958.82225.qm@web51904.mail.re2.yahoo.com> Message-ID: On Thu, Jan 1, 2009 at 1:34 AM, Guilherme Polo wrote: > On Wed, Dec 31, 2008 at 7:10 PM, Troy Taillefer wrote: >> Hi all, >> >> I was wondering if anyone knew who to change the entry widgets in TkTable to >> replace them with a custom entry widget like AutoCompletionEntry >> http://tkinter.unpythonic.net/wiki/AutocompleteEntry or ValidatingEntry >> http://tkinter.unpythonic.net/wiki/ValidateEntry. > > I would suggest embedding these widgets, and others, instead of trying > to replace the default behaviour of a cell entry in tktable. > Embedding is easy enough given your tktable python wrapper has the > window commands wrapped: > > import Tkinter > import tktable > > table = tktable.Table() > table.window_configure("2,3", window=Tkinter.Entry()) > table.pack() > > table.mainloop() > > I'm using Tkinter.Entry here, but you could just as well use this > AutoCompleteEntry widget. This "2,3" is the cell index -- third row, > fourth column. > The wrapper I used there can be found at XXX (forgot the link, it is > on http://tkinter.unpythonic.net/wiki but the wiki is inaccessible > now) and also in tktable's cvs since about 1-2 month(s) ago (except > that the one in cvs doesn't yet have the latest updates). > >> Also if anyone knows how >> to enhance TkTable to do column sorting or point me to some good links it >> would be greatly apreciated thanks. >> > > It is a matter of reorganizing the ArrayVar associated to the table > since tktable doesn't have a built-in sort yet. Have you tried doing > anything like this ? > I've added something here now: http://tkinter.unpythonic.net/wiki/SorTable (I wanted to take SortableTable but someone else took it before me) >> Troy > -- -- Guilherme H. Polo Goncalves From galileon at gmail.com Fri Jan 2 17:17:29 2009 From: galileon at gmail.com (Nawal Husnoo) Date: Fri, 2 Jan 2009 16:17:29 +0000 Subject: [Tkinter-discuss] Python2.5.1+Tkinter+Tile0.8.2 Message-ID: <185c18a00901020817v1c328b6dm717bfa81f8f3f515@mail.gmail.com> Dear Tkinter users/developers, I'm just starting out in Python Tkinter programming, and I tried to use the Tile module to improve the looks of the Tk program I am writing. When I run the script written in below, it works fine, using the Tile module to make the Tk look ok. However, when I try to use tkMessageBox.showwarning() as in the script, it fails with the error below. I've tried to cat | grep for "background" in the files mentionned in the error, but nothing turns up. I can't find where the "-background" switch is getting stuck in. I know the "background" switch doesn't work with Tile, but I can't find it to remove it. Any ideas please? Thanks, Nawal. /usr/lib/python2.4/site-packages/apt/__init__.py:2: RuntimeWarning: Python C API version mismatch for module apt_pkg: This Python has API version 1013, module apt_pkg has version 1012. import apt_pkg Traceback (most recent call last): File "./tktest.py", line 81, in tkMessageBox.showwarning("Open file","Cannot open this file\n") File "/usr/lib/python2.5/lib-tk/tkMessageBox.py", line 85, in showwarning return _show(title, message, WARNING, OK, **options) File "/usr/lib/python2.5/lib-tk/tkMessageBox.py", line 72, in _show res = Message(**options).show() File "/usr/lib/python2.5/lib-tk/tkCommonDialog.py", line 48, in show s = w.tk.call(self.command, *w._options(self.options)) _tkinter.TclError: unknown option "-background" Here's the script: #! /usr/bin/env python from Tkinter import * import tkMessageBox def callback(): print "called the callback!" root = Tk() root.tk.call('package', 'require', 'tile') root.tk.call('namespace', 'import', '-force', 'ttk::*') root.tk.call('ttk::setTheme', 'clam') def callback(): print "called the callback!" # create a toolbar toolbar = Frame(root) b = Button(toolbar, text="new", width=6, command=callback) b.pack(side=LEFT, padx=2, pady=2) b = Button(toolbar, text="open", width=6, command=callback) b.pack(side=LEFT, padx=2, pady=2) toolbar.pack(side=TOP, fill=X) status = Label(root, text="", relief=SUNKEN, anchor=W) status.pack(side=BOTTOM, fill=X) # create a menu menu = Menu(root) root.config(menu=menu) filemenu = Menu(menu) menu.add_cascade(label="File", menu=filemenu) filemenu.add_command(label="New", command=callback) filemenu.add_command(label="Open...", command=callback) filemenu.add_separator() filemenu.add_command(label="Exit", command=callback) #tkMessageBox.showwarning("Open file","Cannot open this file\n") mainloop() -- The best way to predict the future is to invent it. - Alan Kay http://www.galileon.co.uk/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From pellegrini at ill.fr Mon Jan 5 12:09:02 2009 From: pellegrini at ill.fr (pellegrini) Date: Mon, 05 Jan 2009 12:09:02 +0100 Subject: [Tkinter-discuss] Problem with grid layout Message-ID: <4961EA4E.3060404@ill.fr> Hello everybody, I have a problem with the grid management. Here is the following simple script: ###################################################################### from Tkinter import * root = Tk() f = Frame(root) f.grid(row = 0, column = 0, sticky = W) f1 = Frame(f, relief = GROOVE, bd = 2) f1.grid(row = 0, column = 0, sticky = W) str1 = StringVar(root,'%-20s' % 'Label') Label(f1, textvariable = str1, anchor = W).grid(row = 0, column = 0, sticky = W) Button(f1, text = 'Button1').grid(row = 0, column = 1) f2 = Frame(f, relief = GROOVE, bd = 2) f2.grid(row = 1, column = 0, sticky = W) str2 = StringVar(root,'%-20s' % 'BiggerLabel') Label(f2, textvariable = str2, anchor = W).grid(row = 0, column = 0, sticky = W) Button(f2, text = 'Button2').grid(row = 0, column = 1) root.mainloop() ###################################################################### I would expect that script to produce two frames with exactly the same size but it is not the case. However the two labels have the same size by construction (i.e. 20). Would you have any idea ? thank you very much Eric Pellegrini From pellegrini at ill.fr Mon Jan 5 12:12:44 2009 From: pellegrini at ill.fr (pellegrini) Date: Mon, 05 Jan 2009 12:12:44 +0100 Subject: [Tkinter-discuss] Problem with grid layout Message-ID: <4961EB2C.7020903@ill.fr> Hello everybody, I have a problem with the grid management. Here is the following simple script: ###################################################################### from Tkinter import * root = Tk() f = Frame(root) f.grid(row = 0, column = 0, sticky = W) f1 = Frame(f, relief = GROOVE, bd = 2) f1.grid(row = 0, column = 0, sticky = W) str1 = StringVar(root,'%-20s' % 'Label') Label(f1, textvariable = str1, anchor = W).grid(row = 0, column = 0, sticky = W) Button(f1, text = 'Button1').grid(row = 0, column = 1) f2 = Frame(f, relief = GROOVE, bd = 2) f2.grid(row = 1, column = 0, sticky = W) str2 = StringVar(root,'%-20s' % 'BiggerLabel') Label(f2, textvariable = str2, anchor = W).grid(row = 0, column = 0, sticky = W) Button(f2, text = 'Button2').grid(row = 0, column = 1) root.mainloop() ###################################################################### I would expect that script to produce two frames with exactly the same size but it is not the case. However the two labels have the same size by construction (i.e. 20). Would you have any idea ? thank you very much Eric Pellegrini From ggpolo at gmail.com Mon Jan 5 13:07:11 2009 From: ggpolo at gmail.com (Guilherme Polo) Date: Mon, 5 Jan 2009 10:07:11 -0200 Subject: [Tkinter-discuss] Problem with grid layout In-Reply-To: <4961EA4E.3060404@ill.fr> References: <4961EA4E.3060404@ill.fr> Message-ID: On Mon, Jan 5, 2009 at 9:09 AM, pellegrini wrote: > Hello everybody, > > I have a problem with the grid management. > > Here is the following simple script: > > ###################################################################### > from Tkinter import * > root = Tk() > f = Frame(root) > f.grid(row = 0, column = 0, sticky = W) > > f1 = Frame(f, relief = GROOVE, bd = 2) > f1.grid(row = 0, column = 0, sticky = W) > str1 = StringVar(root,'%-20s' % 'Label') > Label(f1, textvariable = str1, anchor = W).grid(row = 0, column = 0, sticky > = W) > Button(f1, text = 'Button1').grid(row = 0, column = 1) > > f2 = Frame(f, relief = GROOVE, bd = 2) > f2.grid(row = 1, column = 0, sticky = W) > str2 = StringVar(root,'%-20s' % 'BiggerLabel') > Label(f2, textvariable = str2, anchor = W).grid(row = 0, column = 0, sticky > = W) > Button(f2, text = 'Button2').grid(row = 0, column = 1) > > root.mainloop() > ###################################################################### > > I would expect that script to produce two frames with exactly the same size > but it is not the case. > However the two labels have the same size by construction (i.e. 20). > > Would you have any idea ? > strings of same length won't give you labels of same size, since that matters nothing when you are not using a monospace font. If you just want frames with same size, change theirs stickys to "ew". > thank you very much > > Eric Pellegrini > > -- -- Guilherme H. Polo Goncalves From drunkenmousehide at hotmail.com Fri Jan 9 02:28:32 2009 From: drunkenmousehide at hotmail.com (waffles123) Date: Thu, 8 Jan 2009 17:28:32 -0800 (PST) Subject: [Tkinter-discuss] Scrolling canvas (Including all widgets on it) Message-ID: <21364650.post@talk.nabble.com> I'm trying to make a canvas scrollable, but the problem is I can only get things that I've drawn, or what not on the canvas to move. I want to be able to move every widget (In this case, 70 odd entry boxes, and a few labels) The full code is http://www.nomorepasting.com/getpaste.php?pasteid=23309 -- View this message in context: http://www.nabble.com/Scrolling-canvas-%28Including-all-widgets-on-it%29-tp21364650p21364650.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From michael.odonnell at uam.es Fri Jan 9 09:08:15 2009 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Fri, 9 Jan 2009 09:08:15 +0100 Subject: [Tkinter-discuss] Scrolling canvas (Including all widgets on it) In-Reply-To: <21364650.post@talk.nabble.com> References: <21364650.post@talk.nabble.com> Message-ID: <47e491110901090008o71e46e51k55914e3a0b5dd413@mail.gmail.com> Hi Waffles, Rather than using place() to put widgets within the canvas, you need to actually draw them. Use the canvas method: create_window() E.g., taking two of your lines: self.topic_label = Label(self.label, text='Topic:', font=15, bg='white') self.topic_label.place(x=16, y=8) Should be: self.topic_label = Label(self.label, text='Topic:', font=15, bg='white') self.label.create_window(16, 8, window=self.topic_label, anchor=NW) Mick On Fri, Jan 9, 2009 at 2:28 AM, waffles123 wrote: > > I'm trying to make a canvas scrollable, but the problem is I can only get > things that I've drawn, or what not on the canvas to move. I want to be able > to move every widget (In this case, 70 odd entry boxes, and a few labels) > > The full code is http://www.nomorepasting.com/getpaste.php?pasteid=23309 > -- > View this message in context: http://www.nabble.com/Scrolling-canvas-%28Including-all-widgets-on-it%29-tp21364650p21364650.html > Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From ggpolo at gmail.com Fri Jan 9 10:37:20 2009 From: ggpolo at gmail.com (Guilherme Polo) Date: Fri, 9 Jan 2009 07:37:20 -0200 Subject: [Tkinter-discuss] Scrolling canvas (Including all widgets on it) In-Reply-To: <21364650.post@talk.nabble.com> References: <21364650.post@talk.nabble.com> Message-ID: On Thu, Jan 8, 2009 at 11:28 PM, waffles123 wrote: > > I'm trying to make a canvas scrollable, but the problem is I can only get > things that I've drawn, or what not on the canvas to move. I want to be able > to move every widget (In this case, 70 odd entry boxes, and a few labels) > > The full code is http://www.nomorepasting.com/getpaste.php?pasteid=23309 To get a scrollable canvas you will need to apply several tricks to it. I would start suggesting by embedding a single frame at position 0, 0 on it, and then create all the other widgets using this frame as the parent. Next you will need to wait the widgets appear (with wait_visibility) and then adjust the scrollregion of the Canvas, as well its width to something reasonable, and possibly how much the scrollbars scrolls. I'm leaving only the tips right now because I'm leaving right now. Nevertheless, you can find several implementations of those through Google. -- -- Guilherme H. Polo Goncalves From ggpolo at gmail.com Sat Jan 10 03:58:08 2009 From: ggpolo at gmail.com (Guilherme Polo) Date: Sat, 10 Jan 2009 00:58:08 -0200 Subject: [Tkinter-discuss] Scrolling canvas (Including all widgets on it) In-Reply-To: References: <21364650.post@talk.nabble.com> Message-ID: On Fri, Jan 9, 2009 at 7:37 AM, Guilherme Polo wrote: > On Thu, Jan 8, 2009 at 11:28 PM, waffles123 > wrote: >> >> I'm trying to make a canvas scrollable, but the problem is I can only get >> things that I've drawn, or what not on the canvas to move. I want to be able >> to move every widget (In this case, 70 odd entry boxes, and a few labels) >> >> The full code is http://www.nomorepasting.com/getpaste.php?pasteid=23309 > > To get a scrollable canvas you will need to apply several tricks to > it. I would start suggesting by embedding a single frame at position > 0, 0 on it, and then create all the other widgets using this frame as > the parent. Next you will need to wait the widgets appear (with > wait_visibility) and then adjust the scrollregion of the Canvas, as > well its width to something reasonable, and possibly how much the > scrollbars scrolls. > > I'm leaving only the tips right now because I'm leaving right now. > Nevertheless, you can find several implementations of those through > Google. I've just added a simple ScrolledFrame to http://tkinter.unpythonic.net/wiki/ScrolledFrame Don't be surprised if it doesn't work for you, it contains several bugs in different categories :) Improvements over time are likely to happen, especially if someone uses it. -- -- Guilherme H. Polo Goncalves From Cameron at phaseit.net Mon Jan 12 04:04:05 2009 From: Cameron at phaseit.net (Cameron Laird) Date: Mon, 12 Jan 2009 03:04:05 +0000 Subject: [Tkinter-discuss] Have anyone mentioned lightbuttons? Message-ID: <20090112030405.GA14059@lairds.us> I think will interest many Tkinter developers. From Cameron at phaseit.net Mon Jan 12 16:40:35 2009 From: Cameron at phaseit.net (Cameron Laird) Date: Mon, 12 Jan 2009 15:40:35 +0000 Subject: [Tkinter-discuss] Python2.5.1+Tkinter+Tile0.8.2 In-Reply-To: <185c18a00901020817v1c328b6dm717bfa81f8f3f515@mail.gmail.com> References: <185c18a00901020817v1c328b6dm717bfa81f8f3f515@mail.gmail.com> Message-ID: <20090112154035.GA11443@lairds.us> On Fri, Jan 02, 2009 at 04:17:29PM +0000, Nawal Husnoo wrote: . . . > I'm just starting out in Python Tkinter programming, and I tried to use the > Tile module to improve the looks of the Tk program I am writing. > > When I run the script written in below, it works fine, using > the Tile module to make the Tk look ok. However, when I try to use > tkMessageBox.showwarning() as in the script, it fails with the error below. > I've tried to cat | grep for "background" in the files mentionned in the > error, but nothing turns up. I can't find where the "-background" switch is > getting stuck in. I know the "background" switch doesn't work with Tile, but > I can't find it to remove it. Any ideas please? Can you upgrade to 8.5 of Tk? might help you. From klappnase at web.de Mon Jan 12 20:36:00 2009 From: klappnase at web.de (Michael Lange) Date: Mon, 12 Jan 2009 20:36:00 +0100 Subject: [Tkinter-discuss] Python2.5.1+Tkinter+Tile0.8.2 In-Reply-To: <20090112154035.GA11443@lairds.us> References: <185c18a00901020817v1c328b6dm717bfa81f8f3f515@mail.gmail.com> <20090112154035.GA11443@lairds.us> Message-ID: <20090112203600.32e7f78e.klappnase@web.de> On Mon, 12 Jan 2009 15:40:35 +0000 Cameron Laird wrote: > On Fri, Jan 02, 2009 at 04:17:29PM +0000, Nawal Husnoo wrote: > . > . > . > > I'm just starting out in Python Tkinter programming, and I tried to use the > > Tile module to improve the looks of the Tk program I am writing. > > > > When I run the script written in below, it works fine, using > > the Tile module to make the Tk look ok. However, when I try to use > > tkMessageBox.showwarning() as in the script, it fails with the error below. > > I've tried to cat | grep for "background" in the files mentionned in the > > error, but nothing turns up. I can't find where the "-background" switch is > > getting stuck in. I know the "background" switch doesn't work with Tile, but > > I can't find it to remove it. Any ideas please? > > Can you upgrade to 8.5 of Tk? http://tkinter.unpythonic.net/wiki/tk85_and_python > > might help you. I think the problematic part is this: root.tk.call('package', 'require', 'tile') root.tk.call('namespace', 'import', '-force', 'ttk::*') root.tk.call('ttk::setTheme', 'clam') If I understand this correctly it will override the names of the core tk widgets with their themed counterparts. So the file using the (no longer existing) "background" option is probably msgbox.tcl . If you want to use tile you are certainly better off using Guilherme Polo's ttk module. Michael From rowen at u.washington.edu Mon Jan 12 21:17:43 2009 From: rowen at u.washington.edu (Russell E. Owen) Date: Mon, 12 Jan 2009 12:17:43 -0800 Subject: [Tkinter-discuss] Python2.5.1+Tkinter+Tile0.8.2 References: <185c18a00901020817v1c328b6dm717bfa81f8f3f515@mail.gmail.com> <20090112154035.GA11443@lairds.us> Message-ID: In article <20090112154035.GA11443 at lairds.us>, Cameron Laird wrote: > On Fri, Jan 02, 2009 at 04:17:29PM +0000, Nawal Husnoo wrote: > . > . > . > > I'm just starting out in Python Tkinter programming, and I tried to use the > > Tile module to improve the looks of the Tk program I am writing. > > > > When I run the script written in below, it works fine, using > > the Tile module to make the Tk look ok. However, when I try to use > > tkMessageBox.showwarning() as in the script, it fails with the error below. > > I've tried to cat | grep for "background" in the files mentionned in the > > error, but nothing turns up. I can't find where the "-background" switch is > > getting stuck in. I know the "background" switch doesn't work with Tile, but > > I can't find it to remove it. Any ideas please? > > Can you upgrade to 8.5 of Tk? http://tkinter.unpythonic.net/wiki/tk85_and_python > > might help you. Is that safe? I thought Python 2.5 was not fully compatible with Tcl/Tk 8.5. -- Russell From ggpolo at gmail.com Mon Jan 12 22:16:58 2009 From: ggpolo at gmail.com (Guilherme Polo) Date: Mon, 12 Jan 2009 19:16:58 -0200 Subject: [Tkinter-discuss] Python2.5.1+Tkinter+Tile0.8.2 In-Reply-To: References: <185c18a00901020817v1c328b6dm717bfa81f8f3f515@mail.gmail.com> <20090112154035.GA11443@lairds.us> Message-ID: On Mon, Jan 12, 2009 at 6:17 PM, Russell E. Owen wrote: > In article <20090112154035.GA11443 at lairds.us>, > Cameron Laird wrote: > >> On Fri, Jan 02, 2009 at 04:17:29PM +0000, Nawal Husnoo wrote: >> . >> . >> . >> > I'm just starting out in Python Tkinter programming, and I tried to use the >> > Tile module to improve the looks of the Tk program I am writing. >> > >> > When I run the script written in below, it works fine, using >> > the Tile module to make the Tk look ok. However, when I try to use >> > tkMessageBox.showwarning() as in the script, it fails with the error below. >> > I've tried to cat | grep for "background" in the files mentionned in the >> > error, but nothing turns up. I can't find where the "-background" switch is >> > getting stuck in. I know the "background" switch doesn't work with Tile, but >> > I can't find it to remove it. Any ideas please? >> >> Can you upgrade to 8.5 of Tk? > http://tkinter.unpythonic.net/wiki/tk85_and_python > >> might help you. > > Is that safe? I thought Python 2.5 was not fully compatible with Tcl/Tk > 8.5. > For some values of Python 2.5, yes. Python 2.5.3 should have no problems with it, but I can't really say you are wrong because I (think) there was another issue related to Python 2.5.x and Tk 8.5 but I can't remember. I will try to find it now. -- -- Guilherme H. Polo Goncalves From ggpolo at gmail.com Mon Jan 12 22:31:21 2009 From: ggpolo at gmail.com (Guilherme Polo) Date: Mon, 12 Jan 2009 19:31:21 -0200 Subject: [Tkinter-discuss] Python2.5.1+Tkinter+Tile0.8.2 In-Reply-To: References: <185c18a00901020817v1c328b6dm717bfa81f8f3f515@mail.gmail.com> <20090112154035.GA11443@lairds.us> Message-ID: On Mon, Jan 12, 2009 at 7:16 PM, Guilherme Polo wrote: > On Mon, Jan 12, 2009 at 6:17 PM, Russell E. Owen wrote: >> In article <20090112154035.GA11443 at lairds.us>, >> Cameron Laird wrote: >> >>> On Fri, Jan 02, 2009 at 04:17:29PM +0000, Nawal Husnoo wrote: >>> . >>> . >>> . >>> > I'm just starting out in Python Tkinter programming, and I tried to use the >>> > Tile module to improve the looks of the Tk program I am writing. >>> > >>> > When I run the script written in below, it works fine, using >>> > the Tile module to make the Tk look ok. However, when I try to use >>> > tkMessageBox.showwarning() as in the script, it fails with the error below. >>> > I've tried to cat | grep for "background" in the files mentionned in the >>> > error, but nothing turns up. I can't find where the "-background" switch is >>> > getting stuck in. I know the "background" switch doesn't work with Tile, but >>> > I can't find it to remove it. Any ideas please? >>> >>> Can you upgrade to 8.5 of Tk? >> http://tkinter.unpythonic.net/wiki/tk85_and_python > >>> might help you. >> >> Is that safe? I thought Python 2.5 was not fully compatible with Tcl/Tk >> 8.5. >> > > For some values of Python 2.5, yes. > Python 2.5.3 should have no problems with it, but I can't really say > you are wrong because I (think) there was another issue related to > Python 2.5.x and Tk 8.5 but I can't remember. I will try to find it > now. Just found it. If you have the privilege of being able to run an own-compiled-version of Python (or, if possible, just update to Python 2.6), you could apply the following patch: http://svn.python.org/view/python/trunk/Modules/_tkinter.c?rev=59653&view=diff&r1=59653&r2=59652&p1=python/trunk/Modules/_tkinter.c&p2=/python/trunk/Modules/_tkinter.c That one wasn't backported to python 2.5, but I also don't remember how to exactly hit the bug -- but will try reproducing it here (this also remembers me of going back to finish the another python <-> tcl/tk bridge). -- -- Guilherme H. Polo Goncalves From ggpolo at gmail.com Mon Jan 12 22:47:57 2009 From: ggpolo at gmail.com (Guilherme Polo) Date: Mon, 12 Jan 2009 19:47:57 -0200 Subject: [Tkinter-discuss] Python2.5.1+Tkinter+Tile0.8.2 In-Reply-To: References: <185c18a00901020817v1c328b6dm717bfa81f8f3f515@mail.gmail.com> <20090112154035.GA11443@lairds.us> Message-ID: On Mon, Jan 12, 2009 at 7:31 PM, Guilherme Polo wrote: > On Mon, Jan 12, 2009 at 7:16 PM, Guilherme Polo wrote: >> On Mon, Jan 12, 2009 at 6:17 PM, Russell E. Owen wrote: >>> In article <20090112154035.GA11443 at lairds.us>, >>> Cameron Laird wrote: >>> >>>> On Fri, Jan 02, 2009 at 04:17:29PM +0000, Nawal Husnoo wrote: >>>> . >>>> . >>>> . >>>> > I'm just starting out in Python Tkinter programming, and I tried to use the >>>> > Tile module to improve the looks of the Tk program I am writing. >>>> > >>>> > When I run the script written in below, it works fine, using >>>> > the Tile module to make the Tk look ok. However, when I try to use >>>> > tkMessageBox.showwarning() as in the script, it fails with the error below. >>>> > I've tried to cat | grep for "background" in the files mentionned in the >>>> > error, but nothing turns up. I can't find where the "-background" switch is >>>> > getting stuck in. I know the "background" switch doesn't work with Tile, but >>>> > I can't find it to remove it. Any ideas please? >>>> >>>> Can you upgrade to 8.5 of Tk? >>> http://tkinter.unpythonic.net/wiki/tk85_and_python > >>>> might help you. >>> >>> Is that safe? I thought Python 2.5 was not fully compatible with Tcl/Tk >>> 8.5. >>> >> >> For some values of Python 2.5, yes. >> Python 2.5.3 should have no problems with it, but I can't really say >> you are wrong because I (think) there was another issue related to >> Python 2.5.x and Tk 8.5 but I can't remember. I will try to find it >> now. > > Just found it. If you have the privilege of being able to run an > own-compiled-version of Python (or, if possible, just update to Python > 2.6), you could apply the following patch: > http://svn.python.org/view/python/trunk/Modules/_tkinter.c?rev=59653&view=diff&r1=59653&r2=59652&p1=python/trunk/Modules/_tkinter.c&p2=/python/trunk/Modules/_tkinter.c > > That one wasn't backported to python 2.5, but I also don't remember > how to exactly hit the bug -- but will try reproducing it here (this > also remembers me of going back to finish the another python <-> > tcl/tk bridge). > Ah, yes: import Tkinter text = Tkinter.Text() text.insert('end', 'hi there') def test(x): print x, type(x), "< bad" text.tk.createcommand("test", test) text.tk.call("test", text.bbox('1.0')) x = text.bbox('1.0') print x, type(x) This is specially problematic in IDLE, but can affect other code too. The problem is that bbox is supposed to return a tuple in Python, which it returns, but then _tkinter (in Python 2.5) is not doing proper object conversions in callbacks and you end up getting a string in the example. -- -- Guilherme H. Polo Goncalves From ggpolo at gmail.com Mon Jan 12 22:57:58 2009 From: ggpolo at gmail.com (Guilherme Polo) Date: Mon, 12 Jan 2009 19:57:58 -0200 Subject: [Tkinter-discuss] Python2.5.1+Tkinter+Tile0.8.2 In-Reply-To: References: <185c18a00901020817v1c328b6dm717bfa81f8f3f515@mail.gmail.com> <20090112154035.GA11443@lairds.us> Message-ID: >> Just found it. If you have the privilege of being able to run an >> own-compiled-version of Python (or, if possible, just update to Python >> 2.6), you could apply the following patch: >> http://svn.python.org/view/python/trunk/Modules/_tkinter.c?rev=59653&view=diff&r1=59653&r2=59652&p1=python/trunk/Modules/_tkinter.c&p2=/python/trunk/Modules/_tkinter.c >> >> That one wasn't backported to python 2.5, but I also don't remember >> how to exactly hit the bug -- but will try reproducing it here (this >> also remembers me of going back to finish the another python <-> >> tcl/tk bridge). >> > > Ah, yes: > > import Tkinter > > text = Tkinter.Text() > text.insert('end', 'hi there') > > def test(x): > print x, type(x), "< bad" > > text.tk.createcommand("test", test) > text.tk.call("test", text.bbox('1.0')) > > x = text.bbox('1.0') > print x, type(x) > > This is specially problematic in IDLE, but can affect other code too. > The problem is that bbox is supposed to return a tuple in Python, > which it returns, but then _tkinter (in Python 2.5) is not doing > proper object conversions in callbacks and you end up getting a string > in the example. > Eh.. that wasn't the actual problem, give me some time :P -- -- Guilherme H. Polo Goncalves From ggpolo at gmail.com Tue Jan 13 00:12:56 2009 From: ggpolo at gmail.com (Guilherme Polo) Date: Mon, 12 Jan 2009 21:12:56 -0200 Subject: [Tkinter-discuss] Python2.5.1+Tkinter+Tile0.8.2 In-Reply-To: References: <185c18a00901020817v1c328b6dm717bfa81f8f3f515@mail.gmail.com> <20090112154035.GA11443@lairds.us> Message-ID: On Mon, Jan 12, 2009 at 7:57 PM, Guilherme Polo wrote: >>> Just found it. If you have the privilege of being able to run an >>> own-compiled-version of Python (or, if possible, just update to Python >>> 2.6), you could apply the following patch: >>> http://svn.python.org/view/python/trunk/Modules/_tkinter.c?rev=59653&view=diff&r1=59653&r2=59652&p1=python/trunk/Modules/_tkinter.c&p2=/python/trunk/Modules/_tkinter.c >>> >>> That one wasn't backported to python 2.5, but I also don't remember >>> how to exactly hit the bug -- but will try reproducing it here (this >>> also remembers me of going back to finish the another python <-> >>> tcl/tk bridge). >>> >> >> Ah, yes: >> >> import Tkinter >> >> text = Tkinter.Text() >> text.insert('end', 'hi there') >> >> def test(x): >> print x, type(x), "< bad" >> >> text.tk.createcommand("test", test) >> text.tk.call("test", text.bbox('1.0')) >> >> x = text.bbox('1.0') >> print x, type(x) >> >> This is specially problematic in IDLE, but can affect other code too. >> The problem is that bbox is supposed to return a tuple in Python, >> which it returns, but then _tkinter (in Python 2.5) is not doing >> proper object conversions in callbacks and you end up getting a string >> in the example. >> > > Eh.. that wasn't the actual problem, give me some time :P Trying a bit more I found this one: import Tkinter root = Tkinter.Tk() print Tkinter.TkVersion def test(): return (1, 2, 3) root.tk.createcommand("test", test) x = root.tk.call("test") print x, type(x) With tk8.4 this returns a str, with tk8.5 and python 2.5.2 this happens too, but with tk8.5 and python 2.6 it returns a tuple. I believe this must cause trouble when using tk 8.5 specifically because of other conversions errors, not this one alone, which didn't happen with tk 8.4. To check something that gives you the problem, run EditorWindow.py (in idlelib) then press 'a' and then tab for autocomplete, it should hit the bug while using python 2.5 and tk 8.5. -- -- Guilherme H. Polo Goncalves From jepler at unpythonic.net Sat Jan 17 19:23:01 2009 From: jepler at unpythonic.net (Jeff Epler) Date: Sat, 17 Jan 2009 12:23:01 -0600 Subject: [Tkinter-discuss] tkinter wiki migrated to a new machine Message-ID: <20090117182301.GA18625@unpythonic.net> .. and a newer version of moin. please let me know if you discover any problems. thanks, Jeff From ggpolo at gmail.com Sat Jan 17 19:49:43 2009 From: ggpolo at gmail.com (Guilherme Polo) Date: Sat, 17 Jan 2009 16:49:43 -0200 Subject: [Tkinter-discuss] tkinter wiki migrated to a new machine In-Reply-To: <20090117182301.GA18625@unpythonic.net> References: <20090117182301.GA18625@unpythonic.net> Message-ID: On Sat, Jan 17, 2009 at 4:23 PM, Jeff Epler wrote: > .. and a newer version of moin. > It got a bit prettier, I like it. > please let me know if you discover any problems. > > thanks, > Jeff -- -- Guilherme H. Polo Goncalves From red_haired_freak at hotmail.com Thu Jan 22 02:39:33 2009 From: red_haired_freak at hotmail.com (Ru-D) Date: Wed, 21 Jan 2009 17:39:33 -0800 (PST) Subject: [Tkinter-discuss] Basic Tkinter help Message-ID: <21593735.post@talk.nabble.com> I am relatively new to Tkinter and am finding some simple problems difficult to understand/rectify The following code displays two windows; my maximised application window and a small window called Tk: from Tkinter import * class APP(Toplevel): def __init__(self, master): Toplevel.__init__(self, master) self.master = master root = Tk() app = APP(root) app.state("zoomed") app.title("Title") root.mainloop() I can fix this by inserting the line root.withdraw() after root = Tk() but this seems like a clumsy solution to me. Could someone please help me understand why two windows are being made Ru-D -- View this message in context: http://www.nabble.com/Basic-Tkinter-help-tp21593735p21593735.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From red_haired_freak at hotmail.com Thu Jan 22 02:44:37 2009 From: red_haired_freak at hotmail.com (Ru-D) Date: Wed, 21 Jan 2009 17:44:37 -0800 (PST) Subject: [Tkinter-discuss] Basic Tkinter help Message-ID: <21593741.post@talk.nabble.com> I am relatively new to Tkinter and am finding some simple problems difficult to understand/rectify The following code displays two windows; my maximised application window and a small window called Tk: from Tkinter import * class APP(Toplevel): def __init__(self, master): Toplevel.__init__(self, master) self.master = master root = Tk() app = APP(root) app.state("zoomed") app.title("Title") root.mainloop() I can fix this by inserting the line root.withdraw() after root = Tk() but this seems like a clumsy solution to me. Could someone please help me understand why two windows are being made and suggest a better way to do this. Thanks, Ru-D -- View this message in context: http://www.nabble.com/Basic-Tkinter-help-tp21593741p21593741.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From red_haired_freak at hotmail.com Thu Jan 22 02:50:42 2009 From: red_haired_freak at hotmail.com (Ru-D) Date: Wed, 21 Jan 2009 17:50:42 -0800 (PST) Subject: [Tkinter-discuss] Basic Tkinter help Message-ID: <21593746.post@talk.nabble.com> I am relatively new to Tkinter and am finding some simple problems difficult to understand/rectify The following code displays two windows; my maximised application window and a small window called Tk: from Tkinter import * class APP(Toplevel): def __init__(self, master): Toplevel.__init__(self, master) self.master = master root = Tk() app = APP(root) app.state("zoomed") app.title("Title") root.mainloop() I can fix this by inserting the line root.withdraw() after root = Tk() but this seems like a clumsy solution to me. Could someone please help me understand why two windows are being made and suggest a better way to do this. Thanks, Ru-D -- View this message in context: http://www.nabble.com/Basic-Tkinter-help-tp21593746p21593746.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From michael.odonnell at uam.es Thu Jan 22 08:53:07 2009 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Thu, 22 Jan 2009 08:53:07 +0100 Subject: [Tkinter-discuss] Basic Tkinter help In-Reply-To: <21593746.post@talk.nabble.com> References: <21593746.post@talk.nabble.com> Message-ID: <47e491110901212353t45b86c51w4b533b507a2b9c4a@mail.gmail.com> Dear Ru-D, The following line makes one window: > root = Tk() And your other line makes another: > app = APP(root) (APP being a Toplevel window) So the root.withdraw() is quite correct (many of us use it, that is if we don't make use of the main window for the application itself). Mick On Thu, Jan 22, 2009 at 2:50 AM, Ru-D wrote: > > I am relatively new to Tkinter and am finding some simple problems difficult > to understand/rectify > > The following code displays two windows; my maximised application window and > a small window called Tk: > > > from Tkinter import * > > class APP(Toplevel): > def __init__(self, master): > Toplevel.__init__(self, master) > self.master = master > > root = Tk() > app = APP(root) > app.state("zoomed") > app.title("Title") > > root.mainloop() > > I can fix this by inserting the line root.withdraw() after root = Tk() but > this seems like a clumsy solution to me. Could someone please help me > understand why two windows are being made and suggest a better way to do > this. > > Thanks, > Ru-D > -- > View this message in context: http://www.nabble.com/Basic-Tkinter-help-tp21593746p21593746.html > Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From donaldkenney at gmail.com Tue Jan 27 17:51:16 2009 From: donaldkenney at gmail.com (vtcodger) Date: Tue, 27 Jan 2009 08:51:16 -0800 (PST) Subject: [Tkinter-discuss] How to set a constant in lambda Message-ID: <21689312.post@talk.nabble.com> I came across a problem that probably has a simple, clever, answer -- but it is eluding me. I was trying to create a set of tab buttons on a Tkinter page using Buttons. These are created dynamically when the user loads a file. I don't know in advance how many files will get opened, so I want to have a variable number of tabs. So we have a Frame T; and an array of tabs XT[]; and a function switch_tabs(n) that will handle the details of switching the data base, titles, etc. I compute the tab number: Whoopsie = len(XT) And I create a new Button: XT.append(Button(T,text="Viola:New Tab",command=lambda: switch_tabs(whoopsie)) It all works fine except for this one minor detail. Whoopsie can't be a constant because I don't know in advance what constant to use. And if whoopsie is a variable, it apparently is evaluated at execution time, and will have the then current value of whoopsie, not the value I wanted to set at creation time. I tried everything I could think of including copy.copy(whoopsie) to get a constant set so that switch_tabs could know which tab to switch to. Couldn't do it. I was starting to look at tracing back through stack frames when it came to me that RadioButtons unlike generic Buttons have a variable-value attribute pair that behaves as I desire. So this manifestation of the problem is worked around. But I expect that I'll see this problem again in some other guise. Am I missing something? Probably something simple? What? -- View this message in context: http://www.nabble.com/How-to-set-a-constant-in-lambda-tp21689312p21689312.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From ggpolo at gmail.com Tue Jan 27 18:15:54 2009 From: ggpolo at gmail.com (Guilherme Polo) Date: Tue, 27 Jan 2009 15:15:54 -0200 Subject: [Tkinter-discuss] How to set a constant in lambda In-Reply-To: <21689312.post@talk.nabble.com> References: <21689312.post@talk.nabble.com> Message-ID: On Tue, Jan 27, 2009 at 2:51 PM, vtcodger wrote: > > I came across a problem that probably has a simple, clever, answer -- but it > is eluding me. I was trying to create a set of tab buttons on a Tkinter > page using Buttons. These are created dynamically when the user loads a > file. I don't know in advance how many files will get opened, so I want to > have a variable number of tabs. > You could consider using a Notebook widget. > So we have a Frame T; and an array of tabs XT[]; and a function > switch_tabs(n) that will handle the details of switching the data base, > titles, etc. I compute the tab number: > > Whoopsie = len(XT) > > And I create a new Button: > > XT.append(Button(T,text="Viola:New Tab",command=lambda: > switch_tabs(whoopsie)) > > It all works fine except for this one minor detail. Whoopsie can't be a > constant because I don't know in advance what constant to use. This makes my head hurts. Email's title was: "How to set a constant in lambda", but you just said you don't want it. > And if > whoopsie is a variable, it apparently is evaluated at execution time, and > will have the then current value of whoopsie, not the value I wanted to set > at creation time. Constants and variables do not exist at Python, they are all names. Can I assume that by "constant" you mean a immutable type and by "variable" a mutable type ? You could have put better names for these things instead of "whoopsie, Whoopsie" to help a bit. So, what is switch_tabs supposed to do ? And how this 'whoopsie' thing affects it ? Does it move you to the latest tab created ? If this is the case, you could consider a pre-defined value like 'end' or even None maybe so switch_tabs can check for these values and understand they mean: "move to the latest tab". > I tried everything I could think of including > copy.copy(whoopsie) to get a constant set so that switch_tabs could know > which tab to switch to. > > Couldn't do it. I was starting to look at tracing back through stack frames > when it came to me that RadioButtons unlike generic Buttons have a > variable-value attribute pair that behaves as I desire. What do you desire ? > So this > manifestation of the problem is worked around. But I expect that I'll see > this problem again in some other guise. -- -- Guilherme H. Polo Goncalves From ggpolo at gmail.com Wed Jan 28 03:23:57 2009 From: ggpolo at gmail.com (Guilherme Polo) Date: Wed, 28 Jan 2009 00:23:57 -0200 Subject: [Tkinter-discuss] ANN: Ttk wrapper 0.3 Message-ID: Hello, pyttk 0.3 has just been released! It is available at http://pypi.python.org/pypi/pyttk/0.3 This release was supposed to have happened several weeks ago but I ended up delaying it a lot, but well, finally it is here. This one includes bug fixes, backward incompatible changes, improvements and what not. Nothing really radical, but the changes are there. For a full complete list of changes be sure to read http://gpolo.ath.cx:81/posts/pyttk-03-released/ (if I haven't forgotten anything). What is this wrapper for ? -------------------------------- This wrapper provides classes to allow using the Tk themed widget set, which has been included in Tk 8.5 but can be used with earlier versions if you have Tile installed. Ttk is based on a revised and enhanced version of TIP #48 (http://tip.tcl.tk/48) specified style engine. What is Ttk ? ---------------- The basic idea of ttk is to separate, to the extent possible, the code implementing a widget's behavior from the code implementing its appearance. Widget class bindings are primarily responsible for maintaining the widget state and invoking callbacks, all aspects of the widgets appearance lies at Themes. More informations ----------------------- http://gpolo.ath.cx:81/projects/pyttk/ http://gpolo.ath.cx:81/posts/pyttk-03-released/ Thanks everyone who have been using and supporting the module, -- -- Guilherme H. Polo Goncalves From Allen.Taylor at mdacorporation.com Wed Jan 28 22:54:11 2009 From: Allen.Taylor at mdacorporation.com (Allen Taylor) Date: Wed, 28 Jan 2009 16:54:11 -0500 Subject: [Tkinter-discuss] event_generate question Message-ID: <49808DB3.FA48.005C.0@mdacorporation.com> I'm trying to generate some events in Tkinter but it doesn't seem to be working the way I expected. Here's an example of what I'm trying to do... def click(): print 'click' from Tkinter import * top=Tk() b=Button(top, text='Hit me', command=click) b.event_generate('', x=0, y=0) b.event_generate('', x=0, y=0) The appearance of the button changes after the event (to depressed), and again after the event (to normal again), but the associated button command (the click function) is not called. If I bind a function for the event to the button using the bind method, it gets called, but I really need the associated command to get called too. Also, I tried doing this with a Pmw.ScrolledListBox with an associated dblclickcommand, so I tried to generate and events, but to my surprise, I received the following error message for both cases: _tkinter.TclError: Double or Triple modifier not allowed These problems are getting in the way of my attempt to automate GUI testing with Tk. Am I missing something? (Ok, I really don't need the first case, because I can simple call the button's invoke method. But in the second case, the associated action is only invoked via the double click action.) Allen B. Taylor MDA 9445 Airport Road Brampton, ON L6S 4J3 905-790-2800 ext. 4350 allen.taylor at mdacorporation.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ggpolo at gmail.com Thu Jan 29 00:18:35 2009 From: ggpolo at gmail.com (Guilherme Polo) Date: Wed, 28 Jan 2009 21:18:35 -0200 Subject: [Tkinter-discuss] event_generate question In-Reply-To: <49808DB3.FA48.005C.0@mdacorporation.com> References: <49808DB3.FA48.005C.0@mdacorporation.com> Message-ID: On Wed, Jan 28, 2009 at 7:54 PM, Allen Taylor wrote: > I'm trying to generate some events in Tkinter but it doesn't seem to be > working the way I expected. Here's an example of what I'm trying to do... > > def click(): > print 'click' > > from Tkinter import * > top=Tk() > b=Button(top, text='Hit me', command=click) > > b.event_generate('', x=0, y=0) > b.event_generate('', x=0, y=0) > > The appearance of the button changes after the event (to > depressed), and again after the event (to normal again), > but the associated button command (the click function) is not called. Weren't you the guy who found something else to run these kind of tests ? :P If it is you then apparently my earlier email about taking a look at the ttk tests got ignored, but it is fine. You will want to generate an event before those ones, also, if your code is just that then also pack the button and wait for its visibility before generating the events. > If I > bind a function for the event to the button using the bind method, it gets > called, but I really need the associated command to get called too. > > Also, I tried doing this with a Pmw.ScrolledListBox with an associated > dblclickcommand, so I tried to generate and > events, but to my surprise, I received the > following error message for both cases: > > _tkinter.TclError: Double or Triple modifier not allowed Well, it makes some sense. How do you double click something ? I'm afraid you don't have a special key to double click, instead you just click twice (if you happen to have one then it just simulates the double click for you). In resume: import Tkinter root = Tkinter.Tk() def click(): print "click" def test(event): print "double" return "break" btn = Tkinter.Button(command=click) btn.bind('', test) btn.pack() btn.wait_visibility() btn.event_generate('', x=0, y=0) btn.event_generate('', x=0, y=0) btn.event_generate('', x=0, y=0) btn.event_generate('', x=0, y=0) btn.event_generate('', x=0, y=0) > > These problems are getting in the way of my attempt to automate GUI testing > with Tk. Am I missing something? > > (Ok, I really don't need the first case, because I can simple call the > button's invoke method. But in the second case, the associated action is > only invoked via the double click action.) > > Allen B. Taylor > MDA > 9445 Airport Road > Brampton, ON L6S 4J3 > 905-790-2800 ext. 4350 > allen.taylor at mdacorporation.com -- -- Guilherme H. Polo Goncalves From Allen.Taylor at mdacorporation.com Thu Jan 29 17:24:25 2009 From: Allen.Taylor at mdacorporation.com (Allen Taylor) Date: Thu, 29 Jan 2009 11:24:25 -0500 Subject: [Tkinter-discuss] event_generate question In-Reply-To: References: <49808DB3.FA48.005C.0@mdacorporation.com> Message-ID: <498191E9.FA48.005C.0@mdacorporation.com> Hello Guilherme, > >>> Guilherme Polo 2009-01-28 18:18 >>> > On Wed, Jan 28, 2009 at 7:54 PM, Allen Taylor > wrote: > > I'm trying to generate some events in Tkinter but it doesn't seem to be > > working the way I expected. Here's an example of what I'm trying to do... > > > > def click(): > > print 'click' > > > > from Tkinter import * > > top=Tk() > > b=Button(top, text='Hit me', command=click) > > > > b.event_generate('', x=0, y=0) > > b.event_generate('', x=0, y=0) > > > > The appearance of the button changes after the event (to > > depressed), and again after the event (to normal again), > > but the associated button command (the click function) is not called. > > Weren't you the guy who found something else to run these kind of tests ? :P > If it is you then apparently my earlier email about taking a look at > the ttk tests got ignored, but it is fine. On the contrary, I looked into ttk and found it wasn't what I was looking for. We are doing full application black box test, not unit testing. Besides, using ttk would require a porting effort to an application we don't want to make any changes to. Instead, I decided to bite the bullet and create a layer that exposes Tkinter widgets to the AT-SPI world so we can use dogtail, LDTP, Accerciser, at-poke, or whatever. The new layer is called Tka11y (a11y = Accessibility). > > You will want to generate an event before those ones, also, if > your code is just that then also pack the button and wait for its > visibility before generating the events. Yes, my code did the pack (forgot to include it above), but I didn't know about the . Adding this caused things to work. Thanks! > > > If I > > bind a function for the event to the button using the bind method, it gets > > called, but I really need the associated command to get called too. > > > > Also, I tried doing this with a Pmw.ScrolledListBox with an associated > > dblclickcommand, so I tried to generate and > > events, but to my surprise, I received the > > following error message for both cases: > > > > _tkinter.TclError: Double or Triple modifier not allowed > > Well, it makes some sense. How do you double click something ? I'm > afraid you don't have a special key to double click, instead you just > click twice (if you happen to have one then it just simulates the > double click for you). I tried this with the ScrolledListBox. Here's what I'm doing to simulate the double click. It seems to work fine. slb = Pmw.ScrolledListBox(top, dblclickcommand=click) # Same click() as above slb.pack() # I didn't forget this time :-) lb = slb.component('listbox') # Must generate event for subordinate listbox widget lb.event_generate('') lb.event_generate('',x=0,y=0) # Probably not needed, but it reflects reality more closely for i in range(2): lb.event_generate('',x=0,y=0) lb.event_generate('',x=0,y=0) lb.event_generate('') # For good measure Notably, the event must be generated for the contained listbox widget. If the event is sent to the ScrolledListBox itself, it doesn't work. > > In resume: > > import Tkinter > > root = Tkinter.Tk() > > def click(): > print "click" > > def test(event): > print "double" > return "break" > > btn = Tkinter.Button(command=click) > btn.bind('', test) > btn.pack() > btn.wait_visibility() > > btn.event_generate('', x=0, y=0) > btn.event_generate('', x=0, y=0) > btn.event_generate('', x=0, y=0) > btn.event_generate('', x=0, y=0) > btn.event_generate('', x=0, y=0) > > > > > > These problems are getting in the way of my attempt to automate GUI testing > > with Tk. Am I missing something? > > After making the appropriate changes to Tka11y, I am now able to generate the double click from, for example, Accerciser and the application responses appropriately. Thanks for the help. Is there any good documentation on the event system? I've been using http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm, but obviously, there's not enough detail, especially for event_generate. BTW, I will be releasing Tka11y soon (within a few weeks). I've carved out a spot at http://tkinter.unpythonic.net/wiki/Tka11y (accessible from the front page). Stay tuned... > > (Ok, I really don't need the first case, because I can simple call the > > button's invoke method. But in the second case, the associated action is > > only invoked via the double click action.)kk > > > > Allen B. Taylor > > MDA > > 9445 Airport Road > > Brampton, ON L6S 4J3 > > 905-790-2800 ext. 4350 > > allen.taylor at mdacorporation.com > > > > -- > -- Guilherme H. Polo Goncalves > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > Allen -------------- next part -------------- An HTML attachment was scrubbed... URL: From ggpolo at gmail.com Thu Jan 29 17:32:43 2009 From: ggpolo at gmail.com (Guilherme Polo) Date: Thu, 29 Jan 2009 14:32:43 -0200 Subject: [Tkinter-discuss] event_generate question In-Reply-To: <498191E9.FA48.005C.0@mdacorporation.com> References: <49808DB3.FA48.005C.0@mdacorporation.com> <498191E9.FA48.005C.0@mdacorporation.com> Message-ID: On Thu, Jan 29, 2009 at 2:24 PM, Allen Taylor wrote: > Hello Guilherme, >> >>> Guilherme Polo 2009-01-28 18:18 >>> >> On Wed, Jan 28, 2009 at 7:54 PM, Allen Taylor >> wrote: >> > I'm trying to generate some events in Tkinter but it doesn't seem to be >> > working the way I expected. Here's an example of what I'm trying to >> > do... >> > >> > def click(): >> > print 'click' >> > >> > from Tkinter import * >> > top=Tk() >> > b=Button(top, text='Hit me', command=click) >> > >> > b.event_generate('', x=0, y=0) >> > b.event_generate('', x=0, y=0) >> > >> > The appearance of the button changes after the event (to >> > depressed), and again after the event (to normal >> > again), >> > but the associated button command (the click function) is not called. >> >> Weren't you the guy who found something else to run these kind of tests ? >> :P >> If it is you then apparently my earlier email about taking a look at >> the ttk tests got ignored, but it is fine. > On the contrary, I looked into ttk and found it wasn't what I was looking > for. We are doing full application black box test, not unit testing. > Besides, using ttk would require a porting effort to an application we don't > want to make any changes to. I never told you to move to ttk, just to look at its tests. It doesn't matter if you are using unittest or not, what matters is that it contains support functions like this one you are using, which do not depend on ttk. > Instead, I decided to bite the bullet and > create a layer that exposes Tkinter widgets to the AT-SPI world so we can > use dogtail, LDTP, Accerciser, at-poke, or whatever. The new layer is called > Tka11y (a11y = Accessibility). > >> >> You will want to generate an event before those ones, also, if >> your code is just that then also pack the button and wait for its >> visibility before generating the events. > Yes, my code did the pack (forgot to include it above), but I didn't know > about the . Adding this caused things to work. Thanks! > >> >> > If I >> > bind a function for the event to the button using the bind method, it >> > gets >> > called, but I really need the associated command to get called too. >> > >> > Also, I tried doing this with a Pmw.ScrolledListBox with an associated >> > dblclickcommand, so I tried to generate and >> > events, but to my surprise, I received the >> > following error message for both cases: >> > >> > _tkinter.TclError: Double or Triple modifier not allowed >> >> Well, it makes some sense. How do you double click something ? I'm >> afraid you don't have a special key to double click, instead you just >> click twice (if you happen to have one then it just simulates the >> double click for you). > I tried this with the ScrolledListBox. Here's what I'm doing to simulate the > double click. It seems to work fine. > > slb = Pmw.ScrolledListBox(top, dblclickcommand=click) # Same click() as > above > slb.pack() # I didn't forget this time :-) > I remember having some problem in some platform when not waiting for visibility. > lb = slb.component('listbox') # Must generate event for subordinate > listbox widget > lb.event_generate('') > lb.event_generate('',x=0,y=0) # Probably not needed, but it > reflects reality more closely > for i in range(2): > lb.event_generate('',x=0,y=0) > lb.event_generate('',x=0,y=0) > lb.event_generate('') # For good measure > Notably, the event must be generated for the contained listbox widget. If > the event is sent to the ScrolledListBox itself, it doesn't work. > >> >> In resume: >> >> import Tkinter >> >> root = Tkinter.Tk() >> >> def click(): >> print "click" >> >> def test(event): >> print "double" >> return "break" >> >> btn = Tkinter.Button(command=click) >> btn.bind('', test) >> btn.pack() >> btn.wait_visibility() >> >> btn.event_generate('', x=0, y=0) >> btn.event_generate('', x=0, y=0) >> btn.event_generate('', x=0, y=0) >> btn.event_generate('', x=0, y=0) >> btn.event_generate('', x=0, y=0) >> >> >> > >> > These problems are getting in the way of my attempt to automate GUI >> > testing >> > with Tk. Am I missing something? >> > > > After making the appropriate changes to Tka11y, I am now able to generate > the double click from, for example, Accerciser and the application responses > appropriately. Thanks for the help. > > Is there any good documentation on the event system? I've been using > http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm, but > obviously, there's not enough detail, especially for event_generate. > Probably the tk documentation itself, http://www.tcl.tk/man/tcl8.5/TkCmd/event.htm (change 8.5 as needed). > BTW, I will be releasing Tka11y soon (within a few weeks). I've carved out a > spot at http://tkinter.unpythonic.net/wiki/Tka11y (accessible from the front > page). Stay tuned... >> > (Ok, I really don't need the first case, because I can simple call the >> > button's invoke method. But in the second case, the associated action is >> > only invoked via the double click action.)kk >> > >> > Allen B. Taylor >> > MDA >> > 9445 Airport Road >> > Brampton, ON L6S 4J3 >> > 905-790-2800 ext. 4350 >> > allen.taylor at mdacorporation.com >> -- -- Guilherme H. Polo Goncalves From david.giesen at kodak.com Thu Jan 29 17:15:58 2009 From: david.giesen at kodak.com (david.giesen at kodak.com) Date: Thu, 29 Jan 2009 11:15:58 -0500 Subject: [Tkinter-discuss] How to set a constant in lambda In-Reply-To: Message-ID: With lambda, you need to set the value of the variable at the time the lambda is created, or else the variable is grabbed from the environment at the time the lambda runs. You can do this by using the variable as a default argument. In your case, change: XT.append(Button(T,text="Viola:New Tab",command=lambda:switch_tabs(whoopsie)) to XT.append(Button(T,text="Viola:New Tab",command=lambda x=Whoopsie:switch_tabs(x)) ought to do it. Dave David J. Giesen | Research Scientist | FPEG US Display OLED Materials R+D | Eastman Kodak Company | 2/83/KRL MC02216 | Rochester, NY 14650 | david.giesen at kodak.com | 1-585-588-0480 Office | www.kodak.com > From: vtcodger > > I came across a problem that probably has a simple, clever, answer -- but it > is eluding me. I was trying to create a set of tab buttons on a Tkinter > page using Buttons. These are created dynamically when the user loads a > file. I don't know in advance how many files will get opened, so I want to > have a variable number of tabs. > > So we have a Frame T; and an array of tabs XT[]; and a function > switch_tabs(n) that will handle the details of switching the data base, > titles, etc. I compute the tab number: > > Whoopsie = len(XT) > > And I create a new Button: > > XT.append(Button(T,text="Viola:New Tab",command=lambda: > switch_tabs(whoopsie)) > > It all works fine except for this one minor detail. Whoopsie can't be a > constant because I don't know in advance what constant to use. And if > whoopsie is a variable, it apparently is evaluated at execution time, and > will have the then current value of whoopsie, not the value I wanted to set > at creation time. I tried everything I could think of including > copy.copy(whoopsie) to get a constant set so that switch_tabs could know > which tab to switch to. > > Couldn't do it. I was starting to look at tracing back through stack frames > when it came to me that RadioButtons unlike generic Buttons have a > variable-value attribute pair that behaves as I desire. So this > manifestation of the problem is worked around. But I expect that I'll see > this problem again in some other guise. > > Am I missing something? Probably something simple? What? > -- From ggpolo at gmail.com Thu Jan 29 18:00:40 2009 From: ggpolo at gmail.com (Guilherme Polo) Date: Thu, 29 Jan 2009 15:00:40 -0200 Subject: [Tkinter-discuss] How to set a constant in lambda In-Reply-To: References: Message-ID: On Thu, Jan 29, 2009 at 2:15 PM, wrote: > With lambda, you need to set the value of the variable at the time the > lambda is created, or else the variable is grabbed from the environment at > the time the lambda runs. You can do this by using the variable as a > default argument. In your case, change: > > XT.append(Button(T,text="Viola:New > Tab",command=lambda:switch_tabs(whoopsie)) > > to > > XT.append(Button(T,text="Viola:New Tab",command=lambda > x=Whoopsie:switch_tabs(x)) > Ah, it looks like you got what he meant. And to me, when you start having problem with lambda and solves it by doing lambda bindings, that is a good time to move to real functions. > ought to do it. > > Dave > > David J. Giesen | Research Scientist | FPEG US Display OLED Materials R+D > | > Eastman Kodak Company | 2/83/KRL MC02216 | Rochester, NY 14650 | > david.giesen at kodak.com | 1-585-588-0480 Office | > www.kodak.com > > -- -- Guilherme H. Polo Goncalves From david.giesen at kodak.com Thu Jan 29 19:48:48 2009 From: david.giesen at kodak.com (david.giesen at kodak.com) Date: Thu, 29 Jan 2009 13:48:48 -0500 Subject: [Tkinter-discuss] How to set a constant in lambda In-Reply-To: Message-ID: I also dislike lambdas for this purpose. I'd recommend that the original poster build a class - many ways they could go with this, but here is one rough sketch (haven't checked for syntax errors, etc.): class PageButton(Button): def __init__(self, master, text=None, page_number=0): self.page_number = page_number self.text = text if not self.text: self.text = 'Page #' + str(self.page_number) Button.__init__(self, master, text=self.text, command=self.switch_tabs) self.master = master def switch_tabs(self): # do whatever is required to switch tabs here, using self to reference the button and self.page_number to reference the page XT=[] # command to create a new button XT.append(PageButton(T, page_number=len(XT))) Dave David J. Giesen | Research Scientist | FPEG US Display OLED Materials R+D | Eastman Kodak Company | 2/83/KRL MC02216 | Rochester, NY 14650 | david.giesen at kodak.com | 1-585-588-0480 Office | www.kodak.com Guilherme Polo wrote on 01/29/2009 12:00:40 PM: > On Thu, Jan 29, 2009 at 2:15 PM, wrote: > > With lambda, you need to set the value of the variable at the time the > > lambda is created, or else the variable is grabbed from the environment at > > the time the lambda runs. You can do this by using the variable as a > > default argument. In your case, change: > > > > XT.append(Button(T,text="Viola:New > > Tab",command=lambda:switch_tabs(whoopsie)) > > > > to > > > > XT.append(Button(T,text="Viola:New Tab",command=lambda > > x=Whoopsie:switch_tabs(x)) > > > > Ah, it looks like you got what he meant. > > And to me, when you start having problem with lambda and solves it by > doing lambda bindings, that is a good time to move to real functions. > > > ought to do it. > > > > Dave > > > > David J. Giesen | Research Scientist | FPEG US Display OLED Materials R+D > > | > > Eastman Kodak Company | 2/83/KRL MC02216 | Rochester, NY 14650 | > > david.giesen at kodak.com | 1-585-588-0480 Office | > > www.kodak.com > > > > > > -- > -- Guilherme H. Polo Goncalves > So we have a Frame T; and an array of tabs XT[]; and a function > switch_tabs(n) that will handle the details of switching the data base, > titles, etc. I compute the tab number: > > Whoopsie = len(XT) > > And I create a new Button: > > XT.append(Button(T,text="Viola:New Tab",command=lambda: > switch_tabs(whoopsie)) > > It all works fine except for this one minor detail. Whoopsie can't be a > constant because I don't know in advance what constant to use. And if > whoopsie is a variable, it apparently is evaluated at execution time, and > will have the then current value of whoopsie, not the value I wanted to set > at creation time. I tried everything I could think of including > copy.copy(whoopsie) to get a constant set so that switch_tabs could know > which tab to switch to. > From mattx_13 at hotmail.com Fri Jan 30 14:59:39 2009 From: mattx_13 at hotmail.com (AbsoluteMatt) Date: Fri, 30 Jan 2009 05:59:39 -0800 (PST) Subject: [Tkinter-discuss] Running system calls through TKinter Message-ID: <21747662.post@talk.nabble.com> Hi All, I have been writing a little app in python/tkinter to allow non technical users at my office setup/restore manipulate Oracle databases. I am using cx_Oracle plugin as well. The app works fine at the moment, doing everything I want it to. However when it comes to importing a db I am just using imp.exe and dpimp.exe basically making external system calls to run it. I know this is not ideal and I should probably be using popen etc, but I am not to sure on how to get it working. I tried a while ago and it broke more than it fixed so I paniced and went back to good old command prompt method. I want to be able to view the output of an oracle import in realtime, anyone that has seen imp/exp knows that when running on command line you can see the tables importing as they import line by line. Ideally I would like to have a "process" tab on my tkinter app rather than a seperate DOS prompt running the command, where you can see this execution. I cant remember exactly what I tried before, but I think it involved using popen and stdout and then printing stdout. However when I did it like this it used to print out output in bulk blocks not nicely one line at a time. So.... Is there anyway to embed a command window inside a tkinter window, or does anyone know a way of outputting system calls in to a tkinter window in realtime, one line at a time. I think I have explained my problem really badly, so sorry. I have searched online and all I seem to get is the same use popen. Maybe I don't understand the popen stuff well enough, but its time for another shot. This little DOS prompt by the side of my app is getting on my nerves. Any Suggestions?, Im lost! Many Thanks, Matt -- View this message in context: http://www.nabble.com/Running-system-calls-through-TKinter-tp21747662p21747662.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From ggpolo at gmail.com Fri Jan 30 18:52:39 2009 From: ggpolo at gmail.com (Guilherme Polo) Date: Fri, 30 Jan 2009 15:52:39 -0200 Subject: [Tkinter-discuss] Running system calls through TKinter In-Reply-To: <21747662.post@talk.nabble.com> References: <21747662.post@talk.nabble.com> Message-ID: On Fri, Jan 30, 2009 at 11:59 AM, AbsoluteMatt wrote: > > Hi All, > > I have been writing a little app in python/tkinter to allow non technical > users at my office setup/restore manipulate Oracle databases. I am using > cx_Oracle plugin as well. > > The app works fine at the moment, doing everything I want it to. However > when it comes to importing a db I am just using imp.exe and dpimp.exe > basically making external system calls to run it. I know this is not ideal > and I should probably be using popen etc, but I am not to sure on how to get > it working. I tried a while ago and it broke more than it fixed so I paniced > and went back to good old command prompt method. > > I want to be able to view the output of an oracle import in realtime, Tricky! > anyone > that has seen imp/exp knows that when running on command line you can see > the tables importing as they import line by line. Ideally I would like to > have a "process" tab on my tkinter app rather than a seperate DOS prompt > running the command, where you can see this execution. > > I cant remember exactly what I tried before, but I think it involved using > popen and stdout and then printing stdout. However when I did it like this > it used to print out output in bulk blocks not nicely one line at a time. > > So.... Is there anyway to embed a command window inside a tkinter window, I don't think so, maybe something like powershell might be able. It would be easy to do it with xterm, for example, since it has support for a -into option. > or > does anyone know a way of outputting system calls in to a tkinter window in > realtime, one line at a time. > > I think I have explained my problem really badly, so sorry. Actually I think you did well explaining it ;) > I have searched > online and all I seem to get is the same use popen. Maybe I don't understand > the popen stuff well enough, but its time for another shot. This little DOS > prompt by the side of my app is getting on my nerves. > > Any Suggestions?, Im lost! > Oh well, let me start it and someone with more Windows (got one of these yesterday, so now I can at least test code there :) experience can improve it. The code is ugly on purpose so you may resist to just copy and paste it, and it is also an indication that it might not work! import subprocess import Tkinter from win32pipe import PeekNamedPipe import msvcrt root = Tkinter.Tk() proc = subprocess.Popen(['c:/python26/python.exe', '-u', 'ex1.py'], stdout=subprocess.PIPE) out = proc.stdout hndl = msvcrt.get_osfhandle(out.fileno()) def check_output(): retcode = proc.poll() # using PeekNamedPipe to check for data available -- it returns immediately # (at least in single thread applications) _, avail, _ = PeekNamedPipe(hndl, 0) if avail: text.insert('end', out.read(avail)) if retcode is not None: return else: text.after(100, check_output) text = Tkinter.Text() text.pack() text.after_idle(check_output) root.mainloop() The sample used, ex1.py, is this one: import time print "hi" time.sleep(2) print "there" Note that I have cheated by using a sample that happens to be a python file and I "just happened" to run python in unbuffered mode. This is where you will likely have problems, your .exe probably doesn't flush after every single line. But hopefully this help you in some way. > Many Thanks, > > Matt > -- -- Guilherme H. Polo Goncalves From ggpolo at gmail.com Fri Jan 30 20:17:17 2009 From: ggpolo at gmail.com (Guilherme Polo) Date: Fri, 30 Jan 2009 17:17:17 -0200 Subject: [Tkinter-discuss] Running system calls through TKinter In-Reply-To: References: <21747662.post@talk.nabble.com> Message-ID: On Fri, Jan 30, 2009 at 3:52 PM, Guilherme Polo wrote: > On Fri, Jan 30, 2009 at 11:59 AM, AbsoluteMatt wrote: >> >> Hi All, >> >> I have been writing a little app in python/tkinter to allow non technical >> users at my office setup/restore manipulate Oracle databases. I am using >> cx_Oracle plugin as well. >> >> The app works fine at the moment, doing everything I want it to. However >> when it comes to importing a db I am just using imp.exe and dpimp.exe >> basically making external system calls to run it. I know this is not ideal >> and I should probably be using popen etc, but I am not to sure on how to get >> it working. I tried a while ago and it broke more than it fixed so I paniced >> and went back to good old command prompt method. >> >> I want to be able to view the output of an oracle import in realtime, > > Tricky! > >> anyone >> that has seen imp/exp knows that when running on command line you can see >> the tables importing as they import line by line. Ideally I would like to >> have a "process" tab on my tkinter app rather than a seperate DOS prompt >> running the command, where you can see this execution. >> >> I cant remember exactly what I tried before, but I think it involved using >> popen and stdout and then printing stdout. However when I did it like this >> it used to print out output in bulk blocks not nicely one line at a time. >> >> So.... Is there anyway to embed a command window inside a tkinter window, > > I don't think so, maybe something like powershell might be able. It > would be easy to do it with xterm, for example, since it has support > for a -into option. I just noticed there is a win32process module included with pywin32, so it must be possible. Better than that, there is something ready already called pyconsole. It is found it here: http://code.google.com/p/pyconsole/ I got it and tried doing an example with it: import Tkinter import pyconsole class ConsoleProcessWindow(Tkinter.Text): def __init__(self, master=None): Tkinter.Text.__init__(self) self.console_process = pyconsole.ConsoleProcess('cmd.exe', console_update=self.console_update) self.last_line = 0 def test(self): self.console_process.write('dir\n') def console_update(self, x, y, text): self.after_idle(lambda: self.update_text(x, y, text)) def update_text(self, x, y, text): y += 1 for i in xrange(y - self.last_line): self.insert('%d.0' % (self.last_line + i + 1), '\n') self.last_line = y self.insert('%d.%d' % (y, x), text) self.update_idletasks() class App(Tkinter.Frame): def __init__(self): Tkinter.Frame.__init__(self) self.console = ConsoleProcessWindow(self) self.console.pack(side='left', fill='both', expand=True) vscroll = Tkinter.Scrollbar(orient='vertical', command=self.console.yview) self.console['yscrollcommand'] = vscroll.set vscroll.pack(side='right', fill='y') self.after(500, self.console.test) root = Tkinter.Tk() app = App() app.pack(fill='both', expand=True) root.mainloop() And it works! So you just need to send things to this ConsoleProcess like you would do in your typical command prompt. -- -- Guilherme H. Polo Goncalves From ggpolo at gmail.com Sat Jan 31 02:54:54 2009 From: ggpolo at gmail.com (Guilherme Polo) Date: Fri, 30 Jan 2009 23:54:54 -0200 Subject: [Tkinter-discuss] Running system calls through TKinter In-Reply-To: References: <21747662.post@talk.nabble.com> Message-ID: >>> So.... Is there anyway to embed a command window inside a tkinter window, Here now: http://tkinter.unpythonic.net/wiki/CmdTk -- -- Guilherme H. Polo Goncalves