From sxn02 at yahoo.com Fri Dec 1 18:30:01 2006 From: sxn02 at yahoo.com (Sorin Schwimmer) Date: Fri, 1 Dec 2006 09:30:01 -0800 (PST) Subject: [Tkinter-discuss] How to dettach a Toplevel Message-ID: <20061201173001.34653.qmail@web56010.mail.re3.yahoo.com> > 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 No, it doesn't :-( I used the following test code: #! /usr/bin/python from time import sleep import sys,os,thread from Tkinter import * def one_th(): sys.stderr.write('In the thread...\n') if os.fork()==0: os.setsid() if os.fork()==0: sys.stdin=open('/dev/null','r') sys.stdout=open('/dev/null','w') thread.start_new_thread(one_th,()) while True: sleep(60) try: rtk=Tk(screenName=':0.0') except: continue break Label(rtk,text='It works').grid() sys.stderr.write('Entering mainloop\n') rtk.mainloop() sys.exit(0) I can see on root's console "In the thread...", and, after a while, "Entering mainloop", but nothing shows up in user's screen. Maybe it's simply impossible... 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/20061201/577a834f/attachment.html From sxn02 at yahoo.com Fri Dec 1 19:13:12 2006 From: sxn02 at yahoo.com (Sorin Schwimmer) Date: Fri, 1 Dec 2006 10:13:12 -0800 (PST) Subject: [Tkinter-discuss] Rotated text Message-ID: <20061201181312.24650.qmail@web56014.mail.re3.yahoo.com> Does anyone know about a Tkinter extension to allow 90dgr rotated labels (or other text widget)? Thanks, Sorin ____________________________________________________________________________________ Want to start your own business? Learn how on Yahoo! Small Business. http://smallbusiness.yahoo.com/r-index -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061201/a436988f/attachment.html From klappnase at web.de Mon Dec 4 18:52:29 2006 From: klappnase at web.de (Michael Lange) Date: Mon, 4 Dec 2006 18:52:29 +0100 Subject: [Tkinter-discuss] Ann.: Updated TkTreectrl wrapper Message-ID: <20061204185229.77ccc6f7.klappnase@web.de> Hi, I have uploaded an updated version of the Tkinter wrapper for the Tk treectrl widget (http://tktreectrl.sourceforge.net). The major change in this release is the introduction of a few new widget classes: _MultiListbox_ is a Treectrl widget set up to work as a (more or less) full-featured and very flexible multi column listbox widget. The _ScrolledTreectrl_ and _ScrolledMultiListbox_ classes use ideas shamelessly stolen from Pmw.ScrolledListbox to add one or two static or automatic scrollbars to the widgets. They both inherit from the _ScrolledWidget_ class that is supposed to make it easy to add scrollbars to any other Listbox or Canvas alike Tkinter widget. Changes to the Treectrl widget: I added the second (optional) _last_ argument to column_delete() (new in treectrl-2.1.1) and fixed a few minor bugs. The url is: Regards Michael From fredrik at pythonware.com Mon Dec 4 19:29:47 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 04 Dec 2006 19:29:47 +0100 Subject: [Tkinter-discuss] ANN: WCK for Tkinter 1.1.1 (december 4, 2006) Message-ID: The Widget Construction Kit (WCK) is an extension API that allows you to implement custom widgets in pure Python. The WCK can be (and is being) used for everything from light-weight display widgets to full-blown editor frameworks. WCK 1.1.1 is a maintenance release for Python 2.5, which fixes a few shutdown issues and potential crashes under 2.5. If you use the WCK under earlier versions, upgrading is optional. For more information, see: http://www.effbot.org/zone/wck.htm Downloads: http://www.effbot.org/downloads#tkinter3000 enjoy /F From sxn02 at yahoo.com Tue Dec 5 16:54:34 2006 From: sxn02 at yahoo.com (Sorin Schwimmer) Date: Tue, 5 Dec 2006 07:54:34 -0800 (PST) Subject: [Tkinter-discuss] Rotated text Message-ID: <20061205155434.38212.qmail@web56010.mail.re3.yahoo.com> I dug over the weekend and found a solution to my problem. If anyone is interested in such a thing, here is an example of rotated text using BLT: #! /usr/bin/python from Tkinter import * import Pmw r=Tk() g=Pmw.Blt.Graph(r) g.axis_configure('x',hide=1) g.axis_configure('y',hide=1) g.marker_create('text',rotate=90,text='Dufferin St.',coord=(.5,.5),background='#ffffff') g.marker_create('text',text='Finch Ave.',coord=(.3,.17),background='#ffffff') g.marker_create('text',text='Martin Ross St.',coord=(.3,.72),background='#ffffff') g.marker_create('line',coord=(.1,.7,.48,.7,.48,.2,.2,.2)) g.marker_create('line',coord=(.1,.75,.48,.75,.48,.92)) g.marker_create('line',coord=(.2,.14,.48,.14,.48,.1)) g.marker_create('line',coord=(.52,.1,.52,.14,.6,.14)) g.marker_create('line',coord=(.6,.2,.52,.2,.52,.92)) g.marker_create('polygon',coord=(.3,.68,.2,.68,.2,.58,.3,.58),fill='white',linewidth=1) g.marker_create('polygon',coord=(.28,.68,.26,.68,.26,.58,.28,.58),fill='gray') g.grid() r.mainloop() 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/20061205/7d60661b/attachment.htm From garbage_account_02 at yahoo.com Wed Dec 6 15:13:08 2006 From: garbage_account_02 at yahoo.com (G G) Date: Wed, 6 Dec 2006 06:13:08 -0800 (PST) Subject: [Tkinter-discuss] Radiobutton issue Message-ID: <858548.5793.qm@web36703.mail.mud.yahoo.com> Hello, I was trying to disable Radiobutton widget, with passing Tkinter.Radiobutton(...,state='disabled') . also tried Tkinter.Radiobutton(...,state=Tkinter.DISABLED) and Tkinter.Radiobutton(...,state=DISABLED) and but no success. In first two cases there is no error message but radiobutton doesn't get disabled... In the third case I got Python error saying DISABLED is not defined. Is there any known issue/problem with disabling Radiobutton widget? thanks a lot --------------------------------- Everyone is raving about the all-new Yahoo! Mail beta. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061206/abba73f9/attachment.html From bob at passcal.nmt.edu Wed Dec 6 17:29:41 2006 From: bob at passcal.nmt.edu (Bob Greschke) Date: Wed, 6 Dec 2006 09:29:41 -0700 Subject: [Tkinter-discuss] Radiobutton issue References: <858548.5793.qm@web36703.mail.mud.yahoo.com> Message-ID: <003701c71953$bd27f180$2d1a8a81@workblab> From: G G To: tkinter-discuss at python.org Sent: Wednesday, December 06, 2006 7:13 AM Subject: [Tkinter-discuss] Radiobutton issue I was trying to disable Radiobutton widget, with passing Tkinter.Radiobutton(...,state='disabled') . also tried Tkinter.Radiobutton(...,state=Tkinter.DISABLED) and Tkinter.Radiobutton(...,state=DISABLED) and but no success. In first two cases there is no error message but radiobutton doesn't get disabled... In the third case I got Python error saying DISABLED is not defined. Is there any known issue/problem with disabling Radiobutton widget? thanks a lot ====== It sounds like you may not be importing Tkinter in the "usual" way. from Tkinter import * is what I usually use and then things like state=DISABLED will work. from Tkinter import * Root = Tk() RadButVar = StringVar() RadButVar.set("2") <- set to which button should be initially "on" if any Rb1 = Radiobutton(Root, text = "TestBut1", variable = RadButVar, value = "1") Rb1.pack() Rb2 = Radiobutton(Root, text = "TestBut2", variable = RadButVar, value = "2") Rb2.pack() Root.mainloop() The above works and I can put state=DISABLED in either or both of the Radiobutton lines and get predictable results. I can also do things like Rb2.config(state = DISABLED) later in the program and it works, however, if a radiobutton is selected when you change the state to DISABLED it will stay selected until the user selects another one of the associated radiobuttons. Bob From harlinseritt at yahoo.com Thu Dec 7 12:14:57 2006 From: harlinseritt at yahoo.com (Harlin Seritt) Date: Thu, 7 Dec 2006 03:14:57 -0800 (PST) Subject: [Tkinter-discuss] Tkinter-discuss Digest, Vol 34, Issue 5 In-Reply-To: Message-ID: <542092.71342.qm@web50606.mail.yahoo.com> Hiya G G In case you're a freak about namespace polution (and that's really a good thing), you can generally rest assured that you'll be almost always fine when you do a full namespace import of Tkinter module. Harlin Seritt tkinter-discuss-request at python.org wrote: Send Tkinter-discuss mailing list submissions to tkinter-discuss at python.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/tkinter-discuss or, via email, send a message with subject or body 'help' to tkinter-discuss-request at python.org You can reach the person managing the list at tkinter-discuss-owner at python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Tkinter-discuss digest..." Today's Topics: 1. Radiobutton issue (G G) 2. Re: Radiobutton issue (Bob Greschke) ---------------------------------------------------------------------- Message: 1 Date: Wed, 6 Dec 2006 06:13:08 -0800 (PST) From: G G Subject: [Tkinter-discuss] Radiobutton issue To: tkinter-discuss at python.org Message-ID: <858548.5793.qm at web36703.mail.mud.yahoo.com> Content-Type: text/plain; charset="iso-8859-1" Hello, I was trying to disable Radiobutton widget, with passing Tkinter.Radiobutton(...,state='disabled') . also tried Tkinter.Radiobutton(...,state=Tkinter.DISABLED) and Tkinter.Radiobutton(...,state=DISABLED) and but no success. In first two cases there is no error message but radiobutton doesn't get disabled... In the third case I got Python error saying DISABLED is not defined. Is there any known issue/problem with disabling Radiobutton widget? thanks a lot --------------------------------- Everyone is raving about the all-new Yahoo! Mail beta. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061206/abba73f9/attachment-0001.html ------------------------------ Message: 2 Date: Wed, 6 Dec 2006 09:29:41 -0700 From: "Bob Greschke" Subject: Re: [Tkinter-discuss] Radiobutton issue To: "G G" , Message-ID: <003701c71953$bd27f180$2d1a8a81 at workblab> Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original From: G G To: tkinter-discuss at python.org Sent: Wednesday, December 06, 2006 7:13 AM Subject: [Tkinter-discuss] Radiobutton issue I was trying to disable Radiobutton widget, with passing Tkinter.Radiobutton(...,state='disabled') . also tried Tkinter.Radiobutton(...,state=Tkinter.DISABLED) and Tkinter.Radiobutton(...,state=DISABLED) and but no success. In first two cases there is no error message but radiobutton doesn't get disabled... In the third case I got Python error saying DISABLED is not defined. Is there any known issue/problem with disabling Radiobutton widget? thanks a lot ====== It sounds like you may not be importing Tkinter in the "usual" way. from Tkinter import * is what I usually use and then things like state=DISABLED will work. from Tkinter import * Root = Tk() RadButVar = StringVar() RadButVar.set("2") <- set to which button should be initially "on" if any Rb1 = Radiobutton(Root, text = "TestBut1", variable = RadButVar, value = "1") Rb1.pack() Rb2 = Radiobutton(Root, text = "TestBut2", variable = RadButVar, value = "2") Rb2.pack() Root.mainloop() The above works and I can put state=DISABLED in either or both of the Radiobutton lines and get predictable results. I can also do things like Rb2.config(state = DISABLED) later in the program and it works, however, if a radiobutton is selected when you change the state to DISABLED it will stay selected until the user selects another one of the associated radiobuttons. Bob ------------------------------ _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss at python.org http://mail.python.org/mailman/listinfo/tkinter-discuss End of Tkinter-discuss Digest, Vol 34, Issue 5 ********************************************** --------------------------------- Everyone is raving about the all-new Yahoo! Mail beta. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061207/d70116a2/attachment.htm From kw at codebykevin.com Thu Dec 7 18:11:33 2006 From: kw at codebykevin.com (Kevin Walzer) Date: Thu, 07 Dec 2006 12:11:33 -0500 Subject: [Tkinter-discuss] Bug in pybwidgets/ListBox? Message-ID: <45784B45.6030809@codebykevin.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I'm trying to use pybwidgets in an application I'm developing; the BWidgets listbox supports insertion of images alongside text, and is nicer than the alternatives I've looked at (various tree widgets, for instance). I've found what I think is a bug. When the BWidgets listbox is placed inside a panewindow, it does not properly display the selectforeground/selectbackground colors--in fact, it provides no visual feedback at all that a listbox item is selected. The following code illustrates the problem. The listbox does respond to button events; when an item is selected, text is printed to the text widget. But there is no visual selection feedback in the listbox itself. Can someone review this, test it, and let me know if I'm doing something wrong, or if this is in fact a bug? Thanks. - --- import Tkinter from bwidget import * import bwidget root = Tkinter.Tk() right = "" m = Tkinter.PanedWindow(root, orient="horizontal") m.pack(fill="both", expand=1) textimage = Tkinter.PhotoImage(data=""" R0lGODlhEAAQANUAAAAAAODg4MjIyIiIiODg6OjQ+NjY4ODo6ODQ8OjY8OjQ8ODQ6ODY6NDI4Njg 6BgYGNDQ0NDQyMDAwNjQ6Njg4NjQ0NDY4BAQEKioqCAgIHh4eKigoLCoqJiYmAgICLCwsLi4uNjY 6NDQ2NjY2Ojo8ODo8Ojw8ODg8Ojo6PDw+PDw8Pj4+Pjw+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAC0AIf/8SUNDUkdCRzEwMTIA AALMYXBwbAIAAABtbnRyUkdCIFhZWiAH1gALABQAAAAAAABhY3NwQVBQTAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA9tYAAQAAAADTLWFwcGwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAxyWFlaAAABFAAAABRnWFlaAAABKAAAABRiWFlaAAABPAAAABR3dHB0 AAABUAAAABRjaGFkAAABZAAAACxyVFJDAAABkAAAAA5nVFJDAAABoAAAAA5iVFJDAAABsAAAAA52 Y2d0AAABwAAAADBu/2RpbgAAAfAAAAA4ZGVzYwAAAigAAAB0Y3BydAAAApwAAAAtWFlaIAAAAAAA AHRLAAA+HQAAA8xYWVogAAAAAAAAWnMAAKymAAAXJlhZWiAAAAAAAAAoGAAAFVcAALgzWFlaIAAA AAAAAPNRAAEAAAABFsxzZjMyAAAAAAABDEIAAAXe///zJgAAB5MAAP2Q///7ov///aMAAAPcAADA bmN1cnYAAAAAAAAAAQI5AABjdXJ2AAAAAAAAAAECOQAAY3VydgAAAAAAAAABAjkAAHZjZ3QAAAAA AAAAAQABAAAAAAAAAAEAAAABAAAAAAAAAAEAAAABAAAAAAAAAAEAANxuZGluAAAAAAAAADAAAKFI AABXCgAAS4UAAJrhAAAnrgAAE7YAAFANAABUOQACOOQAAjjkAAI45GRlc2MAAAAAAAAAGkNhbGli cmF0ZWQgUkdCIENvbG9yc3BhY2UAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAdGV4dAAAAABDb3B5cmln aHQgQXBwbGUgQ29tcHV0ZXIsIEluYy4sIDIwMDUAAAAAACwAAAAAEAAQAAAGmUCNZEgsDgWDFmjF Yq2e0Cjk8VkVFKRS6XQiEBwhVYS6SiRMpDQJdfCmBGQzOuv1OlTwKgKRLdW/YXAcZQpzKH8UeA8Y KwsLJH9fBgYkEouNC211Dg6TlZcTmZuTnpaMExOaBBSkBiimK6iaAaykrw8bKw0NBK0GFiIiByCX DAxpqpIqlhoBI8/QFRDTEAEdHi0Z2tvc2xctQQA7 """) left = ListBox(m, selectbackground="black", selectforeground="white") m.add(left) for text in "abcde": left.insert("end", text=text*3, image=textimage) left.bind_image("", (lambda event: printstuff())) left.bind_text("", (lambda event: printstuff())) right = Tkinter.Text(m) m.add(right) right=right def printstuff(): global right right.insert("end", "pressed\n") root.mainloop() -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFeEtEEsLm8HXyq4sRAhslAJ9S9wifqlh9xe9QqNosDESj1oZO0wCbB8yr N+2+YX9LYgesxHwP5tmCOhw= =NsRv -----END PGP SIGNATURE----- From bob at passcal.nmt.edu Fri Dec 8 00:25:08 2006 From: bob at passcal.nmt.edu (Bob Greschke) Date: Thu, 7 Dec 2006 16:25:08 -0700 Subject: [Tkinter-discuss] Tkinter-discuss Digest, Vol 34, Issue 5 References: <542092.71342.qm@web50606.mail.yahoo.com> Message-ID: <022101c71a56$ef830800$2d1a8a81@workblab> ----- Original Message ----- From: Harlin Seritt To: tkinter-discuss at python.org Sent: Thursday, December 07, 2006 4:14 AM Subject: Re: [Tkinter-discuss] Tkinter-discuss Digest, Vol 34, Issue 5 Hiya G G In case you're a freak about namespace polution (and that's really a good thing), you can generally rest assured that you'll be almost always fine when you do a full namespace import of Tkinter module. Harlin Seritt ======= Yeah, I forgot to mention that using something like from Tkinter import * can get you into trouble if you happen to do something like name a variable "Radiobutton". To see a list of things you shouldn't name variables and functions you can start the Python interpreter, enter 'from Tkinter import *' and then dir() and it will list everything...although you also have to then enter commands like dir(__builtins__), etc. to get the complete list. Is there a way to get the complete list of used keywords with one command? In my programs my variables always start with an upper case letter and my functions always start with a lower case letter (that's just backwards to normal human beings) which has seemed to keep me out of trouble for about 300,000 lines of code. I usually do things like from time import sleep, gmtime, time instead of using from time import *. I guess it's only Tkinter where I import *. Bob From dave.opstad at monotypeimaging.com Fri Dec 8 16:41:20 2006 From: dave.opstad at monotypeimaging.com (Opstad, Dave) Date: Fri, 8 Dec 2006 10:41:20 -0500 Subject: [Tkinter-discuss] Tkinter-discuss Digest, Vol 34, Issue 5 In-Reply-To: <022101c71a56$ef830800$2d1a8a81@workblab> Message-ID: I've always disliked the "from xxx import *" paradigm, specifically because it makes it harder to recognize where certain symbols come from. As the Zen of Python teaches us, "Namespaces are one honking great idea!" As an alternative I use "import Tkinter as T". This doesn't increase the typing burden much --- Button(...) becomes T.Button(...) --- but it always allows me to recognize any symbols belonging to Tkinter's namespace. Just my two cents. Dave -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061208/d81d0f76/attachment.html From bob at passcal.nmt.edu Sun Dec 10 23:25:00 2006 From: bob at passcal.nmt.edu (Bob Greschke) Date: Sun, 10 Dec 2006 15:25:00 -0700 Subject: [Tkinter-discuss] Getting labels from a Text field References: Message-ID: <019801c71caa$089f63b0$2d1a8a81@workblab> Re: [Tkinter-discuss] Tkinter-discuss Digest, Vol 34, Issue 5I have a "form" in my program that has a Text() field with a little text, some Buttons with pictures, and some Labels inserted into it. If I just do a Text().get(0.0, END) all I get is the text. Is there a way to get, pardon my C, a pointer to the Labels so I can cget the text from them? A picture of my form: www.greschke.com/unlinked/images/getem.jpg I specifically want the 7-digit number in the light blue areas (the Labels). I can keep a list of the numbers as I insert the Labels, but the user may edit some of them out of the list (like with the keyboard), so then my list wouldn't match. Thanks! Bob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20061210/50029862/attachment.htm From kw at codebykevin.com Thu Dec 14 23:30:18 2006 From: kw at codebykevin.com (Kevin Walzer) Date: Thu, 14 Dec 2006 17:30:18 -0500 Subject: [Tkinter-discuss] Can't get sorted list of fonts on my system Message-ID: <4581D07A.1010505@codebykevin.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I'm trying to get an alphabetical list of the available fonts on my system for use in a Tkinter application. This code returns an unsorted tuple of the fonts: fonts = tkFont.families() To get a sorted list, I've assembled the following snippet, based on code in idlelib: fonts=list(tkFont.families()) fontlist=fonts.sort() print fontlist However, this code doesn't work. "print fontlist" returns the output "None" in my console, and no list of fonts is displayed in my application. Any ideas on what I'm doing wrong? - -- 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 iD8DBQFFgdB6EsLm8HXyq4sRAsmdAJ9D3xSg+DX9x2eAkrlwmxrnibLUugCfSiGO KRy6zKYEX6asU+hsjPYYXV4= =MYSE -----END PGP SIGNATURE----- From bob at passcal.nmt.edu Thu Dec 14 23:54:00 2006 From: bob at passcal.nmt.edu (Bob Greschke) Date: Thu, 14 Dec 2006 15:54:00 -0700 Subject: [Tkinter-discuss] Can't get sorted list of fonts on my system References: <4581D07A.1010505@codebykevin.com> Message-ID: <019f01c71fd2$beb45130$2d1a8a81@workblab> > fonts=list(tkFont.families()) > fontlist=fonts.sort() > print fontlist Yer gonna kick yourself. :) fonts = list(tkFont.families()) fonts.sort() print fonts .sort() just sorts in place. It doesn't return anything. Bob From dnichols32 at comcast.net Thu Dec 21 01:44:56 2006 From: dnichols32 at comcast.net (mopman) Date: Wed, 20 Dec 2006 16:44:56 -0800 (PST) Subject: [Tkinter-discuss] tkFileDialog: shuts down root window Message-ID: <8000939.post@talk.nabble.com> Hello, I'm using python tkinter to create a GUI. I wish to collect 4 files from a user so for this part I created a GUI that has a Label, Entry and Button. To get the file I use tkFileDialog askopenfilename. My problem is that after a few file selections using the tkFileDialog, the root window is destroyed (the whole program just dissappears). I have created a simpler example and was able to reproduce the same thing with this. I've just started using tkinter so I have no idea what I may be doing wrong. If anyone has any ideas please let me know. If you run the following code, just click the Browse button, and select a file. The file selected is displayed in the Entry field. Click the Browse button again and select another file or the same file. Do those steps several times and for me after the sixth or seventh time the window shuts down. If I restart the program, it may only take one or two times for the root window to be destroyed. BTW, I'm using python 2.4 on Windows XP. Does anyone have any ideas why this may be happening? ################################################################################ from Tkinter import * import Pmw import tkFileDialog import os.path filepath = 'C:\\Documents and Settings\\admin\\Desktop\\' class App(Frame): def __init__(self,master): Frame.__init__(self, master, bg='gray') self.enttxt = StringVar() lbl = Label(self,text='File 1:') lbl.grid(row = 0,column = 0,sticky = W,padx = 5,pady = 5) self.e1 = Entry(self,textvariable = self.enttxt,width = 50) self.e1.grid(row = 0,column = 1,columnspan = 3,sticky = W,padx = 5,pady = 5) btn = Button(self,text='Browse ...',width = 12, command = self.browse) btn.grid(row = 0,column = 4,sticky=W,padx=5,pady=5) def browse(self): fileformats = [('Text File ','*.csv'), ('All Files ','*.*')] retval = tkFileDialog.askopenfilename(title='Choose File', initialdir=filepath, filetypes=fileformats, parent = self) if retval: self.enttxt.set(os.path.abspath(retval)) def main(): root = Tk() root.withdraw() root.title('test') root.configure(bg='gray') app = App(root) app.pack() root.update() root.deiconify() root.mainloop() if __name__ == '__main__': main() -- View this message in context: http://www.nabble.com/tkFileDialog%3A-shuts-down-root-window-tf2863117.html#a8000939 Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From fredrik at pythonware.com Thu Dec 21 08:51:47 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 21 Dec 2006 08:51:47 +0100 Subject: [Tkinter-discuss] tkFileDialog: shuts down root window In-Reply-To: <8000939.post@talk.nabble.com> References: <8000939.post@talk.nabble.com> Message-ID: mopman wrote: > I'm using python tkinter to create a GUI. I wish to collect 4 files from a > user so for this part I created a GUI that has a Label, Entry and Button. > To get the file I use tkFileDialog askopenfilename. My problem is that > after a few file selections using the tkFileDialog, the root window is > destroyed (the whole program just dissappears). > > I have created a simpler example and was able to reproduce the same thing > with this. I've just started using tkinter so I have no idea what I may be > doing wrong. If anyone has any ideas please let me know. I don't have Pmw on this machine, but if I comment out the "import Pmw" line, the program works perfectly fine for me (Python 2.4.3, XP, running from the command prompt). - do you still get the same problem if you remove the Pmw import ? - how do you run the program ? From dnichols32 at comcast.net Thu Dec 21 18:02:27 2006 From: dnichols32 at comcast.net (mopman) Date: Thu, 21 Dec 2006 09:02:27 -0800 (PST) Subject: [Tkinter-discuss] tkFileDialog: shuts down root window In-Reply-To: References: <8000939.post@talk.nabble.com> Message-ID: <8011208.post@talk.nabble.com> Hello, Thank you for the reply. I commented out the Pmw import and still have the same results. I usually run the program through Eclipse with the Pydev plugin. But I also have tried running it by bringing up a window console and I have the same result. So I don't think it is a problem is with the IDE. This morning I ran the program on a different computer and still was able to reproduce on a different computer. One thing to note is that this morning the computer is a P4 2.8 Ghz machine. It took much longer to destroy the root window. (The first time I would say 20 times, but after the first time, it only took 4 or 5 times to do it a second time) The other computer is a P4 1.8 Ghz, it takes fewer times. Could it be a race condition? Thank you again for your response. Fredrik Lundh wrote: > > mopman wrote: > >> I'm using python tkinter to create a GUI. I wish to collect 4 files from >> a >> user so for this part I created a GUI that has a Label, Entry and >> Button. >> To get the file I use tkFileDialog askopenfilename. My problem is that >> after a few file selections using the tkFileDialog, the root window is >> destroyed (the whole program just dissappears). >> >> I have created a simpler example and was able to reproduce the same thing >> with this. I've just started using tkinter so I have no idea what I may >> be >> doing wrong. If anyone has any ideas please let me know. > > I don't have Pmw on this machine, but if I comment out the "import Pmw" > line, the program works perfectly fine for me (Python 2.4.3, XP, running > from the command prompt). > > - do you still get the same problem if you remove the Pmw import ? > > - how do you run the program ? > > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > -- View this message in context: http://www.nabble.com/tkFileDialog%3A-shuts-down-root-window-tf2863117.html#a8011208 Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From bob at passcal.nmt.edu Thu Dec 21 21:00:56 2006 From: bob at passcal.nmt.edu (Bob Greschke) Date: Thu, 21 Dec 2006 13:00:56 -0700 Subject: [Tkinter-discuss] Disabling menu things Message-ID: <01c801c7253a$ba93d590$2d1a8a81@workblab> In this context: from Tkinter import * Root = Tk() def about(): # Whatever return def progQuitter(): # Whatever return def makeMenu(Win): global Fi # or most likely a dictionary that achieves the same thing global Hp global Top Top = Menu(Win) Win.configure(menu = Top) Fi = Menu(Top, tearoff = 0) Top.add_cascade(label = "File", menu = Fi) Fi.add_command(label = "Quit", command = progQuitter) Hp = Menu(Top, tearoff = 0) Top.add_cascade(label = "Help", menu = Hp) Hp.add_command(label = "About", command = about) return makeMenu(Root) Root.mainloop() I want to write a function like def disableMenu("File", "Quit") # Finds the Quit item in File cascade and sets its state to DISABLED return How would disableMenu() entrycget() through the menu items to find the index of the "Quit" item? How do I get a list of the cascades ("File", "Help" - just looping through Top.entrycget(i, "label") seems to do that) and then a list of the items in those cascades ("Quit", "About")? As an aside print Fi.entrycget(1, "label") seems to work, but (2, "label") doesn't. It says "-label" is an unknown option. I guess I don't know what I'm doing. :) Thanks! Bob From bob at passcal.nmt.edu Thu Dec 21 21:19:12 2006 From: bob at passcal.nmt.edu (Bob Greschke) Date: Thu, 21 Dec 2006 13:19:12 -0700 Subject: [Tkinter-discuss] Fw: Disabling menu things (oops) Message-ID: <025801c7253d$47606180$2d1a8a81@workblab> >> As an aside >> >> print Fi.entrycget(1, "label") >> >> seems to work, but (2, "label") doesn't. It says "-label" is an unknown >> option. I guess I don't know what I'm doing. :) I should have said that entrycget(2, "label") doesn't work on a longer menu (in my real program) not this example snippit. Bob From dnichols32 at comcast.net Thu Dec 21 23:03:25 2006 From: dnichols32 at comcast.net (mopman) Date: Thu, 21 Dec 2006 14:03:25 -0800 (PST) Subject: [Tkinter-discuss] tkFileDialog: shuts down root window In-Reply-To: References: <8000939.post@talk.nabble.com> Message-ID: <8015842.post@talk.nabble.com> Ahha! I know how to reproduce this! I was starting to think it was the Eclipse IDE but I did a reboot and ran from the windows console to make sure it wasn't to repeat: 1) Right after reboot, I opened a window console, did a cd to my python directory and entered "python .py" to open the ui window 2) click the browse button - file browser opens with my list of .csv files 4) here is the trick - DOUBLE click the file you want in the list. - with the double click you don't need to click the Open button, the double clicked file is entered in Entry field and tkfiledialog window closes 5) click the Browse button in the UI again and here is where I get some different behaviors. Some times after clicking the browse button the second time, I can wait, (for me it took about 15 seconds), and then the root window is destroyed. Other times, the root window is destroyed immediately, other times I need to do the browse, double click, browse, double click three or four times. But seems that I can consistently repeat this with at max four of these browse, double click cycles. It seems that all I have to do is have one double click in the tkfiledialog to kill my whole app. Can anyone else reproduce this? Thanks again. Fredrik Lundh wrote: > > mopman wrote: > >> I'm using python tkinter to create a GUI. I wish to collect 4 files from >> a >> user so for this part I created a GUI that has a Label, Entry and >> Button. >> To get the file I use tkFileDialog askopenfilename. My problem is that >> after a few file selections using the tkFileDialog, the root window is >> destroyed (the whole program just dissappears). >> >> I have created a simpler example and was able to reproduce the same thing >> with this. I've just started using tkinter so I have no idea what I may >> be >> doing wrong. If anyone has any ideas please let me know. > > I don't have Pmw on this machine, but if I comment out the "import Pmw" > line, the program works perfectly fine for me (Python 2.4.3, XP, running > from the command prompt). > > - do you still get the same problem if you remove the Pmw import ? > > - how do you run the program ? > > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > -- View this message in context: http://www.nabble.com/tkFileDialog%3A-shuts-down-root-window-tf2863117.html#a8015842 Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From jrcagle at juno.com Sun Dec 24 22:42:45 2006 From: jrcagle at juno.com (Jeff Cagle) Date: Sun, 24 Dec 2006 16:42:45 -0500 Subject: [Tkinter-discuss] Sizing In-Reply-To: References: Message-ID: <458EF455.1050909@juno.com> This is an ignorant question, so thanks in advance for your patience. I'm trying to code a card game, and I have lots of little .gif's used to display card images as follows: from Tkinter import * import Image, ImageTk ... class Card(object): def display(self, canvas, x, y, angle) im = Image.open(self.URL) im = im.rotate(angle) self.image = ImageTk.PhotoImage(im) canvas.create_image(x,y,image=self.image) ... The idea is to show four hands of 13 cards, each hand facing inwards. Oddly, when I display them, the right hand gets truncated. The dimensions of the canvas print out as 265x378. I can fix it by assigning height and width of the canvas manually, but it made me wonder: why doesn't the canvas autosize? Thanks, Jeff Cagle From klappnase at web.de Mon Dec 25 01:53:59 2006 From: klappnase at web.de (Michael Lange) Date: Mon, 25 Dec 2006 01:53:59 +0100 Subject: [Tkinter-discuss] Sizing In-Reply-To: <458EF455.1050909@juno.com> References: <458EF455.1050909@juno.com> Message-ID: <20061225015359.62bbfe55.klappnase@web.de> On Sun, 24 Dec 2006 16:42:45 -0500 Jeff Cagle wrote: > This is an ignorant question, so thanks in advance for your patience. > > I'm trying to code a card game, and I have lots of little .gif's used to > display card images as follows: > > from Tkinter import * > import Image, ImageTk > ... > class Card(object): > > def display(self, canvas, x, y, angle) > im = Image.open(self.URL) > im = im.rotate(angle) > self.image = ImageTk.PhotoImage(im) > canvas.create_image(x,y,image=self.image) > > ... > > The idea is to show four hands of 13 cards, each hand facing inwards. > > Oddly, when I display them, the right hand gets truncated. The > dimensions of the canvas print out as 265x378. I can fix it by > assigning height and width of the canvas manually, but it made me > wonder: why doesn't the canvas autosize? > Probably because it is not wanted in many cases that the size of the widget increases when new items are added. Imagine a situation, where the bounding box of all canvas item exceeds the screen dimensions. Or maybe you do not want to resize the widget at all but use scrollbars instead. For your problem it might be the best choice to check out the maximum possible size of the canvas and apply this manually. I hope this helps Michael From dnichols32 at comcast.net Wed Dec 27 22:02:00 2006 From: dnichols32 at comcast.net (mopman) Date: Wed, 27 Dec 2006 13:02:00 -0800 (PST) Subject: [Tkinter-discuss] tkFileDialog: shuts down root window In-Reply-To: References: <8000939.post@talk.nabble.com> Message-ID: <8067425.post@talk.nabble.com> I believe I have the missing piece to this puzzle. This only happens when selecting files from the Desktop. If I'm selecting files from any other location it is fine. To repeat: 1) in the code that I submitted, change the initialdir to your python dir: e.g. 'C:\\Python24' 2) run code - window appears 3) click Browse button - filedialog appears 4) click Desktop button on left hand side of file dialog - changes to Desktop location 5) select a file from list and click Open (you can also double click on file to select it doesn't matter) - path is displayed in Entry field 6) click Browse button again 7) click Desktop button again 8) Now here it is - slowly move cursor to a filename in the list - as soon as cursor is over file the application shuts down. My observations: 1) It takes two times selecting a file from the desktop for this to happen. 2) It seems to happen on the second time as soon as the pop up displays the file info (i.e. if you move cursor over a file, a pop up appears with file type, date and size info). 3) This only happens when selecting from desktop. I can select files without any problems from any other location. Fredrik Lundh wrote: > > mopman wrote: > >> I'm using python tkinter to create a GUI. I wish to collect 4 files from >> a >> user so for this part I created a GUI that has a Label, Entry and >> Button. >> To get the file I use tkFileDialog askopenfilename. My problem is that >> after a few file selections using the tkFileDialog, the root window is >> destroyed (the whole program just dissappears). >> >> I have created a simpler example and was able to reproduce the same thing >> with this. I've just started using tkinter so I have no idea what I may >> be >> doing wrong. If anyone has any ideas please let me know. > > I don't have Pmw on this machine, but if I comment out the "import Pmw" > line, the program works perfectly fine for me (Python 2.4.3, XP, running > from the command prompt). > > - do you still get the same problem if you remove the Pmw import ? > > - how do you run the program ? > > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > -- View this message in context: http://www.nabble.com/tkFileDialog%3A-shuts-down-root-window-tf2863117.html#a8067425 Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From jepler at unpythonic.net Wed Dec 27 22:44:04 2006 From: jepler at unpythonic.net (Jeff Epler) Date: Wed, 27 Dec 2006 15:44:04 -0600 Subject: [Tkinter-discuss] tkFileDialog: shuts down root window In-Reply-To: <8067425.post@talk.nabble.com> References: <8000939.post@talk.nabble.com> <8067425.post@talk.nabble.com> Message-ID: <20061227214404.GB9882@unpythonic.net> You should determine whether this error happens with wish.exe as well as with Python's Tkinter module. If it does, please submit a bug report to http://sf.net/projects/tktoolkit http://sf.net/tracker/?group_id=12997&atid=112997 Jeff From dnichols32 at comcast.net Wed Dec 27 23:53:44 2006 From: dnichols32 at comcast.net (mopman) Date: Wed, 27 Dec 2006 14:53:44 -0800 (PST) Subject: [Tkinter-discuss] tkFileDialog: shuts down root window In-Reply-To: <20061227214404.GB9882@unpythonic.net> References: <8000939.post@talk.nabble.com> <8067425.post@talk.nabble.com> <20061227214404.GB9882@unpythonic.net> Message-ID: <8068564.post@talk.nabble.com> Yes, this happens on wish.exe as well. to repeat: 1) start Dos console and cd to C:\Tcl\demos\Tk8.4 2) at prompt enter: wish widget.tcl - widget demonstration window opens 3) scroll to Common Dialogs and select 2. File selection dialog 4) click browse button in dialog 5) click Desktop button on left hand side of dialog 6) double click any .txt file - file path entered in entry field 7) click browse button again 8) click Desktop button again 9) just move cursor over a .txt file The dialog is destroyed. Note: this happens in XP, I wasn't able to reproduce on Win 2000. I will go ahead and log a bug. Jeff Epler wrote: > > You should determine whether this error happens with wish.exe as well as > with Python's Tkinter module. If it does, please submit a bug report to > http://sf.net/projects/tktoolkit > http://sf.net/tracker/?group_id=12997&atid=112997 > > Jeff > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > -- View this message in context: http://www.nabble.com/tkFileDialog%3A-shuts-down-root-window-tf2863117.html#a8068564 Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.