From ghoyle at gmail.com Mon Nov 13 10:01:42 2006 From: ghoyle at gmail.com (Greg Hoyle) Date: Mon, 13 Nov 2006 03:01:42 -0600 Subject: [Tkinter-discuss] Python shell still running after program has been terminated Message-ID: Howdy, While making a small program using python 2.4.4, I have run into a problem getting the python shell to stop running the program. I am not certain of what the problem could be and i'm wondering if there's a way that I can avoid encountering this problem in the future. The details are below. I can run the program (I normally use F5) without any problems, once; however, when I try to run it again (with or without new changes made to the code), I get an error window that states "Already Executing: The Python Shell window is already executing a command; please wait until it is finished." This window appears twice (back to back) then this is printed out in the shell window: ________________________________________________________________ Exception in Tkinter callback Traceback (most recent call last): File "C:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__ return self.func(*args) File "C:\Python24\lib\idlelib\ScriptBinding.py", line 166, in run_module_event interp.runcode(code) File "C:\Python24\lib\idlelib\PyShell.py", line 697, in runcode self.interp.restart_subprocess() AttributeError: ModifiedInterpreter instance has no attribute 'interp' _________________________________________________________________ Just in case you need it, here's the code that im using that causes this: ############################################### from Tkinter import * root = Tk() listbox = Listbox(root) listbox.pack() name_list = ('name1', 'name2', 'name3', 'name4') for item in name_list: listbox.insert(END, item) print name_list root.mainloop() ################################################# Am I missing something? I am using windows xp media center and the file is save as .pyw. I cant think of any other information that you might need. If you do need more, please let me know and i'll provide it. Thanks for any assitance that you can provide. Greg -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061113/fbcf73f5/attachment.html From gerardo at computo-industrial.com.mx Tue Nov 14 01:32:36 2006 From: gerardo at computo-industrial.com.mx (Gerardo Juarez) Date: Mon, 13 Nov 2006 19:32:36 -0500 (EST) Subject: [Tkinter-discuss] Python shell still running after program has been terminated In-Reply-To: Message-ID: Hi, Yes it does that. No, I don't know what causes it but it seems to be an interaction with the OS. I assume you are using IDLE. Have you tried Shell/Restart Shell (Ctrl+F6)? It has worked for me most of the times. It is interesting that an application using several threads seems easier to stop cleanly. On Mon, 13 Nov 2006, Greg Hoyle wrote: > Howdy, > > While making a small program using python 2.4.4, I have run into a problem > getting the python shell to stop running the program. I am not certain of > what the problem could be and i'm wondering if there's a way that I can > avoid encountering this problem in the future. The details are below. > > I can run the program (I normally use F5) without any problems, once; > however, when I try to run it again (with or without new changes made to the > code), I get an error window that states "Already Executing: The Python > Shell window is already executing a command; please wait until it is > finished." This window appears twice (back to back) then this is printed out > in the shell window: > > ________________________________________________________________ > Exception in Tkinter callback > Traceback (most recent call last): > File "C:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__ > return self.func(*args) > File "C:\Python24\lib\idlelib\ScriptBinding.py", line 166, in > run_module_event > interp.runcode(code) > File "C:\Python24\lib\idlelib\PyShell.py", line 697, in runcode > self.interp.restart_subprocess() > AttributeError: ModifiedInterpreter instance has no attribute 'interp' > _________________________________________________________________ > > > > Just in case you need it, here's the code that im using that causes this: > > ############################################### > from Tkinter import * > root = Tk() > > listbox = Listbox(root) > listbox.pack() > > name_list = ('name1', 'name2', 'name3', 'name4') > > for item in name_list: > listbox.insert(END, item) > > print name_list > > root.mainloop() > ################################################# > > > Am I missing something? I am using windows xp media center and the file is > save as .pyw. I cant think of any other information that you might need. If > you do need more, please let me know and i'll provide it. > > Thanks for any assitance that you can provide. > > Greg > From kw at kevin-walzer.com Mon Nov 13 22:23:21 2006 From: kw at kevin-walzer.com (Kevin Walzer) Date: Mon, 13 Nov 2006 16:23:21 -0500 Subject: [Tkinter-discuss] ANN: Martin Franklin's Tile/Tablelist Tkinter wrappers now at SourceForge Message-ID: <4558E249.6050109@kevin-walzer.com> I have posted Martin Franklin's Tkinter wrappers for the TableList package (http://www.nemethi.de/) and the Tile theming extension (http://tktable.sourceforge.net/tile/) at SourceForge. Mr. Franklin previously hosted these wrappers at the URL's below: http://mfranklin.is-a-geek.org/docs/TableList/index.html http://mfranklin.is-a-geek.org/docs/Tile/index.html Mr. Franklin had previously announced the wrappers on these lists: http://mail.python.org/pipermail/tkinter-discuss/2005-January/000302.html http://mail.python.org/pipermail/tkinter-discuss/2005-March/000365.html His licensing terms were not explicit, but my reading of the threads indicates he intended the wrappers to be freely reusable. I had downloaded the extensions several months ago, intending to try them out. Since then Mr. Franklin's site seems to have gone offline, and the extensions are not available elsewhere. Because they are the best-available Tkinter wrappers for these two powerful Tk extensions, I have made them available at a SF site I maintain for various Tk extensions. The download link is below: https://sourceforge.net/project/showfiles.php?group_id=165637&package_id=211496&release_id=463359 At present I have only posted the extensions themselves. The only documentation is that provided by Mr. Franklin in his source code. After I spend more time using these extensions in an application I am developing, I will probably update the package with additional documentation. If I have misstepped by making these extensions available at SF, I invite Mr. Franklin to contact me on- or off-list. -- Kevin Walzer Code by Kevin http://www.codebykevin.com From Vasilis.Vlachoudis at cern.ch Sat Nov 18 23:29:35 2006 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Sat, 18 Nov 2006 23:29:35 +0100 Subject: [Tkinter-discuss] Canvas cursor position Message-ID: <455F894F.7070307@cern.ch> Dear all, in my application I am using editable text items inside a Canvas with the Canvas.create_text(). My problem is how to find the position (x,y) of the insert cursor from an editable text item in a canvas, so when the cursor goes out of the window to scroll the canvas to see the cursor? While I can set the cursor with Canvas.icursor(item,"@%d,%d"%(x,y)), I cannot get back the x,y position with the function Canvas.index(item, index). It returns only a numerical index of the cursor position. Vasilis From pekka.niiranen at wlanmail.com Sun Nov 19 12:06:11 2006 From: pekka.niiranen at wlanmail.com (Pekka Niiranen) Date: Sun, 19 Nov 2006 13:06:11 +0200 Subject: [Tkinter-discuss] Tkinter grid manipulation question Message-ID: Hi, I found this code from Internet: from Tkinter import * rows = [] for i in range(5): cols = [] for j in range(4): e = Entry(relief=RIDGE) e.grid(row=i, column=j, sticky=N+S+E+W) e.insert(END, '%d.%d' % (i, j)) cols.append(e) rows.append(cols) # print Grid.grid_info(e) def onPress(): for row in rows: for col in row: print col.get(), print Button(text='Fetch', command=onPress).grid() mainloop() How can I change its behaviour so that when I hit Enter on current cell the cursor moves automatically to cell below it? (I should bind the Enter -button and call to adjust current cell location) -pekka- From fredrik at pythonware.com Sun Nov 19 12:43:39 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 19 Nov 2006 12:43:39 +0100 Subject: [Tkinter-discuss] Tkinter grid manipulation question In-Reply-To: References: Message-ID: Pekka Niiranen wrote: > How can I change its behaviour so that when I hit Enter on current cell > the cursor moves automatically to cell below it? > > (I should bind the Enter -button and call > to adjust current cell location) call focus_set() on the widget that should get focus: http://effbot.org/tkinterbook/widget.htm#Tkinter.Widget.focus_set-method From sxn02 at yahoo.com Wed Nov 22 20:33:05 2006 From: sxn02 at yahoo.com (Sorin Schwimmer) Date: Wed, 22 Nov 2006 11:33:05 -0800 (PST) Subject: [Tkinter-discuss] Windows beautification Message-ID: <20061122193305.59826.qmail@web56001.mail.re3.yahoo.com> Hi All, 1. I'd like to be able to put an icon on the titlebar. I read about using iconwindow together with a Label, but how? My code: from Tkinter import * import Image,ImageTk root=Tk() im=ImageTk.PhotoImage(Image.open("mcut16.png")) # a 16x16 image lb=Label(root,image=im) root.iconwindow(lb) yields the following error: Traceback (most recent call last): File "", line 1, in ? File "/usr/local/lib/python2.4/lib-tk/Tkinter.py", line 1473, in wm_iconwindow return self.tk.call('wm', 'iconwindow', self._w, pathName) _tkinter.TclError: can't use .-1211821748 as icon window: not at top level How should I do it? 2. I'd like to be able to set the colour of the window decoration. I'd like to distinguish between similar windows based on their title (and, if possible, border) colour. Can I accomplish that? 3. Where can I find a detailed documentation about what arguments go in the wm_ family of Toplevel methods (meaning, format)? Thanks, Sorin ____________________________________________________________________________________ Sponsored Link Online degrees - find the right program to advance your career. www.nextag.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061122/80776023/attachment.html From klappnase at web.de Wed Nov 22 21:50:37 2006 From: klappnase at web.de (Michael Lange) Date: Wed, 22 Nov 2006 21:50:37 +0100 Subject: [Tkinter-discuss] Windows beautification In-Reply-To: <20061122193305.59826.qmail@web56001.mail.re3.yahoo.com> References: <20061122193305.59826.qmail@web56001.mail.re3.yahoo.com> Message-ID: <20061122215037.4a4a35bd.klappnase@web.de> On Wed, 22 Nov 2006 11:33:05 -0800 (PST) Sorin Schwimmer wrote: > Hi All, > > 1. I'd like to be able to put an icon on the titlebar. I read about using iconwindow together > with a Label, but how? My code: > > from Tkinter import * > import Image,ImageTk > > root=Tk() > im=ImageTk.PhotoImage(Image.open("mcut16.png")) # a 16x16 image > lb=Label(root,image=im) > root.iconwindow(lb) > > yields the following error: > > Traceback (most recent call last): > File "", line 1, in ? > File "/usr/local/lib/python2.4/lib-tk/Tkinter.py", line 1473, in wm_iconwindow > return self.tk.call('wm', 'iconwindow', self._w, pathName) > _tkinter.TclError: can't use .-1211821748 as icon window: not at top level > > How should I do it? > I think you need a Toplevel() window instead of a Label. Michael From sxn02 at yahoo.com Wed Nov 22 22:23:05 2006 From: sxn02 at yahoo.com (Sorin Schwimmer) Date: Wed, 22 Nov 2006 15:23:05 -0600 (CST) Subject: [Tkinter-discuss] Windows beautification Message-ID: <20061122212305.42171.qmail@web56002.mail.re3.yahoo.com> > I think you need a Toplevel() window instead of a Label. > Michael I'm not sure I understand. Can you illustrate with an example? Thanks, Sorin ____________________________________________________________________________________ Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061122/e5b0be2f/attachment.html From godson.g at gmail.com Thu Nov 23 08:00:28 2006 From: godson.g at gmail.com (Godson) Date: Thu, 23 Nov 2006 12:30:28 +0530 Subject: [Tkinter-discuss] Windows beautification In-Reply-To: <20061122212305.42171.qmail@web56002.mail.re3.yahoo.com> References: <20061122212305.42171.qmail@web56002.mail.re3.yahoo.com> Message-ID: On 11/23/06, Sorin Schwimmer wrote: > > > I think you need a Toplevel() window instead of a Label. > > > Michael > > I'm not sure I understand. Can you illustrate with an example? > > Thanks, > Sorin > > ------------------------------ > Everyone is raving about the all-new Yahoo! Mail beta. > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > > if all you want is to set icon for a window you can simply do that with the following in code from Tkinter import* root=Tk() root.iconbitmap("c:\\python25\\smiley.ico") iconbitmap is capable of readiong windows .ico files and it can simply set the icon, so you dont have to go in to all the hacking of label image tk etc etc. 2) The window decoration is drawn by the OS not by the Tkinter. That window decoration is a kind of global look and feel that you get for all the windows in your machine as decided by the theme manager. If you still insist on doing that from with Tkinter simply restrict the window manager from decorating your windows. use "overrideredirect" method on root window root.overrideredirect(1) But it has lots of troubles like you cant move the window normally, for that you have to write additional code. 3) http://effbot.org/tkinterbook/wm.htm -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061123/d16d9588/attachment.html From klappnase at web.de Thu Nov 23 11:02:09 2006 From: klappnase at web.de (Michael Lange) Date: Thu, 23 Nov 2006 11:02:09 +0100 Subject: [Tkinter-discuss] Windows beautification In-Reply-To: <20061122212305.42171.qmail@web56002.mail.re3.yahoo.com> References: <20061122212305.42171.qmail@web56002.mail.re3.yahoo.com> Message-ID: <20061123110209.48b8d57f.klappnase@web.de> On Wed, 22 Nov 2006 15:23:05 -0600 (CST) Sorin Schwimmer wrote: > > I think you need a Toplevel() window instead of a Label. > > > Michael > > I'm not sure I understand. Can you illustrate with an example? > > Thanks, > Sorin > >>> from Tkinter import * >>> root = Tk() >>> top = Toplevel() >>> img = PhotoImage(file='your-icon-here') >>> Label(top, image=img).pack() >>> top.overrideredirect(1)# not sure if this is necessary >>> root.iconwindow(top) '' >>> On linux (with IceWM) the iconwindow is not visible, but at least the Toplevel disappears and Tk does not complain. Maybe it works on windows. Michael From sxn02 at yahoo.com Thu Nov 23 17:22:25 2006 From: sxn02 at yahoo.com (Sorin Schwimmer) Date: Thu, 23 Nov 2006 08:22:25 -0800 (PST) Subject: [Tkinter-discuss] Windows beautification Message-ID: <20061123162225.38070.qmail@web56012.mail.re3.yahoo.com> Hello again, Thanks for replys. I should have pointed out that I'm on Linux, with KDE. > On linux (with IceWM) the iconwindow is not visible, but at least the Toplevel > disappears and Tk does not complain. Maybe it works on windows. > > Michael Same happens to me. I started exploring the Label idea based on Fredrik's Lundh suggestion in http://www.pythonware.com/library/tkinter/introduction/x9905-icon-methods.htm It may be that I misunderstood his method. > iconbitmap is capable of readiong windows .ico files and it can simply set > the icon, so you dont have to go in to all the hacking of label image tk etc > etc. The above-mentioned piece of documentation states that iconbitmap works with monochrome icons; I'd like to go Kodak For the 2nd point, I thought that things like colormapwindows may be useful. But I don't know what args to pass, and how to experiment with it, so it led me to the third point. I read the suggested material, but it's too brief for my level of knowledge. Is there something more detailed available, to explain what goes in colormapwindows, or in command? Thanks again, Sorin ____________________________________________________________________________________ Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061123/4ef0bc29/attachment.html From klappnase at web.de Thu Nov 23 17:43:57 2006 From: klappnase at web.de (Michael Lange) Date: Thu, 23 Nov 2006 17:43:57 +0100 Subject: [Tkinter-discuss] Windows beautification In-Reply-To: <20061123162225.38070.qmail@web56012.mail.re3.yahoo.com> References: <20061123162225.38070.qmail@web56012.mail.re3.yahoo.com> Message-ID: <20061123174357.5a719465.klappnase@web.de> On Thu, 23 Nov 2006 08:22:25 -0800 (PST) Sorin Schwimmer wrote: > > Same happens to me. I started exploring the Label idea based on Fredrik's Lundh suggestion in > http://www.pythonware.com/library/tkinter/introduction/x9905-icon-methods.htm > > It may be that I misunderstood his method. > > Or maybe he should change "This method are ignored by some window managers (including Windows)." into "most window managers". > > iconbitmap is capable of readiong windows .ico files and it can simply set > > the icon, so you dont have to go in to all the hacking of label image tk etc > > etc. > > The above-mentioned piece of documentation states that iconbitmap works with > monochrome icons; I'd like to go Kodak > If it is an option for you, you could try Tk-8.5, which includes a new iconphoto command; it is not implemented in Tkinter yet, but using it should be as simple as (untested): root = Tk() img = PhotoImage(file='your-icon') root.tk.call('wm', 'iconphoto', root._w, img) > For the 2nd point, I thought that things like colormapwindows may be useful. But I don't > know what args to pass, and how to experiment with it, so it led me to the third point. > > I read the suggested material, but it's too brief for my level of knowledge. Is there something > more detailed available, to explain what goes in colormapwindows, or in command? > > You might want to have a look at the wm manpage where all these are explained in more detail and you will find out quickly how to "translate" this into Tkinter. i hope this helps Michael From cappy2112 at gmail.com Sun Nov 26 21:54:32 2006 From: cappy2112 at gmail.com (Tony Cappellini) Date: Sun, 26 Nov 2006 12:54:32 -0800 Subject: [Tkinter-discuss] First timer using tkinter Message-ID: <8249c4ac0611261254v26377b95w5fe3473b8bf26f84@mail.gmail.com> This is the first time I've used tkinter. Windows XP is the platform The program I want to write is pretty simple. I've read through some online tutorials, however, I'm looking for some examples of 1. How to keep a tkinter gui on top of all other windows/apps, and how to programmatically enabled/disable the "on-top" feature, if possible 2. I'm using the Python interpreter in interactive mode for input, but I'd like a small tkinter Window displayed above it to show the value of some important variables (this is what I need the OnTop option for). If possible, I'd like to couple the console window together with a small Tkinter window to display some important variables. I would like to find a example that shows how to put the python interpreter console window and a small tkinter window "together", one above the other. thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061126/e95889f9/attachment.html From kw at codebykevin.com Sun Nov 26 22:06:03 2006 From: kw at codebykevin.com (Kevin Walzer) Date: Sun, 26 Nov 2006 16:06:03 -0500 Subject: [Tkinter-discuss] Several entries on Tile and TableList at the Tkinter wiki Message-ID: <456A01BB.8090007@codebykevin.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I'm not sure how often members of this list visit the Tkinter wiki at http://tkinter.unpythonic.net/wiki/FrontPage; this wiki seems to have less traffic in general than the Tcl/Tk wiki at http://wiki.tcl.tk. Given that, I hope it's not out of line for me to call attention to several pages that I've posted about integrating Tile (http://tktable.sourceforge.net/tile) and TableList (http://www.nemethi.de, http://wiki.tcl.tk/5527) into Tkinter applications. I've noted a serious lack of resources/documentation about these two powerful Tk components. In addition to some documentation, screenshots, and sample applications, I've posted updated versions of the original TableList and Tile wrappers by Martin Franklin, a member of this list. I should take this moment to thank Mr. Franklin for his work on these wrappers; whatever I added to them was pretty minimal compared to the heavy lifting he did. He originally posted them on the Internet last year, but the site that hosted them has gone dark. Anyway, Mr. Franklin, if you are reading this, thank you for your hard work; it has been enormously helpful. I hope my own efforts extend your work and make it even more useful for other Tkinter developers. Here are the links: http://tkinter.unpythonic.net/wiki/UsingTile http://tkinter.unpythonic.net/wiki/TileWrapper http://tkinter.unpythonic.net/wiki/TableListWrapper http://tkinter.unpythonic.net/wiki/TableListTileWrapper http://tkinter.unpythonic.net/wiki/PyLocateTile http://tkinter.unpythonic.net/wiki/PyLocate Hope these prove useful to others, as starting points for your own work if nothing else. Corrections and improvements are of course invited; it's a wiki! Regards, Kevin Walzer - -- Kevin Walzer Code by Kevin http://www.codebykevin.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFagG7EsLm8HXyq4sRAhrEAKCBw2t8tqFtvNFSbi8UgEq0wKxzjACfWOnL PY7JIyUaO27ftGyjJAVgGVo= =iq7a -----END PGP SIGNATURE----- From Cameron at phaseit.net Sun Nov 26 22:43:22 2006 From: Cameron at phaseit.net (Cameron Laird) Date: Sun, 26 Nov 2006 21:43:22 +0000 Subject: [Tkinter-discuss] First timer using tkinter In-Reply-To: <8249c4ac0611261254v26377b95w5fe3473b8bf26f84@mail.gmail.com> References: <8249c4ac0611261254v26377b95w5fe3473b8bf26f84@mail.gmail.com> Message-ID: <20061126214322.GA13806@lairds.us> On Sun, Nov 26, 2006 at 12:54:32PM -0800, Tony Cappellini wrote: . . . > This is the first time I've used tkinter. Windows XP is the platform > > The program I want to write is pretty simple. > > I've read through some online tutorials, however, I'm looking for some > examples of > > 1. How to keep a tkinter gui on top of all other windows/apps, and how to > programmatically enabled/disable the "on-top" feature, if possible . . . A great exercise would be to adapt for the Tkinter Wiki . From cappy2112 at gmail.com Mon Nov 27 01:20:47 2006 From: cappy2112 at gmail.com (Tony Cappellini) Date: Sun, 26 Nov 2006 16:20:47 -0800 Subject: [Tkinter-discuss] Method to call when gui is first displayed Message-ID: <8249c4ac0611261620s5786cb67mb1cfd1c99ed9195e@mail.gmail.com> I'm porting a cmd line app to a tkinter gui app. The program displays 2 menu items, and a status bar, when the program is initially launched. I need to kick off a function which goes out to the lan, performs some CVS operations which take a variable amount of time, depending on network activity. I don't want to do the CVS stuff before the gui is displayed because it looks like the program is hung. I would like to use the program status bar to keep the user informed about what is going on. I want to call the function which talks to CVS after the gui is displayed, but without formal having to do anything. After I call mainloop(), the gui is displayed, but then nothing happens until the user selects a menu option. (as it should be). Is there a tk method that I can register a callback with that indicates the gui is displayed, and mainloop is running? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061126/38530220/attachment.htm From cappy2112 at gmail.com Mon Nov 27 04:30:51 2006 From: cappy2112 at gmail.com (Tony Cappellini) Date: Sun, 26 Nov 2006 19:30:51 -0800 Subject: [Tkinter-discuss] moving from pack to grid Message-ID: <8249c4ac0611261930g3d7e0b6ej3fc3c0bf639999f1@mail.gmail.com> I've got a main window which is 640 * 400. self.root.geometry("600x400") self.label.pack(side=BOTTOM, fill=X) This line would put the label at the bottom of the window, and extend to both left and right edges of the window. I want to change to grid geometry because I have several more widgets to put in the main window. self.label.grid(row=5, column=2, column=0) This put the label at row 5, in the center of the window, but the label didn't extend to the window edges. After reading this http://effbot.org/tkinterbook/grid.htm I tried playing around with other options, but can't get the label to move any lower in the main window self.label.grid(row=10, column=2, column=0) didn't move the label any lower than row 5 My main window isn't constructed using pack(), so I'm not mixing grid and pack in this program. Although, the main window isn't calling grid explicitly either- that's a bit confusing, because I thought all widgets had to call grid or pack to be displayed... What args do I need to move the label to the bottom of the window, and centered so it extends to both left and right edges? I don't like to hard-code a row number, I'd rather make it dynamic in case the window grows or shrinks. thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061126/1bd6d6cc/attachment.htm From mkieverpy at tlink.de Mon Nov 27 09:54:52 2006 From: mkieverpy at tlink.de (mkieverpy at tlink.de) Date: Mon, 27 Nov 2006 09:54:52 +0100 Subject: [Tkinter-discuss] Method to call when gui is first displayed Message-ID: <456aa7dc6c39f5.23036646@> Tony Cappellini askted: >I want to call the function which talks to CVS after the gui is displayed, >but without formal having to do anything. >After I call mainloop(), the gui is displayed, but then nothing happens >until the user selects a menu option. (as it should be). >Is there a tk method that I can register a callback with that indicates the >gui is displayed, and mainloop is running? There are some events you can use (see the documentation of bind). This example using the '' event of an Entry works for me (on Linux/X11): --------------------------------------- from Tkinter import * def ready(evt): print 'ready', evt.__dict__ l.delete(0,END) l.insert(0, 'gui ready') tk = Tk() l = Entry(tk, width=20) l.insert(0, 'building gui') l.pack() l.bind('', ready) tk.mainloop() --------------------------------------- The problem is: you should use the event callback just to start the network activity, not monitoring it. You'll need some kind of threading/subprocesses or other to do this. The event types are not well documented in my tk/tcl installation, so I cannot tell you if '' is the best choice here. Hope this helps, Matthias Kievernagel (mkiever - at - web - dot - de) From mkieverpy at tlink.de Mon Nov 27 09:55:18 2006 From: mkieverpy at tlink.de (mkieverpy at tlink.de) Date: Mon, 27 Nov 2006 09:55:18 +0100 Subject: [Tkinter-discuss] Method to call when gui is first displayed Message-ID: <456aa7f610f1f8.09267745@> Tony Cappellini askted: >I want to call the function which talks to CVS after the gui is displayed, >but without formal having to do anything. >After I call mainloop(), the gui is displayed, but then nothing happens >until the user selects a menu option. (as it should be). >Is there a tk method that I can register a callback with that indicates the >gui is displayed, and mainloop is running? There are some events you can use (see the documentation of bind). This example using the '' event of an Entry works for me (on Linux/X11): --------------------------------------- from Tkinter import * def ready(evt): print 'ready', evt.__dict__ l.delete(0,END) l.insert(0, 'gui ready') tk = Tk() l = Entry(tk, width=20) l.insert(0, 'building gui') l.pack() l.bind('', ready) tk.mainloop() --------------------------------------- The problem is: you should use the event callback just to start the network activity, not monitoring it. You'll need some kind of threading/subprocesses or other to do this. The event types are not well documented in my tk/tcl installation, so I cannot tell you if '' is the best choice here. Hope this helps, Matthias Kievernagel (mkiever - at - web - dot - de) From mkieverpy at tlink.de Mon Nov 27 10:18:23 2006 From: mkieverpy at tlink.de (mkieverpy at tlink.de) Date: Mon, 27 Nov 2006 10:18:23 +0100 Subject: [Tkinter-discuss] Method to call when gui is first displayed Message-ID: <456aad5f7163c9.91352012@> Oops, sorry - too fast. The Map-Event occurs every time the widget is mapped to the screen, i.e. every transition from iconified->windowed calls ready(). So the ready-callback should be changed so it runs only once. Some questions from me: Any pointer to a better documentation (better than 'man n bind') for the event types? 'man n bind' mentions a 'Create' event type, python does not. Who is wrong, who is right? Why? Matthias Kievernagel (mkiever - at - web - dot - de) From fredrik at pythonware.com Mon Nov 27 10:27:46 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 27 Nov 2006 10:27:46 +0100 Subject: [Tkinter-discuss] Method to call when gui is first displayed In-Reply-To: <8249c4ac0611261620s5786cb67mb1cfd1c99ed9195e@mail.gmail.com> References: <8249c4ac0611261620s5786cb67mb1cfd1c99ed9195e@mail.gmail.com> Message-ID: Tony Cappellini wrote: > I want to call the function which talks to CVS after the gui is > displayed, but without formal having to do anything. here's one way to do it: root = Tk() # populate UI # run event loop until widget is properly displayed root.wait_visibility() # start talking to CVS root.mainloop() From m_tayseer82 at yahoo.com Mon Nov 27 11:21:22 2006 From: m_tayseer82 at yahoo.com (Mohammad Tayseer) Date: Mon, 27 Nov 2006 02:21:22 -0800 (PST) Subject: [Tkinter-discuss] First timer using tkinter In-Reply-To: <20061126214322.GA13806@lairds.us> Message-ID: <20061127102122.80641.qmail@web31110.mail.mud.yahoo.com> from Tkinter import * root = Tk() root.wm_attributes('-topmost', 1) works for Python 2.4 on WinXp --------------------------------- Access over 1 million songs - Yahoo! Music Unlimited. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061127/994b79a7/attachment.htm From sxn02 at yahoo.com Mon Nov 27 17:05:10 2006 From: sxn02 at yahoo.com (Sorin Schwimmer) Date: Mon, 27 Nov 2006 08:05:10 -0800 (PST) Subject: [Tkinter-discuss] moving from pack to grid Message-ID: <20061127160510.52085.qmail@web56004.mail.re3.yahoo.com> > self.label.grid(row=5, column=2, column=0) Why do you have "column" twice? Grid will always compact your GUI: if you grid something on row 3, and rows 0..2 are empty, everything is pushed up. If you add a widget at row 2, row three goes down one level to make room for row two. Similarly, for columns to the left. If you need to have the empty rows/columns shown as empty, grid some placeholders (a label with an empty text, stuff like that), and destroy them when replacing with the real widgets. Example (untested): from Tkinter import * root=Tk() l1=Label(root, text='A label') l1.grid(row=2) # rows 0 and 1 are empty, so the grid manager will put the label on top # let's push it down, to the real home row pl1=Label(root) # first placeholder pl1.grid(row=0) pl2=Label(root) pl2.grid(row=1) # second placeholder # now let's put something on row 0, "real stuff" vr=StringVar() en=Entry(root, textvariable=vr) pl1.destroy() en.grid(row=0) root.mainloop() About filling a cell in the grid: check the sticky option. About filling two or more adjacent cells with one widget: check the rowspan and columnspan options. Hope this help, Sorin __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061127/a4448edd/attachment.html From Cameron at phaseit.net Mon Nov 27 17:12:48 2006 From: Cameron at phaseit.net (Cameron Laird) Date: Mon, 27 Nov 2006 16:12:48 +0000 Subject: [Tkinter-discuss] Method to call when gui is first displayed In-Reply-To: <456aa7dc6c39f5.23036646@> References: <456aa7dc6c39f5.23036646@> Message-ID: <20061127161248.GA21281@lairds.us> On Mon, Nov 27, 2006 at 09:54:52AM +0100, mkieverpy at tlink.de wrote: . . . > >I want to call the function which talks to CVS after the gui is displayed, > >but without formal having to do anything. . . . > The problem is: you should use the event callback just to start > the network activity, not monitoring it. > You'll need some kind of threading/subprocesses or other > to do this. > The event types are not well documented in my tk/tcl installation, > so I cannot tell you if '' is the best choice here. . . . ? I suspect we're confusing each other. It certainly is possible to monitor network activity in an event-oriented way; were you say- ing that you do not recommend such an approach? From mkieverpy at tlink.de Mon Nov 27 17:44:38 2006 From: mkieverpy at tlink.de (mkieverpy at tlink.de) Date: Mon, 27 Nov 2006 17:44:38 +0100 Subject: [Tkinter-discuss] Method to call when gui is first displayed Message-ID: <456b15f65f4970.40210225@> > On Mon, Nov 27, 2006 at 09:54:52AM +0100, mkieverpy at tlink.de wrote: > > >I want to call the function which talks to CVS after the gui is displayed, > > >but without formal having to do anything. > . > > The problem is: you should use the event callback just to start > > the network activity, not monitoring it. > > You'll need some kind of threading/subprocesses or other > > to do this. > > The event types are not well documented in my tk/tcl installation, > > so I cannot tell you if '' is the best choice here. > . > ? I suspect we're confusing each other. It certainly is possible > to monitor network activity in an event-oriented way; were you say- > ing that you do not recommend such an approach? No. What I wanted to say is that the gui is inactive while an event callback is processed. So the Map-event callback should only be used to initiate the network activity but return immediately afterwards. (not polling/waiting for the end of network transfer). Different events/callbacks or similar should be used for monitoring. But, of course, Fredrik Lundh's proposed method is better (I did not know this one), if the application allows for network activity to finish with the gui being inactive. Matthias Kievernagel (mkiever - at - web - dot - de) From mkieverpy at tlink.de Mon Nov 27 17:44:42 2006 From: mkieverpy at tlink.de (mkieverpy at tlink.de) Date: Mon, 27 Nov 2006 17:44:42 +0100 Subject: [Tkinter-discuss] Method to call when gui is first displayed Message-ID: <456b15fa62efa4.04582067@> > On Mon, Nov 27, 2006 at 09:54:52AM +0100, mkieverpy at tlink.de wrote: > > >I want to call the function which talks to CVS after the gui is displayed, > > >but without formal having to do anything. > . > > The problem is: you should use the event callback just to start > > the network activity, not monitoring it. > > You'll need some kind of threading/subprocesses or other > > to do this. > > The event types are not well documented in my tk/tcl installation, > > so I cannot tell you if '' is the best choice here. > . > ? I suspect we're confusing each other. It certainly is possible > to monitor network activity in an event-oriented way; were you say- > ing that you do not recommend such an approach? No. What I wanted to say is that the gui is inactive while an event callback is processed. So the Map-event callback should only be used to initiate the network activity but return immediately afterwards. (not polling/waiting for the end of network transfer). Different events/callbacks or similar should be used for monitoring. But, of course, Fredrik Lundh's proposed method is better (I did not know this one), if the application allows for network activity to finish with the gui being inactive. Matthias Kievernagel (mkiever - at - web - dot - de) From Cameron at phaseit.net Mon Nov 27 18:10:19 2006 From: Cameron at phaseit.net (Cameron Laird) Date: Mon, 27 Nov 2006 17:10:19 +0000 Subject: [Tkinter-discuss] Method to call when gui is first displayed In-Reply-To: <456b15f65f4970.40210225@> References: <456b15f65f4970.40210225@> Message-ID: <20061127171019.GA5058@lairds.us> On Mon, Nov 27, 2006 at 05:44:38PM +0100, mkieverpy at tlink.de wrote: . . . > > > >I want to call the function which talks to CVS after the gui is displayed, > > > >but without formal having to do anything. > > . > > > The problem is: you should use the event callback just to start > > > the network activity, not monitoring it. > > > You'll need some kind of threading/subprocesses or other > > > to do this. > > > The event types are not well documented in my tk/tcl installation, > > > so I cannot tell you if '' is the best choice here. > > . > > ? I suspect we're confusing each other. It certainly is possible > > to monitor network activity in an event-oriented way; were you say- > > ing that you do not recommend such an approach? > > No. What I wanted to say is that the gui is inactive while an event callback > is processed. So the Map-event callback should only be used to initiate the > network activity but return immediately afterwards. > (not polling/waiting for the end of network transfer). > Different events/callbacks or similar should be used for monitoring. > > But, of course, Fredrik Lundh's proposed method is better > (I did not know this one), if the application allows for network > activity to finish with the gui being inactive. . . . Ah! All cleared up. I entirely agree: it's best to define a distinct event/poll/monitor/... And, yes, as always, Fredrik's counsel is on-target. From cappy2112 at gmail.com Mon Nov 27 18:44:46 2006 From: cappy2112 at gmail.com (Tony Cappellini) Date: Mon, 27 Nov 2006 09:44:46 -0800 Subject: [Tkinter-discuss] Tkinter-discuss Digest, Vol 33, Issue 9 In-Reply-To: References: Message-ID: <8249c4ac0611270944h6f023b17o69f313e2996396d1@mail.gmail.com> And it works for me too- with 2.3.4 Thanks! ate: Mon, 27 Nov 2006 02:21:22 -0800 (PST) From: Mohammad Tayseer Subject: Re: [Tkinter-discuss] First timer using tkinter To: tkinter-discuss at python.org Message-ID: <20061127102122.80641.qmail at web31110.mail.mud.yahoo.com> Content-Type: text/plain; charset="iso-8859-1" from Tkinter import * root = Tk() root.wm_attributes('-topmost', 1) works for Python 2.4 on WinXp -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061127/45ca3061/attachment.html From cappy2112 at gmail.com Mon Nov 27 18:50:52 2006 From: cappy2112 at gmail.com (Tony Cappellini) Date: Mon, 27 Nov 2006 09:50:52 -0800 Subject: [Tkinter-discuss] Tkinter-discuss Digest, Vol 33, Issue 8 In-Reply-To: References: Message-ID: <8249c4ac0611270950k175a7609y8f44eb93ff3fbba8@mail.gmail.com> Date: Mon, 27 Nov 2006 10:27:46 +0100 From: Fredrik Lundh Subject: Re: [Tkinter-discuss] Method to call when gui is first displayed To: tkinter-discuss at python.org Message-ID: Content-Type: text/plain; charset=ISO-8859-1; format=flowed here's one way to do it: root = Tk() # populate UI # run event loop until widget is properly displayed root.wait_visibility() # start talking to CVS root.mainloop() I've tried this in the interpeter- outside of the actual program I am targeting- for the moment. When I call Tk() a blank tk window appears. When I call wait_visibility() the call never returns. However, since the call to Tk() pops up the window- my menu should be visible, and the program status bar as well. So I'll try this in my target program as soon as I fix a few errors. BTW I'm stick using python 2.3.4 with whatever version of Tk goes with it- perhaps there are some behavioral differences. thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061127/ba60a09a/attachment.html From klappnase at web.de Mon Nov 27 18:55:47 2006 From: klappnase at web.de (Michael Lange) Date: Mon, 27 Nov 2006 18:55:47 +0100 Subject: [Tkinter-discuss] moving from pack to grid In-Reply-To: <8249c4ac0611261930g3d7e0b6ej3fc3c0bf639999f1@mail.gmail.com> References: <8249c4ac0611261930g3d7e0b6ej3fc3c0bf639999f1@mail.gmail.com> Message-ID: <20061127185547.2edebdd3.klappnase@web.de> On Sun, 26 Nov 2006 19:30:51 -0800 "Tony Cappellini" wrote: (...) > What args do I need to move the label to the bottom of the window, and > centered so it extends to both left and right edges? > I don't like to hard-code a row number, I'd rather make it dynamic in case > the window grows or shrinks. > Hi Tony, in order to make the label through all grid columns, use: label.grid(row=5, column=0, columnspan=) If you want the label to use more space than it actually needs, use the grid() command's sticky option. You can pass one or more of 'n', 's', 'w' and 'e' to the sticky argument; sticky='w' will put the widget to the leftmost edge of its parent, sticky='ew' will stretch it from left to right, so in your case you might want: label.grid(row=5, column=0, columnspan=, sticky='ews') This stretching beyond the widget's requested width will however only take effect, if you specify the "weight" for the parent's grid row, resp. column: parent.grid_rowconfigure(5, weight=1) (this is similar to pack(fill='y')). I hope this helps Michael From sxn02 at yahoo.com Tue Nov 28 18:25:06 2006 From: sxn02 at yahoo.com (Sorin Schwimmer) Date: Tue, 28 Nov 2006 09:25:06 -0800 (PST) Subject: [Tkinter-discuss] How to dettach a Toplevel Message-ID: <20061128172506.81779.qmail@web56010.mail.re3.yahoo.com> Hi, If I have: from Tkinter import * root=Tk() tl=Toplevel() root.mainloop() and then close the root window, it will take tl with it. Is there a way to keep tl alive after root dies? Thanks, Sorin ____________________________________________________________________________________ Yahoo! Music Unlimited Access over 1 million songs. http://music.yahoo.com/unlimited -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061128/302ea94e/attachment.htm From camfarnell at cogeco.ca Tue Nov 28 18:39:14 2006 From: camfarnell at cogeco.ca (Cam) Date: Tue, 28 Nov 2006 12:39:14 -0500 Subject: [Tkinter-discuss] Stumped In-Reply-To: <20060403112616.39095.qmail@web31108.mail.mud.yahoo.com> References: <20060403112616.39095.qmail@web31108.mail.mud.yahoo.com> Message-ID: <456C7442.6090802@cogeco.ca> This is probably really simple but I haven't yet figured it out. It happens in the context of a much larger program but stripped to it's essence is per the little program below. The general idea is that the user clicks on a button, that initiates an operation which is going to take some time, so I would like to allow the user to press ESCAPE to cancel the operation. In the code below the "on_button" function is the one that takes some time, but if the user presses ESCAPE while it is running, the escape isn't processed until *after* the "on_button" function returns which sort of defeats the purpose. I've tried inserting update_idletasks() into the function and various other things without success. Any suggestions? I'm running Python 2.4.2 under Linux. Thanks Cam Farnell - - - - - from Tkinter import * import time def on_button(): for J in range(10): print J if CancelNow: break time.sleep(1) def Cancel(Event): print 'Cancelling now' CancelNow = True Root.quit() Root = Tk() Root.bind_all('',Cancel) B = Button(Root,command=on_button,text='Go') B.pack() CancelNow = False Root.mainloop() From sxn02 at yahoo.com Tue Nov 28 19:11:02 2006 From: sxn02 at yahoo.com (Sorin Schwimmer) Date: Tue, 28 Nov 2006 10:11:02 -0800 (PST) Subject: [Tkinter-discuss] Stumped Message-ID: <20061128181102.85835.qmail@web56013.mail.re3.yahoo.com> Add in your functions, first statement after def global CancelNow This way everybody refers *the same* flag. I would normally move your second-last statement (CancelNow = False) just below imports. De-stumped? Sorin ____________________________________________________________________________________ Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061128/ffe44964/attachment.htm From bob at greschke.com Tue Nov 28 19:06:34 2006 From: bob at greschke.com (Bob Greschke) Date: Tue, 28 Nov 2006 11:06:34 -0700 Subject: [Tkinter-discuss] Stumped References: <20060403112616.39095.qmail@web31108.mail.mud.yahoo.com> <456C7442.6090802@cogeco.ca> Message-ID: <000601c71317$f147d260$201a8a81@UNIBLAB> Adding the ----- lines seems to work. > from Tkinter import * > import time > > def on_button(): > for J in range(10): > print J > if CancelNow: > break > time.sleep(1) ------ Root.update() > > def Cancel(Event): ------ global CancelNow > print 'Cancelling now' > CancelNow = True > Root.quit() > > Root = Tk() > Root.bind_all('',Cancel) > > B = Button(Root,command=on_button,text='Go') > B.pack() > CancelNow = False > > Root.mainloop() From sxn02 at yahoo.com Tue Nov 28 19:42:28 2006 From: sxn02 at yahoo.com (Sorin Schwimmer) Date: Tue, 28 Nov 2006 10:42:28 -0800 (PST) Subject: [Tkinter-discuss] Stumped Message-ID: <20061128184228.10792.qmail@web56011.mail.re3.yahoo.com> I never tried Bob's Greschke idea of using update() in a callback, because of this reason: http://www.pythonware.com/library/tkinter/introduction/x9374-event-processing.htm Sorin __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061128/2f028ca0/attachment.html From bob at passcal.nmt.edu Tue Nov 28 20:03:33 2006 From: bob at passcal.nmt.edu (Bob Greschke) Date: Tue, 28 Nov 2006 12:03:33 -0700 Subject: [Tkinter-discuss] Stumped References: <20061128184228.10792.qmail@web56011.mail.re3.yahoo.com> Message-ID: <019a01c7131f$e6626330$2d1a8a81@workblab> ----- Original Message ----- From: Sorin Schwimmer To: tkinter-discuss at python.org Sent: Tuesday, November 28, 2006 11:42 AM Subject: Re: [Tkinter-discuss] Stumped I never tried Bob's Greschke idea of using update() in a callback, because of this reason: http://www.pythonware.com/library/tkinter/introduction/x9374-event-processing.htm Sorin ------------ I've thought about that from time-to-time too, but I've never seemed to run into any problems. I wonder if it is something like on_button() will only be called if the Go button is pushed, and it doesn't call any other function, and/or it doesn't generate any other events kindof a thing? on_button() is so simple that it never gets itself into trouble? I use it quite a bit like after setting the text of a status message field to make sure the message (and maybe a beep) gets displayed, though most of the time I call it on the item that I am writing to or working with (like Text().update() or Button().update(), and not Root.update()). B.update(), instead of Root.update() will also work in the example program. Bob -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.409 / Virus Database: 268.14.19/556 - Release Date: 11/28/2006 From camfarnell at cogeco.ca Tue Nov 28 20:21:35 2006 From: camfarnell at cogeco.ca (Cam) Date: Tue, 28 Nov 2006 14:21:35 -0500 Subject: [Tkinter-discuss] Stumped In-Reply-To: <019a01c7131f$e6626330$2d1a8a81@workblab> References: <20061128184228.10792.qmail@web56011.mail.re3.yahoo.com> <019a01c7131f$e6626330$2d1a8a81@workblab> Message-ID: <456C8C3F.5030401@cogeco.ca> The "global" was omitted when I cut the code down to a skeleton example; it's in my big program. I have avoided "update" for the same reason. Even the New Mexico Tech documentation (http://infohost.nmt.edu/tcc/help/pubs/tkinter/universal.html) says never to use "update" inside a callback. Thus I have always used "update_idletasks" when I wanted to make sure something got displayed *now*. That said, inserting "update" does fix the problem without creating any obvious problems. Thanks Cam Bob Greschke wrote: > ----- Original Message ----- > From: Sorin Schwimmer > To: tkinter-discuss at python.org > Sent: Tuesday, November 28, 2006 11:42 AM > Subject: Re: [Tkinter-discuss] Stumped > > I never tried Bob's Greschke idea of using update() in a callback, because > of this reason: > > http://www.pythonware.com/library/tkinter/introduction/x9374-event-processing.htm > > Sorin > > ------------ > > I've thought about that from time-to-time too, but I've never seemed to run > into any problems. I wonder if it is something like on_button() will only > be called if the Go button is pushed, and it doesn't call any other > function, and/or it doesn't generate any other events kindof a thing? > on_button() is so simple that it never gets itself into trouble? I use it > quite a bit like after setting the text of a status message field to make > sure the message (and maybe a beep) gets displayed, though most of the time > I call it on the item that I am writing to or working with (like > Text().update() or Button().update(), and not Root.update()). B.update(), > instead of Root.update() will also work in the example program. > > Bob > > > From sxn02 at yahoo.com Tue Nov 28 21:03:39 2006 From: sxn02 at yahoo.com (Sorin Schwimmer) Date: Tue, 28 Nov 2006 12:03:39 -0800 (PST) Subject: [Tkinter-discuss] A small fix for NoteBook in Tix Message-ID: <20061128200339.38218.qmail@web56011.mail.re3.yahoo.com> Problem: >>> from Tix import * >>> root=Tk() >>> nb=NoteBook(root) >>> nb.add('pg_1', label='pg 1') >>> nb.pages() Traceback (most recent call last): File "", line 1, in ? File "/usr/local/lib/python2.4/lib-tk/Tix.py", line 1160, in pages ret.append(self.subwidget(x)) File "/usr/local/lib/python2.4/lib-tk/Tix.py", line 337, in subwidget raise TclError, "Subwidget " + name + " not child of " + self._name _tkinter.TclError: Subwidget p not child of -1211878740 Visiting Tix.py I found at line 1155 the following function: def pages(self): # Can't call subwidgets_all directly because we don't want .nbframe names = self.tk.split(self.tk.call(self._w, 'pages')) ret = [] for x in names: ret.append(self.subwidget(x)) return ret The issue is that, for only one tab "names" is a string (the name of the tab), while for 2 or more it is a tuple of names of tabs. For an empty NoteBook, "names" is an empty string. The for loop in the case of one tab will go through the letters of the tab's name, and that is where subwidget fails. Resolution: def pages(self): # Can't call subwidgets_all directly because we don't want .nbframe names = self.tk.split(self.tk.call(self._w, 'pages')) ret = [] if names and type(names) == type('a'): # sxn # 1 tab gives a string ret.append(self.subwidget(names)) # sxn # else: # sxn # 2+ tabs give a tuple for x in names: ret.append(self.subwidget(x)) return ret I am on Linux, Python 2.4.2, Tcl/Tk 8.4, Tix 8.2 Sorin ____________________________________________________________________________________ Yahoo! Music Unlimited Access over 1 million songs. http://music.yahoo.com/unlimited -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061128/92acffa2/attachment.htm From klappnase at web.de Tue Nov 28 22:26:02 2006 From: klappnase at web.de (Michael Lange) Date: Tue, 28 Nov 2006 22:26:02 +0100 Subject: [Tkinter-discuss] How to dettach a Toplevel In-Reply-To: <20061128172506.81779.qmail@web56010.mail.re3.yahoo.com> References: <20061128172506.81779.qmail@web56010.mail.re3.yahoo.com> Message-ID: <20061128222602.1682db13.klappnase@web.de> On Tue, 28 Nov 2006 09:25:06 -0800 (PST) Sorin Schwimmer wrote: > Hi, > > If I have: > > > from Tkinter import * > root=Tk() > tl=Toplevel() > root.mainloop() > > > and then close the root window, it will take tl with it. Is there a way to keep tl alive after root dies? > Hi Sorin, maybe what you actually want is *two* Toplevels and *no* root: from Tkinter import * root = Tk() root.withdraw() t1 = Toplevel() t2 = Toplevel() root.mainloop() I hope this helps Michael From sxn02 at yahoo.com Tue Nov 28 23:02:46 2006 From: sxn02 at yahoo.com (Sorin Schwimmer) Date: Tue, 28 Nov 2006 14:02:46 -0800 (PST) Subject: [Tkinter-discuss] How to dettach a Toplevel Message-ID: <20061128220246.75717.qmail@web56010.mail.re3.yahoo.com> Hi Michael, I see your point, but this is not what I am looking for. What I'm trying to achieve goes on the following lines: the user has a GUI and works. A daemon (I'm on Linux) receives a message for the user, so it pops-up a little notification symbol (there is actualy a bit more inter-process communication, but it is not relevant for the GUI part). If the user checks right away what's going on, then the pop-up dissapears. But (s)he may decide to check later, and even decide to close the application; the symbol needs to stay there. My symbol is not intrusive, is a little undecorated window, the size of the "close", "restore", and "minimise" buttons, and I place it close to them. It is on a red background, so it attracts attention, but the user can work with it there without problems. That's why I need to "dettach" it. Thanks anyway for your suggestion, Sorin ____________________________________________________________________________________ Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061128/8e15aeb9/attachment.htm From gerardo at computo-industrial.com.mx Wed Nov 29 04:07:47 2006 From: gerardo at computo-industrial.com.mx (Gerardo Juarez) Date: Tue, 28 Nov 2006 22:07:47 -0500 (EST) Subject: [Tkinter-discuss] Unexpected Checkbutton behaviour In-Reply-To: <20061128220246.75717.qmail@web56010.mail.re3.yahoo.com> Message-ID: Hi, I'm having problems with a widget, which I've been able to isolate to the following example: from Tkinter import * def display(): global x print x root = Tk() x = 0 check = Checkbutton(root, variable=x) check.pack() button = Button(text='Display variable', command=display) button.pack() root.mainloop() As far as I understand the reference, when I click the button, the variable 'x' should reflect the state of the check button, and viceversa, if I change the value of x, from 0 to 1, the widget reflects the change. Well, in practice, I get a constant zero, whether I click or not the checkbutton. I must be missing something, but I can;t figure out what it is. Any comments will be welcome. TIA, Gerardo From camfarnell at cogeco.ca Wed Nov 29 05:09:37 2006 From: camfarnell at cogeco.ca (Cam) Date: Tue, 28 Nov 2006 23:09:37 -0500 Subject: [Tkinter-discuss] Unexpected Checkbutton behaviour In-Reply-To: References: Message-ID: <456D0801.5050509@cogeco.ca> Hi Gerardo, You can't user a regular python variable for "x", you need to create, in this case, an IntVar "control variable". See revised code below, also see http://infohost.nmt.edu/tcc/help/pubs/tkinter/control-variables.html Cam Farnell from Tkinter import * def display(): print x.get() root = Tk() x = IntVar() x.set(0) check = Checkbutton(root, variable=x) check.pack() button = Button(text='Display variable', command=display) button.pack() root.mainloop() Gerardo Juarez wrote: > Hi, > > I'm having problems with a widget, which I've been able to isolate to the > following example: > > from Tkinter import * > > def display(): > global x > print x > > root = Tk() > x = 0 > check = Checkbutton(root, variable=x) > check.pack() > button = Button(text='Display variable', command=display) > button.pack() > root.mainloop() > > As far as I understand the reference, when I click the button, the > variable 'x' should reflect the state of the check button, and viceversa, > if I change the value of x, from 0 to 1, the widget reflects the change. > Well, in practice, I get a constant zero, whether I click or not the > checkbutton. I must be missing something, but I can;t figure out what it > is. Any comments will be welcome. > > TIA, > Gerardo > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From fredrik at pythonware.com Wed Nov 29 08:03:38 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 29 Nov 2006 08:03:38 +0100 Subject: [Tkinter-discuss] Unexpected Checkbutton behaviour In-Reply-To: References: <20061128220246.75717.qmail@web56010.mail.re3.yahoo.com> Message-ID: Gerardo Juarez wrote: > I'm having problems with a widget, which I've been able to isolate to the > following example: > > from Tkinter import * > > def display(): > global x > print x > > root = Tk() > x = 0 > check = Checkbutton(root, variable=x) > check.pack() > button = Button(text='Display variable', command=display) > button.pack() > root.mainloop() > > As far as I understand the reference, when I click the button, the > variable 'x' should reflect the state of the check button you must use a Tkinter variable object, not an arbitrary Python variable: http://effbot.org/tkinterbook/checkbutton.htm#patterns (note that in Python, the parameter expressions are *always* evaluated before the function is actually called, so "variable=x" will pass a zero to the checkbutton. you cannot pass references to variable names in Python, only references to objects). From klappnase at web.de Wed Nov 29 17:53:04 2006 From: klappnase at web.de (Michael Lange) Date: Wed, 29 Nov 2006 17:53:04 +0100 Subject: [Tkinter-discuss] How to dettach a Toplevel In-Reply-To: <20061128220246.75717.qmail@web56010.mail.re3.yahoo.com> References: <20061128220246.75717.qmail@web56010.mail.re3.yahoo.com> Message-ID: <20061129175304.795f317f.klappnase@web.de> On Tue, 28 Nov 2006 14:02:46 -0800 (PST) Sorin Schwimmer wrote: > Hi Michael, > > I see your point, but this is not what I am looking for. What I'm trying to achieve goes on the > following lines: the user has a GUI and works. A daemon (I'm on Linux) receives a message > for the user, so it pops-up a little notification symbol (there is actualy a bit more inter-process > communication, but it is not relevant for the GUI part). If the user checks right away what's > going on, then the pop-up dissapears. But (s)he may decide to check later, and even decide to > close the application; the symbol needs to stay there. > > My symbol is not intrusive, is a little undecorated window, the size of the "close", "restore", > and "minimise" buttons, and I place it close to them. It is on a red background, so it attracts > attention, but the user can work with it there without problems. > > That's why I need to "dettach" it. > Hi Sorin, But then I think you will either have to make the daemon an application running independently from the gui, so it can use its own Tk() window (and run on when the gui app was closed) or (as I suggested) make the main gui window a Toplevel() with an invisible Tk window; I do not see the problem, if the user closes the gui, the app is still running, so the notification symbol may still be visible. Or am I missing something? Michael From gerardo at computo-industrial.com.mx Wed Nov 29 18:38:11 2006 From: gerardo at computo-industrial.com.mx (Gerardo Juarez) Date: Wed, 29 Nov 2006 12:38:11 -0500 (EST) Subject: [Tkinter-discuss] Unexpected Checkbutton behaviour In-Reply-To: Message-ID: Oooh I see! I knew it was a small thing I was overlooking. I read in the reference "Tkinter variable", but I never gave it the meaning it really had. Thanks everyone! Gerardo On Wed, 29 Nov 2006, Fredrik Lundh wrote: > Gerardo Juarez wrote: > > > > I'm having problems with a widget, which I've been able to isolate to the > > following example: > > > > from Tkinter import * > > > > def display(): > > global x > > print x > > > > root = Tk() > > x = 0 > > check = Checkbutton(root, variable=x) > > check.pack() > > button = Button(text='Display variable', command=display) > > button.pack() > > root.mainloop() > > > > As far as I understand the reference, when I click the button, the > > variable 'x' should reflect the state of the check button > > you must use a Tkinter variable object, not an arbitrary Python variable: > > http://effbot.org/tkinterbook/checkbutton.htm#patterns > > (note that in Python, the parameter expressions are *always* evaluated > before the function is actually called, so "variable=x" will pass a zero > to the checkbutton. you cannot pass references to variable names in > Python, only references to objects). > > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From sxn02 at yahoo.com Wed Nov 29 21:02:58 2006 From: sxn02 at yahoo.com (Sorin Schwimmer) Date: Wed, 29 Nov 2006 12:02:58 -0800 (PST) Subject: [Tkinter-discuss] How to dettach a Toplevel Message-ID: <20061129200258.92309.qmail@web56006.mail.re3.yahoo.com> Hi Michael, While the two toplevel solution will work nicely, I'm not sure how would I close the main application (at one point I want to be able to do so). As for the other suggestion, that was my first approach, but it doesn't work. I don't know why, and sometime I'll have to find out, as I'll need later in my project. What happens is that when the users logs in (no authentication required) I have a small script in KDE Autostart to issue an xhost local:root allowing the daemon to show his stuff. The daemon waits until KDE is up and running and xhost was executed, then it does a root=Tk(screenName=':0.0') Nothing comes on. If I fire up a Python interpreter and do the things manualy, it works flawless: I have a graphic window controlled by root, can populate it, withdraw it, iconify it, destroy it... It proves that from an X server standpoint things are set correctly, but my daemon does something wrong (it may be that the window is created and destroyed immediately, I don't know). Thanks for your ideas, and give me more if possible Sorin __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061129/29b20921/attachment.html From jmcmonagle at velseis.com.au Wed Nov 29 22:55:02 2006 From: jmcmonagle at velseis.com.au (John McMonagle) Date: Thu, 30 Nov 2006 07:55:02 +1000 Subject: [Tkinter-discuss] How to dettach a Toplevel In-Reply-To: <20061129200258.92309.qmail@web56006.mail.re3.yahoo.com> References: <20061129200258.92309.qmail@web56006.mail.re3.yahoo.com> Message-ID: <456E01B6.1060702@velseis.com.au> Sorin Schwimmer wrote: > The daemon waits until KDE is up and running and xhost was executed, > then it does a > root=Tk(screenName=':0.0') > > Nothing comes on. If I fire up a Python interpreter and do the things > manualy, it works > flawless: I have a graphic window controlled by root, can populate it, > withdraw it, iconify it, > destroy it... It proves that from an X server standpoint things are set > correctly, but my daemon does something wrong (it may be that the window > is created and destroyed immediately, I don't know). > Do you also start the mainloop in your daemon ? -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. From klappnase at web.de Thu Nov 30 11:17:03 2006 From: klappnase at web.de (Michael Lange) Date: Thu, 30 Nov 2006 11:17:03 +0100 Subject: [Tkinter-discuss] How to dettach a Toplevel In-Reply-To: <20061129200258.92309.qmail@web56006.mail.re3.yahoo.com> References: <20061129200258.92309.qmail@web56006.mail.re3.yahoo.com> Message-ID: <20061130111703.5e7803c8.klappnase@web.de> Hi Sorin, > > While the two toplevel solution will work nicely, I'm not sure how would I close the main application (at one point I want to be able to do so). > As a second thought, you actually do not need two Toplevel windows, you simply could withdraw the main gui window instead of closing it when the user hits the "close" button (use: root.protocol("WM_DELETE_WINDOW", root.withdraw)). This way the popup Toplevel window is still alive after the user has "closed" the app and can do what it is supposed to. If you want to restore the main gui later, there might be a menu or something in the popup window or maybe a lock file to make sure the app will be started only once. > As for the other suggestion, that was my first approach, but it doesn't work. I don't know why, > and sometime I'll have to find out, as I'll need later in my project. > > What happens is that when the users logs in (no authentication required) I have a small script in > KDE Autostart to issue an > xhost local:root > allowing the daemon to show his stuff. > > The daemon waits until KDE is up and running and xhost was executed, then it does a > root=Tk(screenName=':0.0') > > Nothing comes on. If I fire up a Python interpreter and do the things manualy, it works > flawless: I have a graphic window controlled by root, can populate it, withdraw it, iconify it, > destroy it... It proves that from an X server standpoint things are set correctly, but my daemon does something wrong (it may be that the window is created and destroyed immediately, I don't know). > > Hm, sorry, besides what John suggested, no further ideas here. Michael From mkieverpy at tlink.de Thu Nov 30 11:46:45 2006 From: mkieverpy at tlink.de (mkieverpy at tlink.de) Date: Thu, 30 Nov 2006 11:46:45 +0100 Subject: [Tkinter-discuss] How to dettach a Toplevel Message-ID: <456eb695db6267.97913418@> Sorin Schwimmer wrote: >Hi Michael, While the two toplevel solution will work nicely, I'm not sure how would I close the main >application (at one point I want to be able to do so). As for the other suggestion, that was my first >approach, but it doesn't work. I don't know why, and sometime I'll have to find out, as I'll need later in >my project. What happens is that when the users logs in (no authentication required) I have a small >script in KDE Autostart to issue an xhost local:root allowing the daemon to show his stuff. The daemon >waits until KDE is up and running and xhost was executed, then it does a root=Tk(screenName=':0.0') >Nothing comes on. If I fire up a Python interpreter and do the things manualy, it works flawless: I have a >graphic window controlled by root, can populate it, withdraw it, iconify it, destroy it... It proves that from >an X server standpoint things are set correctly, but my daemon does something wrong (it may be that >the window is created and destroyed immediately, I don't know). Thanks for your ideas, and give me >more if possible Sorin Do you use a normal process or really a daemon? When using a daemon it might have something to do with the restricted process environment which prevents python/tcl from starting or something like that. Try to get easy things to work first, like create an empty file from python in a place where everybody is allowed to. Hope this helps, Matthias Kievernagel (mkiever.at.web.dot.de) From sxn02 at yahoo.com Thu Nov 30 18:35:22 2006 From: sxn02 at yahoo.com (Sorin Schwimmer) Date: Thu, 30 Nov 2006 09:35:22 -0800 (PST) Subject: [Tkinter-discuss] How to dettach a Toplevel Message-ID: <20061130173522.56886.qmail@web56013.mail.re3.yahoo.com> Mainloop is included. Basically, the daemon starts a thread that waits for KDE, and does its job in the main thread. The function that is started looks like this: def inittk(): global rtk while True: sleep(60) try: rtk=Tk(screenName=':0.0') except: continue break rtk.mainloop() I omitted labels, entries, the undecoration, withdrawal... but I guess you have the idea of what I try to accomplish. The only thing that goes to my mind is that I start mainloop, but then, as the function and the thread are going out of scope, they take mainloop with them. Pointers are welcomed... Thanks, Sorin ____________________________________________________________________________________ Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061130/802177b3/attachment.htm From sxn02 at yahoo.com Thu Nov 30 19:11:16 2006 From: sxn02 at yahoo.com (Sorin Schwimmer) Date: Thu, 30 Nov 2006 10:11:16 -0800 (PST) Subject: [Tkinter-discuss] How to dettach a Toplevel Message-ID: <20061130181116.11741.qmail@web56004.mail.re3.yahoo.com> After hitting "send" with John's answer I saw Matthias question. So here is my next answer: Yes, it is a daemon "a la carte". It forks, os.setsid, forks, redirects sys.stdin and sys.stdout to /dev/null. The code resides in /etc/init.d and dependencies are taken care of. But I don't think this should be a problem because the following works from the Python prompt, as root, in screen 1, targeting screen 7 (where my KDE loads) which is under control: >>> import sys >>> from Tkinter import * >>> sys.stdout=open('/dev/null','w') >>> r=Tk(screenName=':0.0') >>> Label(r,text='Gutten Tag!').grid() My daemon does all kind of other things, and it does them well; my only issue is when I have to break its silence and inform the user, in GUI, about issues that (s)he may need to take action. My preferred approach was the one described here, my alternative was the dettached Toplevel described in my first posting; I can't make none to work. Thanks for suggestions, Sorin __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061130/1666ad3c/attachment.htm From klappnase at web.de Thu Nov 30 22:46:09 2006 From: klappnase at web.de (Michael Lange) Date: Thu, 30 Nov 2006 22:46:09 +0100 Subject: [Tkinter-discuss] How to dettach a Toplevel In-Reply-To: <20061130173522.56886.qmail@web56013.mail.re3.yahoo.com> References: <20061130173522.56886.qmail@web56013.mail.re3.yahoo.com> Message-ID: <20061130224609.59d70320.klappnase@web.de> On Thu, 30 Nov 2006 09:35:22 -0800 (PST) Sorin Schwimmer wrote: > Mainloop is included. Basically, the daemon starts a thread that waits for KDE, and does its > job in the main thread. The function that is started looks like this: > This sounds like you try to start Tk from a child thread ? I guess that is something one should never do; maybe you could change this, so Tk runs in the main thread and the job in the child thread. I hope this helps Michael > def inittk(): > global rtk > while True: > sleep(60) > try: > rtk=Tk(screenName=':0.0') > except: > continue > break > rtk.mainloop() > > > I omitted labels, entries, the undecoration, withdrawal... but I guess you have the idea of what I > try to accomplish. > > The only thing that goes to my mind is that I start mainloop, but then, as the function and the thread are going out of scope, they take mainloop with them. > > Pointers are welcomed... > > Thanks, > Sorin > > > > > > ____________________________________________________________________________________ > Do you Yahoo!? > Everyone is raving about the all-new Yahoo! Mail beta. > http://new.mail.yahoo.com