From charras at me.com Thu Apr 1 08:02:36 2010 From: charras at me.com (Guido Carballo-Guerrero) Date: Thu, 01 Apr 2010 00:02:36 -0600 Subject: [Tkinter-discuss] Labels not updating its display data Message-ID: <2388F642-3C3D-40D8-9B48-4E203E515FAF@me.com> Is it possible to display and update data using labels in a window, created by another window? This is a program I did that is not working as expected: -------------- next part -------------- A non-text attachment was scrubbed... Name: pro_9.py Type: text/x-python-script Size: 1040 bytes Desc: not available URL: -------------- next part -------------- I'm creating a second window inside of a function call newcount. This other window even have separate variables, but if I use the label type of display, that data is not show, and even less chage its value. Can somebody tell me if it's possible to do what I'm trying? How can I display a value inside of a label, and have that display update its values, when this is trying to be done in a second window. Guido From klappnase at web.de Thu Apr 1 12:27:12 2010 From: klappnase at web.de (Michael Lange) Date: Thu, 1 Apr 2010 12:27:12 +0200 Subject: [Tkinter-discuss] Labels not updating its display data In-Reply-To: <2388F642-3C3D-40D8-9B48-4E203E515FAF@me.com> References: <2388F642-3C3D-40D8-9B48-4E203E515FAF@me.com> Message-ID: <20100401122712.60670f79.klappnase@web.de> Hi Guido, On Thu, 01 Apr 2010 00:02:36 -0600 Guido Carballo-Guerrero wrote: > Is it possible to display and update data using labels in a window, > created by another window? > > This is a program I did that is not working as expected: > > (...) > def newcount(): > > root2 = Tkt.Tk() > var2 = Tkt.IntVar() > frameLabels2 = Tkt.Frame(root2) > frameLabels2.pack() > > def changeVal(): > > var2.set(var2.get()+1) > print 'var2: ',var2.get() > > > Tkt.Label(frameLabels2,text='var2: ').pack(side=Tkt.LEFT) > Tkt.Label(frameLabels2,textvariable=var1).pack(side=Tkt.LEFT) > > Tkt.Button(root2,text="Change value", command=changeVal).pack() > root2.mainloop() There are two problems in this function, first you should _never_ use two instances of Tk() in one program; if you need a second window, use a Tkinter.Toplevel() instead. Second, you assign var1 as textvariable for the Label; I think what you actually intended is to set the current value of var1 as initial value for var2 and then use var2 as textvariable for the label ? If yes, simply change the first lines of newcount() into: def newcount(): root2 = Tkt.Toplevel() var2 = Tkt.IntVar() var2.set(var1.get()) I hope this helps Michael From joebarfett at yahoo.ca Fri Apr 2 15:43:02 2010 From: joebarfett at yahoo.ca (Joe Barfett) Date: Fri, 2 Apr 2010 06:43:02 -0700 (PDT) Subject: [Tkinter-discuss] macPython, menubar won't display, new windows will not display widgets In-Reply-To: Message-ID: <166250.77102.qm@web59408.mail.ac4.yahoo.com> Thank you for your response!?Below is some code that works for me in Python 2.5.2 on Windows XP but will not work in Python 2.5.2 on Mac OSX 10.4 or 10.5.?On the mac, I get a window appearing, but no menu bar. Given that it works on a PC, I'm thinking I need a different Python distro for my macs.?Thanks very very much! from Tkinter import *root = Tk() def hello():?? ?print "hello!" # create a toplevel menumenubar = Menu(root)menubar.add_command(label="Hello!", command=hello)menubar.add_command(label="Quit!", command=root.quit) # display the menuroot.config(menu=menubar)mainloop() --- On Mon, 3/29/10, tkinter-discuss-request at python.org wrote: From: tkinter-discuss-request at python.org Subject: Tkinter-discuss Digest, Vol 73, Issue 5 To: tkinter-discuss at python.org Received: Monday, March 29, 2010, 6:00 AM 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. macPython, menubar won't display,??? new windows will not ? ? ? display widgets (Joe Barfett) ???2. Re: macPython, menubar won't display, new windows will not ? ? ? display widgets (Kevin Walzer) ---------------------------------------------------------------------- Message: 1 Date: Sun, 28 Mar 2010 09:55:29 -0700 (PDT) From: Joe Barfett To: tkinter-discuss at python.org Subject: [Tkinter-discuss] macPython, menubar won't display,??? new ??? windows will not display widgets Message-ID: <470422.35265.qm at web59402.mail.ac4.yahoo.com> Content-Type: text/plain; charset="iso-8859-1" Hello, I've had problems getting menus to appear in my Tkinter applications using python 2.5.2 and Mac OSX tiger and leopard. I've extensively searched for help and found only this link: http://www.learningpython.com/2006/03/27/using-menus-in-tkinter/ someone else has had the same problem but no solution is posted. Additionally, I find that if I make a new window with toplevel, widgets on the window will not display immediately, but will after the window is refreshed. With Tile so easily available, I really don't want to invest in learning another GUI toolkit for python. Tkinter solves all my needs (I'm a scientific programmer) and really I just want to make a more friendly and user oriented scientific application. Thanks if you can help! I can post source code if needed, but I'm hoping someone has just heard of the problem before and can point me in the right direction. Cheers from Canada! joe ? ? ? ? __________________________________________________________________ Looking for the perfect gift? Give the gift of Flickr! http://www.flickr.com/gift/ -------------- next part -------------- An HTML attachment was scrubbed... URL: ------------------------------ Message: 2 Date: Sun, 28 Mar 2010 13:28:21 -0400 From: Kevin Walzer To: tkinter-discuss at python.org Subject: Re: [Tkinter-discuss] macPython, menubar won't display, new ??? windows will not display widgets Message-ID: <4BAF91B5.5000301 at codebykevin.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed On 3/28/10 12:55 PM, Joe Barfett wrote: > Thanks if you can help! I can post source code if needed, but I'm hoping > someone has just heard of the problem before and can point me in the > right direction. Cheers from Canada! > There are no systematic issues with Tkinter on OS X that I'm aware of: if a menu isn't displaying there's probably an issue with your code. Please post a code sample to help us reproduce the problem. --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com ------------------------------ _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss at python.org http://mail.python.org/mailman/listinfo/tkinter-discuss End of Tkinter-discuss Digest, Vol 73, Issue 5 ********************************************** __________________________________________________________________ Looking for the perfect gift? Give the gift of Flickr! http://www.flickr.com/gift/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From charras at me.com Fri Apr 2 20:32:03 2010 From: charras at me.com (Guido Carballo-Guerrero) Date: Fri, 02 Apr 2010 12:32:03 -0600 Subject: [Tkinter-discuss] Tkinter-discuss Digest, Vol 74, Issue 2 In-Reply-To: References: Message-ID: Michael; Thank you very much. I'm kinda new to Python and Tkinter, and didn't know anything about Toplevel, that was exactly what I need. But tell me, why I can't use two instances of Tk? The way I saw this, was that I was just creating a new object, so I don't understand what is the problem in creating a second object of Tk. I know it doesn't work, but I will like to understand why. If you don't know the answer, don't mind. Thank you very much anyway. You really help me on this one. Charras On Apr 2, 2010, at 4:00 AM, 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. Re: Labels not updating its display data (Michael Lange) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Thu, 1 Apr 2010 12:27:12 +0200 > From: Michael Lange > To: tkinter-discuss at python.org > Subject: Re: [Tkinter-discuss] Labels not updating its display data > Message-ID: <20100401122712.60670f79.klappnase at web.de> > Content-Type: text/plain; charset=US-ASCII > > Hi Guido, > > On Thu, 01 Apr 2010 00:02:36 -0600 > Guido Carballo-Guerrero wrote: > >> Is it possible to display and update data using labels in a window, >> created by another window? >> >> This is a program I did that is not working as expected: >> >> > (...) >> def newcount(): >> >> root2 = Tkt.Tk() >> var2 = Tkt.IntVar() >> frameLabels2 = Tkt.Frame(root2) >> frameLabels2.pack() >> >> def changeVal(): >> >> var2.set(var2.get()+1) >> print 'var2: ',var2.get() >> >> >> Tkt.Label(frameLabels2,text='var2: ').pack(side=Tkt.LEFT) >> Tkt.Label(frameLabels2,textvariable=var1).pack(side=Tkt.LEFT) >> >> Tkt.Button(root2,text="Change value", command=changeVal).pack() >> root2.mainloop() > > There are two problems in this function, first you should _never_ use > two instances of Tk() in one program; if you need a second window, use > a Tkinter.Toplevel() instead. > Second, you assign var1 as textvariable for the Label; I think what you > actually intended is to set the current value of var1 as initial value > for var2 and then use var2 as textvariable for the label ? If yes, > simply change the first lines of newcount() into: > > def newcount(): > > root2 = Tkt.Toplevel() > var2 = Tkt.IntVar() > var2.set(var1.get()) > > I hope this helps > > Michael > > > > > > > ------------------------------ > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > > End of Tkinter-discuss Digest, Vol 74, Issue 2 > ********************************************** From klappnase at web.de Fri Apr 2 21:02:15 2010 From: klappnase at web.de (Michael Lange) Date: Fri, 2 Apr 2010 21:02:15 +0200 Subject: [Tkinter-discuss] Tkinter-discuss Digest, Vol 74, Issue 2 In-Reply-To: References: Message-ID: <20100402210215.38b2ffff.klappnase@web.de> Hi Guido, On Fri, 02 Apr 2010 12:32:03 -0600 Guido Carballo-Guerrero wrote: > Michael; > > Thank you very much. I'm kinda new to Python and Tkinter, and didn't > know anything about Toplevel, that was exactly what I need. > > But tell me, why I can't use two instances of Tk? The way I saw this, > was that I was just creating a new object, so I don't understand what > is the problem in creating a second object of Tk. I know it doesn't > work, but I will like to understand why. > I will try to explain, though I am not a no.1 expert :) The Tk() window is not just a widget, like a Button or a Toplevel, but has its own associated Tcl interpreter which is controlled through Python; so if you have two Tk instances in your application, you have two different Tcl interpreters running. As you noticed in your first code example, this did work, but not exactly as you expected. The reason is that the two Tcl interpreters cause some unwanted side effects, because they can coexist, but not interact; for example, (IIRC) you created two IntVars, but IntVar2 inside the second Tcl interpreter, which will not work when trying to use it as textvariable for a Label belonging to Tcl interpreter #1 ; if the application becomes more complex, it will obviously become hard to avoid running into traps like this, when OTOH there is not really a benefit from the second Tk() window. I hope this helps Michael From Cameron at phaseit.net Fri Apr 2 21:20:39 2010 From: Cameron at phaseit.net (Cameron Laird) Date: Fri, 2 Apr 2010 19:20:39 +0000 Subject: [Tkinter-discuss] Tkinter-discuss Digest, Vol 74, Issue 2 In-Reply-To: <20100402210215.38b2ffff.klappnase@web.de> References: <20100402210215.38b2ffff.klappnase@web.de> Message-ID: <20100402192039.GA22021@lairds.us> On Fri, Apr 02, 2010 at 09:02:15PM +0200, Michael Lange wrote: . . . > > But tell me, why I can't use two instances of Tk? The way I saw this, > > was that I was just creating a new object, so I don't understand what > > is the problem in creating a second object of Tk. I know it doesn't > > work, but I will like to understand why. > > > > I will try to explain, though I am not a no.1 expert :) > > The Tk() window is not just a widget, like a Button or a Toplevel, but > has its own associated Tcl interpreter which is controlled through > Python; so if you have two Tk instances in your application, you have > two different Tcl interpreters running. > As you noticed in your first code example, this did work, but not > exactly as you expected. The reason is that the two Tcl interpreters > cause some unwanted side effects, because they can coexist, but not > interact; for example, (IIRC) you created two IntVars, but IntVar2 > inside the second Tcl interpreter, which will not work when trying to > use it as textvariable for a Label belonging to Tcl interpreter #1 ; if > the application becomes more complex, it will obviously become hard to > avoid running into traps like this, when OTOH there is not really a > benefit from the second Tk() window. > > I hope this helps . . . Worse, each Tk() instance opens a "graphical context", and *their* behavior isn't well-defined beyond one-per-process. From teh_sh_meister at yahoo.com Tue Apr 6 23:03:39 2010 From: teh_sh_meister at yahoo.com (Nemes Andrei) Date: Tue, 6 Apr 2010 14:03:39 -0700 (PDT) Subject: [Tkinter-discuss] background threading Message-ID: <739697.10029.qm@web59906.mail.ac4.yahoo.com> Hi everyone! I am trying to make an application in Tkinter that goes to Tray instead of closing. I have programmed the whole interface, including notifications in Tkinter. The problem is, I could not find any library to make the tray icon itself, so I built a tray icon class using wxPython that runs on a separate thread. So basically now, I'm withdrawing the main Tk window, and then showing the tray icon. The core problem, however, is that while the system tray icon (aka wx main loop) is active, the main program built in Tk completely freezes, including it's notifications. So, my question is, how to make the tray icon thread run in the background, and still have my main program functional? class trayIcon(object): def __init__(self): #setup app self.app=wx.PySimpleApp() #setup icon object self.actualIcon = wx.Icon(icon, wx.BITMAP_TYPE_ICO) #setup taskbar icon self.tbicon = wx.TaskBarIcon() self.tbicon.SetIcon(self.actualIcon, name) #add taskbar icon event wx.EVT_TASKBAR_RIGHT_UP(self.tbicon, self.right) wx.EVT_TASKBAR_LEFT_DCLICK(self.tbicon, self.left) self.app.MainLoop() def right(self,event): global shouldQuit self.app.ExitMainLoop() shouldQuit=True def left(self,event): self.app.ExitMainLoop() class Thread(threading.Thread): def __init__(self, main): threading.Thread.__init__(self) self.setName("wx") self.main=main def run(self): self.Icon=trayIcon() and here is how I defined it in the main program (must state that this is a class method itself): def toTray(self): global shouldQuit self.main.withdraw() self.myTray=Thread(self.Main) self.myTray.start() while self.myTray.isAlive(): pass if shouldQuit: self.Quit() else: self.main.deiconify() I'm calling the isAlive() method to wait for the wx loop to be ended through it's controls, and then show the main window again; I know this holds up the function in place, but that should not hold the entire program should it? I must state that using wx to do the entire interface would not be a choice, as I find it a lot harder to use than Tk. Another solution to the problem would be pointing me to a more convenient tray icon constructor (instructions how to use would be greatly appreciated) if you know any. I hope someone can help me. Thank you for your time and support. Regards, Andrei Nemes -------------- next part -------------- An HTML attachment was scrubbed... URL: From kw at codebykevin.com Wed Apr 7 00:37:42 2010 From: kw at codebykevin.com (Kevin Walzer) Date: Tue, 06 Apr 2010 18:37:42 -0400 Subject: [Tkinter-discuss] background threading In-Reply-To: <739697.10029.qm@web59906.mail.ac4.yahoo.com> References: <739697.10029.qm@web59906.mail.ac4.yahoo.com> Message-ID: <4BBBB7B6.9070601@codebykevin.com> On 4/6/10 5:03 PM, Nemes Andrei wrote: > > Another solution to the problem would be pointing me to a more > convenient tray icon constructor (instructions how to use would be > greatly appreciated) if you know any. > > I hope someone can help me. Thank you for your time and support. This seems a rather convoluted way to do things. There are various Tk extensions that provide system tray functionality and it should be fairly simple to write a Python wrapper for them. If you're on Windows, look at winico: http://wiki.tcl.tk/4089 If you're on *Nix, look at tktray: http://wiki.tcl.tk/5972 or freedock: http://wiki.tcl.tk/4090 --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From klappnase at web.de Wed Apr 7 11:04:21 2010 From: klappnase at web.de (Michael Lange) Date: Wed, 7 Apr 2010 11:04:21 +0200 Subject: [Tkinter-discuss] background threading In-Reply-To: <4BBBB7B6.9070601@codebykevin.com> References: <739697.10029.qm@web59906.mail.ac4.yahoo.com> <4BBBB7B6.9070601@codebykevin.com> Message-ID: <20100407110421.a0ae693f.klappnase@web.de> Hi, On Tue, 06 Apr 2010 18:37:42 -0400 Kevin Walzer wrote: > On 4/6/10 5:03 PM, Nemes Andrei wrote: > > > > > Another solution to the problem would be pointing me to a more > > convenient tray icon constructor (instructions how to use would be > > greatly appreciated) if you know any. > > > > I hope someone can help me. Thank you for your time and support. > > This seems a rather convoluted way to do things. There are various Tk > extensions that provide system tray functionality and it should be > fairly simple to write a Python wrapper for them. > > If you're on Windows, look at winico: > > http://wiki.tcl.tk/4089 > > If you're on *Nix, look at tktray: > > http://wiki.tcl.tk/5972 > > or freedock: > > http://wiki.tcl.tk/4090 > > --Kevin > If you want to use tktray, I already wrote a wrapper for it; to create a tray icon, you can do something like: root = Tk() root.withdraw() img = PhotoImage(file='image.gif') icon = TkTray.Icon(root) icon.configure(image=img) icon.menu.add_command(label='Quit', command=root.quit) HTH Michael ######## file TkTray.py ##################################### import Tkinter class Icon(Tkinter.BaseWidget, Tkinter.Wm): def __init__(self, master=None, cnf={}, **kw): if not master: if Tkinter._support_default_root: if not Tkinter._default_root: Tkinter._default_root = Tkinter.Tk() master = Tkinter._default_root self.TktrayVersion = master.tk.call('package', 'require', 'tktray') # stolen from Tkinter.Toplevel if kw: cnf = Tkinter._cnfmerge((cnf, kw)) extra = () for wmkey in ['screen', 'class_', 'class', 'visible', 'colormap']: if cnf.has_key(wmkey): val = cnf[wmkey] # TBD: a hack needed because some keys # are not valid as keyword arguments if wmkey[-1] == '_': opt = '-'+wmkey[:-1] else: opt = '-'+wmkey extra = extra + (opt, val) del cnf[wmkey] Tkinter.BaseWidget.__init__(self, master, 'tktray::icon', cnf, {}, extra) self.protocol("WM_DELETE_WINDOW", self.destroy) self.menu = Tkinter.Menu(self, tearoff=0) self.bind('<3>', self._popupmenu) def bbox(self): return self._getints(self.tk.call(self._w, 'bbox')) or None def _popupmenu(self, event): w, h = self.menu.winfo_reqwidth(), self.menu.winfo_reqheight() x0, y0, x1, y1 = self.bbox() # get the coords for the popup menu; we want it to the mouse pointer's # left and above the pointer in case the taskbar is on the bottom of the # screen, else below the pointer; add 1 pixel towards the pointer in each # dimension, so the pointer is '*inside* the menu when the button is being # released, so the menu will not unpost on the initial button-release event if y0 > self.winfo_screenheight() / 2: # assume the panel is at the bottom of the screen x, y = event.x_root - w + 1, event.y_root - h + 1 else: x, y = event.x_root - w + 1, event.y_root - 1 # make sure that x is not outside the screen if x < 5: x = 5 self.menu.tk_popup(x, y) ################################################################# From klappnase at web.de Tue Apr 13 23:13:19 2010 From: klappnase at web.de (Michael Lange) Date: Tue, 13 Apr 2010 23:13:19 +0200 Subject: [Tkinter-discuss] background threading In-Reply-To: <843371.22436.qm@web59905.mail.ac4.yahoo.com> References: <739697.10029.qm@web59906.mail.ac4.yahoo.com> <4BBBB7B6.9070601@codebykevin.com> <20100407110421.a0ae693f.klappnase@web.de> <843371.22436.qm@web59905.mail.ac4.yahoo.com> Message-ID: <20100413231319.9991025b.klappnase@web.de> Hi, On Wed, 7 Apr 2010 08:00:38 -0700 (PDT) Nemes Andrei wrote: > I'm sorry for being such a beginner in this, but could not find where > to download the winico. Is it included in Tk already? I think you will have to download winico-0.6.zip from http://sourceforge.net/projects/tktable/files/ and copy the winico-0.6 folder into your Python's Tcl folder so that Tk can find it. Unfortunately there does not seem to be a Tkinter wrapper available, so you will have to write it yourself :( >From a quick glance at the winico manpage a quick'n'dirty wrapper could look like this (untested!): ############# file Winico.py ############################## import Tkinter class Winico: def __init__(self, filename): master = Tkinter._default_root if not master: raise RuntimeError, 'Too early to create icon' self.WinicoVersion = master.tk.call('package', 'require', 'winico') self.tk = master.tk def createfrom(self, filename): return self.tk.call('winico', 'createfrom', filename) def delete(self, id_): self.tk.call('winico', 'delete', id_) def load(self, resourcename, filename=None): return self.tk.call('winico', 'load', resourcename, filename) def info(self, id_=None): # the output should of course be formatted somehow return self.tk.call('winico', 'info', id_) def setwindow(self, size='big', pos=None): return self.tk.call('winico', 'setwindow', size, pos) def taskbar_add(self, id_, callback=None, pos=None, text=None): args = () if callback: args += ('-callback', callback) if pos: args += ('-pos', pos) if text: args += ('-text', text) return self.tk.call('winico', 'taskbar', 'add', id_, *args) def taskbar_modify(self, id_, callback=None, pos=None, text=None): args = () if callback: args += ('-callback', callback) if pos: args += ('-pos', pos) if text: args += ('-text', text) return self.tk.call('winico', 'taskbar', 'modify', id_, *args) def taskbar_delete(self, id_): return self.tk.call('winico', 'taskbar', 'delete', id_) ######################################################### If you compare this with the winico man page from http://tktable.sourceforge.net/winico/winico.html you will probably see the point how this is supposed to work. Another problem is how to write the callback function for mouse clicks onto the icon. I guess you will have to add the percent substitutions and register the callback manually, like: import Tkinter, Winico root = Tkinter.Tk() def your_callback(icon_id, message_specifier): if message_specifier == "WM_LBUTTONDBLCLK": (... do something with icon_id...) elif message_specifier == "WM_RBUTTONDOWN": (... do something else with icon_id...) # register the callback for Tk: cmd = (root.register(your_callback), '%i', '%m') # create an icon icon = Winico.Winico() icon_id = icon.createfrom("some.ico") icon.taskbar_add(icon_id, callback=cmd, text="Your text here") I think you see the point, how the percent substitutions are passed to the callback. I hope this helps Michael PS: I forwarded this to the list, maybe it is interesting for other people, too, I hope that's ok. From gq.ciba at gmail.com Sat Apr 17 06:37:38 2010 From: gq.ciba at gmail.com (=?GB2312?B?uajHvw==?=) Date: Sat, 17 Apr 2010 12:37:38 +0800 Subject: [Tkinter-discuss] Embedding Inline GIFs Message-ID: Hi, when I make toolbar in my program, I wrote the following code according with the Python Cookbook,9.6 Embedding Inline GIFs Using Tkinter. #!/usr/bin/env python import base64 import Image import Tkinter str = "icon='''\n" + base64.encodestring(open("D:\My Documents\My Pictures\objects_020.gif").read( )) + "'''" print str exec(str) root = Tkinter.Tk( ) iconImage = Tkinter.PhotoImage(master=root, format="gif", data=icon) Tkinter.Button(image=iconImage).pack( ) root.mainloop() I found some gif image would run well with this above codes, but the others show the following information. Traceback (most recent call last): File "gif.py", line 11, in iconImage = Tkinter.PhotoImage(master=root, format="gif", data=icon) File "C:\Python26\lib\lib-tk\Tkinter.py", line 3285, in __init__ Image.__init__(self, 'photo', name, cnf, master, **kw) File "C:\Python26\lib\lib-tk\Tkinter.py", line 3241, in __init__ self.tk.call(('image', 'create', imgtype, name,) + options) _tkinter.TclError: error reading color map what am I doing wrong? Your help will be greatly appreciated, Gong. -------------- next part -------------- An HTML attachment was scrubbed... URL: From igor.e.novikov at gmail.com Sat Apr 17 12:04:48 2010 From: igor.e.novikov at gmail.com (Igor Novikov) Date: Sat, 17 Apr 2010 13:04:48 +0300 Subject: [Tkinter-discuss] Embedding Inline GIFs In-Reply-To: References: Message-ID: Hi, It seems your GIF file contains features which are not supported by regular Tcl/Tk GIF loader. I would recommend you to try using PIL (Python Image Library) for image uploading. Also please note that latest PIL 1.1.7 allows using PNG images with alpha channel. I think PNG icons are better then GIF due to full range alpha channel. Regards, Igor Novikov sK1 Project http://sk1project.org On Sat, Apr 17, 2010 at 7:37 AM, ?? wrote: > Hi, > > when I make toolbar in my program, I wrote the following code according > with the Python Cookbook,9.6 Embedding Inline GIFs Using Tkinter. > > #!/usr/bin/env python > import base64 > import Image > import Tkinter > str = "icon='''\n" + base64.encodestring(open("D:\My Documents\My > Pictures\objects_020.gif").read( )) + "'''" > print str > exec(str) > root = Tkinter.Tk( ) > iconImage = Tkinter.PhotoImage(master=root, format="gif", data=icon) > Tkinter.Button(image=iconImage).pack( ) > root.mainloop() > > I found some gif image would run well with this above codes, but the > others show the following information. > > Traceback (most recent call last): > File "gif.py", line 11, in > iconImage = Tkinter.PhotoImage(master=root, format="gif", data=icon) > File "C:\Python26\lib\lib-tk\Tkinter.py", line 3285, in __init__ > Image.__init__(self, 'photo', name, cnf, master, **kw) > File "C:\Python26\lib\lib-tk\Tkinter.py", line 3241, in __init__ > self.tk.call(('image', 'create', imgtype, name,) + options) > _tkinter.TclError: error reading color map > > what am I doing wrong? > Your help will be greatly appreciated, > Gong. > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From flahertyk1 at hotmail.com Mon Apr 19 05:25:13 2010 From: flahertyk1 at hotmail.com (kimmyaf) Date: Sun, 18 Apr 2010 20:25:13 -0700 (PDT) Subject: [Tkinter-discuss] Combobox - global var not found Message-ID: <28286729.post@talk.nabble.com> I am experimenting with TKinter for the first time for my programming course. Trying to get a combobox working. At this point I'm not trying to write elegant code, but at least get it to work for now. I keep getting the error below. Shouldnt It recognize the Combobox widget from the import? "NameError: global name 'Combobox' is not defined" I'm sure there is something really obvious going on but I've been starting at it forever and not finding it. I've been using this as reference. http://www.tkdocs.com/tutorial/widgets.html http://www.tkdocs.com/tutorial/widgets.html I have the import line from TKinter import * #Combo box combovar = StringVar() self.combo = Combobox(self.frame, textvariable=combovar) self.combo['values'] = get_available_routes() self.combo.var = combovar self.combo.bind('<>', self.get_locations) self.combo.grid(row=0, column=2) -- View this message in context: http://old.nabble.com/Combobox----global-var-not-found-tp28286729p28286729.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From waynejwerner at gmail.com Mon Apr 19 17:01:43 2010 From: waynejwerner at gmail.com (Wayne Werner) Date: Mon, 19 Apr 2010 10:01:43 -0500 Subject: [Tkinter-discuss] Combobox - global var not found In-Reply-To: <28286729.post@talk.nabble.com> References: <28286729.post@talk.nabble.com> Message-ID: On Sun, Apr 18, 2010 at 10:25 PM, kimmyaf wrote: > > I am experimenting with TKinter for the first time for my programming > course. > Trying to get a combobox working. At this point I'm not trying to write > elegant code, but at least get it to work for now. > > I keep getting the error below. Shouldnt It recognize the Combobox widget > from the import? > > "NameError: global name 'Combobox' is not defined" > > I'm sure there is something really obvious going on but I've been starting > at it forever and not finding it. I've been using this as reference. > > http://www.tkdocs.com/tutorial/widgets.html > http://www.tkdocs.com/tutorial/widgets.html > > I have the import line > from TKinter import * > > #Combo box > combovar = StringVar() > self.combo = Combobox(self.frame, textvariable=combovar) > self.combo['values'] = get_available_routes() > self.combo.var = combovar > self.combo.bind('<>', self.get_locations) > self.combo.grid(row=0, column=2) > > A google search for "Tkinter combobox" brings this as the first result: http://mail.python.org/pipermail/tutor/2004-July/030533.html Apparently the default installation of Tkinter doesn't contain a combobox, but it's accessible through some extensions/plugins HTH, Wayne -------------- next part -------------- An HTML attachment was scrubbed... URL: From igor.e.novikov at gmail.com Mon Apr 19 20:47:48 2010 From: igor.e.novikov at gmail.com (Igor Novikov) Date: Mon, 19 Apr 2010 21:47:48 +0300 Subject: [Tkinter-discuss] Combobox - global var not found In-Reply-To: <28286729.post@talk.nabble.com> References: <28286729.post@talk.nabble.com> Message-ID: Hi, Please note that Combobox widget is a Tile widget. To instantiate this object you should import that from ttk module. Here is a code from your reference link: countryvar = StringVar() country = *ttk*.Combobox(*parent*, textvariable=countryvar) Regards, Igor Novikov sK1 Project http://sk1project.org On Mon, Apr 19, 2010 at 6:25 AM, kimmyaf wrote: > > I am experimenting with TKinter for the first time for my programming > course. > Trying to get a combobox working. At this point I'm not trying to write > elegant code, but at least get it to work for now. > > I keep getting the error below. Shouldnt It recognize the Combobox widget > from the import? > > "NameError: global name 'Combobox' is not defined" > > I'm sure there is something really obvious going on but I've been starting > at it forever and not finding it. I've been using this as reference. > > http://www.tkdocs.com/tutorial/widgets.html > http://www.tkdocs.com/tutorial/widgets.html > > I have the import line > from TKinter import * > > #Combo box > combovar = StringVar() > self.combo = Combobox(self.frame, textvariable=combovar) > self.combo['values'] = get_available_routes() > self.combo.var = combovar > self.combo.bind('<>', self.get_locations) > self.combo.grid(row=0, column=2) > > -- > View this message in context: > http://old.nabble.com/Combobox----global-var-not-found-tp28286729p28286729.html > Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: From charras at me.com Tue Apr 20 16:31:45 2010 From: charras at me.com (Guido Carballo-Guerrero) Date: Tue, 20 Apr 2010 07:31:45 -0700 Subject: [Tkinter-discuss] How can I install or find ttk Message-ID: <5551416012671439769633618272715483126-Webmail@me.com> Hello, I want to use Treeview, and apparently this is part of ttk. I have Python 2.6.5 install in my computer, which is running Windows XP. The problem I have is that Python can't find ttk. When I do: >>> from Tkinter import ttk Traceback (most recent call last): File "", line 1, in from Tkinter import ttk ImportError: cannot import name ttk I get the previous error. Can anybody tell me what is wrong? Or how can I use treeview. Maybe, somebody can even give me another option, instead of treeview, 'cause what I need is just display tables, but for what I have seen so far, treeview gives the better look option. Guido From waynejwerner at gmail.com Tue Apr 20 19:38:42 2010 From: waynejwerner at gmail.com (Wayne Werner) Date: Tue, 20 Apr 2010 12:38:42 -0500 Subject: [Tkinter-discuss] How can I install or find ttk In-Reply-To: <5551416012671439769633618272715483126-Webmail@me.com> References: <5551416012671439769633618272715483126-Webmail@me.com> Message-ID: On Tue, Apr 20, 2010 at 9:31 AM, Guido Carballo-Guerrero wrote: > Hello, I want to use Treeview, and apparently this is part of ttk. I have > Python 2.6.5 install in my computer, which is running Windows XP. The > problem I have is that Python can't find ttk. When I do: > > >>> from Tkinter import ttk > > Traceback (most recent call last): > File "", line 1, in > from Tkinter import ttk > ImportError: cannot import name ttk > > I get the previous error. Can anybody tell me what is wrong? Or how can I > use treeview. Maybe, somebody can even give me another option, instead of > treeview, 'cause what I need is just display tables, but for what I have > seen so far, treeview gives the better look option. > >From a quick google search it appears that ttk is only installed by default with >= Python 3.1 Not sure what other options are out there, though. -Wayne -------------- next part -------------- An HTML attachment was scrubbed... URL: From igor.e.novikov at gmail.com Tue Apr 20 19:53:26 2010 From: igor.e.novikov at gmail.com (Igor Novikov) Date: Tue, 20 Apr 2010 20:53:26 +0300 Subject: [Tkinter-discuss] How can I install or find ttk In-Reply-To: References: <5551416012671439769633618272715483126-Webmail@me.com> Message-ID: hmmm... ttk.py is a part of Python 2.6.2 (located in the same folder as Tkinter: %Python%\Lib\lib-tk\) Regards, Igor Novikov sK1 Project http://sk1project.org On Tue, Apr 20, 2010 at 8:38 PM, Wayne Werner wrote: > On Tue, Apr 20, 2010 at 9:31 AM, Guido Carballo-Guerrero wrote: > >> Hello, I want to use Treeview, and apparently this is part of ttk. I have >> Python 2.6.5 install in my computer, which is running Windows XP. The >> problem I have is that Python can't find ttk. When I do: >> >> >>> from Tkinter import ttk >> >> Traceback (most recent call last): >> File "", line 1, in >> from Tkinter import ttk >> ImportError: cannot import name ttk >> >> I get the previous error. Can anybody tell me what is wrong? Or how can I >> use treeview. Maybe, somebody can even give me another option, instead of >> treeview, 'cause what I need is just display tables, but for what I have >> seen so far, treeview gives the better look option. >> > > From a quick google search it appears that ttk is only installed by default > with >= Python 3.1 > > Not sure what other options are out there, though. > > -Wayne > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From charras at me.com Tue Apr 20 23:41:11 2010 From: charras at me.com (Guido Carballo-Guerrero) Date: Tue, 20 Apr 2010 14:41:11 -0700 Subject: [Tkinter-discuss] from where can I download and install ttk? Message-ID: <158962765377242388415329400834021625740-Webmail@me.com> Hello, I have install in my computer Python 2.6.5, but I just realize that Tkinter for this version don't have ttk install. Does anybody know from where can I download ttk to install it. Apparently Python 3.1 already have ttk inside of Tkinter, is there a reason why I should prefer to use 2.6.5? What are the differences between them (2.6 and 3.1)? Guido From klappnase at web.de Wed Apr 21 09:34:11 2010 From: klappnase at web.de (Michael Lange) Date: Wed, 21 Apr 2010 09:34:11 +0200 Subject: [Tkinter-discuss] from where can I download and install ttk? In-Reply-To: <158962765377242388415329400834021625740-Webmail@me.com> References: <158962765377242388415329400834021625740-Webmail@me.com> Message-ID: <20100421093411.aec6b002.klappnase@web.de> Hi, On Tue, 20 Apr 2010 14:41:11 -0700 Guido Carballo-Guerrero wrote: > Hello, I have install in my computer Python 2.6.5, but I just realize > that Tkinter for this version don't have ttk install. Does anybody > know from where can I download ttk to install it. > ttk is in a separate python module, I am not sure if this is already included in your version. You can try this with an "import ttk" statement, if this fails you can download the ttk module from here: < http://pypi.python.org/pypi/pyttk > and, after you installed it, you should be able to do something like: from Tkinter import * import ttk root = Tk() tree = ttk.Treeview(root) I hope this helps Michael From flahertyk1 at hotmail.com Thu Apr 22 03:30:22 2010 From: flahertyk1 at hotmail.com (kimmyaf) Date: Wed, 21 Apr 2010 18:30:22 -0700 (PDT) Subject: [Tkinter-discuss] Combobox - global var not found In-Reply-To: <28286729.post@talk.nabble.com> References: <28286729.post@talk.nabble.com> Message-ID: <28323292.post@talk.nabble.com> Thanks for the replies. I have the Pmw uploaded and my import statement is correct, but I'm still having issues. I must move on with the rest of my project and hope to come back to this functionality if i have time at the end. kimmyaf wrote: > > I am experimenting with TKinter for the first time for my programming > course. Trying to get a combobox working. At this point I'm not trying to > write elegant code, but at least get it to work for now. > > I keep getting the error below. Shouldnt It recognize the Combobox widget > from the import? > > "NameError: global name 'Combobox' is not defined" > > I'm sure there is something really obvious going on but I've been starting > at it forever and not finding it. I've been using this as reference. > > http://www.tkdocs.com/tutorial/widgets.html > http://www.tkdocs.com/tutorial/widgets.html > > I have the import line > from TKinter import * > > #Combo box > combovar = StringVar() > self.combo = Combobox(self.frame, textvariable=combovar) > self.combo['values'] = get_available_routes() > self.combo.var = combovar > self.combo.bind('<>', self.get_locations) > self.combo.grid(row=0, column=2) > > -- View this message in context: http://old.nabble.com/Combobox----global-var-not-found-tp28286729p28323292.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From flahertyk1 at hotmail.com Thu Apr 22 03:38:06 2010 From: flahertyk1 at hotmail.com (kimmyaf) Date: Wed, 21 Apr 2010 18:38:06 -0700 (PDT) Subject: [Tkinter-discuss] Getting a canvas within an existing frame. Message-ID: <28323328.post@talk.nabble.com> I cannot get my canvas to show within my existing frame. I can only get it to build it's own frame. Can someone help? As you can see i've tried a number of different things so i have a lot of stuff commented out at the bottom. attached is a picture of what my GUI looks like. I want the canvas to show in the same frame as the address entries not seperately. Any help is appreciated. I see a lot of examples on the web but they are all building the canvas in their own frame. I need it in the other frame. class App: def __init__(self, master): self.master = master # store link to master window (or: self.frame._root()) self.frame = Frame(master) # make a frame with master as parent self.frame.grid(row=0, column=0) # initiate drawing of frame in master window # make a label self.label = Label(self.frame, text="Massachusetts Bay Transit Authority - Bus Locator", justify=LEFT, font= ("Helvetica","16", "bold")) self.label.grid(row=0, column=0, columnspan=4) print self.label.cget("font") # what's my font? # make another label self.label = Label(self.frame, text="Enter your current location", justify=LEFT, font= ("Helvetica","12")) self.label.grid(row=1, column=0) print self.label.cget("font") # what's my font? #######################################TEXT FIELDS############## # make address text entry field self.entry_addr = StringVar() self.entry = Entry(self.frame, width=25, textvariable=self.entry_addr) self.entry_addr.set("Address line 1") self.entry.grid(row=1, column=1) # make City text entry field self.entry_city = StringVar() self.entry = Entry(self.frame, width=25, textvariable=self.entry_city) self.entry_city.set("City") self.entry.grid(row=2, column=1) # make State text entry field self.entry_state = StringVar() self.entry = Entry(self.frame, width=11, textvariable=self.entry_state) self.entry_state.set("State Abvtn") self.entry.grid(row=3, column=1) # make Zip text entry field self.entry_zip = StringVar() self.entry = Entry(self.frame, width=5, textvariable=self.entry_zip) self.entry_zip.set("zip") self.entry.grid(row=4, column=1) ###################################CANVAS####################### # Tkinter cannot use a PIL Image directly, but we can make a PhotoImage from it #img = Image.open("Imgfolder\map.jpg") #define a new frame and put a text area in it #self.imgframe=Frame(self.frame) #self.text=Text(self.textframe,height=30, width=50,wrap=WORD) #self.text.pack(side=LEFT, fill=BOTH) #tkinter_phimg = ImageTk.PhotoImage(i) # can do only after Tk()! self.imgframe = Tkinter.Tk() self.canvas = Tkinter.Canvas(self.imgframe, width=50, height=50) #canvas.pack() http://old.nabble.com/file/p28323328/frames.jpg -- View this message in context: http://old.nabble.com/Getting-a-canvas-within-an-existing-frame.-tp28323328p28323328.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From kw at codebykevin.com Thu Apr 22 03:39:08 2010 From: kw at codebykevin.com (Kevin Walzer) Date: Wed, 21 Apr 2010 21:39:08 -0400 Subject: [Tkinter-discuss] Combobox - global var not found In-Reply-To: <28323292.post@talk.nabble.com> References: <28286729.post@talk.nabble.com> <28323292.post@talk.nabble.com> Message-ID: <4BCFA8BC.9060504@codebykevin.com> On 4/21/10 9:30 PM, kimmyaf wrote: > > Thanks for the replies. I have the Pmw uploaded and my import statement is > correct, but I'm still having issues. I must move on with the rest of my > project and hope to come back to this functionality if i have time at the > end. The combobox requires you to import ttk, I believe. Did you try that? --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From flahertyk1 at hotmail.com Thu Apr 22 03:50:46 2010 From: flahertyk1 at hotmail.com (kimmyaf) Date: Wed, 21 Apr 2010 18:50:46 -0700 (PDT) Subject: [Tkinter-discuss] Combobox - global var not found In-Reply-To: <4BCFA8BC.9060504@codebykevin.com> References: <28286729.post@talk.nabble.com> <28323292.post@talk.nabble.com> <4BCFA8BC.9060504@codebykevin.com> Message-ID: <28323392.post@talk.nabble.com> There are two versions. There is a combobox in Pmw, which i did import/install and still had issues. I haven't tried ttk.. I may try that if I have time at the end. Thanks! Kevin Walzer-5 wrote: > > On 4/21/10 9:30 PM, kimmyaf wrote: >> >> Thanks for the replies. I have the Pmw uploaded and my import statement >> is >> correct, but I'm still having issues. I must move on with the rest of my >> project and hope to come back to this functionality if i have time at the >> end. > > The combobox requires you to import ttk, I believe. Did you try that? > > --Kevin > > -- > Kevin Walzer > Code by Kevin > http://www.codebykevin.com > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > -- View this message in context: http://old.nabble.com/Combobox----global-var-not-found-tp28286729p28323392.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From klappnase at web.de Thu Apr 22 11:08:59 2010 From: klappnase at web.de (Michael Lange) Date: Thu, 22 Apr 2010 11:08:59 +0200 Subject: [Tkinter-discuss] Getting a canvas within an existing frame. In-Reply-To: <28323328.post@talk.nabble.com> References: <28323328.post@talk.nabble.com> Message-ID: <20100422110859.b0b32870.klappnase@web.de> Hi, On Wed, 21 Apr 2010 18:38:06 -0700 (PDT) kimmyaf wrote: > > I cannot get my canvas to show within my existing frame. I can only > get it to build it's own frame. Can someone help? As you can see i've > tried a number of different things so i have a lot of stuff commented > out at the bottom. attached is a picture of what my GUI looks like. I > want the canvas to show in the same frame as the address entries not > seperately. Any help is appreciated. I see a lot of examples on the > web but they are all building the canvas in their own frame. I need > it in the other frame. > >From your code and the screenshot I am not sure what exactly did not work for you. The screenshot shows the canvas in a second window, which works but is apparently not what you want (BTW, in your code you use a second instance of Tkinter.Tk() to open the second window, which is one of the upper case "don't"s in Tkinter :) If you need a second window you should use Tkinter.Toplevel() instead). >From the commented out parts of your code I think you meant to do: #define a new frame and put a text area in it self.imgframe=Frame(self.frame) #tkinter_phimg = ImageTk.PhotoImage(i) # can do only after Tk()! self.canvas = Tkinter.Canvas(self.imgframe, width=50, height=50) self.canvas.pack() Not sure what you tried already, but here self.imgframe is never pack()ed, so maybe the solution is as simple as that? Or, have you tried to omit self.imgframe and put the canvas directly into self.frame , and if yes, what exactly happened? Regards Michael From Cameron at phaseit.net Thu Apr 22 14:33:31 2010 From: Cameron at phaseit.net (Cameron Laird) Date: Thu, 22 Apr 2010 12:33:31 +0000 Subject: [Tkinter-discuss] Combobox - global var not found In-Reply-To: <28323392.post@talk.nabble.com> References: <28286729.post@talk.nabble.com> <28323292.post@talk.nabble.com> <4BCFA8BC.9060504@codebykevin.com> <28323392.post@talk.nabble.com> Message-ID: <20100422123331.GB22095@lairds.us> On Wed, Apr 21, 2010 at 06:50:46PM -0700, kimmyaf wrote: . . . > There are two versions. There is a combobox in Pmw, which i did > import/install and still had issues. I haven't tried ttk.. I may try that if > I have time at the end. Thanks! . . . There are even more, including "pure Tk" alternatives, but they're recommended only for special situations. It's definitely right to focus first on Pmw and ttk. From charras at me.com Thu Apr 22 15:22:54 2010 From: charras at me.com (Guido Carballo-Guerrero) Date: Thu, 22 Apr 2010 06:22:54 -0700 Subject: [Tkinter-discuss] from where can I download and install ttk? In-Reply-To: <20100421093411.aec6b002.klappnase@web.de> References: <158962765377242388415329400834021625740-Webmail@me.com> <20100421093411.aec6b002.klappnase@web.de> Message-ID: <133592954785267759737912251929648418443-Webmail@me.com> Michale, thank you very much. In case anybody else have problems with this, here is what I did to have ttk working: 1. I just download ttk from here: http://pypi.python.org/pypi/pyttk 2. After downloading the file, decompress it. 3. Double click in the setup.py file, which create the ttk.pyc, and copy both, the ttk.py and ttk.pyc into %Python%\Lib\lib-tk After that one should be able to use the ttk modules. Guido On Wednesday, April 21, 2010, at 12:34AM, "Michael Lange" wrote: >Hi, > >On Tue, 20 Apr 2010 14:41:11 -0700 >Guido Carballo-Guerrero wrote: > >> Hello, I have install in my computer Python 2.6.5, but I just realize >> that Tkinter for this version don't have ttk install. Does anybody >> know from where can I download ttk to install it. >> > >ttk is in a separate python module, I am not sure if this is already >included in your version. You can try this with an "import ttk" >statement, if this fails you can download the ttk module from here: >< http://pypi.python.org/pypi/pyttk > and, after you installed it, you >should be able to do something like: > > from Tkinter import * > import ttk > root = Tk() > tree = ttk.Treeview(root) > >I hope this helps > >Michael > > > From charras at me.com Thu Apr 22 15:33:22 2010 From: charras at me.com (Guido Carballo-Guerrero) Date: Thu, 22 Apr 2010 06:33:22 -0700 Subject: [Tkinter-discuss] How can I tell Tkinter where to look for Tcl/Tk? Message-ID: <90985688593587882826021665073305247847-Webmail@me.com> Hello, I have a Mac, running OS X 10.6.3, and have Python 2.6.4 install. I already install ttk, got it from: http://pypi.python.org/pypi/pyttk But when I try to use ttk, it with me the following error: Traceback (most recent call last): File "/Users/Charras/Documents/CS/Python/programs/Tkinter/ttk/prueba1.py", line 6, in style = ttk.Style() File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/ttk.py", line 392, in __init__ _load_tile(master) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/ttk.py", line 60, in _load_tile master.tk.eval('package require tile') # TclError may be raised here TclError: can't find package tile I read somewhere that this mean that I had an old Tcl/Tk version, and I check it, and yes, that was the case: >>> import Tkinter as Tkt >>> Tkt.TkVersion 8.4000000000000004 So I download and install version 8.5 from activestate.com. Now I have TCL/TK 8.5 install in my machine, inside of "/Library/Frameworks/Tcl.framework/Versions/8.5". and "/Library/Frameworks/Tk.framework/Versions/8.5"., but I guess that if even after doing this, Tkinter still sees 8.4 is 'cause I need to tell it to go and load this new version and read from there, but I don't know how to do that. Can somebody guide me on how to do it? Regards Guido From igor.e.novikov at gmail.com Thu Apr 22 17:13:01 2010 From: igor.e.novikov at gmail.com (Igor Novikov) Date: Thu, 22 Apr 2010 18:13:01 +0300 Subject: [Tkinter-discuss] How can I tell Tkinter where to look for Tcl/Tk? In-Reply-To: <90985688593587882826021665073305247847-Webmail@me.com> References: <90985688593587882826021665073305247847-Webmail@me.com> Message-ID: _tkinter.so is a native extension and linked against system libtcl.so and libtk.so. Therefore to use latest Tcl/Tk versions in distributable application you need compiling a bundle for your application and recompile _tkinter.so It's just a theory. We have no ported yet sK1 application on MacOS X platform so I can just supposing this. But the same issues were under Linux platform right after Tcl/Tk 8.5 release. Fortunately, under Linux package repositories allow managing different version of Tcl/Tk libraries. Regards, Igor Novikov sK1 Project http://sk1project.org On Thu, Apr 22, 2010 at 4:33 PM, Guido Carballo-Guerrero wrote: > Hello, I have a Mac, running OS X 10.6.3, and have Python 2.6.4 install. I > already install ttk, got it from: > > http://pypi.python.org/pypi/pyttk > > But when I try to use ttk, it with me the following error: > > Traceback (most recent call last): > File "/Users/Charras/Documents/CS/Python/programs/Tkinter/ttk/prueba1.py", > line 6, in > style = ttk.Style() > File > "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/ttk.py", > line 392, in __init__ > _load_tile(master) > File > "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/ttk.py", > line 60, in _load_tile > master.tk.eval('package require tile') # TclError may be raised here > TclError: can't find package tile > > I read somewhere that this mean that I had an old Tcl/Tk version, and I > check it, and yes, that was the case: > > >>> import Tkinter as Tkt > >>> Tkt.TkVersion > 8.4000000000000004 > > So I download and install version 8.5 from activestate.com. Now I have > TCL/TK 8.5 install in my machine, inside of > "/Library/Frameworks/Tcl.framework/Versions/8.5". and > "/Library/Frameworks/Tk.framework/Versions/8.5"., but I guess that if even > after doing this, Tkinter still sees 8.4 is 'cause I need to tell it to go > and load this new version and read from there, but I don't know how to do > that. > > Can somebody guide me on how to do it? > > Regards > > Guido > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Fri Apr 23 10:21:16 2010 From: klappnase at web.de (Michael Lange) Date: Fri, 23 Apr 2010 10:21:16 +0200 Subject: [Tkinter-discuss] How can I tell Tkinter where to look for Tcl/Tk? In-Reply-To: <90985688593587882826021665073305247847-Webmail@me.com> References: <90985688593587882826021665073305247847-Webmail@me.com> Message-ID: <20100423102116.b0b1383f.klappnase@web.de> Hi, On Thu, 22 Apr 2010 06:33:22 -0700 Guido Carballo-Guerrero wrote: > Hello, I have a Mac, running OS X 10.6.3, and have Python 2.6.4 > install. I already install ttk, got it from: > > http://pypi.python.org/pypi/pyttk > > But when I try to use ttk, it with me the following error: > > Traceback (most recent call last): > File > "/Users/Charras/Documents/CS/Python/programs/Tkinter/ttk/prueba1.py", > line 6, in style = ttk.Style() File > "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/ttk.py", > line 392, in __init__ _load_tile(master) File > "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/ttk.py", > line 60, in _load_tile master.tk.eval('package require tile') # > TclError may be raised here TclError: can't find package tile > > I read somewhere that this mean that I had an old Tcl/Tk version, and > I check it, and yes, that was the case: > > >>> import Tkinter as Tkt > >>> Tkt.TkVersion > 8.4000000000000004 > I think that it is probably much easier to install the tile extension for Tk-8.4 than upgrading Tcl/Tk and Python to Tk-8.5 . You can look for tile packages here: http://sourceforge.net/projects/tktable/files/ and once tile is installed you can use ttk just as if you had Tk-8.5 . I hope this helps Michael From joebarfett at yahoo.ca Fri Apr 23 19:23:30 2010 From: joebarfett at yahoo.ca (Joe Barfett) Date: Fri, 23 Apr 2010 10:23:30 -0700 (PDT) Subject: [Tkinter-discuss] problem with menus, Tkinter on macpython In-Reply-To: Message-ID: <370517.57911.qm@web59411.mail.ac4.yahoo.com> Hello again, The last time I updated, I think my code was scrambled. I am still having the same problem in that I cannot make?a menu appear using Tkinter on macpython. The exact same code works very well on my PC. This is the code: ? from Tkinter import * root = Tk() def hello(): ??? print "hello!" # create a toplevel menu menubar = Menu(root) menubar.add_command(label="Hello!", command=hello) # display the menu root.config(menu=menubar) mainloop() I'm using windows XP and python version 2.5 with Tkinter. A menu appears. The exact same code on OSX 10.5 and 10.5 in macpython will display a frame but no menu. Can anyone help? Thanks very much! joe -------------- next part -------------- An HTML attachment was scrubbed... URL: From flahertyk1 at hotmail.com Mon Apr 26 00:12:03 2010 From: flahertyk1 at hotmail.com (kimmyaf) Date: Sun, 25 Apr 2010 15:12:03 -0700 (PDT) Subject: [Tkinter-discuss] Getting a canvas within an existing frame. In-Reply-To: <28323328.post@talk.nabble.com> References: <28323328.post@talk.nabble.com> Message-ID: <28359260.post@talk.nabble.com> Ok i got this figured out. It's important to create the canvas in a class that is subclassed from Frame. kimmyaf wrote: > > I cannot get my canvas to show within my existing frame. I can only get > it to build it's own frame. Can someone help? As you can see i've tried a > number of different things so i have a lot of stuff commented out at the > bottom. attached is a picture of what my GUI looks like. I want the canvas > to show in the same frame as the address entries not seperately. Any help > is appreciated. I see a lot of examples on the web but they are all > building the canvas in their own frame. I need it in the other frame. > > > class App: > def __init__(self, master): > > self.master = master # store link to master window (or: > self.frame._root()) > self.frame = Frame(master) # make a frame with master as parent > self.frame.grid(row=0, column=0) # initiate drawing of frame in > master window > > # make a label > self.label = Label(self.frame, text="Massachusetts Bay Transit > Authority - Bus Locator", justify=LEFT, > font= ("Helvetica","16", "bold")) > self.label.grid(row=0, column=0, columnspan=4) > print self.label.cget("font") # what's my font? > > # make another label > self.label = Label(self.frame, text="Enter your current location", > justify=LEFT, > font= ("Helvetica","12")) > self.label.grid(row=1, column=0) > print self.label.cget("font") # what's my font? > > > #######################################TEXT FIELDS############## > # make address text entry field > self.entry_addr = StringVar() > self.entry = Entry(self.frame, width=25, > textvariable=self.entry_addr) > self.entry_addr.set("Address line 1") > > self.entry.grid(row=1, column=1) > > > # make City text entry field > self.entry_city = StringVar() > self.entry = Entry(self.frame, width=25, > textvariable=self.entry_city) > self.entry_city.set("City") > > self.entry.grid(row=2, column=1) > > > > # make State text entry field > self.entry_state = StringVar() > self.entry = Entry(self.frame, width=11, > textvariable=self.entry_state) > self.entry_state.set("State Abvtn") > > self.entry.grid(row=3, column=1) > > > > # make Zip text entry field > self.entry_zip = StringVar() > self.entry = Entry(self.frame, width=5, > textvariable=self.entry_zip) > self.entry_zip.set("zip") > > self.entry.grid(row=4, column=1) > > > > ###################################CANVAS####################### > # Tkinter cannot use a PIL Image directly, but we can make a > PhotoImage from it > #img = Image.open("Imgfolder\map.jpg") > > #define a new frame and put a text area in it > #self.imgframe=Frame(self.frame) > #self.text=Text(self.textframe,height=30, width=50,wrap=WORD) > #self.text.pack(side=LEFT, fill=BOTH) > > #tkinter_phimg = ImageTk.PhotoImage(i) # can do only after Tk()! > self.imgframe = Tkinter.Tk() > self.canvas = Tkinter.Canvas(self.imgframe, width=50, height=50) > #canvas.pack() > > http://old.nabble.com/file/p28323328/frames.jpg > -- View this message in context: http://old.nabble.com/Getting-a-canvas-within-an-existing-frame.-tp28323328p28359260.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From kw at codebykevin.com Mon Apr 26 16:18:58 2010 From: kw at codebykevin.com (Kevin Walzer) Date: Mon, 26 Apr 2010 10:18:58 -0400 Subject: [Tkinter-discuss] problem with menus, Tkinter on macpython In-Reply-To: <370517.57911.qm@web59411.mail.ac4.yahoo.com> References: <370517.57911.qm@web59411.mail.ac4.yahoo.com> Message-ID: <4BD5A0D2.3060507@codebykevin.com> On 4/23/10 1:23 PM, Joe Barfett wrote: > Hello again, > The last time I updated, I think my code was scrambled. I am still > having the same problem in that I cannot make a menu appear using > Tkinter on macpython. The exact same code works very well on my PC. > > I'm using windows XP and python version 2.5 with Tkinter. A menu > appears. The exact same code on OSX 10.5 and 10.5 in macpython will > display a frame but no menu. > Can anyone help? > Thanks very much! > joe > Try this: from Tkinter import * root = Tk() def hello(): print "hello!" # create a toplevel menu menubar = Menu(root) root.config(menu=menubar) hellomenu=Menu(menubar) menubar.add_cascade(label="Hello", menu=hellomenu) hellomenu.add_command(label="Hello!", command=hello) # display the menu root.config(menu=menubar) mainloop() It adds a "hello" submenu that's visible on the Mac. I'm not sure why the other code works on Windows, but this should work too. --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From charras at me.com Wed Apr 28 00:44:39 2010 From: charras at me.com (Guido Carballo-Guerrero) Date: Tue, 27 Apr 2010 15:44:39 -0700 Subject: [Tkinter-discuss] Returning control from a toplevel window Message-ID: <166854088122158260668598175024134054933-Webmail@me.com> How can I get back into a while loop if I go to a new pop-up toplevel window, that is created when I press one button. I'm attaching a sample of the code that I'm trying to make. The problem that I have is that after the button is press and the new toplevel window, what ever is inside of the while loop doesn't do anything anymore. Is as if I got out of the while loop. Is there a way in which I can get back into the while loop once the toplevel window is destroy? Guido -------------- next part -------------- A non-text attachment was scrubbed... Name: prueba_while.py Type: application/octet-stream Size: 980 bytes Desc: not available URL: From klappnase at web.de Wed Apr 28 09:59:35 2010 From: klappnase at web.de (Michael Lange) Date: Wed, 28 Apr 2010 09:59:35 +0200 Subject: [Tkinter-discuss] Returning control from a toplevel window In-Reply-To: <166854088122158260668598175024134054933-Webmail@me.com> References: <166854088122158260668598175024134054933-Webmail@me.com> Message-ID: <20100428095935.b1603a90.klappnase@web.de> Hi, On Tue, 27 Apr 2010 15:44:39 -0700 Guido Carballo-Guerrero wrote: > How can I get back into a while loop if I go to a new pop-up toplevel > window, that is created when I press one button. > > I'm attaching a sample of the code that I'm trying to make. The > problem that I have is that after the button is press and the new > toplevel window, what ever is inside of the while loop doesn't do > anything anymore. Is as if I got out of the while loop. > > Is there a way in which I can get back into the while loop once the > toplevel window is destroy? > > Guido > (...) > def new(): > root2 = Tkt.Toplevel() > > def ask_quit2(): > root2.destroy() > > root2.protocol("WM_DELETE_WINDOW", ask_quit2) > > L1 = ttk.Label(root2) > L1.config(text = 'Window2') > L1.pack() > > root2.mainloop() ^^^^^^^^^^^^^^^^ The second call to mainloop() is the problem, just remove it and everything will work as expected. mainloop() must only be called once per application (for the main Tk() window). I hope this helps Michael From charras at me.com Wed Apr 28 18:38:52 2010 From: charras at me.com (Guido Carballo-Guerrero) Date: Wed, 28 Apr 2010 09:38:52 -0700 Subject: [Tkinter-discuss] Returning control from a toplevel Message-ID: <136229730319579015045648507306353248985-Webmail@me.com> Michael; What I did to solve the problem, was put the while loop inside of a function, so when I'm exiting the toplevel windows, I call that function, in that way I get back into the while loop. Is there a problem with this? What is the problem of calling the mainloop in the various windows? Why I can't display the pictures unless I call the mainloop inside of the toplevel windows? What happens when I call the mainloop inside of the toplevel windows, that kick me out of the while loop? Cause you're right, when I don't call mainloop inside of the new toplevel window, everything keeps running in the main program as if anything had happen. Regards! Guido From charras at me.com Wed Apr 28 18:25:14 2010 From: charras at me.com (Guido Carballo-Guerrero) Date: Wed, 28 Apr 2010 09:25:14 -0700 Subject: [Tkinter-discuss] Returning control from a toplevel window In-Reply-To: <6551204378998110350696841214457341689-Webmail@me.com> References: <6551204378998110350696841214457341689-Webmail@me.com> Message-ID: <135309418626461127698077214559959044750-Webmail@me.com> Micheal, but if I don't call the mainloop again inside of the toplevel window the pictures that I'm trying to display doesn't show up. Guido > >Message: 2 >Date: Wed, 28 Apr 2010 09:59:35 +0200 >From: Michael Lange >To: tkinter-discuss at python.org >Subject: Re: [Tkinter-discuss] Returning control from a toplevel > window >Message-ID: <20100428095935.b1603a90.klappnase at web.de> >Content-Type: text/plain; charset=US-ASCII > >Hi, > >On Tue, 27 Apr 2010 15:44:39 -0700 >Guido Carballo-Guerrero wrote: > >> How can I get back into a while loop if I go to a new pop-up toplevel >> window, that is created when I press one button. >> >> I'm attaching a sample of the code that I'm trying to make. The >> problem that I have is that after the button is press and the new >> toplevel window, what ever is inside of the while loop doesn't do >> anything anymore. Is as if I got out of the while loop. >> >> Is there a way in which I can get back into the while loop once the >> toplevel window is destroy? >> >> Guido >> >(...) >> def new(): >> root2 = Tkt.Toplevel() >> >> def ask_quit2(): >> root2.destroy() >> >> root2.protocol("WM_DELETE_WINDOW", ask_quit2) >> >> L1 = ttk.Label(root2) >> L1.config(text = 'Window2') >> L1.pack() >> >> root2.mainloop() > ^^^^^^^^^^^^^^^^ > >The second call to mainloop() is the problem, just remove it and >everything will work as expected. mainloop() must only be called >once per application (for the main Tk() window). > >I hope this helps > >Michael > > From klappnase at web.de Wed Apr 28 20:32:23 2010 From: klappnase at web.de (Michael Lange) Date: Wed, 28 Apr 2010 20:32:23 +0200 Subject: [Tkinter-discuss] Returning control from a toplevel In-Reply-To: <136229730319579015045648507306353248985-Webmail@me.com> References: <136229730319579015045648507306353248985-Webmail@me.com> Message-ID: <20100428203223.77d899a4.klappnase@web.de> Hi, On Wed, 28 Apr 2010 09:38:52 -0700 Guido Carballo-Guerrero wrote: > Michael; > > What I did to solve the problem, was put the while loop inside of a > function, so when I'm exiting the toplevel windows, I call that > function, in that way I get back into the while loop. Is there a > problem with this? What is the problem of calling the mainloop in the > various windows? Why I can't display the pictures unless I call the > mainloop inside of the toplevel windows? What happens when I call the > mainloop inside of the toplevel windows, that kick me out of the > while loop? Cause you're right, when I don't call mainloop inside of > the new toplevel window, everything keeps running in the main program > as if anything had happen. That's a lot of questions :) Maybe one of the gurus here can explain better than me why exactly there must not be more than one mainloop. I think the problem with your stopped while loop happens because the mainloop() does not return until the main application window is destroyed. You can verify this by adding a "print" statement after the second mainloop() to the new() function in your previous example. If you are not able to display images in the Toplevel window there is surely something else wrong with your code, so maybe you can post a short code example that shows this problem? It should definitely be possible to put images in a Toplevel without a second mainloop :) Regards Michael From waynejwerner at gmail.com Wed Apr 28 22:06:18 2010 From: waynejwerner at gmail.com (Wayne Werner) Date: Wed, 28 Apr 2010 15:06:18 -0500 Subject: [Tkinter-discuss] Returning control from a toplevel In-Reply-To: <20100428203223.77d899a4.klappnase@web.de> References: <136229730319579015045648507306353248985-Webmail@me.com> <20100428203223.77d899a4.klappnase@web.de> Message-ID: On Wed, Apr 28, 2010 at 1:32 PM, Michael Lange wrote: > That's a lot of questions :) > Maybe one of the gurus here can explain better than me why exactly > there must not be more than one mainloop. I think the problem with your > stopped while loop happens because the mainloop() does not return until > the main application window is destroyed. You can verify this by adding > a "print" statement after the second mainloop() to the new() function > in your previous example. > If you are not able to display images in the Toplevel window there is > surely something else wrong with your code, so maybe you can post a > short code example that shows this problem? It should definitely be > possible to put images in a Toplevel without a second mainloop :) > The reason that two mainloops don't get along is because of what they're doing. Imagine: while True: do A while True: do B You'll have a lot of A, but no more B. That's an overly simplified version of what's going on, but it's still accurate enough. Tkinter has an event loop that has a few tasks: 1) draw everything, 2) listen for events such as keypresses and mouse clicks, 3) emit events/call callbacks There may be some others, but those are the essential ones. When you try to create two mainloops all of those draw/listen/emit tasks collide and it's not pretty. Michael is correct that you should be able to draw the image without having to resort to two mainloops. Without seeing your code what I would guess is the problem is that you're spawning the window from within your infinite loop - and guess what? Remember those events that the mainloop is supposed to be taking care of? They never happen because the mainloop is awaiting control. A quick example: import Tkinter as tk def looper(): while True: pass root = tk.Tk() b = tk.Button(root, text="Hi", command=looper) b.pack() root.mainloop() Fire that up (from command line preferably) and click the button. Notice how you cannot do anything else? That's because the mainloop is waiting for control that it never gets because it's continually executing the while loop. You now have to kill or ctrl+c the program to break out of the infinite loop. But notice that if you haven't pushed anything else and just hit ctrl+c then your program is still running. The control has been passed back to the main loop of your program. Another interesting thing to notice is (at least it works for me) if you click the close button while the infinite loop is waiting, and then ctrl+c the program quits. Why? Because the click was passed into tkinter's event queue and it was just waiting to be handled. Anyhow, HTH, Wayne -------------- next part -------------- An HTML attachment was scrubbed... URL: From charras at me.com Wed Apr 28 23:21:21 2010 From: charras at me.com (Guido Carballo-Guerrero) Date: Wed, 28 Apr 2010 14:21:21 -0700 Subject: [Tkinter-discuss] Returning control from a toplevel window In-Reply-To: <54081086564611180595499740355576637503-Webmail@me.com> References: <54081086564611180595499740355576637503-Webmail@me.com> Message-ID: <83885458946452559377777547817220791425-Webmail@me.com> Wayne, Michael; This is a sample code that shows what I'm doing. As you can see, even if I don't have a while loop, the picture is not being shown. Am I missing something? What is wrong with my code that I can't open and show the picture in the new Toplevel window? Guido >The second call to mainloop() is the problem, just remove it and >everything will work as expected. mainloop() must only be called >once per application (for the main Tk() window). > >I hope this helps > >Michael > > > > >------------------------------ > >_______________________________________________ >Tkinter-discuss mailing list >Tkinter-discuss at python.org >http://mail.python.org/mailman/listinfo/tkinter-discuss > > >End of Tkinter-discuss Digest, Vol 74, Issue 16 >*********************************************** > > -------------- next part -------------- A non-text attachment was scrubbed... Name: demo_jpg_&_toplevel.py Type: application/octet-stream Size: 886 bytes Desc: not available URL: From charras at me.com Wed Apr 28 23:37:18 2010 From: charras at me.com (Guido Carballo-Guerrero) Date: Wed, 28 Apr 2010 14:37:18 -0700 Subject: [Tkinter-discuss] Returning control from a toplevel window In-Reply-To: References: Message-ID: <26704343380188393798075488275810011241-Webmail@me.com> Michael, Wayne; I'm sorry, I just found my problem. Was something dumb: L1.config(image = photo1) L1.image = image1_2 This was the problem. I should had: L1.config(image = photo1) L1.image = photo1 Now it's working as expected. Thank you very much any way for your help, really appreciated. Guido > >Hi, > >On Tue, 27 Apr 2010 15:44:39 -0700 >Guido Carballo-Guerrero wrote: > >> How can I get back into a while loop if I go to a new pop-up toplevel >> window, that is created when I press one button. >> >> I'm attaching a sample of the code that I'm trying to make. The >> problem that I have is that after the button is press and the new >> toplevel window, what ever is inside of the while loop doesn't do >> anything anymore. Is as if I got out of the while loop. >> >> Is there a way in which I can get back into the while loop once the >> toplevel window is destroy? >> >> Guido >> >(...) >> def new(): >> root2 = Tkt.Toplevel() >> >> def ask_quit2(): >> root2.destroy() >> >> root2.protocol("WM_DELETE_WINDOW", ask_quit2) >> >> L1 = ttk.Label(root2) >> L1.config(text = 'Window2') >> L1.pack() >> >> root2.mainloop() > ^^^^^^^^^^^^^^^^ > >The second call to mainloop() is the problem, just remove it and >everything will work as expected. mainloop() must only be called >once per application (for the main Tk() window). > >I hope this helps > >Michael > > > > >------------------------------ > >_______________________________________________ >Tkinter-discuss mailing list >Tkinter-discuss at python.org >http://mail.python.org/mailman/listinfo/tkinter-discuss > > >End of Tkinter-discuss Digest, Vol 74, Issue 16 >*********************************************** > > From klappnase at web.de Thu Apr 29 10:54:22 2010 From: klappnase at web.de (Michael Lange) Date: Thu, 29 Apr 2010 10:54:22 +0200 Subject: [Tkinter-discuss] Returning control from a toplevel window In-Reply-To: <83885458946452559377777547817220791425-Webmail@me.com> References: <54081086564611180595499740355576637503-Webmail@me.com> <83885458946452559377777547817220791425-Webmail@me.com> Message-ID: <20100429105422.6744beca.klappnase@web.de> Hi, On Wed, 28 Apr 2010 14:21:21 -0700 Guido Carballo-Guerrero wrote: > > Wayne, Michael; > > This is a sample code that shows what I'm doing. As you can see, even > if I don't have a while loop, the picture is not being shown. Am I > missing something? What is wrong with my code that I can't open and > show the picture in the new Toplevel window? > (...) > image1_1 = Image.open('20188.jpg') > image1_2 = image1_1.resize((130,200)) > photo1 = ImageTk.PhotoImage(image1_2) > > L1 = ttk.Label(F1) > L1.config(image = photo1) > L1.image = image1_2 ^^^^^^^^ That is the problem; as you noticed correctly, you have to add a reference to the PhotoImage so it does not get garbage collected. But you need to add the reference to the PhotoImage object, in this case photo1, not the PIL Image. Alternatively you can define the PhotoImage globally, i.e. outside your pic() function. I hope this helps Michael From klappnase at web.de Thu Apr 29 10:55:51 2010 From: klappnase at web.de (Michael Lange) Date: Thu, 29 Apr 2010 10:55:51 +0200 Subject: [Tkinter-discuss] Returning control from a toplevel window In-Reply-To: <26704343380188393798075488275810011241-Webmail@me.com> References: <26704343380188393798075488275810011241-Webmail@me.com> Message-ID: <20100429105551.53ee0db5.klappnase@web.de> Hi, On Wed, 28 Apr 2010 14:37:18 -0700 Guido Carballo-Guerrero wrote: > Michael, Wayne; > > I'm sorry, I just found my problem. Was something dumb: > > L1.config(image = photo1) > L1.image = image1_2 > > This was the problem. I should had: > > L1.config(image = photo1) > L1.image = photo1 > Oh, I should have read this second post first, never mind :) Michael From michael.odonnell at uam.es Thu Apr 29 18:15:36 2010 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Thu, 29 Apr 2010 18:15:36 +0200 Subject: [Tkinter-discuss] Tkinter on iPad/iPhone? Message-ID: Hi all, I was thinking of porting my python application to an iPad, I see that there is general support for python on these devices via PyObjC. However, no support for Tkinter, that I can see. Anyone know of such support? Mick