From klappnase at web.de Thu Feb 1 11:39:41 2007 From: klappnase at web.de (Michael Lange) Date: Thu, 1 Feb 2007 11:39:41 +0100 Subject: [Tkinter-discuss] ImageTk.PhotoImage and semi-transparent images Message-ID: <20070201113941.48803dee.klappnase@web.de> Hello, I noticed that some images do not display correctly when using an ImageTk.PhotoImage . It seems like this only affects images containing semi-transparent pixels (?); I have uploaded an example of what I mean to . Does anyone know if there is anything I missed to avoid this effect? I ask because in my app I currently use Tkimg to display icons and PIL for resizing and I would like to get rid of Tkimg, if possible. Thanks in advance Michael From minadeh at yahoo.ca Thu Feb 15 06:48:53 2007 From: minadeh at yahoo.ca (mina dehghan) Date: Thu, 15 Feb 2007 12:48:53 +0700 (ICT) Subject: [Tkinter-discuss] calling B1-Motion and Leave events symontaneously? Message-ID: <728848.93156.qm@web62302.mail.re1.yahoo.com> Hi, I am trying to implement lasso selection technique to select a set of rectangles on a canvas. When the usr leaves a rectangle while B1 is down the current rectangle is either selected or reselected. So I need to use two events: bound to the canvas and bound to rectangles. But only B1-motion event is called. Does anyone know what the problem is and how to call B1-motion and Leave symontaneously? Thanks, Mina __________________________________________________ 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/20070215/f1cc0fd6/attachment.html From busquets at silver.udg.es Thu Feb 15 16:47:05 2007 From: busquets at silver.udg.es (=?ISO-8859-1?Q?D=EDdac_Busquets?=) Date: Thu, 15 Feb 2007 16:47:05 +0100 Subject: [Tkinter-discuss] Problems with lambda functions in callbacks Message-ID: <45D48079.1050506@eia.udg.es> Hello, I'm trying to create a set of buttons to which I assign a callback that is the same for all of them, except for the parameter (to do this I use a lambda function). I want to get the buttons numbered from 0 to 4, so that when I click on any of them, it prints out its number (that is, button 0 prints 0, button 1 prints 1, etc). The code I wrote is the following: from Tkinter import * root = Tk(); def cb(x): print x; for i in range(5): b = Button(root,text=i,command=lambda:cb(i)); b.pack(); root.mainloop(); This doesn't work, and for any button I click, I only get "4" printed (which is the last value of variable 'i'). Any idea about what is going on? Thanks a lot, D?dac -- ------------------------------------------------------------------------ *D?dac Busquets i Font* Investigador Ram?n y Cajal Universitat de Girona Dept. d'Electr?nica, Inform?tica i Autom?tica Institut d'Inform?tica i Aplicacions Edifici P-IV, Despatx 128 Campus Montilivi 17071 Girona Tel. (+34) 972.41.81.79 Fax. (+34) 972.41.80.98 e-mail: busquets at eia.udg.es web: http://eia.udg.es/~busquets ------------------------------------------------------------------------ Abans d'imprimir aquest correu electr?nic pensa si ?s necessari fer-ho: el medi ambient ?s cosa de tots. ------------------------------------------------------------------------ From stewart at midwinter.ca Thu Feb 15 18:26:20 2007 From: stewart at midwinter.ca (Stewart Midwinter) Date: Thu, 15 Feb 2007 10:26:20 -0700 Subject: [Tkinter-discuss] Problems with lambda functions in callbacks In-Reply-To: <45D48079.1050506@eia.udg.es> References: <45D48079.1050506@eia.udg.es> Message-ID: D?dac, aquest ?s un problem molt interessant. Your code doesn't work because you didn't pass in a reference to i in your lambda. The correct code appears below. BTW, if you set up your application with classes and methods, you will need to pass in a reference to self in the same way: self=self. from Tkinter import * root = Tk(); def cb(x): print x; for i in range(5): b = Button(root,text=i,command=lambda i=i:cb(i)); b.pack(); root.mainloop(); cheers Stewart -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20070215/04841033/attachment.htm From bob at passcal.nmt.edu Thu Feb 15 18:37:56 2007 From: bob at passcal.nmt.edu (Bob Greschke) Date: Thu, 15 Feb 2007 10:37:56 -0700 Subject: [Tkinter-discuss] Problems with lambda functions in callbacks In-Reply-To: <45D48079.1050506@eia.udg.es> References: <45D48079.1050506@eia.udg.es> Message-ID: <01EFF586-A03E-4EEC-ACD2-FA3C008E1723@passcal.nmt.edu> On Feb 15, 2007, at 08:47, D?dac Busquets wrote: > Hello, > > I'm trying to create a set of buttons to which I assign a callback > that > is the same for all of them, except for the parameter (to do this I > use > a lambda function). I want to get the buttons numbered from 0 to 4, so > that when I click on any of them, it prints out its number (that is, > button 0 prints 0, button 1 prints 1, etc). The code I wrote is the > following: > > from Tkinter import * > > root = Tk(); > > def cb(x): > print x; > > for i in range(5): > b = Button(root,text=i,command=lambda:cb(i)); > b.pack(); > > root.mainloop(); > > > This doesn't work, and for any button I click, I only get "4" printed > (which is the last value of variable 'i'). > > Any idea about what is going on? > > Thanks a lot, > > D?dac I've never used a lambda. from Tkinter import * ###################### # BEGIN: class Command # Pass arguments to functions from button presses and menu selections! Nice! # In your declaration: ...command = Command(func, args,...) # Also use in bind() statements # x.bind("", Command(func, args...)) class Command: def __init__(self, func, *args, **kw): self.func = func self.args = args self.kw = kw def __call__(self, *args, **kw): args = self.args+args kw.update(self.kw) apply(self.func, args, kw) # END: class Command root = Tk() def cb(x): print x return for i in range(5): b = Button(root, text=i, command = Command(cb, i)) b.pack() root.mainloop() What were all of the extra semi-colons? Bob From mkieverpy at tlink.de Fri Feb 16 17:37:42 2007 From: mkieverpy at tlink.de (mkieverpy at tlink.de) Date: Fri, 16 Feb 2007 16:37:42 -0000 Subject: [Tkinter-discuss] Problems with lambda functions in callbacks Message-ID: <20070216153813.E7D3CB8D5@mail.terralink.de> Hello D?dac, just to add an explanation, why your code doesn't work: >from Tkinter import * > >root = Tk(); > >def cb(x): > print x; >for i in range(5): > b = Button(root,text=i,command=lambda:cb(i)); The part "lambda:cb(i)" is a function which gets evaluated (called) when a button is clicked. It is evaluated in the scope where it is defined. In this scope (the global scope) the for-loop has finished running long ago. Thus 'i' is always evaluated to '4' regardless which button is pressed because this is the value of 'i' after the end of the loop. Stewart's code: b = Button(root,text=i,command=lambda i=i:cb(i)); This code works because it turns the loop variable 'i' into a default value for the parameter 'i' of the lambda function. And default values are evaluated when the function is defined, i.e. while the loop is running. > b.pack(); > >root.mainloop(); Hope this helps to demystify this behaviour, Matthias Kievernagel (mkiever/at/web/dot/de) From busquets at silver.udg.es Fri Feb 16 18:04:24 2007 From: busquets at silver.udg.es (=?UTF-8?B?RMOtZGFjIEJ1c3F1ZXRz?=) Date: Fri, 16 Feb 2007 18:04:24 +0100 Subject: [Tkinter-discuss] Problems with lambda functions in callbacks In-Reply-To: <20070216153813.E7D3CB8D5@mail.terralink.de> References: <20070216153813.E7D3CB8D5@mail.terralink.de> Message-ID: <45D5E418.7020802@eia.udg.es> Hi, Thank you all for you responses. With Stewart's answer I could get it working. Those were my first lines in python (that is why I had so many semi-colons - I'm so used to C and C++). And also thanks for the explanation. One really needs to know how the programming language works when writing a program. Cheers, D?dac mkieverpy at tlink.de wrote: > Hello D?dac, > > just to add an explanation, why your code doesn't work: > > >from Tkinter import * > >> root = Tk(); >> >> def cb(x): >> print x; >> > > >> for i in range(5): >> b = Button(root,text=i,command=lambda:cb(i)); >> > > The part "lambda:cb(i)" is a function which gets evaluated > (called) when a button is clicked. It is evaluated > in the scope where it is defined. In this scope (the global scope) > the for-loop has finished running long ago. > Thus 'i' is always evaluated to '4' regardless which > button is pressed because this is the value of 'i' > after the end of the loop. > > Stewart's code: > b = Button(root,text=i,command=lambda i=i:cb(i)); > This code works because it turns the loop variable 'i' > into a default value for the parameter 'i' of the lambda function. > And default values are evaluated when the function is defined, > i.e. while the loop is running. > > >> b.pack(); >> >> root.mainloop(); >> > > Hope this helps to demystify this behaviour, > > Matthias Kievernagel > (mkiever/at/web/dot/de) > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > > -- ------------------------------------------------------------------------ *D?dac Busquets i Font* Investigador Ram?n y Cajal Universitat de Girona Dept. d'Electr?nica, Inform?tica i Autom?tica Institut d'Inform?tica i Aplicacions Edifici P-IV, Despatx 128 Campus Montilivi 17071 Girona Tel. (+34) 972.41.81.79 Fax. (+34) 972.41.80.98 e-mail: busquets at eia.udg.es web: http://eia.udg.es/~busquets ------------------------------------------------------------------------ Abans d'imprimir aquest correu electr?nic pensa si ?s necessari fer-ho: el medi ambient ?s cosa de tots. ------------------------------------------------------------------------ From jstradli at nmt.edu Fri Feb 16 17:56:26 2007 From: jstradli at nmt.edu (jstradli at nmt.edu) Date: Fri, 16 Feb 2007 09:56:26 -0700 (MST) Subject: [Tkinter-discuss] Installing Tk.framework to directory other than system directories Message-ID: <52782.129.138.26.20.1171644986.squirrel@webmail.nmt.edu> Hello, Platform: Mac OS X 10.4 I'm trying to install the Tk.framework to a directory other than /Library/Frameworks or /System/Library/Frameworks or ~/Library/Frameworks . I'm wanting to do this so I can create Mac packages with a custom build of Python, Tkinter and some additional modules that can be installed in a completely self contained custom directory. I don't want Tk.framework to be installed to the system directories because it may inadvertently clobber a users Tk.framework ;-). Here is what I have done 1) Built tcl with framework enabled and custom prefix. Then I changed the path the framework was to be installed to in the Makefile (namely /opt//Library/Frameworks) 2) I then repeated the above for tk 3) I configured python with a custom prefix, then I edited setup.py and added to the beginning of the list variable "framework_dirs" the path to my tk and tcl frameworks (/opt//Library/Frameworks) I than ran make and make install After testing this I noticed that it was still linking to the MAC OS default Tk.framework in /System/Library/Frameworks not my newly installed framework? Sorry for the long-windedness I wanted to make it clear what I have done and my end goal. Regards, Joe From sxn02 at yahoo.com Tue Feb 20 00:23:29 2007 From: sxn02 at yahoo.com (Sorin Schwimmer) Date: Mon, 19 Feb 2007 15:23:29 -0800 (PST) Subject: [Tkinter-discuss] Who maintains the Wiki? Message-ID: <832310.68454.qm@web56011.mail.re3.yahoo.com> Hi All, I just noticed at the bottom of http://tkinter.unpythonic.net/wiki/FrontPage a collection of links that don't belong there. Now, I know that there are porn-loving people, but I'm one who thinks that it doesn't belong to this wiki. Does anybody know how to contact the person(s) who maintain this wiki? Thanks, Sorin ____________________________________________________________________________________ Don't pick lemons. See all the new 2007 cars at Yahoo! Autos. http://autos.yahoo.com/new_cars.html From Vasilis.Vlachoudis at cern.ch Tue Feb 20 12:04:17 2007 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Tue, 20 Feb 2007 12:04:17 +0100 Subject: [Tkinter-discuss] Multipage Postscript printing from canvas Message-ID: <2AACD4EB2F123248A064A23843B3A173020C21@cernxchg47.cern.ch> Hi all, In my application I am creating an editor using a scrollable canvas as the main widget. I want to provide a print option for the canvas, creating a multi-page A4/letter format postscript. I made the following method to split the content of the canvas into many postscript files, which will be later send to the printer or joined together to a single file, but I have many problems. 1. How do I create an A4 or letter format page? 2. What is the conversion between pixels in the Canvas and points in the postscript? 3. What is the best way to split the pages? 4. How do I merge everything into a multi-page postscript? class InputCanvas(Canvas): ... def printer(self,filename): bbox = map(int,self.canvas.cget("scrollregion").split()) if bbox is None: return (x,y,w,h) = bbox height = 1000 # For the moment arbitrarily chosen! for y in range(0,h,height): self.canvas.postscript( file=filename+str(y), colormode="color", y=y) #pageheight=12*96) Vasilis -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20070220/c1a87454/attachment.htm From mkieverpy at tlink.de Tue Feb 20 15:05:15 2007 From: mkieverpy at tlink.de (mkieverpy at tlink.de) Date: Tue, 20 Feb 2007 14:05:15 -0000 Subject: [Tkinter-discuss] Multipage Postscript printing from canvas Message-ID: <20070220130500.0EDFFB825@mail.terralink.de> Hello Vasilis, the options to the postscript function are quite extensively explained in the tk canvas man-page (man n canvas). (Beware! I never used this :-) What I have seen from a cursory glance: Use pagewidth or pageheight options for scaling to A4/Letter size Use x, y, height and width options to select a part of the canvas Remember also: there is no size information in canvas coordinates. Scaling of the output is completely up to you. (A4 is 20.99 x 29.70 (says gimp); so for the upper left part of the canvas you might use: c.postscript(... pageheight="29.70c",x="0",y="0",height="297",width="209.9") As I have said, I never used this, this is just what the man-page says (just tried the line above). It says also, that it generates encapsulated postscript, so (with postscript hacking know-how) you could embed all generated parts into a single postscript template file which just references the parts. You might even do this in python, if you don't use the file option. Greetings, Matthias Kievernagel (mkiever/at/web/dot/de) From gerardo at computo-industrial.com.mx Tue Feb 20 17:41:38 2007 From: gerardo at computo-industrial.com.mx (Gerardo Juarez) Date: Tue, 20 Feb 2007 11:41:38 -0500 (EST) Subject: [Tkinter-discuss] Error in TopLevel Window In-Reply-To: <20070220130500.0EDFFB825@mail.terralink.de> Message-ID: Hi, I am having a problem with one application that is proving very difficult to pinpoint. The application downloads its own upgrades from a server and notifies the user that this has been so with a Toplevel window, suggesting to restart the application whenever possible to make changes effective. Everything seems to be normal on Linux, but on Windows 9x, the very first time after a reboot that this upgrade takes place, it is done successfully, but the toplevel window opens blank with a large number as its title (like "1127987922") -which has nothing to do with the title I am using for it- and the application freezes. After killing and restarting it, any further upgrades are uneventful, including the toplevel window message. The problem occurs irrespective of what other applications are running. I have received no reports of this problem on WinXP. Do you know of any conditions under which something like could happen? Have you seen this behaviour before? Any guesses or speculations will be greatly appreciated... Gerardo Juarez From jepler at unpythonic.net Tue Feb 20 18:16:04 2007 From: jepler at unpythonic.net (Jeff Epler) Date: Tue, 20 Feb 2007 11:16:04 -0600 Subject: [Tkinter-discuss] Who maintains the Wiki? In-Reply-To: <832310.68454.qm@web56011.mail.re3.yahoo.com> References: <832310.68454.qm@web56011.mail.re3.yahoo.com> Message-ID: <20070220171602.GA25527@unpythonic.net> I am responsible for the machine where the wiki resides, but it's everyone's job to fix vandalism. Don't complain, but log in and revert the page. Jeff From mannslists at invigorated.org Tue Feb 20 19:08:17 2007 From: mannslists at invigorated.org (Mannequin*) Date: Tue, 20 Feb 2007 18:08:17 +0000 Subject: [Tkinter-discuss] Who maintains the Wiki? In-Reply-To: <832310.68454.qm@web56011.mail.re3.yahoo.com> References: <832310.68454.qm@web56011.mail.re3.yahoo.com> Message-ID: <45DB3911.9030106@invigorated.org> I accidentally sent this directly to Sorin... :P Sorin Schwimmer wrote: > Hi All, > > I just noticed at the bottom of > http://tkinter.unpythonic.net/wiki/FrontPage > a collection of links that don't belong there. > > Now, I know that there are porn-loving people, but I'm > one who thinks that it doesn't belong to this wiki. > > Does anybody know how to contact the person(s) who > maintain this wiki? I'm not a maintainer, but I'm in the process of removing the SPAM. The SPAMmer also hit the "WikiCourse/BasicIntroduction/091 Tips on the Editor", "PythonLanguage", and "WikiWikiWebb". -M. From rowen at cesmail.net Tue Feb 20 20:36:27 2007 From: rowen at cesmail.net (Russell E. Owen) Date: Tue, 20 Feb 2007 11:36:27 -0800 Subject: [Tkinter-discuss] Installing Tk.framework to directory other than system directories References: <52782.129.138.26.20.1171644986.squirrel@webmail.nmt.edu> Message-ID: In article <52782.129.138.26.20.1171644986.squirrel at webmail.nmt.edu>, jstradli at nmt.edu wrote: > Hello, > > Platform: Mac OS X 10.4 > > I'm trying to install the Tk.framework to a directory other than > /Library/Frameworks or /System/Library/Frameworks or ~/Library/Frameworks > . I'm wanting to do this so I can create Mac packages with a custom build > of Python, Tkinter and some additional modules that can be installed in a > completely self contained custom directory. I don't want Tk.framework to > be installed to the system directories because it may inadvertently > clobber a users Tk.framework ;-). > > Here is what I have done > 1) Built tcl with framework enabled and custom prefix. > Then I changed the path the framework was to be > installed to in the Makefile > (namely /opt//Library/Frameworks) > > 2) I then repeated the above for tk > > 3) I configured python with a custom prefix, > then I edited setup.py and added to the > beginning of the list variable "framework_dirs" > the path to my tk and tcl frameworks > (/opt//Library/Frameworks) > I than ran make and make install > > After testing this I noticed that it was still linking to the > MAC OS default Tk.framework in /System/Library/Frameworks not > my newly installed framework? > > Sorry for the long-windedness I wanted to make it clear what > I have done and my end goal. Could you just use py2app to package your application? It handles all this for you. Your own special Python, Tcl and Tk will be included in the resulting application (making it rather large) and the user's own Python, Tcl and Tk will be ignored -- but just for that one application. -- Russell