From stewart at midtoad.homelinux.org Thu May 6 09:04:25 2004 From: stewart at midtoad.homelinux.org (Stewart Midwinter) Date: Thu May 6 09:04:34 2004 Subject: [Tkinter-discuss] Widget collection project In-Reply-To: <20040428220319.26da0d22.klappnase@web.de> References: <20040428220319.26da0d22.klappnase@web.de> Message-ID: <20040506070425.3ed938d5@pc-00065.midtoad.homelinux.org> On Wed, 28 Apr 2004 22:03:19 +0200 Michael Lange spake thusly: > My idea was that many people might have written widgets that are nice, but not > "full-featured", so that it would be cool if you could simply add features by > editing the source code on the wiki page (or maybe fix a bug); on the other > hand you could just copy & paste the code into your application without having > to download and install some package. Michael, my preference would actually be for people to submit their version of the widget as another version, rather than editing the original version of the widget. This is so we can see how different authors think. It also ensures that the original versions are not lost. I've got a widget to send along, BTW. -- Stewart Midwinter running on Mandrake Linux 9.2 e-mail: Stewart 'at' Midwinter.ca, stewart 'at' midtoad.homelinux.org web: http://www.midwinter.ca, http://midtoad.homelinux.org voice: +1.403.714.4329 PGP key:http://www.keyserver.net Umwelt schuetzen, Rad benuetzen! From kenneth.m.mcdonald at sbcglobal.net Fri May 7 19:22:38 2004 From: kenneth.m.mcdonald at sbcglobal.net (Kenneth McDonald) Date: Fri May 7 19:22:44 2004 Subject: [Tkinter-discuss] Any python-friendly Subversion-using Sourceforge-type sites out there? Message-ID: <6E110187-A07D-11D8-AC85-000A956870AC@sbcglobal.net> I have a Tkinter-related project I'd like to put up somewhere for other people to look at/comment on/possibly even help with. However, I really detest CVS. Anyone know of a site using Subversion that will host open-source projects like this? (tigris, the home site for subversion, hosts only stuff related to code management, I believe.) Thanks, Ken From kenneth.m.mcdonald at sbcglobal.net Sat May 8 20:11:10 2004 From: kenneth.m.mcdonald at sbcglobal.net (Kenneth McDonald) Date: Sat May 8 20:11:14 2004 Subject: [Tkinter-discuss] Any way to extract from an event object the event specifier string which fired the event? Message-ID: <5FF09C88-A14D-11D8-AC85-000A956870AC@sbcglobal.net> Let's say I have defined and bound a function to be executed in response to an event: def callback(e): ... When the function is called, e is an event object from which I can extract various bits of info; for example, e.widget is the widget on which the binding was invoked. However, I can't figure out any way to get the event string specifying the firing event, i.e. the string by which 'callback' was originally bound. From looking at Tk bind docs, this seems to be a Tk lack rather than a Tkinter lack, but I'm wondering if there is some other function in Tkinter/Tk which will let me do this. Thanks, Ken From klappnase at web.de Sat May 8 21:21:47 2004 From: klappnase at web.de (Michael Lange) Date: Sat May 8 21:23:08 2004 Subject: [Tkinter-discuss] Any way to extract from an event object the event specifier string which fired the event? In-Reply-To: <5FF09C88-A14D-11D8-AC85-000A956870AC@sbcglobal.net> References: <5FF09C88-A14D-11D8-AC85-000A956870AC@sbcglobal.net> Message-ID: <20040509032147.41192074.klappnase@web.de> On Sat, 8 May 2004 19:11:10 -0500 Kenneth McDonald wrote: > Let's say I have defined and bound a function to be executed > in response to an event: > > def callback(e): > ... > > When the function is called, e is an event object from which I > can extract various bits of info; for example, e.widget is the > widget on which the binding was invoked. > > However, I can't figure out any way to get the event string > specifying the firing event, i.e. the string by which 'callback' > was originally bound. From looking at Tk bind docs, this seems to > be a Tk lack rather than a Tkinter lack, but I'm wondering if > there is some other function in Tkinter/Tk which will let me > do this. > > Thanks, > Ken > That's interesting, I already asked myself the same question. Unfortunately the best idea I had was to collect the information the event object offers and put them together to get the event-sequence; for example I tried a little and it seems that event.type for KeyPress is 2, for KeyRelease 3; with event.keysym we could get the event-sequence: def sequence(event): events = {'2':'KeyPress', '3':'KeyRelease'} return '<%s-%s>' %(events[event.type],event.keysym) This could be very complicated if you want to catch any kind of event I'm afraid, especially if there's no documentation about event types and everything needs to be tried first. Maybe someone else has a better idea, if you find something please let me know, that's very interesting. Thanks Michael From fredrik at pythonware.com Mon May 10 16:49:54 2004 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon May 10 16:50:16 2004 Subject: [Tkinter-discuss] Re: Any way to extract from an event object the eventspecifier string which fired the event? References: <5FF09C88-A14D-11D8-AC85-000A956870AC@sbcglobal.net> Message-ID: Kenneth McDonald wrote: > Let's say I have defined and bound a function to be executed > in response to an event: > > def callback(e): > ... > > When the function is called, e is an event object from which I > can extract various bits of info; for example, e.widget is the > widget on which the binding was invoked. > > However, I can't figure out any way to get the event string > specifying the firing event, i.e. the string by which 'callback' > was originally bound. From looking at Tk bind docs, this seems to > be a Tk lack rather than a Tkinter lack, but I'm wondering if > there is some other function in Tkinter/Tk which will let me > do this. here's one way to do it: def my_bind(widget, event, callback): def proxy(e, event=event, callback=callback): e.event_string = event return callback(e) widget.bind(event, proxy) def my_callback(e): print e.event_string my_bind(widget, "", my_callback) my_bind(widget, "", my_callback) From kenneth.m.mcdonald at sbcglobal.net Tue May 11 15:36:57 2004 From: kenneth.m.mcdonald at sbcglobal.net (Kenneth McDonald) Date: Tue May 11 16:02:03 2004 Subject: [Tkinter-discuss] Re: Any way to extract from an event object the eventspecifier string which fired the event? (Fredrik Lundh) In-Reply-To: References: Message-ID: <90BC0743-A382-11D8-AC85-000A956870AC@sbcglobal.net> Fred, Thanks for the feedback. I was already holding the event string in Python and performing a mapping similar to what you've shown below, but your method is quite a bit cleaner. I hadn't realized (or even thought of the possibility) that the Tkinter event object could be so easily expanded with further information, and that's a big help. It is a shame, though, that this can't actually be done from Tk (so far as anyone has indicated.) Cheers, Ken > Message: 1 > Date: Mon, 10 May 2004 22:49:54 +0200 > From: "Fredrik Lundh" > Subject: [Tkinter-discuss] Re: Any way to extract from an event object > the eventspecifier string which fired the event? > To: tkinter-discuss@python.org > Message-ID: > > Kenneth McDonald wrote: > >> Let's say I have defined and bound a function to be executed >> in response to an event: >> >> def callback(e): >> ... >> >> When the function is called, e is an event object from which I >> can extract various bits of info; for example, e.widget is the >> widget on which the binding was invoked. >> >> However, I can't figure out any way to get the event string >> specifying the firing event, i.e. the string by which 'callback' >> was originally bound. From looking at Tk bind docs, this seems to >> be a Tk lack rather than a Tkinter lack, but I'm wondering if >> there is some other function in Tkinter/Tk which will let me >> do this. > > here's one way to do it: > > def my_bind(widget, event, callback): > def proxy(e, event=event, callback=callback): > e.event_string = event > return callback(e) > widget.bind(event, proxy) > > def my_callback(e): > print e.event_string > > my_bind(widget, "", my_callback) > my_bind(widget, "", my_callback) > > > > > > > > > ------------------------------ > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss@python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > > End of Tkinter-discuss Digest, Vol 3, Issue 4 > ********************************************* > From FBatista at uniFON.com.ar Wed May 12 13:49:37 2004 From: FBatista at uniFON.com.ar (Batista, Facundo) Date: Wed May 12 13:52:24 2004 Subject: [Tkinter-discuss] Clipboard Message-ID: Seems to be missing something fundamental here, sorry. I'm developing a small program (under win32, but should work crossplatform). I want to paste some text in the clipboard, so I do: root.clipboard_clear() root.clipboard_append(mytext) But I can not find a way to retrieve the text from the clipboard! Is there a way? Thank you! . Facundo From mhuening at zedat.fu-berlin.de Wed May 12 14:21:02 2004 From: mhuening at zedat.fu-berlin.de (Matthias Huening) Date: Wed May 12 14:30:48 2004 Subject: [Tkinter-discuss] Re: Clipboard References: Message-ID: "Batista, Facundo" wrote in news:A128D751272CD411BC9200508BC2194D03383981@escpl.tcp.com.ar: > I want to paste some text in the clipboard, so I do: > > root.clipboard_clear() > root.clipboard_append(mytext) > > But I can not find a way to retrieve the text from the clipboard! Is > there a way? root.selection_get(selection="CLIPBOARD") Matthias From Rossana.Airoldi at ciaolab.com Thu May 13 07:53:17 2004 From: Rossana.Airoldi at ciaolab.com (Rossana Airoldi) Date: Thu May 13 07:53:10 2004 Subject: [Tkinter-discuss] Different aspect in windows and linux for the Button's highlight background Message-ID: Hi all The following script has different behaviour in Linux and Windows. In Linux you can see the button?s highlight colors. In Windows when the button has the focus you see a dashed 1 pixel line around the inner space of the button. Is there a way to override this Windows behaviour and to have the interpreter to work in the same way as in Linux? I would appreciate any suggestion, advice you can give me. Have a good day ============================================================================ ================================= from Tkinter import * class Button_test: def __init__(self,master): self.root=master def mainwindow(self,master,title): self.root.geometry("800x600") self.graphRegs = () self.root.configure(bg="#000053") self.root.columnconfigure(0,minsize=19) self.root.columnconfigure(1,minsize=203) self.root.columnconfigure(2,minsize=17) self.root.columnconfigure(3,minsize=441) self.root.columnconfigure(4,minsize=7) self.root.columnconfigure(5,minsize=106) self.root.columnconfigure(6,minsize=7) self.root.rowconfigure(0,minsize=96) self.root.rowconfigure(1,minsize=47) self.root.rowconfigure(2,minsize=19) self.root.rowconfigure(3,minsize=80) self.root.rowconfigure(4,minsize=80) self.root.rowconfigure(5,minsize=80) self.root.rowconfigure(6,minsize=80) self.root.rowconfigure(7,minsize=80) frame1 = Frame(root,height=96,width=400,bg="#000053") self.titolo = Label(frame1,text=title,font=("arial",25),fg="#FFFFFF",bg="#000053",anchor=W ).grid(row=0,column=0,columnspan=3,sticky=W,padx=20) frame1.grid(row=0,column=0,sticky=W,columnspan=6) frame2 = Frame(root,height=96,width=400,bg="#000053") frame2.grid(row=0,column=0,sticky=E,columnspan=6) def menusistema(self,master): frame4 = Frame(root,height=400,width=203,bg="#094AA6") w = Button(master, text="Button1", font=("arial",12), width=18, fg="#000053", bg="#EFF4F8", bd = 6, takefocus=1, highlightthickness = 6, highlightcolor = "#FFCC00", relief = 'ridge') w.grid(row=3, column = 1) w.focus_force() self.root.event_generate('') w1 = Button(master, text="Button2", font=("arial",12), width=18, bg="#EFF4F8", bd = 6, highlightthickness = 6, activeforeground = "#FFCC00", highlightcolor = "#FFCCFF", highlightbackground = "#FFCCFF", relief = 'ridge' ) w1.grid(row=4, column = 1) root = Tk() Gui = Button_test(root) Gui.mainwindow(root,"Button Test") Gui.menusistema(root) root.mainloop() ============================================================================ ================================= -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20040513/0c460d76/attachment-0001.html From jepler at unpythonic.net Thu May 13 12:30:37 2004 From: jepler at unpythonic.net (Jeff Epler) Date: Thu May 13 12:30:52 2004 Subject: [Tkinter-discuss] Different aspect in windows and linux for the Button's highlight background In-Reply-To: References: Message-ID: <20040513163036.GA5112@unpythonic.net> Buttons are drawn by different (C) code on Windows and X platforms. There's little you can do about this fact, unfortunately. Jeff From claird at lairds.com Thu May 13 20:26:58 2004 From: claird at lairds.com (Cameron Laird) Date: Thu May 13 20:27:09 2004 Subject: [Tkinter-discuss] Different aspect in windows and linux for the Button's highlight background In-Reply-To: <20040513163036.GA5112@unpythonic.net> Message-ID: > From tkinter-discuss-bounces+claird=lairds.com@python.org Thu May 13 11:33:08 2004 > . > . > . > Buttons are drawn by different (C) code on Windows and X platforms. > There's little you can do about this fact, unfortunately. > . > . > . ? I don't think I agree with the latter; Jeff, you usually strike me as more imaginative. I can't conveniently get to a Tkinter just now. I have a few ideas, though: A. tinker with the "options database" to make the borders/depth/shadows/... look the same on Windows and Unix. The better-looking-Tk crowd has an extensive literature on this. B. In pure Python, define your own widget subclassed from Label, with all the behavior a button should have. Some- place I've seen tips on how to do this ... C. Steal from the existing implementations of Button to code in C your own widget with the properties you want. I bet people who are *good* with Tkinter can think of more. From eugene at boardkulture.com Thu May 13 23:44:09 2004 From: eugene at boardkulture.com (=?iso-8859-1?Q?EuG=E8Ne?= Van den Bulke) Date: Thu May 13 23:45:04 2004 Subject: [Tkinter-discuss] text doesn't look the same in IDLE/console and in Text widget In-Reply-To: References: Message-ID: <6.1.0.6.2.20040514133212.01b40ec0@pop.pro.proxad.net> Hi, I am pretty new to Python and Tkinter and can't find an answer to an annoying problem I am encountering with the Text widget. I can line things up pretty well in the console or IDLE but in a Text widget I can't ... and don't understand why (I have tried many different fonts but it doens't make any difference). A small program is better than a long explanation : ----- from Tkinter import * root=Tk() display=Text(root,font=("courrier", 12)) display.pack() #the type of string I want to display content="%-6s (%6s) %6s\n" % ('micron','rpi','future') content+="%6i (%6i) %6i\n" %(15,178,3) content+="%6i (%6i) %6i\n" %(15,7,13) #output to the console that looks the way I want it to look print content #output to the Text widget that doesn't :( display.insert(END,content) root.mainloop() ----- Thanks for your help, Eugene From juran at carmen.se Fri May 14 04:30:45 2004 From: juran at carmen.se (David Juran) Date: Fri May 14 04:31:14 2004 Subject: [Tkinter-discuss] translating tkinter Message-ID: <40A483B5.4020103@carmen.se> Hello. I wonder if any attempts have ever been made of making tkinter translatable. If we were to do that and make a translation into german, would you accept it into the distribution? -- David Juran System administrator E-mail: david@carmen.se Phone: +46-31-7226259 +46-7390-18259 Carmen Systems AB Odinsgatan 9 SE-411 03 Goteborg, Sweden From jepler at unpythonic.net Fri May 14 07:36:40 2004 From: jepler at unpythonic.net (Jeff Epler) Date: Fri May 14 07:37:01 2004 Subject: [Tkinter-discuss] text doesn't look the same in IDLE/console and in Text widget In-Reply-To: <6.1.0.6.2.20040514133212.01b40ec0@pop.pro.proxad.net> References: <6.1.0.6.2.20040514133212.01b40ec0@pop.pro.proxad.net> Message-ID: <20040514113640.GB26819@unpythonic.net> I think the problem may be as simple as picking the right font for the Text widget. Try using font=("Courier", 12) instead. There's probably no font called "courrier" on your system (there wasn't on mine) so Tk chooses a "platform-specific default font". On my system, it was an incredibly ugly but fixed-width font. On yours, it must be some proportional-spaced font. Jeff From klappnase at web.de Fri May 14 07:47:10 2004 From: klappnase at web.de (Michael Lange) Date: Fri May 14 07:46:21 2004 Subject: [Tkinter-discuss] text doesn't look the same in IDLE/console and in Text widget In-Reply-To: <6.1.0.6.2.20040514133212.01b40ec0@pop.pro.proxad.net> References: <6.1.0.6.2.20040514133212.01b40ec0@pop.pro.proxad.net> Message-ID: <20040514134710.3f502df2.klappnase@web.de> On Fri, 14 May 2004 13:44:09 +1000 EuG?Ne Van den Bulke wrote: > Hi, > > I am pretty new to Python and Tkinter and can't find an answer to an > annoying problem I am encountering with the Text widget. I can line things > up pretty well in the console or IDLE but in a Text widget I can't ... and > don't understand why (I have tried many different fonts but it doens't make > any difference). A small program is better than a long explanation : > > ----- > from Tkinter import * > > root=Tk() > display=Text(root,font=("courrier", 12)) > display.pack() > > #the type of string I want to display > content="%-6s (%6s) %6s\n" % ('micron','rpi','future') > content+="%6i (%6i) %6i\n" %(15,178,3) > content+="%6i (%6i) %6i\n" %(15,7,13) > > #output to the console that looks the way I want it to look > print content > > #output to the Text widget that doesn't :( > display.insert(END,content) > > root.mainloop() > ----- > > Thanks for your help, > > Eugene > Hi Eugene, could you tell what exactly your problem is, I tried your example and the output looked quite the same to me both on the shell and the text widget: micron ( rpi) future 15 ( 178) 3 15 ( 7) 13 Do you get any other result in your text widget and how does it look like? Regards Michael From corrado.clementi at ciaolab.com Fri May 14 12:08:13 2004 From: corrado.clementi at ciaolab.com (corrado clementi) Date: Fri May 14 12:21:59 2004 Subject: [Tkinter-discuss] Tkinter, multithreading and Windows Message-ID: Hello I'm writing a kiosk application showing some html tables in one frame and an horizontal ticker in a different frame; each frame has its own thread dealing with its widgets and its data.The application works without any problem under Linux; on Windows the same application dies almost immediately, not being able to update the screen (it hangs on calls to Tkinter methods). How can I deal with these 2 frames updating independently one from the other without hanging the application? Shall I run the update() method each time I use a graphic method? I also tried running two different applications, one for displaying the tables and one dealing with the ticker: in this case I have no longer hangs but how can I move the keyboard focus from one application to the other? Thanks Corrado From eugene at boardkulture.com Fri May 14 16:57:30 2004 From: eugene at boardkulture.com (=?iso-8859-1?Q?EuG=E8Ne?= Van den Bulke) Date: Fri May 14 16:57:46 2004 Subject: [Tkinter-discuss] Re: Tkinter-discuss Digest, Vol 3, Issue 7 In-Reply-To: References: Message-ID: <6.1.0.6.2.20040515065251.01b21658@pop.pro.proxad.net> Thanks Jeff, it fixed it ... I am sorry about the stupid spelling mistake in the font name :( My apology for the inconvenience. >I think the problem may be as simple as picking the right font for the >Text widget. > >Try using font=("Courier", 12) instead. > >There's probably no font called "courrier" on your system (there wasn't >on mine) so Tk chooses a "platform-specific default font". On my >system, it was an incredibly ugly but fixed-width font. On yours, it >must be some proportional-spaced font. > >Jeff Eugene From claird at lairds.com Mon May 17 11:54:57 2004 From: claird at lairds.com (Cameron Laird) Date: Mon May 17 11:55:00 2004 Subject: [Tkinter-discuss] Advertisement for "Tcl-URL!" Message-ID: From corrado.clementi at ciaolab.com Tue May 18 05:43:30 2004 From: corrado.clementi at ciaolab.com (corrado clementi) Date: Tue May 18 05:42:11 2004 Subject: [Tkinter-discuss] Pmw, Blt and graphs Message-ID: Hello I'm using Pmw.Blt to create some financial graph; I would like to use two different colors in the plot area, below the line and over the line. I know how to set the background color but I haven't found out a way to perform the above task. Can anyone help me? Thanks in advance corrado From dblank at brynmawr.edu Sun May 23 17:18:40 2004 From: dblank at brynmawr.edu (Douglas S. Blank) Date: Sun May 23 17:27:55 2004 Subject: [Tkinter-discuss] Tkinter under SMP Message-ID: <40B11530.6090702@brynmawr.edu> Hello tkinter-discuss, I'm new to this list, but have a question: I seem to have a lot of problems running tkinter under a particular Linux (RedHat 9), PC computer, which happens to have two processors. Could this be the problem? The problem specifically is that I get very strange Tk errors, like: attempt to apply int(): None but every time it is a different error. I never have any problems (like these) on any other (non-SMP) machine. If this is a problem, is there a known work-around, or plans to fix it? Thanks! -Doug From jepler at unpythonic.net Sun May 23 17:36:04 2004 From: jepler at unpythonic.net (Jeff Epler) Date: Sun May 23 17:36:16 2004 Subject: [Tkinter-discuss] Tkinter under SMP In-Reply-To: <40B11530.6090702@brynmawr.edu> References: <40B11530.6090702@brynmawr.edu> Message-ID: <20040523213604.GA17178@unpythonic.net> I've never seen this error message before. I took a quick look in the Python source, and I couldn't find "attempt to apply" in any of the .c or .py files. The terms "apply", "int()" and "None" make this error unlikely to come from the tcl or tk libraries. Can you provide more information, such as a complete traceback or tcl error? Can you find a small program that produces the error and send it to the list? Jeff From roland at catalogix.se Mon May 24 05:09:41 2004 From: roland at catalogix.se (Roland Hedberg) Date: Mon May 24 05:10:05 2004 Subject: [Tkinter-discuss] Removing widgets Message-ID: <40B1BBD5.7050008@catalogix.se> Hi! I'm a complete newbie on tkinter so I can only hope that this is the right forum for this question. Anyway, I have the following problem: In one part of my main window ( the local definition part), I want to insert labels and entry window pairs. Which labels are printed are dependent on which entry that has been choosen in a listbox in another part of the main window. The pairs are added to a frame that are packed into the main frame. The snippet that does the pairs looks like this: i = 0 for lab in labels: l = Label(local, text=lab+":") l.grid(row=i) self.lab.append(l) e = Entry(local) e.grid(row=i, column=1) self.ent.append(e) i += 1 If another entry from the list is choosen then the labels and accompaning entry windows should change. Noticable is that the number of label/entry pairs differs between different choices in the listbox and that the length of the labels also varies. So what I want to do is to clear the local definition frame of the main window when a new listentry are choosen and then write the new pairs. Preferrably without having the frame size change, but that is secondary at present. My problem is that I am unable to 'clear' the frame, I can't get rid of the labels I once have written (or the entries for that matter). I can overwrite them but that only 'works' if all the labels are of the same length which they aren't. I've tried to use destroy and forget but to no avail. Anyone who knows how to do this ? -- Roland From jepler at unpythonic.net Mon May 24 08:02:21 2004 From: jepler at unpythonic.net (Jeff Epler) Date: Mon May 24 08:02:34 2004 Subject: [Tkinter-discuss] Removing widgets In-Reply-To: <40B1BBD5.7050008@catalogix.se> References: <40B1BBD5.7050008@catalogix.se> Message-ID: <20040524120220.GA25867@unpythonic.net> You'll need to record the children of 'e' somehow, and destroy them all. Or, you can destroy 'e' and start over again. Or, use 'grid_slaves' or 'winfo_children' on 'e' to get a listing of all widgets gridded in 'e', or all widgets that are direct children of 'e', and destroy each of them in turn. Jeff From dblank at cs.brynmawr.edu Mon May 24 12:14:52 2004 From: dblank at cs.brynmawr.edu (Douglas S. Blank) Date: Mon May 24 12:15:00 2004 Subject: [Tkinter-discuss] Tkinter under SMP In-Reply-To: <20040523213604.GA17178@unpythonic.net> References: <40B11530.6090702@brynmawr.edu> <20040523213604.GA17178@unpythonic.net> Message-ID: <40B21F7C.2010109@cs.brynmawr.edu> Doug Blank wrote: > Hello tkinter-discuss, > > I'm new to this list, but have a question: I seem to have a lot of problems running tkinter under a particular Linux (RedHat 9), PC computer, which happens to have two processors. Could this be the problem? > > The problem specifically is that I get very strange Tk errors, like: > > attempt to apply int(): None > > but every time it is a different error. I never have any problems (like these) on any other (non-SMP) machine. To which Jeff Epler wrote: > I've never seen this error message before. > Sorry, that wasn't an exact error message. But it is a different error every time. Here are some examples: ---------------------------------------------------------------------- File "/usr/lib/python2.2/lib-tk/Tkinter.py", line 1969, in create_rectangle return self._create('rectangle', args, kw) File "/usr/lib/python2.2/lib-tk/Tkinter.py", line 1947, in _create (self._w, 'create', itemType) ValueError: invalid literal for int(): None ---------------------------------------------------------------------- File "/usr/lib/python2.2/lib-tk/Tkinter.py", line 1969, in create_rectangle return self._create('rectangle', args, kw) File "/usr/lib/python2.2/lib-tk/Tkinter.py", line 1947, in _create (self._w, 'create', itemType) TclError: unknown option "141138396callit" ---------------------------------------------------------------------- File "/usr/lib/python2.2/lib-tk/Tkinter.py", line 1969, in create_rectangle return self._create('rectangle', args, kw) File "/usr/lib/python2.2/lib-tk/Tkinter.py", line 1947, in _create (self._w, 'create', itemType) TclError: bad screen distance "141139772callit" ---------------------------------------------------------------------- These all come from "create_rectange", but if I run it some more, other Tk commands will cause similar errors. Like I said, it seems to only happen on the dual-CPU computer, and usually only in code that updates the screen a lot, very quickly. I can't really come up with a simple example easily, because it only happens with multiple threads, fast updates, multiple objects, etc. Is there anyone running Tkinter on dual-CPU computers and have Tkinter work reliably? I really suspect that the Tkinter code may not be thread safe. Anyone have any ideas on fixing or minimizing these errors if that is true? (I realize I could boot without SMP, but I'm looking for a fix that is a little more specific to the problem.) Thanks for any suggestions! -Doug > > If this is a problem, is there a known work-around, or plans to fix it? > > Thanks! > > -Doug > I took a quick look in the Python source, and I couldn't find "attempt > to apply" in any of the .c or .py files. The terms "apply", "int()" and > "None" make this error unlikely to come from the tcl or tk libraries. > > Can you provide more information, such as a complete traceback or tcl > error? Can you find a small program that produces the error and send it > to the list? > > Jeff > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss@python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > From jepler at unpythonic.net Mon May 24 18:30:06 2004 From: jepler at unpythonic.net (Jeff Epler) Date: Mon May 24 18:30:16 2004 Subject: [Tkinter-discuss] Tkinter under SMP In-Reply-To: <40B21F7C.2010109@cs.brynmawr.edu> References: <40B11530.6090702@brynmawr.edu> <20040523213604.GA17178@unpythonic.net> <40B21F7C.2010109@cs.brynmawr.edu> Message-ID: <20040524223006.GA28714@unpythonic.net> I did a little research on this and found http://mail.python.org/pipermail/python-dev/2002-December/031107.html I hope somebody else can expand on this, but (at least historically) Tk and Python threads didn't mix. Maybe this is still true to some degree, and maybe depending on the Python version. RedHat 9 had Python 2.2.2. The change discussed in that message was applied to the 2.3 branch, but doesn't exist in 2.2. Jeff From dblank at cs.brynmawr.edu Tue May 25 03:39:27 2004 From: dblank at cs.brynmawr.edu (Douglas S. Blank) Date: Tue May 25 03:39:40 2004 Subject: [Tkinter-discuss] Tkinter under SMP In-Reply-To: <20040524223006.GA28714@unpythonic.net> References: <40B11530.6090702@brynmawr.edu> <20040523213604.GA17178@unpythonic.net> <40B21F7C.2010109@cs.brynmawr.edu> <20040524223006.GA28714@unpythonic.net> Message-ID: <40B2F82F.8010405@cs.brynmawr.edu> Thanks, Jeff, for your poking around. I have installed python2.3, and found that the problem persists. Here is what I think is causing the problem: I usually create a Tk() object like: self.app = Tkinter.Tk() self.app.withdraw() self.win = Tkinter.Toplevel() And in another thread, I might do the same. This seems to be the problem. If these two toplevels get updated slowly, then I'm fine. If I have them all in one thread, it seems fine too. But if I have two, and they are getting updated fairly quickly (multiple times/second) then it either causes a weird bug, or just seg faults. I suspect that there is something global that both apps (or wins) are sharing. Is there a better way of creating multiple Toplevels? Any suggestions would be appreciated! -Doug Jeff Epler wrote: > I did a little research on this and found > http://mail.python.org/pipermail/python-dev/2002-December/031107.html > > I hope somebody else can expand on this, but (at least historically) Tk > and Python threads didn't mix. Maybe this is still true to some degree, > and maybe depending on the Python version. RedHat 9 had Python 2.2.2. > The change discussed in that message was applied to the 2.3 branch, but > doesn't exist in 2.2. > > Jeff > > From klappnase at web.de Tue May 25 06:36:03 2004 From: klappnase at web.de (Michael Lange) Date: Tue May 25 06:43:52 2004 Subject: [Tkinter-discuss] Removing widgets In-Reply-To: <20040524120220.GA25867@unpythonic.net> References: <40B1BBD5.7050008@catalogix.se> <20040524120220.GA25867@unpythonic.net> Message-ID: <20040525123603.133a8a12.klappnase@web.de> On Mon, 24 May 2004 07:02:21 -0500 Jeff Epler wrote: > You'll need to record the children of 'e' somehow, and destroy them all. > Or, you can destroy 'e' and start over again. Or, use 'grid_slaves' or > 'winfo_children' on 'e' to get a listing of all widgets gridded in 'e', or > all widgets that are direct children of 'e', and destroy each of them in > turn. > Another way might be not to destroy the widgets each time, but to hide them under the others. I did something similar by creating different subclasses of Frame and gridding them all in the same place of the main window and then call tkraise() on the corresponding Frame widget when a new item is selected. Example: from Tkinter import * class Pair(Frame): def __init__(self, master, label='pair', **kw): Frame.__init__(self, master, **kw) self.label = Label(self, text=label) self.label.grid(row=0, column=0) self.entry = Entry(self) self.entry.grid(row=0, column=1) root = Tk() root.grid_rowconfigure(0, weight=1) root.grid_columnconfigure(0, weight=1) pair1 = Pair(root, label='pair1') pair1.grid(row=0, column=0, columnspan=2, sticky='news') pair2 = Pair(root, label='pair2') pair2.grid(row=0, column=0, columnspan=2, sticky='news') b1 = Button(root, text='pair1', command=pair1.tkraise) b1.grid(row=1, column=0) b2 = Button(root, text='pair2', command=pair2.tkraise) b2.grid(row=1, column=1) root.mainloop() Best regards Michael From jepler at unpythonic.net Tue May 25 08:06:10 2004 From: jepler at unpythonic.net (Jeff Epler) Date: Tue May 25 08:06:23 2004 Subject: [Tkinter-discuss] Tkinter under SMP In-Reply-To: <40B2F82F.8010405@cs.brynmawr.edu> References: <40B11530.6090702@brynmawr.edu> <20040523213604.GA17178@unpythonic.net> <40B21F7C.2010109@cs.brynmawr.edu> <20040524223006.GA28714@unpythonic.net> <40B2F82F.8010405@cs.brynmawr.edu> Message-ID: <20040525120609.GA29934@unpythonic.net> I don't see why you don't use the toplevel created by self.app() in the first place, instead of a second toplevel. What you're doing seems pretty alien to the way I've ever used Tk, so it would be no surprise if there were more bugs lurking. I'm not sure what to suggest at this point but finding a small program that exhibits the problem. I can test this program on another SMP machine running RedHat 9, as well as non-smp linux machines running other versions. Jeff From dblank at cs.brynmawr.edu Wed May 26 15:17:23 2004 From: dblank at cs.brynmawr.edu (Douglas S. Blank) Date: Wed May 26 15:17:34 2004 Subject: [Tkinter-discuss] Tkinter under SMP In-Reply-To: <20040525120609.GA29934@unpythonic.net> References: <40B11530.6090702@brynmawr.edu> <20040523213604.GA17178@unpythonic.net> <40B21F7C.2010109@cs.brynmawr.edu> <20040524223006.GA28714@unpythonic.net> <40B2F82F.8010405@cs.brynmawr.edu> <20040525120609.GA29934@unpythonic.net> Message-ID: <40B4ED43.8000805@cs.brynmawr.edu> In trying to find out why I have so many issues under SMP, I wrote: > I usually create a Tk() object like: > > self.app = Tkinter.Tk() > self.app.withdraw() > self.win = Tkinter.Toplevel() > > Is there a better way of creating multiple Toplevels? Jeff Epler wrote: > I don't see why you don't use the toplevel created by self.app() in the > first place, instead of a second toplevel. All of the windows that I create are instances of classes. It seems that if that is true, then there is a "root" window that is created that you can't really use, and so I have been hiding it with "withdraw()". Before, I wasn't sharing a common "root", and so did the above idiom before I create a toplevel each time. I've now moved to making all of my windows extend Toplevel and made sure that I only have one Tk() root object. I haven't been able to make a small example to get the system to crash like my larger production code, but I have attached a sample of the style I am now using. Can anyone suggest a better style? Thanks for assistance, --Doug -------------------------------------------------------------------------- import Tkinter import threading class Runner(threading.Thread): def __init__(self, object): threading.Thread.__init__(self) self.object = object self.done = 0 self.start() def run(self): while not self.done and self.isAlive(): self.object.update() self.object.update_idletasks() class Window(Tkinter.Toplevel): def __init__(self, parent, item): Tkinter.Toplevel.__init__(self, parent, width = 100, height = 100) self.count = 0 self.item = item self.frame = Tkinter.Frame(self) self.canvas = Tkinter.Canvas(self.frame) self.label = Tkinter.Label(self.frame, text = "Window %s" % item) self.label.pack() self.frame.pack() self.canvas.pack() if item < 5: self.other = Runner(Window(parent, item + 1)) def update(self): print "Updating...", self.item if self.count % 2 == 0: tag = "red" other = "blue" else: tag = "blue" other = "red" for i in range(10): for j in range(10): self.canvas.create_rectangle((i*10), (j*10), (i*10)+10, (j*10)+10, fill = tag, tag = tag) self.canvas.delete(other) self.count += 1 if __name__ == "__main__": root = Tkinter.Tk() root.withdraw() test0 = Window(root, 100) test0.update() test1 = Runner(Window(root, 1)) test2 = Runner(Window(root, 20)) test0.mainloop() > What you're doing seems pretty alien to the way I've ever used Tk, so > it would be no surprise if there were more bugs lurking. > > I'm not sure what to suggest at this point but finding a small program > that exhibits the problem. I can test this program on another SMP > machine running RedHat 9, as well as non-smp linux machines running > other versions. > > Jeff > > From billtorvalds1 at yahoo.it Mon May 31 07:27:46 2004 From: billtorvalds1 at yahoo.it (leon) Date: Mon May 31 07:27:20 2004 Subject: [Tkinter-discuss] problem loading images Message-ID: <20040531112746.GB422@lautrec> On a debian unstable with python2.3 and python2.3-imaging-tk 1.1.4-3, python2.3-tk 2.3.4-1 I get this behaviour... >>> from Tkinter import * >>> from PIL import Image, ImageTk >>> img = Image.open('image.gif') >>> root = Tk() >>> button2 = Button(root, image=img) Traceback (most recent call last): File "", line 1, in ? File "/usr/lib/python2.3/lib-tk/Tkinter.py", line 1906, in __init__ Widget.__init__(self, master, 'button', cnf, kw) File "/usr/lib/python2.3/lib-tk/Tkinter.py", line 1835, in __init__ self.tk.call( _tkinter.TclError: image "" doesn't exist >>> img it seems there is an istance, but it can't be seen by tk.call(). ?? quite confused about this. any ideas? leon. -- www.lilik.it/users/leonardo 0C5F B8DE 3136 1506 96D0 1806 7674 D513 A66E 7854 From jepler at unpythonic.net Mon May 31 08:31:44 2004 From: jepler at unpythonic.net (Jeff Epler) Date: Mon May 31 08:31:58 2004 Subject: [Tkinter-discuss] problem loading images In-Reply-To: <20040531112746.GB422@lautrec> References: <20040531112746.GB422@lautrec> Message-ID: <20040531123144.GC16742@unpythonic.net> You need to convert the image file to a PhotoImage using ImageTk.PhotoImage() Something like so: > >>> from Tkinter import * > >>> from PIL import Image, ImageTk > >>> img = Image.open('image.gif') > >>> root = Tk() >>> tkImg = ImageTk.PhotoImage(img) >>> button2 = Button(root, image=tkImg) Jeff -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://mail.python.org/pipermail/tkinter-discuss/attachments/20040531/678328c6/attachment.bin From corrado.clementi at ciaolab.com Mon May 31 10:41:02 2004 From: corrado.clementi at ciaolab.com (corrado clementi) Date: Mon May 31 10:40:12 2004 Subject: [Tkinter-discuss] Switching focus between different application Message-ID: <000001c4471d$4c524420$166310ac@ciaolab.com> Hello I've two python applications running on a Windows system (either Win2000 or WinXp); they both use Tkinter as graphical toolkit. I need to switch the focus between the two, but I'm not able to find a way; I've tried all the focus_force, grab_set, .. but they all seem to work only inside a single application. Is there any way to force the focus to a single application? Or something like the Alt-Tab to move the focus to the desired application? I've tried trapping the WM_TAKE_FOCUS protocol, but it does not seem to be implemented under Windows. I also tried trapping the keyboard event from one application and send it to the other, using then an event_generate, but it looks like without the focus the event is not generated. Any suggestion is welcome. Corrado Clementi From jepler at unpythonic.net Mon May 31 11:47:19 2004 From: jepler at unpythonic.net (Jeff Epler) Date: Mon May 31 11:47:32 2004 Subject: [Tkinter-discuss] Switching focus between different application In-Reply-To: <000001c4471d$4c524420$166310ac@ciaolab.com> References: <000001c4471d$4c524420$166310ac@ciaolab.com> Message-ID: <20040531154719.GD19206@unpythonic.net> On Unix, Tk supports the "send" command to execute some Tcl command in the context of a different application. The send manpage mentions that similar functionality is provided by the "dde" command on Windows. You would send a command like "raise ." to raise the main window of the application receiving the command. Another possibility would be to wrap the win32 "SetWindowPos" API, as well as implementing some way to get the HWND of the window you want to raise. Here is how Tk implements the "raise" command on win32: HWND window = TkWinGetHWND(w) SetWindowPos(window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); This would probably not be a difficult project. You could use "ctypes" to do this on Windows without needing a C compiler. The biggest difficulty is that the TkWinGetHWND API is an internal API that is implemented with a C macro. Jeff -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://mail.python.org/pipermail/tkinter-discuss/attachments/20040531/aed3c2bb/attachment.bin