From spooky.ln at tbs-software.com Sat Jan 1 20:56:57 2011 From: spooky.ln at tbs-software.com (spooky.ln at tbs-software.com) Date: Sat, 1 Jan 2011 20:56:57 +0100 Subject: [Tkinter-discuss] horizontal scrollbar in frame with text widget Message-ID: Hi all, I?m new on the list. Now moving from GTK to Tkinter. I have question about packing in frame. Example: frame2 = Frame(self) hScrollbar = ttk.Scrollbar(frame2, orient=HORIZONTAL) self.text = Text(frame2, font='Courier 9', undo=True, background='white', wrap=NONE) self.text.pack(fill=BOTH, expand=1) hScrollbar.pack(side=BOTTOM, fill=X) frame2.pack(side=LEFT, fill=BOTH, expand=1) in this little example i have defined hScrollbar. all working fine until i resize main window when frame2 is. if i resize window under 24lines in Text is visible scrollbar dissapear. is this wrong packing ? thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Sat Jan 1 22:53:04 2011 From: klappnase at web.de (Michael Lange) Date: Sat, 1 Jan 2011 22:53:04 +0100 Subject: [Tkinter-discuss] horizontal scrollbar in frame with text widget In-Reply-To: References: Message-ID: <20110101225304.29d38526.klappnase@web.de> Hi, Thus spoketh unto us on Sat, 1 Jan 2011 20:56:57 +0100: > Hi all, > I?m new on the list. Now moving from GTK to Tkinter. Then welcome aboard :) > I have question about packing in frame. > > Example: > > frame2 = Frame(self) > hScrollbar = ttk.Scrollbar(frame2, orient=HORIZONTAL) > self.text = Text(frame2, > font='Courier 9', > undo=True, > background='white', > wrap=NONE) > self.text.pack(fill=BOTH, expand=1) > hScrollbar.pack(side=BOTTOM, fill=X) > frame2.pack(side=LEFT, fill=BOTH, expand=1) > > in this little example i have defined hScrollbar. > all working fine until i resize main window when frame2 is. > if i resize window under 24lines in Text is visible scrollbar dissapear. > > is this wrong packing ? thanks. I think if you change the packing order, like: hScrollbar.pack(side=BOTTOM, fill=X) self.text.pack(fill=BOTH, expand=1) the scrollbar should remain visible when the window size decreases. Another, less elegant, solution might be to decrease the Text widget's size through its width and height options, however then you will have to make sure somewhere else in your code that you don't end up with a tiny window. I hope this helps Michael P.S. A happy new year to all of you! .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Respect is a rational process -- McCoy, "The Galileo Seven", stardate 2822.3 From spooky.ln at tbs-software.com Sun Jan 2 10:04:40 2011 From: spooky.ln at tbs-software.com (spooky.ln at tbs-software.com) Date: Sun, 2 Jan 2011 10:04:40 +0100 Subject: [Tkinter-discuss] horizontal scrollbar in frame with text widget Message-ID: <4D1A5B8855224361A582F3085DC5FD5D@eeepc> Thanks so much, this helps. i tried set Text height before but scrollbar dissapeared always after line height set. Changing packing order like you write solved my problem. ??? I think if you change the packing order, like: hScrollbar.pack(side=BOTTOM, fill=X) self.text.pack(fill=BOTH, expand=1) the scrollbar should remain visible when the window size decreases. Another, less elegant, solution might be to decrease the Text widget's size through its width and height options, however then you will have to make sure somewhere else in your code that you don't end up with a tiny window. I hope this helps Michael ??? -------------- next part -------------- An HTML attachment was scrubbed... URL: From spooky.ln at tbs-software.com Mon Jan 3 13:50:44 2011 From: spooky.ln at tbs-software.com (spooky.ln at tbs-software.com) Date: Mon, 3 Jan 2011 13:50:44 +0100 Subject: [Tkinter-discuss] Text and newlines [newbie Q] Message-ID: <3CA9615F05F24E0CA6818E9A02E5085A@eeepc> hi all, i have little method for parsing line in tkinter.Text. text.bind(??, parse) def parse(event=None): text = get_current_line() # this give me whole text on line pattern = r?^.*define\s.*):$? # simple search pattern reg = re.compile(pattern, re.S|re.M) # for use with more patterns match = re.search(reg, text) if match: print(?found %s definition.? % match.group(?defkeyword?)) text.insert(?end?, ?\n?) text.insert(?insert linestart?, ?\t?) there is small problem for me. how to insert tab into newline without next ?\n? ? i want only 2 lines not 3. i want: 1. define some: 2. .......[next insert will be here] and not: 1. define some: 2. ....... 3. [now ?end? points here] and second how i define width of tab in chars not in pixels using text.config(tabs=X) thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Mon Jan 3 18:14:08 2011 From: klappnase at web.de (Michael Lange) Date: Mon, 3 Jan 2011 18:14:08 +0100 Subject: [Tkinter-discuss] Text and newlines [newbie Q] In-Reply-To: <3CA9615F05F24E0CA6818E9A02E5085A@eeepc> References: <3CA9615F05F24E0CA6818E9A02E5085A@eeepc> Message-ID: <20110103181408.b875dc3d.klappnase@web.de> Hi, Thus spoketh unto us on Mon, 3 Jan 2011 13:50:44 +0100: > hi all, > i have little method for parsing line in tkinter.Text. > text.bind(??, parse) > def parse(event=None): > text = get_current_line() # > this give me whole text on line pattern = r?^.*define\s P.*):$? # simple search pattern reg = re.compile(pattern, > re.S|re.M) # for use with more patterns match = > re.search(reg, text) if match: > print(?found %s definition.? % match.group(?defkeyword?)) > text.insert(?end?, ?\n?) > text.insert(?insert linestart?, ?\t?) > there is small problem for me. how to insert tab into newline without > next ?\n? ? i want only 2 lines not 3. > i want: > 1. define some: > 2. .......[next insert will be here] > and not: > 1. define some: > 2. ....... > 3. [now ?end? points here] I am not sure what exactly you mean, simply changing your example into if match: print(?found %s definition.? % match.group(?defkeyword?)) text.insert(?end?, ?\t?) does probably not what you want? > and second how i define width of tab in chars not in pixels using > text.config(tabs=X) thanks. This is explained in the text man page: To achieve a different standard spacing, for example every 4 characters, simply configure the widget with ``-tabs "[expr {4 * [font measure $font 0]}] left" -tabstyle wordprocessor''. "Translated" into python this would be something like: from Tkinter import * import tkFont root=Tk() f = tkFont.Font(family='courier', size=-12) text = Text(root, font=f, tabs=(4 * f.measure(0), 'left'), tabstyle='wordprocessor') text.pack(fill=BOTH, expand=1) root.mainloop() Obviously f.measure(0) returns the average width of a character, although this behavior doesn't seem to be documented. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Only a fool fights in a burning house. -- Kank the Klingon, "Day of the Dove", stardate unknown From spooky.ln at tbs-software.com Mon Jan 3 21:36:10 2011 From: spooky.ln at tbs-software.com (spooky.ln at tbs-software.com) Date: Mon, 3 Jan 2011 21:36:10 +0100 Subject: [Tkinter-discuss] Text and newlines [newbie Q] In-Reply-To: <20110103181408.b875dc3d.klappnase@web.de> References: <3CA9615F05F24E0CA6818E9A02E5085A@eeepc> <20110103181408.b875dc3d.klappnase@web.de> Message-ID: <2A3391BB234F463481B649DCD1AE4EDC@eeepc> -----P?vodn? zpr?va----- From: Michael Lange Sent: Monday, January 03, 2011 6:14 PM To: tkinter-discuss at python.org Subject: Re: [Tkinter-discuss] Text and newlines [newbie Q] thanks for Tab info. But in insertion tabs im with no luck. im binding Return event into parse method where i parse line for regexp. if regexp found i want insert some indent using tabs or spaces on new line. but with edit.insert('end', '\t') tab is inserted right after ':' on the same line[1]. if i use insert('end', '\n\t') tabs are on new line[2] [ this is i want] but cursor is on next line[3]. nevermind here's example: import re from tkinter import * from tkinter.font import Font def get_current_line(): start = text.index('insert linestart') end = text.index('insert') return text.get(start, end) def parse(event=None): line = get_current_line() match = re.search(reg, line) if match: print('match!', match.group('defkey')) text.insert('end', '\t') root=Tk() f = Font(family='courier', size=-12) text = Text(root, font=f, tabs=(4 * f.measure(0), 'left'), tabstyle='wordprocessor') text.pack(fill=BOTH, expand=1) text.bind('', parse) text.focus() pattern = r"^.*define\s(?P.*):$" reg = re.compile(pattern, re.S|re.M) root.mainloop() i'm on python 3.1.3 and win7. Hi, Thus spoketh unto us on Mon, 3 Jan 2011 13:50:44 +0100: > hi all, > i have little method for parsing line in tkinter.Text. > text.bind(??, parse) > def parse(event=None): > text = get_current_line() # > this give me whole text on line pattern = r?^.*define\s P.*):$? # simple search pattern reg = re.compile(pattern, > re.S|re.M) # for use with more patterns match = > re.search(reg, text) if match: > print(?found %s definition.? % match.group(?defkeyword?)) > text.insert(?end?, ?\n?) > text.insert(?insert linestart?, ?\t?) > there is small problem for me. how to insert tab into newline without > next ?\n? ? i want only 2 lines not 3. > i want: > 1. define some: > 2. .......[next insert will be here] > and not: > 1. define some: > 2. ....... > 3. [now ?end? points here] I am not sure what exactly you mean, simply changing your example into if match: print(?found %s definition.? % match.group(?defkeyword?)) text.insert(?end?, ?\t?) does probably not what you want? > and second how i define width of tab in chars not in pixels using > text.config(tabs=X) thanks. This is explained in the text man page: To achieve a different standard spacing, for example every 4 characters, simply configure the widget with ``-tabs "[expr {4 * [font measure $font 0]}] left" -tabstyle wordprocessor''. "Translated" into python this would be something like: from Tkinter import * import tkFont root=Tk() f = tkFont.Font(family='courier', size=-12) text = Text(root, font=f, tabs=(4 * f.measure(0), 'left'), tabstyle='wordprocessor') text.pack(fill=BOTH, expand=1) root.mainloop() Obviously f.measure(0) returns the average width of a character, although this behavior doesn't seem to be documented. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Only a fool fights in a burning house. -- Kank the Klingon, "Day of the Dove", stardate unknown _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss at python.org http://mail.python.org/mailman/listinfo/tkinter-discuss From spooky.ln at tbs-software.com Tue Jan 4 00:22:25 2011 From: spooky.ln at tbs-software.com (spooky.ln at tbs-software.com) Date: Tue, 4 Jan 2011 00:22:25 +0100 Subject: [Tkinter-discuss] Text and newlines [newbie Q] In-Reply-To: <2A3391BB234F463481B649DCD1AE4EDC@eeepc> References: <3CA9615F05F24E0CA6818E9A02E5085A@eeepc><20110103181408.b875dc3d.klappnase@web.de> <2A3391BB234F463481B649DCD1AE4EDC@eeepc> Message-ID: <98422E9313474C93AB10B56D89DECB14@eeepc> hi, after few&more trying i changed example to this working: import re from tkinter import * from tkinter.font import Font def get_current_line(): start = text.index('insert linestart') end = text.index('insert') return text.get(start, end) def parse(event=None): line = get_current_line() match = re.search(reg, line) if match: print('match!', match.group('defkey')) text.insert('insert lineend', '\n') # changed text.insert('insert', '\t') # + return 'break' # this was my problem i think root=Tk() f = Font(family='courier', size=-12) text = Text(root, font=f, tabs=(4 * f.measure(0), 'left'), tabstyle='wordprocessor') text.pack(fill=BOTH, expand=1) text.bind('', parse) text.focus() pattern = r"^.*define\s(?P.*):$" reg = re.compile(pattern, re.S|re.M) root.mainloop() From stefan at nortd.com Thu Jan 6 09:53:35 2011 From: stefan at nortd.com (stefanix) Date: Thu, 6 Jan 2011 00:53:35 -0800 (PST) Subject: [Tkinter-discuss] canvas origin is off by 2 pixels, is this normal Message-ID: <30603446.post@talk.nabble.com> I just started using Tkinter and wanted to start using the canvas widget. I am having a weird problem with the origin. Not sure if this is a bug or I am missing something. When I create a canvas with 200x100 pixels and then draw an ellipse into the center (0,0, 200, 100) it is clipped by two pixels top and left and there is space bottom and right of 3 pixels. In other words, I have to draw my ellipse at (2,2,203,103) to perfectly fill out the canvas. code looks something like: c = Canvas(master, width=200, height=100, bg="black") c.pack(side=TOP) c.create_oval(2,2,203,103, fill="red") Any ideas how I fix this, /stefanix -- View this message in context: http://old.nabble.com/canvas-origin-is-off-by-2-pixels%2C-is-this-normal-tp30603446p30603446.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From python at bdurham.com Thu Jan 6 16:28:16 2011 From: python at bdurham.com (python at bdurham.com) Date: Thu, 06 Jan 2011 10:28:16 -0500 Subject: [Tkinter-discuss] canvas origin is off by 2 pixels, is this normal In-Reply-To: <30603446.post@talk.nabble.com> References: <30603446.post@talk.nabble.com> Message-ID: <1294327696.21598.1413795765@webmail.messagingengine.com> Stefanix, When you create your Canvas, try setting these properties in your Canvas creation statement: borderwidth=0 highlightthickness=0 Both these properties consume visual space in your canvas. If you need non-zero values for these properties, then just account for the edge pixels consumed by these features when you do your layout. Malcolm From prog at vtr.net Fri Jan 7 02:49:31 2011 From: prog at vtr.net (craf) Date: Thu, 06 Jan 2011 22:49:31 -0300 Subject: [Tkinter-discuss] Modify the Tab Order Message-ID: <1294364971.2190.4.camel@cristian-desktop> Hi. I wonder if you can change the tab order, first, pass the button 'two' and then the button 'one', without changing the pack of buttons. CODE:-------------------------------------- import Tkinter import ttk master = Tkinter.Tk() b1 = Tkinter.Button(master, text='One') b1.pack(side='right') b2 = Tkinter.Button(master, text='Two') b2.pack(side='right') master.mainloop() --------------------------------------------- It's posibble this?. Regards Cristian Abarzua. From stefan at nortd.com Fri Jan 7 11:27:45 2011 From: stefan at nortd.com (stefanix) Date: Fri, 7 Jan 2011 02:27:45 -0800 (PST) Subject: [Tkinter-discuss] [SOLVED] canvas origin is off by 2 pixels, is this normal In-Reply-To: <1294327696.21598.1413795765@webmail.messagingengine.com> References: <30603446.post@talk.nabble.com> <1294327696.21598.1413795765@webmail.messagingengine.com> Message-ID: <30612982.post@talk.nabble.com> Thanx Malcolm, This totally works. -- View this message in context: http://old.nabble.com/canvas-origin-is-off-by-2-pixels%2C-is-this-normal-tp30603446p30612982.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From prog at vtr.net Fri Jan 7 17:29:08 2011 From: prog at vtr.net (craf) Date: Fri, 07 Jan 2011 13:29:08 -0300 Subject: [Tkinter-discuss] [Fwd: Re: Modify the Tab Order] Message-ID: <1294417748.2130.0.camel@cristian-desktop> Thanks, Andrei.! Regards. Cristian Abarzua F. > De: Nemes Andrei > Para: craf > Asunto: Re: [Tkinter-discuss] Modify the Tab Order > Fecha: Thu, 6 Jan 2011 21:13:40 -0800 (PST) > > Oh, I forgot, you can still use the pack method too if you want ti. It > just matters the order you create them in. Note that you don't have to > pack them immediately after creation. I took the liberty of rearanging > your code a bit. > > > import Tkinter > import ttk > > > master = Tkinter.Tk() > > > b2 = Tkinter.Button(master, text='Two') > b1 = Tkinter.Button(master, text='One') > > > b1.pack(side='right') > b2.pack(side='right') > > > > > master.mainloop() > > > Andrei. > > > ______________________________________________________________________ > From: craf > To: Python Tkinter Ingles > Sent: Fri, January 7, 2011 1:49:31 AM > Subject: [Tkinter-discuss] Modify the Tab Order > > Hi. > > I wonder if you can change the tab order, first, pass the button 'two' > and then the button 'one', without changing the pack of buttons. > > CODE:-------------------------------------- > > import Tkinter > import ttk > > master = Tkinter.Tk() > > b1 = Tkinter.Button(master, text='One') > b1.pack(side='right') > > b2 = Tkinter.Button(master, text='Two') > b2.pack(side='right') > > > master.mainloop() > --------------------------------------------- > > It's posibble this?. > > Regards > > Cristian Abarzua. > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > > From prog at vtr.net Fri Jan 7 17:44:14 2011 From: prog at vtr.net (prog at vtr.net) Date: Fri, 07 Jan 2011 13:44:14 -0300 Subject: [Tkinter-discuss] pack and unpack a frame Message-ID: Hi. I'm testing the ability to pack and unpack a Frame control. The code I use is: ----------------------------------------------------------- import Tkinter import ttk class App: def __init__(self, master): self.root = master self.frame = ttk.Frame(self.root, style='TFrame') self.frame.pack(fill='both', expand='yes') self.b1 = ttk.Button(self.root, text='unpack') self.b1.pack() self.b2 = ttk.Button(self.root, text='pack') self.b2.pack() self.b1.bind('', lambda e, widget=self:unpack(widget)) self.b2.bind('', lambda e, widget=self:pack(widget)) def pack(widget): widget.frame.pack() print (widget.frame.pack_info()) def unpack(widget): widget.frame.pack_forget() master = Tkinter.Tk() master.geometry('640x480') s = ttk.Style() s.configure('TFrame', background='blue') app = App(master) master.mainloop() ----------------------------------------------------------- Unpacking the Frame work, but in trying to repackage it does not work. Thanks in advance!. Regards. Cristian Abarzua F. From klappnase at web.de Fri Jan 7 17:52:46 2011 From: klappnase at web.de (Michael Lange) Date: Fri, 7 Jan 2011 17:52:46 +0100 Subject: [Tkinter-discuss] pack and unpack a frame In-Reply-To: References: Message-ID: <20110107175246.45ca6ab4.klappnase@web.de> Hi, Thus spoketh unto us on Fri, 07 Jan 2011 13:44:14 -0300: > Hi. > > I'm testing the ability to pack and unpack a Frame control. > > The code I use is: > ----------------------------------------------------------- > > import Tkinter > import ttk > > class App: > def __init__(self, master): > self.root = master > self.frame = ttk.Frame(self.root, style='TFrame') > self.frame.pack(fill='both', expand='yes') > > self.b1 = ttk.Button(self.root, text='unpack') > self.b1.pack() > > self.b2 = ttk.Button(self.root, text='pack') > self.b2.pack() > > > self.b1.bind('', lambda e, widget=self:unpack > (widget)) self.b2.bind('', lambda e, widget=self:pack(widget)) > > def pack(widget): > widget.frame.pack() > print (widget.frame.pack_info()) > > def unpack(widget): > widget.frame.pack_forget() > > > > master = Tkinter.Tk() > master.geometry('640x480') > s = ttk.Style() > s.configure('TFrame', background='blue') > app = App(master) > master.mainloop() > ----------------------------------------------------------- > > Unpacking the Frame work, but in trying to repackage it does not work. Actually it does work, however you do not see the frame, because there aren't any widgets inside it and you did not use the fill='both', expand='yes' flags when you re-packed it, so it will end up with 1x1 pixels size. Here I can still see the blue pixel if I look closely right under the "pack" button :) Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Knowledge, sir, should be free to all! -- Harry Mudd, "I, Mudd", stardate 4513.3 From prog at vtr.net Fri Jan 7 19:11:34 2011 From: prog at vtr.net (craf) Date: Fri, 07 Jan 2011 15:11:34 -0300 Subject: [Tkinter-discuss] [Fwd: Re: pack and unpack a frame] Message-ID: <1294423894.2360.4.camel@cristian-desktop> --------- Mensaje reenviado -------- > De: Michael Lange > Para: tkinter-discuss at python.org > Asunto: Re: [Tkinter-discuss] pack and unpack a frame > Fecha: Fri, 7 Jan 2011 17:52:46 +0100 > > Hi, > > Thus spoketh > unto us on Fri, 07 Jan 2011 13:44:14 -0300: > > > Hi. > > > > I'm testing the ability to pack and unpack a Frame control. > > > > The code I use is: > > ----------------------------------------------------------- > > > > import Tkinter > > import ttk > > > > class App: > > def __init__(self, master): > > self.root = master > > self.frame = ttk.Frame(self.root, style='TFrame') > > self.frame.pack(fill='both', expand='yes') > > > > self.b1 = ttk.Button(self.root, text='unpack') > > self.b1.pack() > > > > self.b2 = ttk.Button(self.root, text='pack') > > self.b2.pack() > > > > > > self.b1.bind('', lambda e, widget=self:unpack > > (widget)) self.b2.bind('', lambda e, widget=self:pack(widget)) > > > > def pack(widget): > > widget.frame.pack() > > print (widget.frame.pack_info()) > > > > def unpack(widget): > > widget.frame.pack_forget() > > > > > > > > master = Tkinter.Tk() > > master.geometry('640x480') > > s = ttk.Style() > > s.configure('TFrame', background='blue') > > app = App(master) > > master.mainloop() > > ----------------------------------------------------------- > > > > Unpacking the Frame work, but in trying to repackage it does not work. > > Actually it does work, however you do not see the frame, because there > aren't any widgets inside it and you did not use the fill='both', > expand='yes' flags when you re-packed it, so it will end up with 1x1 > pixels size. Here I can still see the blue pixel if I look closely right > under the "pack" button :) > > Regards > > Michael > > > .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. > > Knowledge, sir, should be free to all! > -- Harry Mudd, "I, Mudd", stardate 4513.3 > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss Hi Michael. Sometimes I'm blinder than a mole ;=) Thanks you for the tips. Regards. Cristian Abarzua From prog at vtr.net Sat Jan 8 00:18:05 2011 From: prog at vtr.net (craf) Date: Fri, 07 Jan 2011 20:18:05 -0300 Subject: [Tkinter-discuss] Problems with hotkeys Message-ID: <1294442285.5016.15.camel@cristian-desktop> Hi. I'm trying to use the hotkeys access to controls. My code is as follows: --------------------------------------------------------------------- import Tkinter class App: def __init__(self, master): self.root = master self.entry = Tkinter.Entry(self.root) self.entry.pack() self.entry.focus_set() self.b1 = Tkinter.Button(self.root, text='One', underline=0) self.b1.pack() self.b2 = Tkinter.Button(self.root, text='Two', underline=0) self.b2.pack() self.b3 = Tkinter.Button(self.root, text='Three', underline=1) self.b3.pack() self.b1.bind('', lambda e, widget=self:one(widget)) self.b2.bind('', lambda e, widget=self:two(widget)) self.b3.bind('', lambda e, widget=self:three(widget)) def one(widget): widget.entry.focus widget.root.title('Press Button One') def two(widget): widget.root.title('Press Button Two') def three(widget): widget.root.title('Press Button Three') master = Tkinter.Tk() master.geometry('640x480') app = App(master) master.mainloop() -------------------------------------------------------------------- 1. The entry control has focus when you open the application. 2. The hotkeys for the buttons work only if they have focus There is a way of pressing a key combination without the focus this on the button that has focus at that time? Thanks and advance. Regards. Cristian Abarz?a From klappnase at web.de Sat Jan 8 00:56:11 2011 From: klappnase at web.de (Michael Lange) Date: Sat, 8 Jan 2011 00:56:11 +0100 Subject: [Tkinter-discuss] Problems with hotkeys In-Reply-To: <1294442285.5016.15.camel@cristian-desktop> References: <1294442285.5016.15.camel@cristian-desktop> Message-ID: <20110108005611.029f3a83.klappnase@web.de> Hi, Thus spoketh craf unto us on Fri, 07 Jan 2011 20:18:05 -0300: (...) > > There is a way of pressing a key combination without the focus this on > the button that has focus at that time? Binding the callback to the widget's toplevel window (so in your case the Tk() instance) instead of the widget itself should do what you want. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Uncontrolled power will turn even saints into savages. And we can all be counted on to live down to our lowest impulses. -- Parmen, "Plato's Stepchildren", stardate 5784.3 From prog at vtr.net Sat Jan 8 02:25:06 2011 From: prog at vtr.net (craf) Date: Fri, 07 Jan 2011 22:25:06 -0300 Subject: [Tkinter-discuss] [Fwd: Problems with hotkeys] Message-ID: <1294449906.2628.3.camel@cristian-desktop> --------- Mensaje reenviado -------- > De: craf > Para: Python Tkinter Ingles > Asunto: [Tkinter-discuss] Problems with hotkeys > Fecha: Fri, 07 Jan 2011 20:18:05 -0300 > > Hi. > > I'm trying to use the hotkeys access to controls. > > My code is as follows: > > --------------------------------------------------------------------- > import Tkinter > > class App: > def __init__(self, master): > self.root = master > > self.entry = Tkinter.Entry(self.root) > self.entry.pack() > self.entry.focus_set() > > self.b1 = Tkinter.Button(self.root, text='One', underline=0) > self.b1.pack() > > self.b2 = Tkinter.Button(self.root, text='Two', underline=0) > self.b2.pack() > > self.b3 = Tkinter.Button(self.root, text='Three', underline=1) > self.b3.pack() > > self.b1.bind('', lambda e, widget=self:one(widget)) > self.b2.bind('', lambda e, widget=self:two(widget)) > self.b3.bind('', lambda e, widget=self:three(widget)) > > def one(widget): > widget.entry.focus > widget.root.title('Press Button One') > > def two(widget): > widget.root.title('Press Button Two') > > def three(widget): > widget.root.title('Press Button Three') > > master = Tkinter.Tk() > master.geometry('640x480') > app = App(master) > master.mainloop() > -------------------------------------------------------------------- > > 1. The entry control has focus when you open the application. > > 2. The hotkeys for the buttons work only if they have focus > > There is a way of pressing a key combination without the focus this on > the button that has focus at that time? > > > Thanks and advance. > > Regards. > > Cristian Abarz?a > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss Hi. I answer: modify this: self.b1.bind('', lambda e, widget=self:one(widget)) self.b2.bind('', lambda e, widget=self:two(widget)) self.b3.bind('', lambda e, widget=self:three(widget)) for this: self.root.bind('', lambda e, widget=self:one(widget)) self.root.bind('', lambda e, widget=self:two(widget)) self.root.bind('', lambda e, widget=self:three(widget)) Regards. Cristian Abarz?a F. From Cameron at phaseit.net Thu Jan 13 17:23:51 2011 From: Cameron at phaseit.net (Cameron Laird) Date: Thu, 13 Jan 2011 16:23:51 +0000 Subject: [Tkinter-discuss] select multiple directories by tkFileDialog Message-ID: <20110113162351.GA19622@lairds.us> I want to select multiple folders at a time but tkFileDialog.askdirectory() doesnt allow "multiple=1" , as does askopenfilename() for files.. is there any way to make this work? -- View this message in context: http://old.nabble.com/select-multiple-directories-by-tkFileDialog-tp30654337p30654337.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From Cameron at phaseit.net Thu Jan 13 17:24:36 2011 From: Cameron at phaseit.net (Cameron Laird) Date: Thu, 13 Jan 2011 16:24:36 +0000 Subject: [Tkinter-discuss] select multiple folders/ directories Message-ID: <20110113162436.GB19622@lairds.us> Hi, I'm currently using tkFileDialog.askdirectory() to select a single directory. I would like to be able to select multiple directories. tkFileDialog.askopenfilenames() seems to do this for files. What can I do in my situation? Are there alternative classes that provide file dialogs better suited for my purpose? I want to select multiple folders at a time but tkFileDialog.askdirectory() doesnt allow "multiple=1".. is there any way to make this work? Thank you in advance Regards, Sujay Kher -- View this message in context: http://old.nabble.com/select-multiple-folders--directories-tp30658702p30658702.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From waynejwerner at gmail.com Thu Jan 13 17:36:11 2011 From: waynejwerner at gmail.com (Wayne Werner) Date: Thu, 13 Jan 2011 10:36:11 -0600 Subject: [Tkinter-discuss] select multiple folders/ directories In-Reply-To: <20110113162436.GB19622@lairds.us> References: <20110113162436.GB19622@lairds.us> Message-ID: On Thu, Jan 13, 2011 at 10:24 AM, Cameron Laird wrote: > Hi, > > I'm currently using tkFileDialog.askdirectory() to select a single > directory. I would like to be able to select multiple directories. > > tkFileDialog.askopenfilenames() seems to do this for files. > > What can I do in my situation? Are there alternative classes that > provide file dialogs better suited for my purpose? > > > I want to select multiple folders at a time but tkFileDialog.askdirectory() > doesnt allow "multiple=1".. is there any way to make this work? > >From my quick test, there doesn't appear to be. However, you can do this: dirs = [] title = 'Choose Directory' while True: dir = tkFileDialog.askdirectory(title=title) if not dir: break title = 'got %s. Next dir' % dirs[-1] Probably not the most elegant solution, but hopefully it helps. Wayne -------------- next part -------------- An HTML attachment was scrubbed... URL: From sujay.kher at gmail.com Thu Jan 13 18:05:30 2011 From: sujay.kher at gmail.com (Sujay) Date: Thu, 13 Jan 2011 09:05:30 -0800 (PST) Subject: [Tkinter-discuss] select multiple folders/ directories In-Reply-To: References: <20110113162436.GB19622@lairds.us> Message-ID: <30664142.post@talk.nabble.com> Thank you Wayne, I really appreciate your swift response. I have solve this problem by using wxpython. Now I am stuck in another problem. I can not select directory from network. Dialogue only shows directory of my local system. In short, i cant access NETWORK in this multidirdialog.. its just based on local file system access. do u have any idea how i can tweek this?? work around? Best regards, Sujay Kher Wayne Werner wrote: > > On Thu, Jan 13, 2011 at 10:24 AM, Cameron Laird > wrote: > >> Hi, >> >> I'm currently using tkFileDialog.askdirectory() to select a single >> directory. I would like to be able to select multiple directories. >> >> tkFileDialog.askopenfilenames() seems to do this for files. >> >> What can I do in my situation? Are there alternative classes that >> provide file dialogs better suited for my purpose? >> >> >> I want to select multiple folders at a time but >> tkFileDialog.askdirectory() >> doesnt allow "multiple=1".. is there any way to make this work? >> > >>From my quick test, there doesn't appear to be. However, you can do this: > > dirs = [] > title = 'Choose Directory' > while True: > dir = tkFileDialog.askdirectory(title=title) > if not dir: > break > title = 'got %s. Next dir' % dirs[-1] > > Probably not the most elegant solution, but hopefully it helps. > > Wayne > > _______________________________________________ > 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/select-multiple-folders--directories-tp30663726p30664142.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From klappnase at web.de Sat Jan 15 21:48:31 2011 From: klappnase at web.de (Michael Lange) Date: Sat, 15 Jan 2011 21:48:31 +0100 Subject: [Tkinter-discuss] Tkinter and signal handling Message-ID: <20110115214831.3173d6d3.klappnase@web.de> Hi, I encountered a strange problem with Tkinter and the handling of signals (on debian linux, both with Python-2.5 / Tk-8.4 and Python-2.6 / Tk-8.6). The problem resembles much the one described in this old message: http://web.archiveorange.com/archive/v/5H3d1OLg2fjze5McyfSL A basic code example: ########################## import Tkinter import signal root = Tkinter.Tk() def handle_signal(signum, frame): print 'Caught signal # %d' % signum signal.signal(2, handle_signal) root.mainloop() ########################## When I run this program from a terminal and hit Ctrl-C I would expect the message to print immediately, however the callback is delayed until the mouse enters the Tkinter window *or* the window receives keyboard focus *or* thewindow is being (partially) obscured with another window. The same effect happens when I do a kill -2 on the process from another terminal. What baffles me even more is that I have another Tkinter app here, where the signal handling works flawlessly, however this is a complex app with quite a bunch of modules, and I am not sure where to look for the magic that makes it work there; in the few lines of code that define this app's signal handling I cannot see any fundamental difference to the above example. Does anyone have a clue? Thanks in advance Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Romulan women are not like Vulcan females. We are not dedicated to pure logic and the sterility of non-emotion. -- Romulan Commander, "The Enterprise Incident", stardate 5027.3 From klappnase at web.de Sat Jan 15 22:09:23 2011 From: klappnase at web.de (Michael Lange) Date: Sat, 15 Jan 2011 22:09:23 +0100 Subject: [Tkinter-discuss] Tkinter and signal handling In-Reply-To: <20110115214831.3173d6d3.klappnase@web.de> References: <20110115214831.3173d6d3.klappnase@web.de> Message-ID: <20110115220923.a46359d5.klappnase@web.de> Thus spoketh Michael Lange unto us on Sat, 15 Jan 2011 21:48:31 +0100: > Hi, > > I encountered a strange problem with Tkinter and the handling of signals > (on debian linux, both with Python-2.5 / Tk-8.4 and Python-2.6 / > Tk-8.6). The problem resembles much the one described in this old > message: > > http://web.archiveorange.com/archive/v/5H3d1OLg2fjze5McyfSL > Ok, after reading the answer to this old question for a second time, I found a ugly but working solution, changing the example into: #################################### import Tkinter import signal root = Tkinter.Tk() def poll(): root.after(500, poll) root.after(500, poll) def handle_signal(signum, frame): print 'Caught signal # %d' % signum signal.signal(2, handle_signal) root.mainloop() ################################### Apparently, as soon as root.after() is called the signal reaches the window. Probably there is some active polling-loop like this in the other app I mentioned in the first post. Still it seems like a pain in the neck if you need the loop just for signal handling :( Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Death, when unnecessary, is a tragic thing. -- Flint, "Requiem for Methuselah", stardate 5843.7 From python at bdurham.com Sun Jan 16 15:10:50 2011 From: python at bdurham.com (python at bdurham.com) Date: Sun, 16 Jan 2011 09:10:50 -0500 Subject: [Tkinter-discuss] Tkinter and signal handling In-Reply-To: <20110115214831.3173d6d3.klappnase@web.de> References: <20110115214831.3173d6d3.klappnase@web.de> Message-ID: <1295187050.26836.1415560631@webmail.messagingengine.com> Michael, > until the mouse enters the Tkinter window *or* the window receives keyboard focus Does adding a widget (any widget) that receives keyboard focus to your root form fix this problem? What if you explicitly set focus to this control after you create your root window? I'm not on a Linux box at the moment so I can't test these ideas for you. Malcolm From klappnase at web.de Sun Jan 16 16:05:11 2011 From: klappnase at web.de (Michael Lange) Date: Sun, 16 Jan 2011 16:05:11 +0100 Subject: [Tkinter-discuss] Tkinter and signal handling In-Reply-To: <1295187050.26836.1415560631@webmail.messagingengine.com> References: <20110115214831.3173d6d3.klappnase@web.de> <1295187050.26836.1415560631@webmail.messagingengine.com> Message-ID: <20110116160511.32cb06fd.klappnase@web.de> Hi, Thus spoketh python at bdurham.com unto us on Sun, 16 Jan 2011 09:10:50 -0500: > Michael, > > > until the mouse enters the Tkinter window *or* the window receives > > keyboard focus > > Does adding a widget (any widget) that receives keyboard focus to your > root form fix this problem? > > What if you explicitly set focus to this control after you create your > root window? > None of these help, in fact of course I first had an app window with widgets, the minimalistic example was just for demonstration ;) Otoh the workaround is easy enough, it just seems a little ... strange to me, and I was surprised that it is so hard to find some information about this issue, I thought adding signal handlers to applications should be a common issue. If no one knows a better solution than the "poll-loop" technique, I think I might add it as a recipe to the wiki. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. It [being a Vulcan] means to adopt a philosophy, a way of life which is logical and beneficial. We cannot disregard that philosophy merely for personal gain, no matter how important that gain might be. -- Spock, "Journey to Babel", stardate 3842.4 From spooky.ln at tbs-software.com Mon Jan 17 17:36:52 2011 From: spooky.ln at tbs-software.com (Martin B.) Date: Mon, 17 Jan 2011 17:36:52 +0100 Subject: [Tkinter-discuss] Disabling widgets [especially ttk.Scale] Message-ID: <20110117173652.69d35be1@tbs-software.com> hi all, i have a little problem with setting state of ttk.Scale widget. i have a ttk.Checkbutton which operates with ttk.Scale. [enabling,disabling] self.check=BooleanVar() button = ttk.Checkbutton(self, text='',variable=self.var,command=self._setActive) self.slider = ttk.Scale(self) def _setActive(self, event=None): if self.check.get(): self.slider.state(statespec=('active',)) else: self.slider.state(statespec=('disabled',)) but if i make checkbutton active, slider is disabled :( how i make Scale state enabled and disabled if self.slider.config(state=NORMAL) is unknown option. sry for newbie Q. thanks From klappnase at web.de Mon Jan 17 19:08:56 2011 From: klappnase at web.de (Michael Lange) Date: Mon, 17 Jan 2011 19:08:56 +0100 Subject: [Tkinter-discuss] Disabling widgets [especially ttk.Scale] In-Reply-To: <20110117173652.69d35be1@tbs-software.com> References: <20110117173652.69d35be1@tbs-software.com> Message-ID: <20110117190856.c049a018.klappnase@web.de> Hi, Thus spoketh "Martin B." unto us on Mon, 17 Jan 2011 17:36:52 +0100: (...) > > but if i make checkbutton active, slider is disabled :( > how i make Scale state enabled and disabled if > self.slider.config(state=NORMAL) is unknown option. if you're familiar with Tkinter states, the handling of states in ttk may seem a bit odd. To set a widget to "normal" state you must not define the state "normal" but instead turn off the "disabled" state by prefixing the state name with an exclamation mark. Here's a minimal example how this can be done: ############################################################# import Tkinter import ttk root = Tkinter.Tk() s = ttk.Scale(root) s.pack(side='right', fill='x') var = Tkinter.StringVar() var.set('!disabled') def callback(): s.state((var.get(),)) button = ttk.Checkbutton(root, text='foo', variable=var, onvalue='disabled', offvalue='!disabled', command=callback) button.pack(side='left', padx=40, pady=100) root.mainloop() ############################################################# I hope this helps Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. "What terrible way to die." "There are no good ways." -- Sulu and Kirk, "That Which Survives", stardate unknown From spooky.ln at tbs-software.com Mon Jan 17 19:09:47 2011 From: spooky.ln at tbs-software.com (Martin B.) Date: Mon, 17 Jan 2011 19:09:47 +0100 Subject: [Tkinter-discuss] Disabling widgets [especially ttk.Scale] In-Reply-To: <20110117173652.69d35be1@tbs-software.com> References: <20110117173652.69d35be1@tbs-software.com> Message-ID: <20110117190947.32a501af@tbs-software.com> V Mon, 17 Jan 2011 17:36:52 +0100 "Martin B." naps?no: eh i have solution. must be state(statespec=('active', '!disabled') sry > hi all, > i have a little problem with setting state of ttk.Scale widget. > > i have a ttk.Checkbutton which operates with ttk.Scale. > [enabling,disabling] > > > > self.check=BooleanVar() > button = ttk.Checkbutton(self, > text='',variable=self.var,command=self._setActive) self.slider = > ttk.Scale(self) > > def _setActive(self, event=None): > if self.check.get(): > self.slider.state(statespec=('active',)) > else: > self.slider.state(statespec=('disabled',)) > > > > but if i make checkbutton active, slider is disabled :( > how i make Scale state enabled and disabled if > self.slider.config(state=NORMAL) is unknown option. > > sry for newbie Q. > thanks > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From spooky.ln at tbs-software.com Mon Jan 17 19:14:53 2011 From: spooky.ln at tbs-software.com (Martin B.) Date: Mon, 17 Jan 2011 19:14:53 +0100 Subject: [Tkinter-discuss] Disabling widgets [especially ttk.Scale] In-Reply-To: <20110117190856.c049a018.klappnase@web.de> References: <20110117173652.69d35be1@tbs-software.com> <20110117190856.c049a018.klappnase@web.de> Message-ID: <20110117191453.04ba3d8c@tbs-software.com> V Mon, 17 Jan 2011 19:08:56 +0100 Michael Lange naps?no: Thanks for your example, seems to be better solution that mine :) I think that ttk.Checkbutton variable must be BooleanVar(). now i know that not. thanks > Hi, > > Thus spoketh "Martin B." > unto us on Mon, 17 Jan 2011 17:36:52 +0100: > > (...) > > > > but if i make checkbutton active, slider is disabled :( > > how i make Scale state enabled and disabled if > > self.slider.config(state=NORMAL) is unknown option. > > if you're familiar with Tkinter states, the handling of states in ttk > may seem a bit odd. To set a widget to "normal" state you must not > define the state "normal" but instead turn off the "disabled" state by > prefixing the state name with an exclamation mark. Here's a minimal > example how this can be done: > > ############################################################# > import Tkinter > import ttk > root = Tkinter.Tk() > s = ttk.Scale(root) > s.pack(side='right', fill='x') > > var = Tkinter.StringVar() > var.set('!disabled') > > def callback(): > s.state((var.get(),)) > > button = ttk.Checkbutton(root, text='foo', variable=var, > onvalue='disabled', offvalue='!disabled', command=callback) > button.pack(side='left', padx=40, pady=100) > root.mainloop() > ############################################################# > > > I hope this helps > > Michael > > > .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. > --- ... .--. . .-. > > "What terrible way to die." > "There are no good ways." > -- Sulu and Kirk, "That Which Survives", stardate > unknown _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From jarausch at igpm.rwth-aachen.de Tue Jan 18 09:46:54 2011 From: jarausch at igpm.rwth-aachen.de (Helmut Jarausch) Date: Tue, 18 Jan 2011 09:46:54 +0100 Subject: [Tkinter-discuss] Strange Error - please help Message-ID: <1295340414.14825.1@numa-i> Hi, I'm new to Tkinter+Python and my very first mini-widget fails with a strange error message. I'm using Python 2.7.1 and Tcl/Tk 8.5.9 1 #!/usr/bin/python 2 # _*_ coding: latin1 _*_ 3 4 import Tkinter as Tk 5 6 class LabEntry(Tk.Entry) : 7 def __init__(self,root,label,**args) : 8 self.Frame= Tk.Frame(root) 9 Lab=Tk.Label(self.Frame,text=label) 10 Lab.grid(colmn=0,row=0) 11 Tk.Entry.__init__(self.Frame,args) 12 super(Tk.Entry,self).grid(colmn=1,row=0) 13 14 def grid(self,**args) : 15 self.Frame.grid(args) 16 17 def Finish() : 18 root.destroy() 19 20 root= Tk.Tk() 21 root.protocol('WM_DELETE_WINDOW',Finish) 22 Name= Tk.StringVar() 23 NameE= LabEntry(root,'Name :',textvariable=Name,width=25) 24 NameE.grid(column=0,row=0) 25 Tk.mainloop() Traceback (most recent call last): File "LabEntry.py", line 23, in NameE= LabEntry(root,'Name :',textvariable=Name,width=25) File "LabEntry.py", line 10, in __init__ Lab.grid(colmn=0,row=0) File "/usr/lib64/python2.7/lib-tk/Tkinter.py", line 1901, in grid_configure + self._options(cnf, kw)) _tkinter.TclError: bad option "-colmn": must be -column, -columnspan, - in, -ipadx, -ipady, -padx, -pady, -row, -rowspan, or -sticky Where does this strange option '-colmn' come from. What am I missing? Many thanks for a hint, Helmut. From spooky.ln at tbs-software.com Tue Jan 18 10:22:58 2011 From: spooky.ln at tbs-software.com (Martin B.) Date: Tue, 18 Jan 2011 10:22:58 +0100 Subject: [Tkinter-discuss] Strange Error - please help In-Reply-To: <1295340414.14825.1@numa-i> References: <1295340414.14825.1@numa-i> Message-ID: <20110118102258.2ee01f9f@tbs-software.com> V Tue, 18 Jan 2011 09:46:54 +0100 Helmut Jarausch naps?no: hi, i think on line 10, 12 must be 'column' instead 'colmn' > Hi, I'm new to Tkinter+Python and my very first mini-widget fails > with a strange error message. I'm using Python 2.7.1 and Tcl/Tk 8.5.9 > > 1 #!/usr/bin/python > 2 # _*_ coding: latin1 _*_ > 3 > 4 import Tkinter as Tk > 5 > 6 class LabEntry(Tk.Entry) : > 7 def __init__(self,root,label,**args) : > 8 self.Frame= Tk.Frame(root) > 9 Lab=Tk.Label(self.Frame,text=label) > 10 Lab.grid(colmn=0,row=0) > 11 Tk.Entry.__init__(self.Frame,args) > 12 super(Tk.Entry,self).grid(colmn=1,row=0) > 13 > 14 def grid(self,**args) : > 15 self.Frame.grid(args) > 16 > 17 def Finish() : > 18 root.destroy() > 19 > 20 root= Tk.Tk() > 21 root.protocol('WM_DELETE_WINDOW',Finish) > 22 Name= Tk.StringVar() > 23 NameE= LabEntry(root,'Name :',textvariable=Name,width=25) > 24 NameE.grid(column=0,row=0) > 25 Tk.mainloop() > > Traceback (most recent call last): > File "LabEntry.py", line 23, in > NameE= LabEntry(root,'Name :',textvariable=Name,width=25) > File "LabEntry.py", line 10, in __init__ > Lab.grid(colmn=0,row=0) > File "/usr/lib64/python2.7/lib-tk/Tkinter.py", line 1901, in > grid_configure > + self._options(cnf, kw)) > _tkinter.TclError: bad option "-colmn": must be -column, -columnspan, > - in, -ipadx, -ipady, -padx, -pady, -row, -rowspan, or -sticky > > Where does this strange option '-colmn' come from. > What am I missing? > > Many thanks for a hint, > Helmut. > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From jarausch at igpm.rwth-aachen.de Tue Jan 18 11:23:30 2011 From: jarausch at igpm.rwth-aachen.de (Helmut Jarausch) Date: Tue, 18 Jan 2011 11:23:30 +0100 Subject: [Tkinter-discuss] grid manager does propagate width - why? Message-ID: <1295346210.14825.4@numa-i> Hi, I have two version of a simple labeled entry widget. import Tkinter as Tk class LabEntry(Tk.Entry) : def __init__(self,root,label,**args) : self.Frame= Tk.Frame(root) Lab=Tk.Label(self.Frame,text=label) Lab.grid(column=0,row=0) Tk.Entry.__init__(self,self.Frame,**args) self.grid(column=1,row=0) def grid(self,**args) : self.Frame.grid(**args) def Finish() : root.destroy() root= Tk.Tk() root.protocol('WM_DELETE_WINDOW',Finish) Name= Tk.StringVar() Name.set('') NameF= Tk.Frame(root) NameF.grid(column=0,row=0) Tk.Label(NameF,text='Name :').grid(column=0,row=0) NameE= Tk.Entry(NameF,textvariable=Name,width=25) NameE.grid(column=1,row=0) Tk.mainloop() ------------------------------------------------- This version, which doesn't use LabEntry, reserves space for 25 characters in the entry widget. But, replacing the last 6 lines by NameE= LabEntry(root,'Name :',textvariable=Name,width=25) NameE.grid(column=0,row=0) Tk.mainloop() the (internal) entry widget has only size 0 initially. Why? Many thanks for a hint, Helmut. From spooky.ln at tbs-software.com Tue Jan 18 11:46:03 2011 From: spooky.ln at tbs-software.com (Martin B.) Date: Tue, 18 Jan 2011 11:46:03 +0100 Subject: [Tkinter-discuss] grid manager does propagate width - why? In-Reply-To: <1295346210.14825.4@numa-i> References: <1295346210.14825.4@numa-i> Message-ID: <20110118114603.46d40d49@tbs-software.com> V Tue, 18 Jan 2011 11:23:30 +0100 Helmut Jarausch naps?no: hi, i make little rewrite your LabEntry. seems to work import tkinter as Tk class LabEntry(Tk.Frame) : def __init__(self,root,label,**args) : super().__init__() entry = Tk.Entry(self, **args) entry.grid(column=1, row=0) Lab=Tk.Label(self,text=label) Lab.grid(column=0,row=0) def Finish() : root.destroy() root= Tk.Tk() root.protocol('WM_DELETE_WINDOW',Finish) Name= Tk.StringVar() Name.set('') NameE= LabEntry(root,'Name :',textvariable=Name,width=25) NameE.grid(column=0,row=0) Tk.mainloop() > Hi, > > I have two version of a simple labeled entry widget. > > import Tkinter as Tk > > class LabEntry(Tk.Entry) : > def __init__(self,root,label,**args) : > self.Frame= Tk.Frame(root) > Lab=Tk.Label(self.Frame,text=label) > Lab.grid(column=0,row=0) > Tk.Entry.__init__(self,self.Frame,**args) > self.grid(column=1,row=0) > > def grid(self,**args) : > self.Frame.grid(**args) > > def Finish() : > root.destroy() > > root= Tk.Tk() > root.protocol('WM_DELETE_WINDOW',Finish) > Name= Tk.StringVar() > Name.set('') > NameF= Tk.Frame(root) > NameF.grid(column=0,row=0) > Tk.Label(NameF,text='Name :').grid(column=0,row=0) > NameE= Tk.Entry(NameF,textvariable=Name,width=25) > NameE.grid(column=1,row=0) > Tk.mainloop() > > ------------------------------------------------- > > This version, which doesn't use LabEntry, reserves space for 25 > characters in the entry widget. > > But, replacing the last 6 lines by > > NameE= LabEntry(root,'Name :',textvariable=Name,width=25) > NameE.grid(column=0,row=0) > Tk.mainloop() > > the (internal) entry widget has only size 0 initially. > Why? > > Many thanks for a hint, > Helmut. > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From spooky.ln at tbs-software.com Tue Jan 18 13:37:07 2011 From: spooky.ln at tbs-software.com (Martin B.) Date: Tue, 18 Jan 2011 13:37:07 +0100 Subject: [Tkinter-discuss] grid manager does propagate width - why? In-Reply-To: <1295348077.14825.5@numa-i> References: <1295346210.14825.4@numa-i> <20110118114603.46d40d49@tbs-software.com> <1295348077.14825.5@numa-i> Message-ID: <20110118133707.70c9ba02@tbs-software.com> V Tue, 18 Jan 2011 11:54:37 +0100 Helmut Jarausch naps?no: sry, my english is not good. But your prob is simple. you defined 'grid' method in class. but calling self.grid(column=1, row=0) after Tk.Entry.__init__() cause your problem. this call your defined 'grid' method. Entry not be positioned in grid. this 'grid' Frame. solution is rename your 'grid' method such as 'fgrid' or something else and from main call NameE.fgrid(column=0, row=0) this works import tkinter as Tk class LabEntry(Tk.Entry) : def __init__(self,root,label,**args) : self.Frame= Tk.Frame(root) Lab=Tk.Label(self.Frame,text=label) Lab.grid(column=0,row=0) Tk.Entry.__init__(self,self.Frame,**args) self.grid(column=1,row=0) def fgrid(self,**args) : self.Frame.grid(**args) def Finish() : root.destroy() root= Tk.Tk() root.protocol('WM_DELETE_WINDOW',Finish) Name= Tk.StringVar() Name.set('') #NameF= Tk.Frame(root) #NameF.grid(column=0,row=0) #Tk.Label(NameF,text='Name :').grid(column=0,row=0) #NameE= Tk.Entry(NameF,textvariable=Name,width=25) #NameE.grid(column=1,row=0) #Tk.mainloop() NameE= LabEntry(root,'Name :',textvariable=Name,width=25) NameE.fgrid(column=0,row=0) Tk.mainloop() > Thanks Martin, but now LabEntry is derived from Tk.Frame. > Therefore any method calls to the Entry widget within the LabEntry > widget like a bind method call, doesn't work anymore. > What was wrong with my example? > > Helmut. > > On 01/18/11 11:46:03, Martin B. wrote: > > V Tue, 18 Jan 2011 11:23:30 +0100 > > Helmut Jarausch naps?no: > > > > hi, > > i make little rewrite your LabEntry. > > seems to work > > > > > > > > import tkinter as Tk > > > > class LabEntry(Tk.Frame) : > > def __init__(self,root,label,**args) : > > super().__init__() > > > > entry = Tk.Entry(self, **args) > > entry.grid(column=1, row=0) > > Lab=Tk.Label(self,text=label) > > Lab.grid(column=0,row=0) > > > > def Finish() : > > root.destroy() > > > > root= Tk.Tk() > > root.protocol('WM_DELETE_WINDOW',Finish) > > Name= Tk.StringVar() > > Name.set('') > > NameE= LabEntry(root,'Name :',textvariable=Name,width=25) > > NameE.grid(column=0,row=0) > > Tk.mainloop() > > > > > > > > > Hi, > > > > > > I have two version of a simple labeled entry widget. > > > > > > import Tkinter as Tk > > > > > > class LabEntry(Tk.Entry) : > > > def __init__(self,root,label,**args) : > > > self.Frame= Tk.Frame(root) > > > Lab=Tk.Label(self.Frame,text=label) > > > Lab.grid(column=0,row=0) > > > Tk.Entry.__init__(self,self.Frame,**args) > > > self.grid(column=1,row=0) > > > > > > def grid(self,**args) : > > > self.Frame.grid(**args) > > > > > > def Finish() : > > > root.destroy() > > > > > > root= Tk.Tk() > > > root.protocol('WM_DELETE_WINDOW',Finish) > > > Name= Tk.StringVar() > > > Name.set('') > > > NameF= Tk.Frame(root) > > > NameF.grid(column=0,row=0) > > > Tk.Label(NameF,text='Name :').grid(column=0,row=0) > > > NameE= Tk.Entry(NameF,textvariable=Name,width=25) > > > NameE.grid(column=1,row=0) > > > Tk.mainloop() > > > > > > ------------------------------------------------- > > > > > > This version, which doesn't use LabEntry, reserves space for 25 > > > characters in the entry widget. > > > > > > But, replacing the last 6 lines by > > > > > > NameE= LabEntry(root,'Name :',textvariable=Name,width=25) > > > NameE.grid(column=0,row=0) > > > Tk.mainloop() > > > > > > the (internal) entry widget has only size 0 initially. > > > Why? > > > > > > Many thanks for a hint, > > > Helmut. > > > _______________________________________________ > > > 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 > > > > > From jadeite100 at yahoo.com Tue Jan 18 19:23:15 2011 From: jadeite100 at yahoo.com (jadeite100) Date: Tue, 18 Jan 2011 10:23:15 -0800 (PST) Subject: [Tkinter-discuss] Python error: GC object already tracked Message-ID: <30702737.post@talk.nabble.com> Hi: In the UT web site it says we're suppose to use Python 2.52: http://www.cdf.utoronto.ca/~csc148h/winter/python.shtml I am currently using Windows XP SP3 in my laptop. When I ran the following code in my home computer I get the following exception after the highlighted line in yellow: >>> import media >>> f = media.choose_file() >>> pic = media.load_picture(f) >>> Fatal Python error: GC object already tracked This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. I checked the UT labs and they're using also Python 2.52. I downloaded and install the following libraries: ?Python Imaging Library (PIL) ?pygame ?numpy ?PyGraphics 2 Am I missing something on my laptop to get the above error? How can I tell which software above is install? Maybe I am missing some software? At the UT lab I was able to run the following successfully and see the picture: >>> import media >>> f = media.choose_file() >>> pic = media.load_picture(f) >>> medial.show(pic) Has anybody managed to get the following code working in Windows XP SP3: >>> import media >>> f = media.choose_file() >>> pic = media.load_picture(f) >>> media.show(pic) Yours, Frustrated. -- View this message in context: http://old.nabble.com/Python-error%3A-GC-object-already-tracked-tp30702737p30702737.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From Vasilis.Vlachoudis at cern.ch Wed Jan 19 08:46:39 2011 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Wed, 19 Jan 2011 07:46:39 +0000 Subject: [Tkinter-discuss] Checkbutton label-box order Message-ID: <0BC70B5D93E054469872FFD0FE07220E3219F984@CERNXCHG11.cern.ch> Hi all, How can I create a checkbutton with the text-label on the left Checkbutton(frame, text="Label", variable=...) Label [x] The standard one has the button on the left and the label on the right [x] Label I didn't find any option to change the order. I don't want to create the label and the button separetly since this will destroy most of my grid layouts Vasilis -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Wed Jan 19 10:50:20 2011 From: klappnase at web.de (Michael Lange) Date: Wed, 19 Jan 2011 10:50:20 +0100 Subject: [Tkinter-discuss] Checkbutton label-box order In-Reply-To: <0BC70B5D93E054469872FFD0FE07220E3219F984@CERNXCHG11.cern.ch> References: <0BC70B5D93E054469872FFD0FE07220E3219F984@CERNXCHG11.cern.ch> Message-ID: <20110119105020.5d1cf6fc.klappnase@web.de> Hi, Thus spoketh Vasilis Vlachoudis unto us on Wed, 19 Jan 2011 07:46:39 +0000: > Hi all, > > How can I create a checkbutton with the text-label on the left > Checkbutton(frame, text="Label", variable=...) > Label [x] > > The standard one has the button on the left and the label on the right > [x] Label > > I didn't find any option to change the order. > > I don't want to create the label and the button separetly since this > will destroy most of my grid layouts I think you should create a custom CheckButton class that packs a Checkbutton without text and a separate Label into a Frame, like this example (which is mainly stolen from ScrolledText.py): from Tkinter import * class CheckButton(Checkbutton): def __init__(self, master=None, **kw): self.frame = Frame(master) self.label = Label(self.frame) self.label.pack(side='left', fill='x') if kw.has_key('text'): self.label.configure(text=kw['text']) del(kw['text']) Checkbutton.__init__(self, self.frame, **kw) self.pack(side='right') # Copy geometry methods of self.frame -- hack! methods = vars(Pack).keys() + vars(Grid).keys() + vars(Place).keys() for m in methods: if m[0] != '_' and m != 'config' and m != 'configure': setattr(self, m, getattr(self.frame, m)) def __str__(self): return str(self.frame) if __name__ == '__main__': root = Tk() c = CheckButton(root, text='foobar') c.pack() root.mainloop() Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. You humans have that emotional need to express gratitude. "You're welcome," I believe, is the correct response. -- Spock, "Bread and Circuses", stardate 4041.2 From jarausch at igpm.rwth-aachen.de Wed Jan 19 19:32:56 2011 From: jarausch at igpm.rwth-aachen.de (Helmut Jarausch) Date: Wed, 19 Jan 2011 19:32:56 +0100 Subject: [Tkinter-discuss] setting focus to itself - howto Message-ID: <1295461976.21833.0@numa-i> Hi, I have an Entry widget called Data, whose event is bound to a handler. If this handler recognizes invalid data I clear the corresponding textvariable and set the focus to itself by calling Data.focus_set(). Then I return "break". Thus I'd like to let the user re-enter his data. Unfortunately this doesn't work, the focus always proceeds to the next Entry widget. What am I missing? Thanks for a hint, Helmut. From klappnase at web.de Wed Jan 19 20:21:38 2011 From: klappnase at web.de (Michael Lange) Date: Wed, 19 Jan 2011 20:21:38 +0100 Subject: [Tkinter-discuss] setting focus to itself - howto In-Reply-To: <1295461976.21833.0@numa-i> References: <1295461976.21833.0@numa-i> Message-ID: <20110119202138.9dd000e3.klappnase@web.de> Hi, Thus spoketh Helmut Jarausch unto us on Wed, 19 Jan 2011 19:32:56 +0100: > Hi, > > I have an Entry widget called Data, whose event is bound to a > handler. If this handler recognizes invalid data I clear the > corresponding textvariable and set the focus to itself by calling > Data.focus_set(). Then I return "break". > Thus I'd like to let the user re-enter his data. > Unfortunately this doesn't work, the focus always proceeds to the next > Entry widget. > What am I missing? I am not sure what you actually did and what goes wrong, does the folowing code work for you ? ########################################################## from Tkinter import * root = Tk() e = Entry(root) e.pack(padx=100, pady=100) e2 = Entry(root) e2.pack(padx=100, pady=100) def on_return(event): if event.widget.get() == 'foo':# the only allowed value :) print 'That was correct!' event.widget.event_generate('') else: print 'That was wrong!' event.widget.bell() event.widget.select_range(0, 'end') e.bind('', on_return) e2.bind('', on_return) root.mainloop() ########################################################## Maybe you would also want to have a look at the Entry's validatecommand option or (if it is an option for you) to look at the Pmw.EntryField which has excellent validation mechanisms. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. "That unit is a woman." "A mass of conflicting impulses." -- Spock and Nomad, "The Changeling", stardate 3541.9 From klappnase at web.de Wed Jan 19 21:00:19 2011 From: klappnase at web.de (Michael Lange) Date: Wed, 19 Jan 2011 21:00:19 +0100 Subject: [Tkinter-discuss] setting focus to itself - howto In-Reply-To: <1295466075.21924.0@numa-i> References: <20110119202138.9dd000e3.klappnase@web.de> <1295466075.21924.0@numa-i> Message-ID: <20110119210019.27f6e4f0.klappnase@web.de> Hi, Thus spoketh Helmut Jarausch unto us on Wed, 19 Jan 2011 20:41:15 +0100: > > Thanks Michael. I will check the validatecommand. > Meanwhile I've found a solution though I don't understand > the difference: > As I said, Data.focus_set() doesn't work but > luckily > Event.widget.focus_set() > within the callback for the Data widget does work. This sounds like a namespace problem, but it's hard to tell without an exact code example ;) Maybe if you try and add something like this to your handler func: def on_return(event): print Data, event.widget, Data == event.widget ... it might help you to find out what's going on. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. A Vulcan can no sooner be disloyal than he can exist without breathing. -- Kirk, "The Menagerie", stardate 3012.4 From spooky.ln at tbs-software.com Wed Jan 19 22:07:21 2011 From: spooky.ln at tbs-software.com (Martin B.) Date: Wed, 19 Jan 2011 22:07:21 +0100 Subject: [Tkinter-discuss] setting focus to itself - howto In-Reply-To: <1295461976.21833.0@numa-i> References: <1295461976.21833.0@numa-i> Message-ID: <20110119220721.1a834dbd@tbs-software.com> hi coz i learning tkinter too i write some little app. working in py3.1 --------------------------------------------------------- from tkinter import * class ent(Entry): def __init__(self, parent, **kwargs): super().__init__() self.var = StringVar() self.config(textvariable=self.var) self.bind('', self. check) self.pack() def check(self, event): txt = self.var.get() if txt == 'end': event.widget.event_generate('') return 'break' self.var.set('') event.widget.focus_set() root = Tk() app = ent(root) sdf = ent(root) root.mainloop() V Wed, 19 Jan 2011 19:32:56 +0100 Helmut Jarausch naps?no: > Hi, > > I have an Entry widget called Data, whose event is bound to > a handler. If this handler recognizes invalid data I clear the > corresponding textvariable and set the focus to itself by calling > Data.focus_set(). Then I return "break". > Thus I'd like to let the user re-enter his data. > Unfortunately this doesn't work, the focus always proceeds to the next > Entry widget. > What am I missing? > > Thanks for a hint, > Helmut. > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From prog at vtr.net Thu Jan 27 21:43:13 2011 From: prog at vtr.net (craf) Date: Thu, 27 Jan 2011 17:43:13 -0300 Subject: [Tkinter-discuss] How to avoid screen flicker when using themes Message-ID: <1296160993.2537.14.camel@cristian-desktop> Hi everyone. I am currently learning to use themes or skins for ttk controls on a PC with Ubuntu. The code I attached, place a vertical and horizontal panedwindow control. The theme I use is 'clam'. CODE:================================================================== #! /usr/bin/env python # -*- encoding: utf-8 -*- import Tkinter import ttk class App: def __init__(self, master): self.root = master # FRAME_MASTER-------------------------------------------------- self.frame_master = ttk.Frame(self.root, style='TFrame') self.frame_master.pack(fill="both", expand='yes') # PANED_H------------------------------------------------------- self.paned_h = ttk.Panedwindow(self.frame_master, orient='horizontal', style='TPanedwindow', ) self.paned_h.pack(fill='both', expand='yes') # PANED_V------------------------------------------------------- self.paned_v = ttk.Panedwindow(self.paned_h, orient='vertical', style='v.TPanedwindow') self.paned_v.pack(fill='both', expand='yes') # TREEVIEW------------------------------------------------ self.frame_treeview = ttk.Frame(self.paned_v) self.frame_treeview.pack(fill='both', expand='yes') # FRAME_TEXTEDITOR---------------------------------------------- self.frame_texteditor = ttk.Frame(self.paned_v) self.frame_texteditor.pack(fill='both', expand='yes') self.paned_v.add(self.frame_treeview) self.paned_v.add(self.frame_texteditor) # FRAME--------------------------------------------------------- self.frame_v = ttk.Frame(self.paned_h, style='frame_v.TFrame') self.frame_v.pack(fill='both', expand='yes') self.paned_h.add(self.paned_v) self.paned_h.add(self.frame_v) self.root.wait_visibility(self.root) self.root.update_idletasks() self.paned_h.sashpos(0,200) self.paned_v.sashpos(0,400) master = Tkinter.Tk() #THEME-------------------------------------------------------------- s = ttk.Style() s.theme_use('clam') s.configure('frame_v.TFrame', background='#EFEBE7') s.configure('TFrame', background='#EFEBE7') s.configure('TPanedwindow', background='#EFEBE7') # MAXIMIZED WINDOW master.attributes('-zoomed',1) app = App(master) master.mainloop() PROBLEM:================ When you run the program first and then draw the controls are applied to the selected topic. The problem that occurs is that the color you have selected is different from that comes with the theme 'clam', which is gray. Because of this, there is a flicker when the subject applies to controls. There any way to avoid this flicker. Thanks in advance.! Regards. Cristian Abarz?a F. From georges.arsouze at gmail.com Mon Jan 31 13:22:46 2011 From: georges.arsouze at gmail.com (Georges Arsouze) Date: Mon, 31 Jan 2011 13:22:46 +0100 Subject: [Tkinter-discuss] Missing pixels whith create_line Message-ID: With python3.1 I write this program When I click buton1 there are missing pixels at the end of horizontal and vertical lines why from tkinter import * def tracerCercle(x,y,r,c): "Trac? dans zoneDessin d'un cercle de centre (x,y) de rayon r et de couleur c" zoneDessin.create_oval(x-r,y-r,x+r,y+r,outline=c) def tracerLigne(x1,y1,x2,y2,c): "Trac? dans zoneDessin d'une ligne de couleur c dont les extrimit?s sont (x1,y1) et (x2,y2)" zoneDessin.create_line(x1,y1,x2,y2,fill=c,width=1) def tracerFigure1(): zoneDessin.delete(ALL) # Dessin d'une cible # Trac? des axes tracerLigne(150,0,150,300,'red') tracerLigne(0,150,300,150,'red') # Trac? de cercles concentriques rayon=100 i=1 while(i<10): tracerCercle(150,150,rayon,'red') rayon=rayon-10 i=i+1 def tracerFigure2(): print('eee') # Programme principal fenetre = Tk() zoneDessin = Canvas(fenetre, width =300, height =300, bg ='blue') # zoneDessin est un carr? (300,300) ayant pour syst?me de coordonn?es # origine du rep?re le coin sup?rieur gauche, abscisses et ordonn?es exclusivement positives zoneDessin.pack(side =TOP) bouton1 = Button(fenetre, text ='Dessin 1', command =tracerFigure1) bouton1.pack(side =LEFT, padx =3, pady =3) bouton2 = Button(fenetre, text ='Dessin 2', command =tracerFigure2) bouton2.pack(side =RIGHT, padx =3, pady =3) fenetre.mainloop() Thank you for your help -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Mon Jan 31 17:30:42 2011 From: klappnase at web.de (Michael Lange) Date: Mon, 31 Jan 2011 17:30:42 +0100 Subject: [Tkinter-discuss] Missing pixels whith create_line In-Reply-To: References: Message-ID: <20110131173042.0613b68f.klappnase@web.de> Hi Georges, Thus spoketh Georges Arsouze unto us on Mon, 31 Jan 2011 13:22:46 +0100: > With python3.1 I write this program > When I click buton1 there are missing pixels at the end of horizontal > and vertical lines > why The Canvas widget takes the width of the border and the "highlight" (the additional border that is used to indicate that the widget has keyboard focus) into account when it calculates its coordinates. So the solution to your problem should be to either set borderwidth and highlightthickness to 0 when you create the widget or to include the border(s) into your calculations. My recommendation is to set them both to 0 (and in case you need a decorative border and/or the focus highlight, to pack the Canvas into a separate Frame which has bd=2, highlighthickness=1 or so), especially if you have a lot of items and their coords will be recalculated while the program is running, this might save you quite some headaches. In order to "emulate" focus highlight it is easy to bind a callback to and events on the canvas, which will toggle the surrounding frame's highlightcolor option. I hope this helps Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. First study the enemy. Seek weakness. -- Romulan Commander, "Balance of Terror", stardate 1709.2 From spooky.ln at tbs-software.com Mon Jan 31 17:32:09 2011 From: spooky.ln at tbs-software.com (Martin B.) Date: Mon, 31 Jan 2011 17:32:09 +0100 Subject: [Tkinter-discuss] Missing pixels whith create_line In-Reply-To: References: Message-ID: <20110131173209.5190d6bc@tbs-software.com> V Mon, 31 Jan 2011 13:22:46 +0100 Georges Arsouze naps?no: hi, just try zoneDessin = Canvas(fenetre, width =300, height =300, bg ='blue') zoneDessin.config(highlightthickness=0) > With python3.1 I write this program > When I click buton1 there are missing pixels at the end of horizontal > and vertical lines > why > > from tkinter import * > > def tracerCercle(x,y,r,c): > "Trac? dans zoneDessin d'un cercle de centre (x,y) de rayon r et > de couleur c" > zoneDessin.create_oval(x-r,y-r,x+r,y+r,outline=c) > > def tracerLigne(x1,y1,x2,y2,c): > "Trac? dans zoneDessin d'une ligne de couleur c dont les > extrimit?s sont (x1,y1) et (x2,y2)" > zoneDessin.create_line(x1,y1,x2,y2,fill=c,width=1) > > > def tracerFigure1(): > zoneDessin.delete(ALL) > # Dessin d'une cible > # Trac? des axes > tracerLigne(150,0,150,300,'red') > tracerLigne(0,150,300,150,'red') > # Trac? de cercles concentriques > rayon=100 > i=1 > while(i<10): > tracerCercle(150,150,rayon,'red') > rayon=rayon-10 > i=i+1 > > def tracerFigure2(): > print('eee') > > > > > # Programme principal > fenetre = Tk() > zoneDessin = Canvas(fenetre, width =300, height =300, bg ='blue') > # zoneDessin est un carr? (300,300) ayant pour syst?me de coordonn?es > # origine du rep?re le coin sup?rieur gauche, abscisses et ordonn?es > exclusivement positives > zoneDessin.pack(side =TOP) > bouton1 = Button(fenetre, text ='Dessin 1', command =tracerFigure1) > bouton1.pack(side =LEFT, padx =3, pady =3) > bouton2 = Button(fenetre, text ='Dessin 2', command =tracerFigure2) > bouton2.pack(side =RIGHT, padx =3, pady =3) > fenetre.mainloop() > > Thank you for your help