From klappnase at web.de Thu Jun 1 07:05:04 2006 From: klappnase at web.de (Michael Lange) Date: Thu, 1 Jun 2006 07:05:04 +0200 Subject: [Tkinter-discuss] Scroll a table, but not the first two rows? In-Reply-To: <20060531210301.GA20980@lairds.us> References: <20060531110657.GS17400@kira.niekel.net> <20060531131858.4df4369e.klappnase@web.de> <20060531210301.GA20980@lairds.us> Message-ID: <20060601070504.634bb122.klappnase@web.de> On Wed, 31 May 2006 21:03:01 +0000 Cameron Laird wrote: > On Wed, May 31, 2006 at 01:27:36PM -0700, Russell E. Owen wrote: > . > . > . > > That's how I manage it. It's rather ugly, but it works. I sure wish > > Tkinter had a nice table widget. > > > > Anyway, here's a code fragment (using bare Tkinter; I don't use pmw). > . > . > . > Hmmm; I take it that > isn't for you. On the other hand, you might combine http://wiki.python.org/moin/How_Tkinter_can_exploit_Tcl/Tk_extensions?highlight=%28tkinter%29 > > and . Seems like it is even easier, tktable (http://tktable.sf.net) has a python wrapper included in the demos directory. I am not sure however if the OP had some sort of table widget in mind or if every column should be populated with a variety of widgets. Michael From jaba at findyourcore.com Thu Jun 1 08:10:02 2006 From: jaba at findyourcore.com (jaba at findyourcore.com) Date: Thu, 1 Jun 2006 02:10:02 -0400 (EDT) Subject: [Tkinter-discuss] Scroll a table, but not the first two rows? In-Reply-To: <20060531094520.19281.qmail@web31102.mail.mud.yahoo.com> References: <20060531094520.19281.qmail@web31102.mail.mud.yahoo.com> Message-ID: <50008.68.239.62.234.1149142202.squirrel@findyourcore.com> yes, make two frames: one for the 'header' rows, and one for the scrolled table. > Why don't you separate the table from the header? The header should be > *outside* the ScrolledFrame, so it's not scrolled > > Chris Niekel wrote: Hi, > > I'm trying to build a window that has a table with multiple columns. I'm > using Pmw.ScrolledFrame now, creating the table with the > .grid(row=N,column=N). This works quite good, but when more rows appear > than fit in the window, the header of the column scrolls off. > > Is it possible to have the headers above the columns not scroll, but > scroll > the data below it? The columns and their header should be aligned > properly. > > Thanks, > Chris Niekel > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com From chris at niekel.net Thu Jun 1 21:39:11 2006 From: chris at niekel.net (Chris Niekel) Date: Thu, 1 Jun 2006 21:39:11 +0200 Subject: [Tkinter-discuss] Scroll a table, but not the first two rows? In-Reply-To: <20060601070504.634bb122.klappnase@web.de> References: <20060531110657.GS17400@kira.niekel.net> <20060531131858.4df4369e.klappnase@web.de> <20060531210301.GA20980@lairds.us> <20060601070504.634bb122.klappnase@web.de> Message-ID: <20060601193911.GC18602@kira.niekel.net> On Thu, Jun 01, 2006 at 07:05:04AM +0200, Michael Lange wrote: > Seems like it is even easier, tktable (http://tktable.sf.net) has a python wrapper included in the demos directory. > I am not sure however if the OP had some sort of table widget in mind or if every column > should be populated with a variety of widgets. I mostly have colors in the columns. So now (but I'm novice at tk and tkinter) I use a Label with no text, padx=20,bg='red'. (or other colors). tktable seemed daunting to install (I don't really want to find a functional compiler on windows), so I'm looking at the other options for now. Thanks for the tips so far! Chris From fredrik at pythonware.com Fri Jun 2 14:34:27 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 2 Jun 2006 14:34:27 +0200 Subject: [Tkinter-discuss] Scroll a table, but not the first two rows? References: <20060531110657.GS17400@kira.niekel.net><20060531131858.4df4369e.klappnase@web.de><20060531210301.GA20980@lairds.us><20060601070504.634bb122.klappnase@web.de> <20060601193911.GC18602@kira.niekel.net> Message-ID: Chris Niekel wrote: > I mostly have colors in the columns. So now (but I'm novice at tk and > tkinter) I use a Label with no text, padx=20,bg='red'. (or other colors). so it's a plain display table ? maybe something like this http://effbot.org/zone/wck.htm could help; e.g. the listview widget in http://effbot.org/zone/wck-4.htm could be tweaked to do exactly what you want (make sure you skim the earlier articles too, before you start hacking). From russblau at hotmail.com Mon Jun 5 19:13:05 2006 From: russblau at hotmail.com (Russell Blau) Date: Mon, 5 Jun 2006 13:13:05 -0400 Subject: [Tkinter-discuss] update_idletasks problem Message-ID: I have an application with a button that calls a method that retrieves a page from an external wiki, so it can take a while. I want to use an hourglass/watch cursor to indicate to the user that the page is loading. All the documentation suggests that the way to do this is as follows: def my_slow_method(self): self['cursor'] = 'watch' self.update_idletasks() retrieve_page_from_wiki() # placeholder for my slow retrieve function self['cursor'] = '' where "self" is my Tkinter application, defined as a subclass of Tkinter.Frame. The only problem is, this doesn't work. The cursor never changes to the hourglass! If I comment out the last line, it does change to an hourglass *after* retrieving the page from the wiki, but obviously that's not what I want to do. What's wrong? I'm running Python 2.4 on Windows XP. From haofast2006 at hotmail.com Tue Jun 6 12:24:45 2006 From: haofast2006 at hotmail.com (V H) Date: Tue, 06 Jun 2006 10:24:45 +0000 Subject: [Tkinter-discuss] a question on the top level window Message-ID: Hi all, I use a button to generate a toplevel window. I hope only one such window is existing before I close it manually. But now each time when I click the button a new window is created. How can I do? How do I bind a function to the close of the window by clicking the cross in the up-right side? Following is a example program. You solution or suggetstiong is very appreciated . regards, Vning from Tkinter import * root = Tk() class App: def __init__(self, master): c = Button(master, text="Only one") c.bind("", lambda e, s=self:s.cb(master)) c.pack() def cb(self,master):#, event): win = Toplevel(master) win.title("one") frame= Frame(win) b=Button(frame, text='ok', command=win.quit) b.pack() frame.pack() app=App(root) root.mainloop() _________________________________________________________________ Don't just search. Find. Check out the new MSN Search! http://search.msn.com/ From fredrik at pythonware.com Tue Jun 6 12:52:26 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 06 Jun 2006 12:52:26 +0200 Subject: [Tkinter-discuss] a question on the top level window In-Reply-To: References: Message-ID: V H wrote: > Hi all, > > I use a button to generate a toplevel window. I hope only one such window > is existing before I close it manually. But now each time when I click the > button a new window is created. How can I do? > > How do I bind a function to the close of the window by clicking the cross in > the up-right side? look for "WM_DELETE_WINDOW" on this page: http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm From russblau at hotmail.com Tue Jun 6 14:09:04 2006 From: russblau at hotmail.com (Russell Blau) Date: Tue, 6 Jun 2006 08:09:04 -0400 Subject: [Tkinter-discuss] update_idletasks problem References: Message-ID: Perhaps I should have called this "cursor problem." On further investigation, I disabled the command button while the page is being retrieved, and this works even though the cursor change does not. So now I've got the following code: class Application(Tkinter.Frame): def __init__(self): self.b = Button(self, text="Retrieve Page", command=self.my_slow_method) self.b.pack() def my_slow_method(self): self['cursor'] = 'watch' self.b['state'] = DISABLED self.update_idletasks() retrieve_page_from_wiki() # placeholder function self['cursor'] = '' # reset to default self.b['state'] = NORMAL While the page is being retrieved from the server, the button is disabled, but the cursor remains normal. Is this a Windows problem, or is there something I can do within Tkinter to get the cursor to behave as desired? From olivier.feys at googlemail.com Tue Jun 6 12:45:50 2006 From: olivier.feys at googlemail.com (Olivier Feys) Date: Tue, 06 Jun 2006 12:45:50 +0200 Subject: [Tkinter-discuss] a question on the top level window In-Reply-To: References: Message-ID: <44855CDE.5000501@googlemail.com> here is a solution : from Tkinter import * root = Tk() def callback(): print 'clicked on cross' class App: def __init__(self, master): c = Button(master, text="Only one") c.bind("", lambda e, s=self:s.cb(master)) c.pack() def cb(self,master):#, event): win = Toplevel(master) win.protocol('WM_DELETE_WINDOW',callback) win.title("one") frame= Frame(win) b=Button(frame, text='ok', command=win.quit) b.pack() frame.pack() app=App(root) root.mainloop() Olivier V H wrote: >Hi all, > >I use a button to generate a toplevel window. I hope only one such window >is existing before I close it manually. But now each time when I click the >button a new window is created. How can I do? > >How do I bind a function to the close of the window by clicking the cross in >the up-right side? > >Following is a example program. You solution or suggetstiong is very >appreciated . > >regards, >Vning > > > >from Tkinter import * >root = Tk() >class App: > def __init__(self, master): > c = Button(master, text="Only one") > c.bind("", lambda e, s=self:s.cb(master)) > c.pack() > def cb(self,master):#, event): > win = Toplevel(master) > win.title("one") > frame= Frame(win) > b=Button(frame, text='ok', command=win.quit) > b.pack() > frame.pack() >app=App(root) >root.mainloop() > >_________________________________________________________________ >Don't just search. Find. Check out the new MSN Search! >http://search.msn.com/ > >_______________________________________________ >Tkinter-discuss mailing list >Tkinter-discuss at python.org >http://mail.python.org/mailman/listinfo/tkinter-discuss > > > From olivier.feys at gmail.com Wed Jun 7 08:48:33 2006 From: olivier.feys at gmail.com (Olivier Feys) Date: Wed, 07 Jun 2006 08:48:33 +0200 Subject: [Tkinter-discuss] a question on the top level window In-Reply-To: References: Message-ID: <448676C1.4080907@gmail.com> here is a solution : from Tkinter import * root = Tk() def callback(): print 'clicked on cross' class App: def __init__(self, master): c = Button(master, text="Only one") c.bind("", lambda e, s=self:s.cb(master)) c.pack() def cb(self,master):#, event): win = Toplevel(master) win.protocol('WM_DELETE_WINDOW',callback) win.title("one") frame= Frame(win) b=Button(frame, text='ok', command=win.quit) b.pack() frame.pack() app=App(root) root.mainloop() Olivier V H wrote: >Hi all, > >I use a button to generate a toplevel window. I hope only one such window >is existing before I close it manually. But now each time when I click the >button a new window is created. How can I do? > >How do I bind a function to the close of the window by clicking the cross in >the up-right side? > >Following is a example program. You solution or suggetstiong is very >appreciated . > >regards, >Vning > > > >from Tkinter import * >root = Tk() >class App: > def __init__(self, master): > c = Button(master, text="Only one") > c.bind("", lambda e, s=self:s.cb(master)) > c.pack() > def cb(self,master):#, event): > win = Toplevel(master) > win.title("one") > frame= Frame(win) > b=Button(frame, text='ok', command=win.quit) > b.pack() > frame.pack() >app=App(root) >root.mainloop() > >_________________________________________________________________ >Don't just search. Find. Check out the new MSN Search! >http://search.msn.com/ > >_______________________________________________ >Tkinter-discuss mailing list >Tkinter-discuss at python.org >http://mail.python.org/mailman/listinfo/tkinter-discuss > > > From harlinseritt at yahoo.com Wed Jun 7 12:40:37 2006 From: harlinseritt at yahoo.com (Harlin Seritt) Date: Wed, 7 Jun 2006 03:40:37 -0700 (PDT) Subject: [Tkinter-discuss] Tkinter-discuss Digest, Vol 28, Issue 5 In-Reply-To: Message-ID: <20060607104037.97426.qmail@web52208.mail.yahoo.com> You can create a global or better: a class Flag that gets switched on whenever a toplevel windows becomes active. Harlin Seritt tkinter-discuss-request at python.org wrote: Send Tkinter-discuss mailing list submissions to tkinter-discuss at python.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/tkinter-discuss or, via email, send a message with subject or body 'help' to tkinter-discuss-request at python.org You can reach the person managing the list at tkinter-discuss-owner at python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Tkinter-discuss digest..." Today's Topics: 1. a question on the top level window (V H) 2. Re: a question on the top level window (Fredrik Lundh) 3. Re: update_idletasks problem (Russell Blau) 4. Re: a question on the top level window (Olivier Feys) 5. Re: a question on the top level window (Olivier Feys) ---------------------------------------------------------------------- Message: 1 Date: Tue, 06 Jun 2006 10:24:45 +0000 From: "V H" Subject: [Tkinter-discuss] a question on the top level window To: tkinter-discuss at python.org Message-ID: Content-Type: text/plain; format=flowed Hi all, I use a button to generate a toplevel window. I hope only one such window is existing before I close it manually. But now each time when I click the button a new window is created. How can I do? How do I bind a function to the close of the window by clicking the cross in the up-right side? Following is a example program. You solution or suggetstiong is very appreciated . regards, Vning from Tkinter import * root = Tk() class App: def __init__(self, master): c = Button(master, text="Only one") c.bind("", lambda e, s=self:s.cb(master)) c.pack() def cb(self,master):#, event): win = Toplevel(master) win.title("one") frame= Frame(win) b=Button(frame, text='ok', command=win.quit) b.pack() frame.pack() app=App(root) root.mainloop() _________________________________________________________________ Don't just search. Find. Check out the new MSN Search! http://search.msn.com/ ------------------------------ Message: 2 Date: Tue, 06 Jun 2006 12:52:26 +0200 From: Fredrik Lundh Subject: Re: [Tkinter-discuss] a question on the top level window To: tkinter-discuss at python.org Message-ID: Content-Type: text/plain; charset=ISO-8859-1; format=flowed V H wrote: > Hi all, > > I use a button to generate a toplevel window. I hope only one such window > is existing before I close it manually. But now each time when I click the > button a new window is created. How can I do? > > How do I bind a function to the close of the window by clicking the cross in > the up-right side? look for "WM_DELETE_WINDOW" on this page: http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm ------------------------------ Message: 3 Date: Tue, 6 Jun 2006 08:09:04 -0400 From: "Russell Blau" Subject: Re: [Tkinter-discuss] update_idletasks problem To: tkinter-discuss at python.org Message-ID: Perhaps I should have called this "cursor problem." On further investigation, I disabled the command button while the page is being retrieved, and this works even though the cursor change does not. So now I've got the following code: class Application(Tkinter.Frame): def __init__(self): self.b = Button(self, text="Retrieve Page", command=self.my_slow_method) self.b.pack() def my_slow_method(self): self['cursor'] = 'watch' self.b['state'] = DISABLED self.update_idletasks() retrieve_page_from_wiki() # placeholder function self['cursor'] = '' # reset to default self.b['state'] = NORMAL While the page is being retrieved from the server, the button is disabled, but the cursor remains normal. Is this a Windows problem, or is there something I can do within Tkinter to get the cursor to behave as desired? ------------------------------ Message: 4 Date: Tue, 06 Jun 2006 12:45:50 +0200 From: Olivier Feys Subject: Re: [Tkinter-discuss] a question on the top level window To: V H Cc: tkinter-discuss at python.org Message-ID: <44855CDE.5000501 at googlemail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed here is a solution : from Tkinter import * root = Tk() def callback(): print 'clicked on cross' class App: def __init__(self, master): c = Button(master, text="Only one") c.bind("", lambda e, s=self:s.cb(master)) c.pack() def cb(self,master):#, event): win = Toplevel(master) win.protocol('WM_DELETE_WINDOW',callback) win.title("one") frame= Frame(win) b=Button(frame, text='ok', command=win.quit) b.pack() frame.pack() app=App(root) root.mainloop() Olivier V H wrote: >Hi all, > >I use a button to generate a toplevel window. I hope only one such window >is existing before I close it manually. But now each time when I click the >button a new window is created. How can I do? > >How do I bind a function to the close of the window by clicking the cross in >the up-right side? > >Following is a example program. You solution or suggetstiong is very >appreciated . > >regards, >Vning > > > >from Tkinter import * >root = Tk() >class App: > def __init__(self, master): > c = Button(master, text="Only one") > c.bind("", lambda e, s=self:s.cb(master)) > c.pack() > def cb(self,master):#, event): > win = Toplevel(master) > win.title("one") > frame= Frame(win) > b=Button(frame, text='ok', command=win.quit) > b.pack() > frame.pack() >app=App(root) >root.mainloop() > >_________________________________________________________________ >Don't just search. Find. Check out the new MSN Search! >http://search.msn.com/ > >_______________________________________________ >Tkinter-discuss mailing list >Tkinter-discuss at python.org >http://mail.python.org/mailman/listinfo/tkinter-discuss > > > ------------------------------ Message: 5 Date: Wed, 07 Jun 2006 08:48:33 +0200 From: Olivier Feys Subject: Re: [Tkinter-discuss] a question on the top level window To: V H Cc: tkinter-discuss at python.org Message-ID: <448676C1.4080907 at gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed here is a solution : from Tkinter import * root = Tk() def callback(): print 'clicked on cross' class App: def __init__(self, master): c = Button(master, text="Only one") c.bind("", lambda e, s=self:s.cb(master)) c.pack() def cb(self,master):#, event): win = Toplevel(master) win.protocol('WM_DELETE_WINDOW',callback) win.title("one") frame= Frame(win) b=Button(frame, text='ok', command=win.quit) b.pack() frame.pack() app=App(root) root.mainloop() Olivier V H wrote: >Hi all, > >I use a button to generate a toplevel window. I hope only one such window >is existing before I close it manually. But now each time when I click the >button a new window is created. How can I do? > >How do I bind a function to the close of the window by clicking the cross in >the up-right side? > >Following is a example program. You solution or suggetstiong is very >appreciated . > >regards, >Vning > > > >from Tkinter import * >root = Tk() >class App: > def __init__(self, master): > c = Button(master, text="Only one") > c.bind("", lambda e, s=self:s.cb(master)) > c.pack() > def cb(self,master):#, event): > win = Toplevel(master) > win.title("one") > frame= Frame(win) > b=Button(frame, text='ok', command=win.quit) > b.pack() > frame.pack() >app=App(root) >root.mainloop() > >_________________________________________________________________ >Don't just search. Find. Check out the new MSN Search! >http://search.msn.com/ > >_______________________________________________ >Tkinter-discuss mailing list >Tkinter-discuss at python.org >http://mail.python.org/mailman/listinfo/tkinter-discuss > > > ------------------------------ _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss at python.org http://mail.python.org/mailman/listinfo/tkinter-discuss End of Tkinter-discuss Digest, Vol 28, Issue 5 ********************************************** __________________________________________________ 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/20060607/55d955d1/attachment.html From dblank at brynmawr.edu Sat Jun 10 23:50:54 2006 From: dblank at brynmawr.edu (dblank at brynmawr.edu) Date: Sat, 10 Jun 2006 17:50:54 -0400 (EDT) Subject: [Tkinter-discuss] tag_bind causes memory leak; fix? Message-ID: <48311.68.34.179.248.1149976254.squirrel@webmail.brynmawr.edu> Tkinter users, I have a Tkinter app that redraws objects on a canvas, about 10 times a second. It doesn't reuse the drawn objects, it just draws and deletes. In order to make it so that we can click on these objects, we have code like: self.simulator.canvas.tag_bind("robot-%s" % self.name, "", func=lambda event,robot=self:self.mouse_event(event, "motion", robot)) for each object (a robot). First, is there a better way than doing this after every object creation? One problem with this method is that it appears to cause a memory leak. Trying to unbind these, like: self.simulator.canvas.unbind_all("") or this method: self.simulator.canvas.tag_unbind("robot-%s" % self.name, "") doesn't seem to help. Any ideas on a better way, or how to stop the memory leak? Thanks! -Doug From fredrik at pythonware.com Sun Jun 11 11:38:12 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 11 Jun 2006 11:38:12 +0200 Subject: [Tkinter-discuss] tag_bind causes memory leak; fix? In-Reply-To: <48311.68.34.179.248.1149976254.squirrel@webmail.brynmawr.edu> References: <48311.68.34.179.248.1149976254.squirrel@webmail.brynmawr.edu> Message-ID: dblank at brynmawr.edu wrote: > In order to make it so that we can click on these objects, we have code like: > > self.simulator.canvas.tag_bind("robot-%s" % self.name, "", > func=lambda event,robot=self:self.mouse_event(event, "motion", robot)) > > for each object (a robot). First, is there a better way than doing this > after every object creation? I'd recommend using a canvas-level binding instead, and using find_overlapping to find the appropriate object for each mouse event. e.g. def motion(event): widget = event.widget x = widget.canvasx(event.x) y = widget.canvasy(event.y) d = 5 # overlap, in canvas units items = widget.find_overlapping(x-d, y-d, x+d, y+d) if items: ... process items; topmost is last ... canvas.bind("", motion) (I'd also recommend using a WCK view instead of the Canvas for this purpose, but that won't help you with the bindings issue). From dblank at brynmawr.edu Sun Jun 11 16:53:24 2006 From: dblank at brynmawr.edu (dblank at brynmawr.edu) Date: Sun, 11 Jun 2006 10:53:24 -0400 (EDT) Subject: [Tkinter-discuss] tag_bind causes memory leak; fix! In-Reply-To: References: <48311.68.34.179.248.1149976254.squirrel@webmail.brynmawr.edu> Message-ID: <37298.68.34.179.248.1150037604.squirrel@webmail.brynmawr.edu> > dblank at brynmawr.edu wrote: > >> In order to make it so that we can click on these objects, we have code >> like: >> >> self.simulator.canvas.tag_bind("robot-%s" % self.name, "", >> func=lambda event,robot=self:self.mouse_event(event, "motion", >> robot)) >> >> for each object (a robot). First, is there a better way than doing this >> after every object creation? > Fredrik Lundh said: > I'd recommend using a canvas-level binding instead, and using > find_overlapping to find the appropriate object for each mouse event. > e.g. > > def motion(event): > widget = event.widget > x = widget.canvasx(event.x) > y = widget.canvasy(event.y) > d = 5 # overlap, in canvas units > items = widget.find_overlapping(x-d, y-d, x+d, y+d) > if items: > ... process items; topmost is last ... > > canvas.bind("", motion) Excellent! This solved the "momery leak" and is much more efficient (so that we don't have to rebind these events to new objects 10 times a second). I have posted my adapted solution below. The only sticking point was that this method doesn't have state about what you were clicking on. Actually, now that I say that, I'm not sure why it worked before with object-level bindings. > (I'd also recommend using a WCK view instead of the Canvas for this > purpose, but that won't help you with the bindings issue). When it comes time to rewrite this, I will carefully look at WCK. For now, this is just a very important bug fix (was losing about a megabyte of memory a second). Thanks again! -Doug def dispatch_event(self, event, type): widget = event.widget x = widget.canvasx(event.x) y = widget.canvasy(event.y) d = 5 # overlap, in canvas units items = widget.find_overlapping(x-d, y-d, x+d, y+d) for item in items: tags = self.canvas.gettags(item) for tag in tags: if "robot-" in tag: robot = self.robotsByName[tag[6:]] if "control" in type: self.lastEventRobot = robot else: self.lastEventRobot = None return robot.mouse_event(event, type, robot) if self.lastEventRobot: return self.lastEventRobot.mouse_event(event, type, self.lastEventRobot) def addMouseBindings(self): self.canvas.bind("", func=lambda event=self:self.dispatch_event(event, "motion")) self.canvas.bind("", func=lambda event=self:self.dispatch_event(event, "down")) ... > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From blenderkid at web.de Wed Jun 14 15:54:50 2006 From: blenderkid at web.de (Jan Filip Tristan) Date: Wed, 14 Jun 2006 15:54:50 +0200 Subject: [Tkinter-discuss] Tabbar Message-ID: is there a TabBar for Tkinter like for Qt From geon at post.cz Thu Jun 15 20:28:25 2006 From: geon at post.cz (Pavel Kosina) Date: Thu, 15 Jun 2006 20:28:25 +0200 Subject: [Tkinter-discuss] animated gif Message-ID: <4491A6C9.4040905@post.cz> Hi all, How to animate an animated gif? I made some trials, using metod seek() on instance of Image.open, cause I believe Tkinter can not do this itself, but no success. My gif got 2 frames, and the second one is always more or less black. This script is not "animated", just want to show my approach to the problem: from Tkinter import * from PIL import Image, ImageTk hlavni=Tk() platno=Canvas(hlavni) platno.pack() image = Image.open("myani.gif") frames=[] for frame in range(2): image.seek(frame) frames.append(ImageTk.PhotoImage(image)) platno.create_image(50,50, image=frames[0]) platno.create_image(100,100, image=frames[1]) hlavni.mainloop() Thank you all for any suggestion. -- geon Pavel Kosina From Cameron at phaseit.net Thu Jun 15 20:48:11 2006 From: Cameron at phaseit.net (Cameron Laird) Date: Thu, 15 Jun 2006 18:48:11 +0000 Subject: [Tkinter-discuss] animated gif In-Reply-To: <4491A6C9.4040905@post.cz> References: <4491A6C9.4040905@post.cz> Message-ID: <20060615184811.GA4020@lairds.us> On Thu, Jun 15, 2006 at 08:28:25PM +0200, Pavel Kosina wrote: . . . > How to animate an animated gif? I made some trials, using metod seek() > on instance of Image.open, cause I believe Tkinter can not do this > itself, but no success. My gif got 2 frames, and the second one is > always more or less black. > > This script is not "animated", just want to show my approach to the problem: > > from Tkinter import * > from PIL import Image, ImageTk > > hlavni=Tk() > platno=Canvas(hlavni) > platno.pack() > > image = Image.open("myani.gif") > frames=[] > for frame in range(2): > image.seek(frame) > frames.append(ImageTk.PhotoImage(image)) > > platno.create_image(50,50, image=frames[0]) > platno.create_image(100,100, image=frames[1]) > > hlavni.mainloop() . . . 1. I wrote a gif animator for Tk: . 2. While I'm busy today, maybe on the weekend I'll adapt it to Tkinter and comment on what you've written. From harlinseritt at yahoo.com Sat Jun 17 23:02:21 2006 From: harlinseritt at yahoo.com (Harlin Seritt) Date: Sat, 17 Jun 2006 14:02:21 -0700 (PDT) Subject: [Tkinter-discuss] Tkinter-discuss Digest, Vol 28, Issue 9 In-Reply-To: Message-ID: <20060617210221.55267.qmail@web52202.mail.yahoo.com> Not sure exactly what a Qt tab-bar is. If you mean something like the bar on the top of your web browser that uses buttons w/ icons then you'll have to make a bar using a frame in Tkinter. Luckily this is not hard to do with Python/Tkinter. Harlin Seritt tkinter-discuss-request at python.org wrote: Send Tkinter-discuss mailing list submissions to tkinter-discuss at python.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/tkinter-discuss or, via email, send a message with subject or body 'help' to tkinter-discuss-request at python.org You can reach the person managing the list at tkinter-discuss-owner at python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Tkinter-discuss digest..." Today's Topics: 1. Tabbar (Jan Filip Tristan) ---------------------------------------------------------------------- Message: 1 Date: Wed, 14 Jun 2006 15:54:50 +0200 From: Jan Filip Tristan Subject: [Tkinter-discuss] Tabbar To: tkinter-discuss at python.org Message-ID: Content-Type: text/plain; charset=us-ascii is there a TabBar for Tkinter like for Qt ------------------------------ _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss at python.org http://mail.python.org/mailman/listinfo/tkinter-discuss End of Tkinter-discuss Digest, Vol 28, Issue 9 ********************************************** --------------------------------- New Yahoo! Messenger with Voice. Call regular phones from your PC and save big. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20060617/3ef8b65c/attachment.html From Ilknur.Ozturk at cabot.com.tr Mon Jun 19 15:12:33 2006 From: Ilknur.Ozturk at cabot.com.tr (Ilknur Ozturk) Date: Mon, 19 Jun 2006 16:12:33 +0300 Subject: [Tkinter-discuss] some key symbols Message-ID: <79CD3DAD56583A4298D4941761CF687A502F68@cabottrexch.cabot.local> Hi all, I am using keyboard to send the parameters to my functions. (event.keysym), but some of the keys are not working. Those are +, - and Break. The keysym for those keys in Tkinter book are defined as Add, Subtruct and Cancel . Is there anyone else who knows the correct symbols? Thanks, ilknur ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com ********************************************************************** ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20060619/7314fb32/attachment.htm From fredrik at pythonware.com Mon Jun 19 15:42:34 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 19 Jun 2006 15:42:34 +0200 Subject: [Tkinter-discuss] some key symbols In-Reply-To: <79CD3DAD56583A4298D4941761CF687A502F68@cabottrexch.cabot.local> References: <79CD3DAD56583A4298D4941761CF687A502F68@cabottrexch.cabot.local> Message-ID: Ilknur Ozturk wrote: > I am using keyboard to send the parameters to my functions. > (event.keysym), but some of the keys are not working. Those are +, - and > Break. The keysym for those keys in Tkinter book are defined as /Add, > Subtruct/ and /Cancel . /Is there anyone else who knows the correct > symbols? plus, minus, and Cancel sounds more likely. here's a little program that prints the keysym when you press a key: import Tkinter def callback(e): print e.keysym, repr(e.char) w = Tkinter.Frame(width=512, height=512) w.bind("", callback) w.focus_set() w.pack() w.mainloop() From mikejaysteiner at yahoo.com Tue Jun 20 18:40:37 2006 From: mikejaysteiner at yahoo.com (Mike Steiner) Date: Tue, 20 Jun 2006 09:40:37 -0700 (PDT) Subject: [Tkinter-discuss] creating widgets generically, with a loop? Message-ID: <20060620164037.64147.qmail@web33112.mail.mud.yahoo.com> Some background info: I have a Python/Tkinter script that displays a dialog with buttons, where each button launches a file for editing. Sort of like an HTML file in a browser, except with my script I can launch it using a particular program. I've been trying to figure out a way of storing widget information (name of each widget, x and y positions, and a command to execute when activated) in an array so I can generically create each widget instead of hard-coding all the information. For example, here's a snippet of what I currently use: ... Button(top, text="OO design info", command=self.launch_file23).grid(sticky="w",row=10,column=5) ... ... def launch_file23 ( self ): os.spawnl ( os.P_NOWAIT , "c:\\Program Files\\TextPad 4\\TextPad.exe" , "TextPad.exe" , "d:\\My Documents\\prog_oo_design.txt" ) ... If there was a way I could pass arguments to launch_file23 from the "command=" parameter, that would solve the problem nicely - I could store the info in an array, and then just loop to create the buttons. Any ideas? Michael Steiner MikeJaySteiner at yahoo.com (480) 720-8902 (cell) __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From Cameron at phaseit.net Tue Jun 20 20:43:21 2006 From: Cameron at phaseit.net (Cameron Laird) Date: Tue, 20 Jun 2006 18:43:21 +0000 Subject: [Tkinter-discuss] writing a function to create button In-Reply-To: <79CD3DAD56583A4298D4941761CF687A448769@cabottrexch.cabot.local> References: <79CD3DAD56583A4298D4941761CF687A448769@cabottrexch.cabot.local> Message-ID: <20060620184321.GA12139@lairds.us> On Fri, May 05, 2006 at 04:53:30PM +0300, Ilknur Ozturk wrote: . . . > Actually my aim is a little bit different. I put one of the buttons in > my code; > > button_name = "menu" > self.menu = Button(self.mycontainer, > command=lambda > arg1=button_name: > self.writecommand(arg1) > ) > self.menu.configure(text="menu") > self.menu.grid(row=2, column=0) > ch = "" > self.menu.bind(ch, > lambda > event, arg1=button_name: > self.writecommand(arg1) > ) > > This part repeatedly occurs in my code for different buttons, but those > buttons placed in a different frames (not each in one, group by group) > > For each button, button_name, configuration and geometry are changing. > It can be divided 2 or more functions if it can be achieved in any way. . . . This confuses me. I'm trying to catch up on a few loose ends; I'm in arrears by weeks. I've re-read this thread, and I still don't understand the aim. I'm confident, though, that there are easier ways to meet the true requirements. Is the intent to work with Buttons, or Menubuttons? It's quite unusual to need to bind conventional events to Buttons; it's more typical to rely on .command. My suggestion: simplify your question down to a more "atomic" one. There are too many things going on in the code above for me to understand. From Cameron at phaseit.net Tue Jun 20 21:16:58 2006 From: Cameron at phaseit.net (Cameron Laird) Date: Tue, 20 Jun 2006 19:16:58 +0000 Subject: [Tkinter-discuss] Tabbar In-Reply-To: References: Message-ID: <20060620191657.GB19351@lairds.us> On Wed, Jun 14, 2006 at 03:54:50PM +0200, Jan Filip Tristan wrote: . . . > is there a TabBar for Tkinter like for Qt . . . No. Well, yes. Sort of. The Tk tradition, on which Tkinter largely is built, is to code in terms of "notebook" widgets . An example appears here: . PMW has a notebook, and there are several others. From mkieverpy at tlink.de Wed Jun 21 08:54:14 2006 From: mkieverpy at tlink.de (mkieverpy at tlink.de) Date: Wed, 21 Jun 2006 08:54:14 +0200 Subject: [Tkinter-discuss] creating widgets generically, with a loop? Message-ID: <4498ed16535783.64209823@> > > Some background info: I have a Python/Tkinter script that displays a > dialog with buttons, where each button launches a file for editing. > Sort of like an HTML file in a browser, except with my script I can > launch it using a particular program. > > I've been trying to figure out a way of storing widget information > (name of each widget, x and y positions, and a command to execute > when activated) in an array so I can generically create each widget > instead of hard-coding all the information. For example, here's a > snippet of what I currently use: > > ... > Button(top, text="OO design info", > command=self.launch_file23).grid(sticky="w",row=10,column=5) > ... > > ... > def launch_file23 ( self ): os.spawnl ( os.P_NOWAIT , > "c:\\Program Files\\TextPad 4\\TextPad.exe" , "TextPad.exe" , "d:\\My > > > Documents\\prog_oo_design.txt" ) > ... > > If there was a way I could pass arguments to launch_file23 from the > "command=" parameter, that would solve the problem nicely - I could > store the info in an array, and then just loop to create the buttons. > > Any ideas? > > > Michael Steiner > MikeJaySteiner at yahoo.com > (480) 720-8902 (cell) > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss An idea using subclassing of 'Button': -------------------------------------------------- from Tkinter import * class ButtonParam ( Button ): def __init__ ( self, param, parent, **kw ): Button.__init__ ( self, parent, kw ) self.Param = param def launch ( self ): print 'My Param:', self.Param if __name__ == '__main__': tk = Tk () for bspec in [('text1','par1'),('text2','par2'),('text3','par3')]: b = ButtonParam ( bspec [1], tk, text=bspec [0] ) b.configure ( command=b.launch ) b.pack () tk.mainloop () ------------------------------------------------------------------ Perhaps the parameters to __init__ need additional tweaking and you might want more than one parameter. Hope this helps, Matthias Kievernagel Software-Development mkiever/at/web/dot/de From mkieverpy at tlink.de Wed Jun 21 08:54:08 2006 From: mkieverpy at tlink.de (mkieverpy at tlink.de) Date: Wed, 21 Jun 2006 08:54:08 +0200 Subject: [Tkinter-discuss] creating widgets generically, with a loop? Message-ID: <4498ed103d7420.54942924@> > > Some background info: I have a Python/Tkinter script that displays a > dialog with buttons, where each button launches a file for editing. > Sort of like an HTML file in a browser, except with my script I can > launch it using a particular program. > > I've been trying to figure out a way of storing widget information > (name of each widget, x and y positions, and a command to execute > when activated) in an array so I can generically create each widget > instead of hard-coding all the information. For example, here's a > snippet of what I currently use: > > ... > Button(top, text="OO design info", > command=self.launch_file23).grid(sticky="w",row=10,column=5) > ... > > ... > def launch_file23 ( self ): os.spawnl ( os.P_NOWAIT , > "c:\\Program Files\\TextPad 4\\TextPad.exe" , "TextPad.exe" , "d:\\My > > > Documents\\prog_oo_design.txt" ) > ... > > If there was a way I could pass arguments to launch_file23 from the > "command=" parameter, that would solve the problem nicely - I could > store the info in an array, and then just loop to create the buttons. > > Any ideas? > > > Michael Steiner > MikeJaySteiner at yahoo.com > (480) 720-8902 (cell) > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss An idea using subclassing of 'Button': -------------------------------------------------- from Tkinter import * class ButtonParam ( Button ): def __init__ ( self, param, parent, **kw ): Button.__init__ ( self, parent, kw ) self.Param = param def launch ( self ): print 'My Param:', self.Param if __name__ == '__main__': tk = Tk () for bspec in [('text1','par1'),('text2','par2'),('text3','par3')]: b = ButtonParam ( bspec [1], tk, text=bspec [0] ) b.configure ( command=b.launch ) b.pack () tk.mainloop () ------------------------------------------------------------------ Perhaps the parameters to __init__ need additional tweaking and you might want more than one parameter. Hope this helps, Matthias Kievernagel Software-Development mkiever/at/web/dot/de From mfranklin1 at gatwick.westerngeco.slb.com Wed Jun 21 11:13:54 2006 From: mfranklin1 at gatwick.westerngeco.slb.com (Martin Franklin) Date: Wed, 21 Jun 2006 10:13:54 +0100 Subject: [Tkinter-discuss] creating widgets generically, with a loop? In-Reply-To: <20060620164037.64147.qmail@web33112.mail.mud.yahoo.com> References: <20060620164037.64147.qmail@web33112.mail.mud.yahoo.com> Message-ID: <44990DD2.8040807@gatwick.westerngeco.slb.com> Mike Steiner wrote: > Some background info: I have a Python/Tkinter script that displays a > dialog with buttons, where each button launches a file for editing. > Sort of like an HTML file in a browser, except with my script I can > launch it using a particular program. > > I've been trying to figure out a way of storing widget information > (name of each widget, x and y positions, and a command to execute > when activated) in an array so I can generically create each widget > instead of hard-coding all the information. For example, here's a > snippet of what I currently use: > > ... > Button(top, text="OO design info", > command=self.launch_file23).grid(sticky="w",row=10,column=5) > ... > > ... > def launch_file23 ( self ): os.spawnl ( os.P_NOWAIT , > "c:\\Program Files\\TextPad 4\\TextPad.exe" , "TextPad.exe" , "d:\\My > > > Documents\\prog_oo_design.txt" ) > ... > > If there was a way I could pass arguments to launch_file23 from the > "command=" parameter, that would solve the problem nicely - I could > store the info in an array, and then just loop to create the buttons. > > Any ideas? > Perhaps: my_buttons = [ ## fullpath names should be used here but for the sake of wrapping ("OO design info", "TextPad.exe", "oo_design.txt"), ("AA design info", "TextPad.exe", "aa_design.txt"), ("ZZ design info", "TextPad.exe", "zz_design.txt"), ] def launchit(external, filename): external_short = os.path.split()[1] def real_launchitit(): os.spawnl(os.P_NOWAIT, external, external_short, filename) return real_launchit for text, external, filename in my_buttons: b = Button(self, text=text, command=self.launchit(external, filename)) b.grid() From olivier.feys at gmail.com Wed Jun 21 12:08:50 2006 From: olivier.feys at gmail.com (Olivier Feys) Date: Wed, 21 Jun 2006 12:08:50 +0200 Subject: [Tkinter-discuss] application busy problem Message-ID: <44991AB2.3080205@gmail.com> Hi, I'm using Tkinter to create an application which parses some huge text files (from 50kb to 120Mb). When the files are being parsed, I would like to forbid the user to do anything else and to show the application is busy(like an icon that turns over itself), because when he clicks on anything, the application fails. Olivier From mikejaysteiner at yahoo.com Wed Jun 21 17:29:29 2006 From: mikejaysteiner at yahoo.com (Mike Steiner) Date: Wed, 21 Jun 2006 08:29:29 -0700 (PDT) Subject: [Tkinter-discuss] creating widgets generically, with a loop? In-Reply-To: <44990DD2.8040807@gatwick.westerngeco.slb.com> Message-ID: <20060621152929.34054.qmail@web33110.mail.mud.yahoo.com> Does this work - does the "command=" parameter allow the function value to contain parameters too? If so, it would solve the problem easily! --- Martin Franklin wrote: > [ stuff omitted ] > for text, external, filename in my_buttons: > b = Button(self, text=text, command=self.launchit(external, > filename)) > b.grid() Michael Steiner MikeJaySteiner at yahoo.com __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From fredrik at pythonware.com Wed Jun 21 17:31:31 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 21 Jun 2006 17:31:31 +0200 Subject: [Tkinter-discuss] creating widgets generically, with a loop? In-Reply-To: <20060621152929.34054.qmail@web33110.mail.mud.yahoo.com> References: <44990DD2.8040807@gatwick.westerngeco.slb.com> <20060621152929.34054.qmail@web33110.mail.mud.yahoo.com> Message-ID: Mike Steiner wrote: > Does this work - does the "command=" parameter allow the function > value to contain parameters too? If so, it would solve the problem > easily! the code *calls* the given method, and passes the return value (in this case, an instance of the inner function) to the Button constructor. > --- Martin Franklin wrote: >> [ stuff omitted ] >> for text, external, filename in my_buttons: >> b = Button(self, text=text, command=self.launchit(external, >> filename)) >> b.grid() > > > Michael Steiner > MikeJaySteiner at yahoo.com > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com From Cameron at phaseit.net Wed Jun 21 17:42:41 2006 From: Cameron at phaseit.net (Cameron Laird) Date: Wed, 21 Jun 2006 15:42:41 +0000 Subject: [Tkinter-discuss] creating widgets generically, with a loop? In-Reply-To: References: <44990DD2.8040807@gatwick.westerngeco.slb.com> <20060621152929.34054.qmail@web33110.mail.mud.yahoo.com> Message-ID: <20060621154241.GA16943@lairds.us> On Wed, Jun 21, 2006 at 05:31:31PM +0200, Fredrik Lundh wrote: . . . > > Does this work - does the "command=" parameter allow the function > > value to contain parameters too? If so, it would solve the problem > > easily! > > the code *calls* the given method, and passes the return value (in this > case, an instance of the inner function) to the Button constructor. . . . While I've largely lost track now of who said and/or wants what, it *is* true, though, that .command can be parametrized, at a couple of different level, if that's what's required. From fredrik at pythonware.com Wed Jun 21 17:52:53 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 21 Jun 2006 17:52:53 +0200 Subject: [Tkinter-discuss] creating widgets generically, with a loop? In-Reply-To: <20060621154241.GA16943@lairds.us> References: <44990DD2.8040807@gatwick.westerngeco.slb.com> <20060621152929.34054.qmail@web33110.mail.mud.yahoo.com> <20060621154241.GA16943@lairds.us> Message-ID: Cameron Laird wrote: . > While I've largely lost track now of who said and/or wants what, > it *is* true, though, that .command can be parametrized, at a > couple of different level, if that's what's required. that's what martin's example does, of course -- mike appeared to think that the command=foo(bar) syntax meant that "foo" was a callback, rather than a function producing a callback. From klappnase at web.de Wed Jun 21 22:54:46 2006 From: klappnase at web.de (Michael Lange) Date: Wed, 21 Jun 2006 22:54:46 +0200 Subject: [Tkinter-discuss] application busy problem In-Reply-To: <44991AB2.3080205@gmail.com> References: <44991AB2.3080205@gmail.com> Message-ID: <20060621225446.2f384bfd.klappnase@web.de> On Wed, 21 Jun 2006 12:08:50 +0200 Olivier Feys wrote: > Hi, > > I'm using Tkinter to create an application which parses some huge text > files (from 50kb to 120Mb). When the files are being parsed, I would > like to forbid the user to do anything else and to show the application > is busy(like an icon that turns over itself), because when he clicks on > anything, the application fails. > > Hi Olivier, you probably want a dialog window that grabs all events: top = Toplevel() top.transient(rootwindow) top.grab_set() Label(top, text="Computing, please wait...").pack() The call to transient() makes the dialog always stay on top of the application's root window, grab_set() prevents any events from being delivered to other windows in your app. I hope this helps Michael From jmcmonagle at velseis.com.au Thu Jun 22 06:24:46 2006 From: jmcmonagle at velseis.com.au (John McMonagle) Date: Thu, 22 Jun 2006 14:24:46 +1000 Subject: [Tkinter-discuss] Mouse wheel event for Canvas Message-ID: <1150950286.5055.12.camel@kuepper.vels-int.com.au> I tried binding mouse wheel events (, ) to a Tkinter Canvas widget with the hope of using the event.delta value to subsequently scroll the Canvas. However, it seems that event.delta always returns 0. For example, from Tkinter import * r = Tk() c = Canvas(r, scrollregion=(0,0,500,500), height=200, width=200) s = Scrollbar(r, command=c.yview) c.pack(side=LEFT) s.pack(side=RIGHT, fill=Y) c.configure(yscrollcommand=s.set) c.create_rectangle(10,10,100,100) c.create_rectangle(10,200,100,300) def rollWheel(event): print event.delta c.bind('', rollWheel) c.bind('', rollWheel) c.focus_set() r.mainloop() Has anyone successfully managed to wheel scroll a Tkinter Canvas widget ? Regards, John -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. From mfranklin1 at gatwick.westerngeco.slb.com Thu Jun 22 09:15:08 2006 From: mfranklin1 at gatwick.westerngeco.slb.com (Martin Franklin) Date: Thu, 22 Jun 2006 08:15:08 +0100 Subject: [Tkinter-discuss] creating widgets generically, with a loop? In-Reply-To: <20060621152929.34054.qmail@web33110.mail.mud.yahoo.com> References: <20060621152929.34054.qmail@web33110.mail.mud.yahoo.com> Message-ID: <449A437C.6000307@gatwick.westerngeco.slb.com> Mike Steiner wrote: > Does this work - does the "command=" parameter allow the function > value to contain parameters too? If so, it would solve the problem > easily! > > --- Martin Franklin wrote: >> [ stuff omitted ] >> for text, external, filename in my_buttons: >> b = Button(self, text=text, command=self.launchit(external, >> filename)) >> b.grid() > Mike, Sorry I should have provided some doc strings ;) The magic in my example is here:- ## this function is called when you create the Button widget def launchit(external, filename): external_short = os.path.split()[1] ## this inner function has access to the outer functions ## namespace def real_launchit(): os.spawnl(os.P_NOWAIT, external, external_short, filename) ## return a reference to the inner function ## this 'reference to a function' will be called when the button ## is pressed return real_launchit on re-reading the example I noticed I had made a couple of typoes Cheers Martin From olivier.feys at gmail.com Thu Jun 22 12:05:43 2006 From: olivier.feys at gmail.com (Olivier Feys) Date: Thu, 22 Jun 2006 12:05:43 +0200 Subject: [Tkinter-discuss] application busy problem In-Reply-To: <20060621225446.2f384bfd.klappnase@web.de> References: <44991AB2.3080205@gmail.com> <20060621225446.2f384bfd.klappnase@web.de> Message-ID: <449A6B77.7030001@gmail.com> Thank you for answering me Michael, Maybe my question is not well asked : Is it possible to launch an other thread, for example : - at the beginning of the application, before all the needed imports, a small window appears and displays informations or animations (gif) ? - the same thing when application is working, this time without hiding tha main window, but by inserting a small gif in the corner of the application. Michael Lange wrote: >On Wed, 21 Jun 2006 12:08:50 +0200 >Olivier Feys wrote: > > > >>Hi, >> >>I'm using Tkinter to create an application which parses some huge text >>files (from 50kb to 120Mb). When the files are being parsed, I would >>like to forbid the user to do anything else and to show the application >>is busy(like an icon that turns over itself), because when he clicks on >>anything, the application fails. >> >> >> >> > >Hi Olivier, > >you probably want a dialog window that grabs all events: > > top = Toplevel() > top.transient(rootwindow) > top.grab_set() > Label(top, text="Computing, please wait...").pack() > >The call to transient() makes the dialog always stay on top of the application's root window, >grab_set() prevents any events from being delivered to other windows in your app. > >I hope this helps > >Michael > > >_______________________________________________ >Tkinter-discuss mailing list >Tkinter-discuss at python.org >http://mail.python.org/mailman/listinfo/tkinter-discuss > > > From mikejaysteiner at yahoo.com Thu Jun 22 18:00:52 2006 From: mikejaysteiner at yahoo.com (Mike Steiner) Date: Thu, 22 Jun 2006 09:00:52 -0700 (PDT) Subject: [Tkinter-discuss] creating widgets generically, with a loop? In-Reply-To: <449A437C.6000307@gatwick.westerngeco.slb.com> Message-ID: <20060622160052.55652.qmail@web33108.mail.mud.yahoo.com> It works! Thanks for your help. I've included the complete (it's small) source file below, in case anyone's curious. ----- start of .py file ----- import os from Tkinter import * class App: def __init__( self , top ): top.geometry ( "+0+0" ) my_buttons = [ ( "button_text1" , "program_name1" , "file_name1" , 1 , 0 ) , ( "button_text2" , "program_name2" , "file_name2" , 0 , 1 ) ] for text , external , filename , row , col in my_buttons: b = Button( top , font=("Verdana",7) , pady=0 , borderwidth=0 , text=text , command=self.launchit(external,filename) ) b.grid( sticky="w" , row=row , column=col ) ## this function is called when you create the Button widget def launchit ( self , external , filename ): external_short = os.path.split( external )[1] ## this inner function has access to the outer functions ## namespace def real_launchit ( ): os.spawnl ( os.P_NOWAIT , external , external_short , filename ) ## return a reference to the inner function ## this 'reference to a function' will be called when the button ## is pressed return real_launchit root = Tk() app = App(root) root.mainloop() ----- end of .py file ----- --- Martin Franklin wrote: > Mike Steiner wrote: > > Does this work - does the "command=" parameter allow the function > > value to contain parameters too? If so, it would solve the > problem > > easily! > > > > --- Martin Franklin > wrote: > >> [ stuff omitted ] > >> for text, external, filename in my_buttons: > >> b = Button(self, text=text, command=self.launchit(external, > >> filename)) > >> b.grid() > > > > > Mike, > > > Sorry I should have provided some doc strings ;) The magic in my > example is here:- > > ## this function is called when you create the Button widget > def launchit(external, filename): > external_short = os.path.split()[1] > > ## this inner function has access to the outer functions > ## namespace > def real_launchit(): > os.spawnl(os.P_NOWAIT, external, external_short, filename) > > ## return a reference to the inner function > ## this 'reference to a function' will be called when the > button > ## is pressed > return real_launchit > > > on re-reading the example I noticed I had made a couple of typoes > > Cheers > Martin > > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > Michael Steiner MikeJaySteiner at yahoo.com __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From jmcmonagle at velseis.com.au Fri Jun 23 02:08:14 2006 From: jmcmonagle at velseis.com.au (John McMonagle) Date: Fri, 23 Jun 2006 10:08:14 +1000 Subject: [Tkinter-discuss] Mouse wheel event for Canvas In-Reply-To: <1150950286.5055.12.camel@kuepper.vels-int.com.au> References: <1150950286.5055.12.camel@kuepper.vels-int.com.au> Message-ID: <1151021294.5055.18.camel@kuepper.vels-int.com.au> On Thu, 2006-06-22 at 14:24 +1000, John McMonagle wrote: > I tried binding mouse wheel events (, ) to a Tkinter > Canvas widget with the hope of using the event.delta value to > subsequently scroll the Canvas. > > However, it seems that event.delta always returns 0. > > For example, > > from Tkinter import * > > r = Tk() > c = Canvas(r, scrollregion=(0,0,500,500), height=200, width=200) > s = Scrollbar(r, command=c.yview) > c.pack(side=LEFT) > s.pack(side=RIGHT, fill=Y) > c.configure(yscrollcommand=s.set) > c.create_rectangle(10,10,100,100) > c.create_rectangle(10,200,100,300) > > def rollWheel(event): > print event.delta > > c.bind('', rollWheel) > c.bind('', rollWheel) > > c.focus_set() > > r.mainloop() > > > Has anyone successfully managed to wheel scroll a Tkinter Canvas > widget ? > > Regards, > > John > > > I worked it out. c.bind('', lambda event: event.widget.yview_scroll(-1, UNITS)) c.bind('', lambda event: event.widget.yview_scroll(1, UNITS)) I also changed the yscrollincrement to '5p'. The default moved a bit too much. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. From klappnase at web.de Fri Jun 23 23:46:19 2006 From: klappnase at web.de (Michael Lange) Date: Fri, 23 Jun 2006 23:46:19 +0200 Subject: [Tkinter-discuss] Mouse wheel event for Canvas In-Reply-To: <1150950286.5055.12.camel@kuepper.vels-int.com.au> References: <1150950286.5055.12.camel@kuepper.vels-int.com.au> Message-ID: <20060623234619.03f1741c.klappnase@web.de> On Thu, 22 Jun 2006 14:24:46 +1000 John McMonagle wrote: > I tried binding mouse wheel events (, ) to a Tkinter > Canvas widget with the hope of using the event.delta value to > subsequently scroll the Canvas. > > However, it seems that event.delta always returns 0. > > For example, > > from Tkinter import * > > r = Tk() > c = Canvas(r, scrollregion=(0,0,500,500), height=200, width=200) > s = Scrollbar(r, command=c.yview) > c.pack(side=LEFT) > s.pack(side=RIGHT, fill=Y) > c.configure(yscrollcommand=s.set) > c.create_rectangle(10,10,100,100) > c.create_rectangle(10,200,100,300) > > def rollWheel(event): > print event.delta > > c.bind('', rollWheel) > c.bind('', rollWheel) > > c.focus_set() > > r.mainloop() > > > Has anyone successfully managed to wheel scroll a Tkinter Canvas > widget ? > Hi John, here is a code snippet I have successfully used: self.canvas.bind('<4>', lambda event : self.canvas.xview('scroll', -1, 'units')) self.canvas.bind('<5>', lambda event : self.canvas.xview('scroll', 1, 'units')) or if you do not like the lambda, you can use a callback like this: def rollWheel(event): if event.num == 4: self.canvas.xview('scroll', -1, 'units') elif event.num == 5: self.canvas.xview('scroll', 1, 'units') I hope this helps Michael From klappnase at web.de Sat Jun 24 00:07:52 2006 From: klappnase at web.de (Michael Lange) Date: Sat, 24 Jun 2006 00:07:52 +0200 Subject: [Tkinter-discuss] application busy problem In-Reply-To: <449A6B77.7030001@gmail.com> References: <44991AB2.3080205@gmail.com> <20060621225446.2f384bfd.klappnase@web.de> <449A6B77.7030001@gmail.com> Message-ID: <20060624000752.257bae5b.klappnase@web.de> On Thu, 22 Jun 2006 12:05:43 +0200 Olivier Feys wrote: > Thank you for answering me Michael, > > Maybe my question is not well asked : > > Is it possible to launch an other thread, for example : > > - at the beginning of the application, before all the needed imports, a > small window appears and displays informations or animations (gif) ? Do you mean some kind of "splash screen"? In this case try something like this: from Tkinter import * root = Tk() root.withdraw() splash = Toplevel() # fill the Toplevel with other widgets and perform # other maybe time consuming things splash.destroy() root.deiconify() > - the same thing when application is working, this time without hiding > tha main window, but by inserting a small gif in the corner of the > application. > > then you will have to disable all the widgets in the main window that might cause problems if the user clicks on them. For the "busy" icon you could use a Label and set its "image" option to the empty string when the process has finished to make the icon disappear. I hope this helps Michael From mike at pcblokes.com Tue Jun 27 13:49:35 2006 From: mike at pcblokes.com (Michael Foord) Date: Tue, 27 Jun 2006 12:49:35 +0100 Subject: [Tkinter-discuss] Button Overrelief Message-ID: <44A11B4F.2030601@pcblokes.com> Hello all, I have some Tkinter buttons that display images. I would like to change these to 'active' images when the mouse is over the button. I see that the button widget can take an 'overrelief' argument in the constructor. What values can this take ? Also - can anyone provide an example of using the equivalent of a 'mouseover' event to change the image used by a button in Tkinter ? I'm afraid google has not helped me much here. Much Appreciated, Fuzzyman http://www.voidspace.org.uk/python/index.shtml From fredrik at pythonware.com Tue Jun 27 14:43:38 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 27 Jun 2006 14:43:38 +0200 Subject: [Tkinter-discuss] Button Overrelief References: <44A11B4F.2030601@pcblokes.com> Message-ID: Michael Foord wrote: > I have some Tkinter buttons that display images. I would like to change > these to 'active' images when the mouse is over the button. > > I see that the button widget can take an 'overrelief' argument in the > constructor. What values can this take ? same as RELIEF; see http://effbot.org/tkinterbook/button.htm#Tkinter.Button.config-method > Also - can anyone provide an example of using the equivalent of a > 'mouseover' event to change the image used by a button in Tkinter ? I'm > afraid google has not helped me much here. you can use and events for this; see: http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm#events From fuzzyman at voidspace.org.uk Tue Jun 27 13:47:07 2006 From: fuzzyman at voidspace.org.uk (Fuzzyman) Date: Tue, 27 Jun 2006 12:47:07 +0100 Subject: [Tkinter-discuss] Button Overrelief Message-ID: <44A11ABB.5050805@voidspace.org.uk> Hello all, I have some Tkinter buttons that display images. I would like to change these to 'active' images when the mouse is over the button. I see that the button widget can take an 'overrelief' argument in the constructor. What values can this take ? Also - can anyone provide an example of using the equivalent of a 'mouseover' event to change the image used by a button in Tkinter ? I'm afraid google has not helped me much here. Much Appreciated, Fuzzyman http://www.voidspace.org.uk/python/index.shtml From mike at pcblokes.com Thu Jun 29 22:03:44 2006 From: mike at pcblokes.com (Michael Foord) Date: Thu, 29 Jun 2006 21:03:44 +0100 Subject: [Tkinter-discuss] Button Overrelief In-Reply-To: References: <44A11B4F.2030601@pcblokes.com> Message-ID: <44A43220.809@pcblokes.com> Fredrik Lundh wrote: > Michael Foord wrote: > > >> I have some Tkinter buttons that display images. I would like to change >> these to 'active' images when the mouse is over the button. >> >> I see that the button widget can take an 'overrelief' argument in the >> constructor. What values can this take ? >> > > same as RELIEF; see > > http://effbot.org/tkinterbook/button.htm#Tkinter.Button.config-method > > >> Also - can anyone provide an example of using the equivalent of a >> 'mouseover' event to change the image used by a button in Tkinter ? I'm >> afraid google has not helped me much here. >> > > you can use and events for this; see: > > http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm#events > > Thanks for your help Fredrik, this is working great. I'll have to experiment with RELIEF and OVERRELIEF. All the best, Fuzzyman http://www.voidspace.org.uk/python/index.shtml > > > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > > > From rkundu at ouray.cudenver.edu Fri Jun 30 20:00:13 2006 From: rkundu at ouray.cudenver.edu (rkundu at ouray.cudenver.edu) Date: Fri, 30 Jun 2006 12:00:13 -0600 Subject: [Tkinter-discuss] Iterate Scale widgets Message-ID: <20060630120013.2pafjg10gg808g0o@maroon.cudenver.edu> The problem with the following program is I am not able to get values corresponding to each scale widgets. I tried initially storing the scale widget names in a list and then get the values but did not work. So, I borrowed the trace variable part of the script from some internet source. In the program below all the scale widgets created are having the same variable ?var?, how do I change the variable names automatically or is there any other way to retrieve the values of scales? Any advice will be appreciated. Thank you, Reema from Tkinter import* import sys, Tkinter, types, copy root = Tk() i = 1 k = 5 var = Tkinter.DoubleVar() oldvalue = var.get() def callback(*args): global oldvalue #An exclamation point tells var that what follows is a Python statement, not a var command. if var.get() != oldvalue: oldvalue = var.get() print var.get() var.trace_variable("w", callback) while i<=k: j=1 var1 = var + i while j<=k: Scale(root, from_ = 0.0, to = 1.0, resolution = 0.1, variable = var, orient = 'horizontal').grid(row=i,column=j) j=j+1 i=i+1 root.mainloop()