From spooky.ln at tbs-software.com Thu Sep 1 11:18:10 2011 From: spooky.ln at tbs-software.com (Martin B) Date: Thu, 1 Sep 2011 11:18:10 +0200 Subject: [Tkinter-discuss] GUI response In-Reply-To: References: Message-ID: <20110901111810.729838c6@tbs-software.com> Hi all, I want to know is my solution is 'clean'. I need good gui response if cpu is very busy. in this example cpu is compute my photo images on to low res. in next step i need compute md5 sums for each image etc. Is it good solution write all gui class as Thread or better way is write only critical cpu code into thread like md5 checksums, resizing etc. in this example i want use slider if cpu is computing, which is work. thanks for your comments. -------------- next part -------------- A non-text attachment was scrubbed... Name: viewer.py Type: text/x-python Size: 1267 bytes Desc: not available URL: From spooky.ln at tbs-software.com Thu Sep 1 11:43:03 2011 From: spooky.ln at tbs-software.com (Martin B) Date: Thu, 1 Sep 2011 11:43:03 +0200 Subject: [Tkinter-discuss] GUI response In-Reply-To: <20110901111810.729838c6@tbs-software.com> References: <20110901111810.729838c6@tbs-software.com> Message-ID: <20110901114303.219dd545@tbs-software.com> V Thu, 1 Sep 2011 11:18:10 +0200 Martin B naps?no: wrong path, I'm sorry. > Hi all, > I want to know is my solution is 'clean'. > I need good gui response if cpu is very busy. in this example cpu is > compute my photo images on to low res. > > in next step i need compute md5 sums for each image etc. > Is it good solution write all gui class as Thread or better way is > write only critical cpu code into thread like md5 checksums, resizing > etc. > > in this example i want use slider if cpu is computing, which is work. > thanks for your comments. From klappnase at web.de Thu Sep 1 12:12:22 2011 From: klappnase at web.de (Michael Lange) Date: Thu, 1 Sep 2011 12:12:22 +0200 Subject: [Tkinter-discuss] GUI response In-Reply-To: <20110901111810.729838c6@tbs-software.com> References: <20110901111810.729838c6@tbs-software.com> Message-ID: <20110901121222.90064e3a.klappnase@web.de> Hi, Thus spoketh Martin B unto us on Thu, 1 Sep 2011 11:18:10 +0200: > Hi all, > I want to know is my solution is 'clean'. > I need good gui response if cpu is very busy. in this example cpu is > compute my photo images on to low res. > > in next step i need compute md5 sums for each image etc. > Is it good solution write all gui class as Thread or better way is > write only critical cpu code into thread like md5 checksums, resizing > etc. > > in this example i want use slider if cpu is computing, which is work. > thanks for your comments. One thing you should *never* do is to try to handle the gui from a child thread. The Tk gui should always be run from the main program thread and communication between the gui and child threads can be done through a lock like a threading.RLock() or a threading.Condition() ; these allow you to safely update some variables from within the child thread and then query this variables' values from the gui thread (typically with an after () loop). The odd thing about gui and threads is, that it might *seem* to work when you touch your gui from the child thread, but weird, unreproducable things may happen. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. "We have the right to survive!" "Not by killing others." -- Deela and Kirk, "Wink of An Eye", stardate 5710.5 From 1248283536 at qq.com Thu Sep 1 16:21:54 2011 From: 1248283536 at qq.com (=?gbk?B?ytjW6rT9zcM=?=) Date: Thu, 1 Sep 2011 22:21:54 +0800 Subject: [Tkinter-discuss] get root.winfo_pointerxy() Message-ID: [code] from Tkinter import * root = Tk() root.title('Simple Plot - Version 1') canvas = Canvas(root, width=450, height=300, bg = 'white') canvas.pack() Button(root, text='Quit', command=root.quit).pack() canvas.create_line(100,250,400,250, width=2) canvas.create_line(100,250,100,50, width=2) for i in range(11): x = 100 + (i * 30) canvas.create_line(x,250,x,245, width=2) #canvas.create_text(x,320, text='%d'% (10*i), anchor=N) for i in range(6): y = 250 - (i * 40) canvas.create_line(100,y,105,y, width=2) canvas.create_text(96,y, text='%5.1f'% (50.*i), anchor=E) for x,y in [(12, 56), (20, 94), (33, 98), (45, 120), (61, 180), (75, 160), (98, 223)]: x = 100 + 3*x y = 250 - (4*y)/5 canvas.create_oval(x-6,y-6,x+6,y+6, width=1, outline='black', fill='SkyBlue2') def myprint(): print root.winfo_pointerxy() canvas.bind("",myprint) root.mainloop() [/code] when i click my left mouse,there is a output: File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1413, in __call__ return self.func(*args) TypeError: myprint() takes no arguments (1 given) what's wrong? -------------- next part -------------- An HTML attachment was scrubbed... URL: From dblank at cs.brynmawr.edu Thu Sep 1 16:37:31 2011 From: dblank at cs.brynmawr.edu (Douglas S. Blank) Date: Thu, 01 Sep 2011 10:37:31 -0400 Subject: [Tkinter-discuss] get root.winfo_pointerxy() In-Reply-To: References: Message-ID: <4E5F98AB.6070001@cs.brynmawr.edu> On 09/01/2011 10:21 AM, ???????? wrote: > def myprint(): > print root.winfo_pointerxy() > > canvas.bind("",myprint) When you bind a function to the canvas, it is expecting a function that takes an argument (which is probably the object to which the binding is bound). So, you could just allow myprint to take an argument, and ignore it: def myprint(arg): print root.winfo_pointerxy() -dsb -- Douglas S. Blank, Associate Professor and Chair Department of Computer Science, Bryn Mawr College http://cs.brynmawr.edu/~dblank (610)526-6501 From Cameron at phaseit.net Thu Sep 1 17:19:56 2011 From: Cameron at phaseit.net (Cameron Laird) Date: Thu, 1 Sep 2011 15:19:56 +0000 Subject: [Tkinter-discuss] get root.winfo_pointerxy() In-Reply-To: <4E5F98AB.6070001@cs.brynmawr.edu> References: <4E5F98AB.6070001@cs.brynmawr.edu> Message-ID: <20110901151956.GA5210@lairds.us> On Thu, Sep 01, 2011 at 10:37:31AM -0400, Douglas S. Blank wrote: . . . > On 09/01/2011 10:21 AM, ???????? wrote: > >def myprint(): > > print root.winfo_pointerxy() > > > >canvas.bind("",myprint) > > When you bind a function to the canvas, it is expecting a function that > takes an argument (which is probably the object to which the binding is > bound). > > So, you could just allow myprint to take an argument, and ignore it: > > def myprint(arg): > print root.winfo_pointerxy() . . . I entirely agree with the counsel Dr. Blank has provided. While I expect the original questioner has all he needs to move forward, I'll provide a bit more detail for the benefit of other readers. Let's look at "arg", "which is probably the object to which the binding is bound". It's not; it's the detected *event* (from which that object can be calculated, though) . That's not all. One could temporarily update myprint's definition to be something like def myprint(arg): print "arg is '%s'." % arg print dir(arg) print root.winfo_pointerxy() to have Python's introspection report more information about the argument. And *that* isn't all, either. If one were somehow stranded-on-a-desert-island and unsure how many (not- necessarily-named) arguments were arriving, one could experiment with def myprint(*kw): print kw ... From 1248283536 at qq.com Fri Sep 2 03:23:04 2011 From: 1248283536 at qq.com (=?gbk?B?ytjW6rT9zcM=?=) Date: Fri, 2 Sep 2011 09:23:04 +0800 Subject: [Tkinter-discuss] =?gbk?b?u9i4tKO6ICBnZXQgIHJvb3Qud2luZm9fcG9p?= =?gbk?q?nterxy=28=29?= Message-ID: def myprint(arg): print "arg.x" , arg.x,"arg.y",arg.y print root.winfo_pointerxy() what i get is: arg.x 102 arg.y 250 (103, 334) arg.x 3 arg.y 1 (4, 85) arg.x 1 arg.y 0 (2, 84) arg.x 0 arg.y 0 (1, 84) why arg.x , arg.y !== root.winfo_pointerxy() ------------------ ???? ------------------ ???: "Cameron Laird"; ????: 2011?9?1?(???) ??11:19 ???: "Douglas S. Blank"; ??: "tkinter-discuss"; ??: Re: [Tkinter-discuss] get root.winfo_pointerxy() On Thu, Sep 01, 2011 at 10:37:31AM -0400, Douglas S. Blank wrote: . . . > On 09/01/2011 10:21 AM, wrote: > >def myprint(): > > print root.winfo_pointerxy() > > > >canvas.bind("",myprint) > > When you bind a function to the canvas, it is expecting a function that > takes an argument (which is probably the object to which the binding is > bound). > > So, you could just allow myprint to take an argument, and ignore it: > > def myprint(arg): > print root.winfo_pointerxy() . . . I entirely agree with the counsel Dr. Blank has provided. While I expect the original questioner has all he needs to move forward, I'll provide a bit more detail for the benefit of other readers. Let's look at "arg", "which is probably the object to which the binding is bound". It's not; it's the detected *event* (from which that object can be calculated, though) . That's not all. One could temporarily update myprint's definition to be something like def myprint(arg): print "arg is '%s'." % arg print dir(arg) print root.winfo_pointerxy() to have Python's introspection report more information about the argument. And *that* isn't all, either. If one were somehow stranded-on-a-desert-island and unsure how many (not- necessarily-named) arguments were arriving, one could experiment with def myprint(*kw): print kw ... -------------- next part -------------- An HTML attachment was scrubbed... URL: From 1248283536 at qq.com Fri Sep 2 04:18:23 2011 From: 1248283536 at qq.com (=?gbk?B?ytjW6rT9zcM=?=) Date: Fri, 2 Sep 2011 10:18:23 +0800 Subject: [Tkinter-discuss] =?gbk?b?u9i4tKO6ICBnZXQgIHJvb3Qud2luZm9fcG9p?= =?gbk?q?nterxy=28=29?= Message-ID: in my program,myprint is: def myprint(arg): x=arg.x y=arg.y canvas.create_text(x,y,text='i am here') canvas.bind("",myprint) now ,when i left click mouse on the point in then canvas first time, there is output: i am here when i left click mouse on the point in then canvas second time,there is output too:i am here what i want to get is : when i left click mouse on the point in then canvas second time,the old output (i am here) disappear, only new output (i am here) in the canvas,how to do ? any advice appreciated. ------------------ ???? ------------------ ???: "Cameron Laird"; ????: 2011?9?1?(???) ??11:19 ???: "Douglas S. Blank"; ??: "tkinter-discuss"; ??: Re: [Tkinter-discuss] get root.winfo_pointerxy() On Thu, Sep 01, 2011 at 10:37:31AM -0400, Douglas S. Blank wrote: . . . > On 09/01/2011 10:21 AM, wrote: > >def myprint(): > > print root.winfo_pointerxy() > > > >canvas.bind("",myprint) > > When you bind a function to the canvas, it is expecting a function that > takes an argument (which is probably the object to which the binding is > bound). > > So, you could just allow myprint to take an argument, and ignore it: > > def myprint(arg): > print root.winfo_pointerxy() . . . I entirely agree with the counsel Dr. Blank has provided. While I expect the original questioner has all he needs to move forward, I'll provide a bit more detail for the benefit of other readers. Let's look at "arg", "which is probably the object to which the binding is bound". It's not; it's the detected *event* (from which that object can be calculated, though) . That's not all. One could temporarily update myprint's definition to be something like def myprint(arg): print "arg is '%s'." % arg print dir(arg) print root.winfo_pointerxy() to have Python's introspection report more information about the argument. And *that* isn't all, either. If one were somehow stranded-on-a-desert-island and unsure how many (not- necessarily-named) arguments were arriving, one could experiment with def myprint(*kw): print kw ... -------------- next part -------------- An HTML attachment was scrubbed... URL: From jmcmonagle at velseis.com Fri Sep 2 04:26:10 2011 From: jmcmonagle at velseis.com (John McMonagle) Date: Fri, 02 Sep 2011 12:26:10 +1000 Subject: [Tkinter-discuss] =?x-gbk?Q?=BB=D8=B8=B4=A3=BA__get__?= =?x-gbk?Q?root=2Ewinfo=5Fpointerxy=28=29?= In-Reply-To: References: Message-ID: <4E603EC2.7080708@velseis.com.au> On 02/09/11 11:23, ???????? wrote: > > def myprint(arg): > print "arg.x" , arg.x,"arg.y",arg.y > print root.winfo_pointerxy() > > what i get is: > arg.x 102 arg.y 250 > (103, 334) > arg.x 3 arg.y 1 > (4, 85) > arg.x 1 arg.y 0 > (2, 84) > arg.x 0 arg.y 0 > (1, 84) > > why arg.x , arg.y !== root.winfo_pointerxy() In your example, arg.x and arg.y refer to the position within the parent window (the canvas) relative to its top left corner. To get the poisition relative to the top left corner of the screen, ie equivalent to root.pointerxy(), you need arg.x_root and arg.y_root. As an exercise, to see all the possible event attributes try dir(arg) in your myprint function. Regards, John -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. From jmcmonagle at velseis.com Fri Sep 2 04:32:20 2011 From: jmcmonagle at velseis.com (John McMonagle) Date: Fri, 02 Sep 2011 12:32:20 +1000 Subject: [Tkinter-discuss] =?x-gbk?Q?=BB=D8=B8=B4=A3=BA__get__?= =?x-gbk?Q?root=2Ewinfo=5Fpointerxy=28=29?= In-Reply-To: References: Message-ID: <4E604034.7020507@velseis.com.au> On 02/09/11 12:18, ???????? wrote: > > in my program,myprint is: > > def myprint(arg): > x=arg.x > y=arg.y > canvas.create_text(x,y,text='i am here') > Take advantage of Tk canvas tags. def myprint(arg): x = arg.x y = arg.y canvas.delete('text') # delete any canvas items with the tag name text canvas.create_text(x, y, text='i am here', tags='text') Regards, John -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. From 1248283536 at qq.com Fri Sep 2 05:59:13 2011 From: 1248283536 at qq.com (=?gbk?B?ytjW6rT9zcM=?=) Date: Fri, 2 Sep 2011 11:59:13 +0800 Subject: [Tkinter-discuss] tkinter and cursor Message-ID: from matplotlib.widgets import Cursor import numpy as np import matplotlib.pyplot as plt fig = plt.figure(figsize=(8, 6)) ax = fig.add_subplot(111, axisbg='#FFFFCC') x, y = 4*(np.random.rand(2, 100)-.5) ax.plot(x, y, 'o') ax.set_xlim(-2, 2) ax.set_ylim(-2, 2) # set useblit = True on gtkagg for enhanced performance cursor = Cursor(ax, useblit=True, color='red', linewidth=2 ) plt.show() you can get a figure with the program, when you move mouse on the canvas (figure),you can see the coordinate on the right corner , i want to make it in tkinter,there is no "move click in the canvas" event in tkinter,how to make it in tkinter?? -------------- next part -------------- An HTML attachment was scrubbed... URL: From jmcmonagle at velseis.com Fri Sep 2 07:48:56 2011 From: jmcmonagle at velseis.com (John McMonagle) Date: Fri, 02 Sep 2011 15:48:56 +1000 Subject: [Tkinter-discuss] tkinter and cursor In-Reply-To: References: Message-ID: <4E606E48.9090703@velseis.com.au> On 02/09/11 13:59, ???????? wrote: > > you can get a figure with the program, when you move mouse on the canvas (figure),you can see the coordinate on the right corner , i want to make it in tkinter,there is no "move click in the canvas" event in tkinter,how to make it in tkinter?? > You can use the "" event. You also should be converting the event.x and event.y to canvas coordinates. This is especially important when your canvas also includes scrollbars. So, using your code from previous posts, from the myprint function onwards, def myprint(event): # convert the event coordinates to canvas coordinates x = canvas.canvasx(event.x) y = canvas.canvasy(event.y) # find the poistion in the top right corner of your canvas widget # less a little bit so as to see the displayed text cx = canvas.winfo_width() - 10 cy = 10 # delete previous displayed text canvas.delete('coords') # display the coordinates canvas.create_text(cx,cy,anchor=E, text='%d,%d' % (x,y), tags='coords') canvas.bind("", myprint) root.mainloop() This will display the canvas coordinate in the top right corner of the canvas widget. Suggested reading on Canvas: http://effbot.org/tkinterbook/canvas.htm Suggested reading on events: http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm Regarsd, John -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. From contropinion at gmail.com Sat Sep 3 11:31:24 2011 From: contropinion at gmail.com (contro opinion) Date: Sat, 3 Sep 2011 17:31:24 +0800 Subject: [Tkinter-discuss] scrolled canvas ,strange problem Message-ID: i have written a program in tkinter to draw stock graph,there are two strange thing i can't understand the attachment is 'AAU' data file(attachment 1).when you download it ,please save it in /tmp/AAU there is a scrolled canvas in it , 1.strang long line,please see my attachment. i have see my data ,my formulation ,no wrong,but the line is so long!! 2.there is no motion event reaction in the right of canvas,only motion event reaction in the left of canvas. 3.i have round function ,but the output is still more fractions than 2. ------------------ ???? ------------------ *???:* "John McMonagle"; *????:* 2011?9?2?(???) ??1:48 *???:* "1248283536"<1248283536 at qq.com>; *??:* "Tkinter-discuss"; *??:* Re: [Tkinter-discuss] tkinter and cursor On 02/09/11 13:59, ???? wrote: > > you can get a figure with the program, when you move mouse on the canvas (figure),you can see the coordinate on the right corner , i want to make it in tkinter,there is no "move click in the canvas" event in tkinter,how to make it in tkinter?? > You can use the "" event. You also should be converting the event.x and event.y to canvas coordinates. This is especially important when your canvas also includes scrollbars. So, using your code from previous posts, from the myprint function onwards, def myprint(event): # convert the event coordinates to canvas coordinates x = canvas.canvasx(event.x) y = canvas.canvasy(event.y) # find the poistion in the top right corner of your canvas widget # less a little bit so as to see the displayed text cx = canvas.winfo_width() - 10 cy = 10 # delete previous displayed text canvas.delete('coords') # display the coordinates canvas.create_text(cx,cy,anchor=E, text='%d,%d' % (x,y), tags='coords') canvas.bind("", myprint) root.mainloop() This will display the canvas coordinate in the top right corner of the canvas widget. Suggested reading on Canvas: http://effbot.org/tkinterbook/canvas.htm Suggested reading on events: http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm Regarsd, John -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: attach1.png Type: image/png Size: 69606 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: attach2.png Type: image/png Size: 56822 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: AAU Type: application/octet-stream Size: 58806 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: draw.py Type: text/x-python Size: 5905 bytes Desc: not available URL: From contropinion at gmail.com Sat Sep 3 16:06:57 2011 From: contropinion at gmail.com (contro opinion) Date: Sat, 3 Sep 2011 22:06:57 +0800 Subject: [Tkinter-discuss] scrolled canvas ,strange problem Message-ID: i have written a program in tkinter to draw stock graph,there are two strange thing i can't understand the attachment is 'AAU' data file(attachment 1).when you download it ,please save it in /tmp/AAU there is a scrolled canvas in it , 1.strang long line,please see my attachment. i have see my data ,my formulation ,no wrong,but the line is so long!! 2.there is no motion event reaction in the right of canvas,only motion event reaction in the left of canvas. 3.i have round function ,but the output is still more fractions than 2. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: attach1.png Type: image/png Size: 69606 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: attach2.png Type: image/png Size: 56822 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: draw.py Type: text/x-python Size: 5905 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: AAU Type: application/octet-stream Size: 58806 bytes Desc: not available URL: From johnmc at velseis.com Sun Sep 4 05:26:49 2011 From: johnmc at velseis.com (johnmc) Date: Sun, 4 Sep 2011 13:26:49 +1000 Subject: [Tkinter-discuss] scrolled canvas ,strange problem In-Reply-To: References: Message-ID: <20110904031116.M54633@velseis.com> On Sat, 3 Sep 2011 17:31:24 +0800, contro opinion wrote > i have written a program in tkinter to draw stock graph,there are two > strange thing i can't understand > the attachment is 'AAU' data file(attachment 1).when you download it > ,please save it in /tmp/AAU > there is a scrolled canvas in it , > > 1.strang long line,please see my attachment. > i have see my data ,my formulation ,no wrong,but the line is so long!! > I haven't analysed it thoroughly, but your horizontal scale for the data does not match the horizontal scale for your labels or motion reporting. The "long line" you see actually matches the data on line 1089 in your data file. The date on this line is 2007-02-27. > 2.there is no motion event reaction in the right of canvas,only > motion event reaction in the left of canvas. The IS a motion event throughout the entire canvas. Again, your problem seems to be with your horizontal scale. The far right coordinate is 5710, yet you only report the motion to 2764, the upper limit of self.xsqueen. > 3.i have round function ,but the output is still more fractions than 2. Whether you round a float or not has no impact on how it is displayed as a string. You need to use the appropriate string formatting. If you want two decimal places try the following format: %.2f rather than %f. The rounding will also be properly handled by the string formatting, so there will be no need to use the round function. Regards, John -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. From contropinion at gmail.com Sun Sep 4 10:54:32 2011 From: contropinion at gmail.com (contro opinion) Date: Sun, 4 Sep 2011 16:54:32 +0800 Subject: [Tkinter-discuss] scrolled canvas ,strange problem In-Reply-To: References: Message-ID: think for John McMonagle only one sentence is wrong ,i revise it : self.xsqueen=[50+4*i for i in range(0,self.pairs)] it is ok,now ^_^ ? 2011?9?3? ??5:31?contro opinion ??? > i have written a program in tkinter to draw stock graph,there are two > strange thing i can't understand > the attachment is 'AAU' data file(attachment 1).when you download it > ,please save it in /tmp/AAU > there is a scrolled canvas in it , > > 1.strang long line,please see my attachment. > i have see my data ,my formulation ,no wrong,but the line is so > long!! > 2.there is no motion event reaction in the right of canvas,only > motion event reaction in the left of canvas. > 3.i have round function ,but the output is still more fractions than > 2. > > > > > > ------------------ ???? ------------------ > *???:* "John McMonagle"; > *????:* 2011?9?2?(???) ??1:48 > *???:* "1248283536"<1248283536 at qq.com>; > *??:* "Tkinter-discuss"; > *??:* Re: [Tkinter-discuss] tkinter and cursor > > On 02/09/11 13:59, ???? wrote: > > > > > you can get a figure with the program, when you move mouse on the > canvas (figure),you can see the coordinate on the right corner , i want to > make it in tkinter,there is no "move click in the canvas" event in > tkinter,how to make it in tkinter?? > > > > You can use the "" event. You also should be converting the > event.x and event.y to canvas coordinates. This is especially important > when your canvas also includes scrollbars. > > > So, using your code from previous posts, from the myprint function onwards, > > > > def myprint(event): > # convert the event coordinates to canvas coordinates > x = canvas.canvasx(event.x) > y = canvas.canvasy(event.y) > > # find the poistion in the top right corner of your canvas widget > # less a little bit so as to see the displayed text > cx = canvas.winfo_width() - 10 > cy = 10 > > # delete previous displayed text > canvas.delete('coords') > > # display the coordinates > canvas.create_text(cx,cy,anchor=E, text='%d,%d' % (x,y), tags='coords') > > canvas.bind("", myprint) > > root.mainloop() > > > This will display the canvas coordinate in the top right corner of the > canvas widget. > > Suggested reading on Canvas: > > http://effbot.org/tkinterbook/canvas.htm > > Suggested reading on events: > > http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm > > Regarsd, > > John > > -- > This message has been scanned for viruses and > dangerous content by MailScanner, and is > believed to be clean. -------------- next part -------------- An HTML attachment was scrubbed... URL: From contropinion at gmail.com Sun Sep 4 05:18:18 2011 From: contropinion at gmail.com (contro opinion) Date: Sun, 4 Sep 2011 11:18:18 +0800 Subject: [Tkinter-discuss] scrolled canvas , strange problem, i find something Message-ID: in my program,i want to draw line which date is ['2008-06-02','2008-06-03','2008-06-04','2008-06-05','2008-06-06','2008-06-09','2008-06-10'] please see the code line draw 130 ,what i get is (please see the attachment) 2010-12-15, it is so strange thing?? i can't understand please download the data (AAU),save it in "/tmp" and run the draw code,you can see. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Screenshot.png Type: image/png Size: 48916 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: AAU Type: application/octet-stream Size: 58806 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: draw Type: application/octet-stream Size: 6395 bytes Desc: not available URL: From 1248283536 at qq.com Mon Sep 5 04:22:09 2011 From: 1248283536 at qq.com (=?gbk?B?ytjW6rT9zcM=?=) Date: Mon, 5 Sep 2011 10:22:09 +0800 Subject: [Tkinter-discuss] scrolled canvas ,strange problem Message-ID: i want to save my phote in computer,so i add canvas.postscript(file="mystock.eps") there is a file named mystock.eps,but nothing in it!I want to know how to save my canvas as an image file. ------------------ Original ------------------ From: "johnmc"; Date: Sun, Sep 4, 2011 11:26 AM To: "contro opinion"; "John McMonagle"; "Tkinter-discuss"; Subject: Re: [Tkinter-discuss] scrolled canvas ,strange problem On Sat, 3 Sep 2011 17:31:24 +0800, contro opinion wrote > i have written a program in tkinter to draw stock graph,there are two > strange thing i can't understand > the attachment is 'AAU' data file(attachment 1).when you download it > ,please save it in /tmp/AAU > there is a scrolled canvas in it , > > 1.strang long line,please see my attachment. > i have see my data ,my formulation ,no wrong,but the line is so long!! > I haven't analysed it thoroughly, but your horizontal scale for the data does not match the horizontal scale for your labels or motion reporting. The "long line" you see actually matches the data on line 1089 in your data file. The date on this line is 2007-02-27. > 2.there is no motion event reaction in the right of canvas,only > motion event reaction in the left of canvas. The IS a motion event throughout the entire canvas. Again, your problem seems to be with your horizontal scale. The far right coordinate is 5710, yet you only report the motion to 2764, the upper limit of self.xsqueen. > 3.i have round function ,but the output is still more fractions than 2. Whether you round a float or not has no impact on how it is displayed as a string. You need to use the appropriate string formatting. If you want two decimal places try the following format: %.2f rather than %f. The rounding will also be properly handled by the string formatting, so there will be no need to use the round function. Regards, John -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss at python.org http://mail.python.org/mailman/listinfo/tkinter-discuss -------------- next part -------------- An HTML attachment was scrubbed... URL: From jmcmonagle at velseis.com Mon Sep 5 07:28:45 2011 From: jmcmonagle at velseis.com (John McMonagle) Date: Mon, 05 Sep 2011 15:28:45 +1000 Subject: [Tkinter-discuss] scrolled canvas ,strange problem In-Reply-To: References: Message-ID: <4E645E0D.6090103@velseis.com.au> On 05/09/11 12:22, ???????? wrote: > i want to save my phote in computer,so i add > canvas.postscript(file="mystock.eps") > > there is a file named mystock.eps,but nothing in it! > > I want to know how to save my canvas as an image file. You need to at least specify a width and height option to the canvas postscript method. Regards, John -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. From alexxx.magni at gmail.com Tue Sep 6 14:24:35 2011 From: alexxx.magni at gmail.com (Alessandro Magni) Date: Tue, 6 Sep 2011 14:24:35 +0200 Subject: [Tkinter-discuss] embedding in Tkinter Message-ID: Hi everybody, I hope somebody here can give me a hand - I'm not so expert in GUI programming. I tried - in a Tkinter program I'm writing - to embed a terminal (linux here) in the main window - the program is a simple wiki, and I believe it's useful to have a small terminal handy... Optionally, I would like also to be able to let my program interact with the terminal - at a minimum I'd like to read the current working directory, and to set it. I tried asking about it on stackoverflow, but without much results (apart from some suggestions about pyGTK being the wave of the future, of course...) I don't know if it is really impossible - but at least I was able to do it in the past with Perl/Tk, so maybe it can be replicated here. The code I used then was something like: $frame3=$mw->Frame(); $cv=$frame3->Canvas()->pack(-expand => 1, -fill => 'both'); my $xtermContainer = $cv->Frame(-container => 1); # this Frame is needed for including the xterm in Tk::Canvas my $xtid = $xtermContainer->id(); my ($xtId) = sprintf hex $xtid; # converting the id from HEX to decimal as xterm requires a decimal Id my $dcontitem = $cv->createWindow($xtermWidth/2,$xtermHeight/2, -window => $xtermContainer, -width => $xtermWidth, -height => $xtermHeight, -state => 'normal'); system("xterm -into $xtId -fn $fontname -geometry $geometry +sb -bg black -fg white -e ./xtermjob.pl &"); (...hoping no python purist wants to shoot me in the head for showing perl in a python mailing list :-) I tried using a code similar to the following, but it doesnt work... termf = Frame(root) termf.pack(side=BOTTOM, fill=X) id=termf.winfo_id() os.system("xterm -into %d -e /root/.bashrc &" % id); Does somebody here have an experience with this problem? Thanks a lot! alessandro From jmcmonagle at velseis.com Wed Sep 7 01:44:21 2011 From: jmcmonagle at velseis.com (John McMonagle) Date: Wed, 07 Sep 2011 09:44:21 +1000 Subject: [Tkinter-discuss] embedding in Tkinter In-Reply-To: References: Message-ID: <4E66B055.6030001@velseis.com.au> On 06/09/11 22:24, Alessandro Magni wrote: > Hi everybody, > I hope somebody here can give me a hand - I'm not so expert in GUI programming. > I tried - in a Tkinter program I'm writing - to embed a terminal > (linux here) in the main window - the program is a simple wiki, and I > believe it's useful to have a small terminal handy... > Optionally, I would like also to be able to let my program interact > with the terminal - at a minimum I'd like to read the current working > directory, and to set it. > > I tried asking about it on stackoverflow, but without much results > (apart from some suggestions about pyGTK being the wave of the future, > of course...) > > I don't know if it is really impossible - but at least I was able to > do it in the past with Perl/Tk, so maybe it can be replicated here. > > The code I used then was something like: > > $frame3=$mw->Frame(); > $cv=$frame3->Canvas()->pack(-expand => 1, -fill => 'both'); > > my $xtermContainer = $cv->Frame(-container => 1); # this Frame is > needed for including the xterm in Tk::Canvas > > my $xtid = $xtermContainer->id(); > my ($xtId) = sprintf hex $xtid; # converting the id from HEX to > decimal as xterm requires a decimal Id > > my $dcontitem = $cv->createWindow($xtermWidth/2,$xtermHeight/2, > -window => $xtermContainer, > -width => $xtermWidth, > -height => $xtermHeight, > -state => 'normal'); > > system("xterm -into $xtId -fn $fontname -geometry $geometry +sb -bg > black -fg white -e ./xtermjob.pl &"); > > > > (...hoping no python purist wants to shoot me in the head for showing > perl in a python mailing list :-) > > > > I tried using a code similar to the following, but it doesnt work... > > termf = Frame(root) > termf.pack(side=BOTTOM, fill=X) > id=termf.winfo_id() > os.system("xterm -into %d -e /root/.bashrc &" % id); > > Does somebody here have an experience with this problem? > > > Thanks a lot! I've modified your little example above with some success: from Tkinter import * import os root = Tk() termf = Frame(root, height=200, width=400) termf.pack(fill=BOTH, expand=YES) wid = termf.winfo_id() os.system('xterm -into %d -geometry 400x200 -e /root/.bashrc&' % wid) root.mainloop() Happy experimenting, John -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. From Cameron at phaseit.net Wed Sep 7 02:44:20 2011 From: Cameron at phaseit.net (Cameron Laird) Date: Wed, 7 Sep 2011 00:44:20 +0000 Subject: [Tkinter-discuss] embedding in Tkinter In-Reply-To: <4E66B055.6030001@velseis.com.au> References: <4E66B055.6030001@velseis.com.au> Message-ID: <20110907004420.GA9773@lairds.us> On Wed, Sep 07, 2011 at 09:44:21AM +1000, John McMonagle wrote: > On 06/09/11 22:24, Alessandro Magni wrote: > > Hi everybody, > > I hope somebody here can give me a hand - I'm not so expert in GUI programming. > > I tried - in a Tkinter program I'm writing - to embed a terminal > > (linux here) in the main window - the program is a simple wiki, and I > > believe it's useful to have a small terminal handy... > > Optionally, I would like also to be able to let my program interact > > with the terminal - at a minimum I'd like to read the current working > > directory, and to set it. . . . > I've modified your little example above with some success: > > from Tkinter import * > import os > > root = Tk() > termf = Frame(root, height=200, width=400) > termf.pack(fill=BOTH, expand=YES) > wid = termf.winfo_id() > os.system('xterm -into %d -geometry 400x200 -e /root/.bashrc&' % wid) > > root.mainloop() . . . Alessandro, when you write "Optionally, I would like also to be able to let my program interact with the terminal - at a minimum I'd like to read the current working directory, and to set it" and "... it doesn't work", I am unsure of your meaning. John answered what I understand of your question about Tkinter coding well; do you also want help communicating between the xterm's $SHELL and the Python application, or do you have what you need for that aspect, already? From trevor at jcmanagement.net Wed Sep 7 02:07:49 2011 From: trevor at jcmanagement.net (Trevor J Christensen) Date: Tue, 06 Sep 2011 18:07:49 -0600 (MDT) Subject: [Tkinter-discuss] Programmatic control of a ttk combobox Message-ID: <21df96ab-3706-4b08-a6ee-1803fb3e1449@zms01.zcs> How could/would one programmatically open/close a ttk combobox (i.e. present/hide the list of values) without requiring the user to click on combobox down arrow? In other words, I want to programmatically change focus (from where ever it is) to the combobox and have the combobox list of values displayed (just as if I had clicked on the combobox down arrow control). I fiddled around with setting state (['pressed'] and ['focus']) but didn't succeed accomplishing this. Trevor -------------- next part -------------- An HTML attachment was scrubbed... URL: From jmcmonagle at velseis.com Wed Sep 7 08:20:34 2011 From: jmcmonagle at velseis.com (John McMonagle) Date: Wed, 07 Sep 2011 16:20:34 +1000 Subject: [Tkinter-discuss] Programmatic control of a ttk combobox In-Reply-To: <21df96ab-3706-4b08-a6ee-1803fb3e1449@zms01.zcs> References: <21df96ab-3706-4b08-a6ee-1803fb3e1449@zms01.zcs> Message-ID: <4E670D32.3090007@velseis.com.au> On 07/09/11 10:07, Trevor J Christensen wrote: > How could/would one programmatically open/close a ttk combobox (i.e. > present/hide the list of values) without requiring the user to click on > combobox down arrow? > > In other words, I want to programmatically change focus (from where ever > it is) to the combobox and have the combobox list of values displayed > (just as if I had clicked on the combobox down arrow control). I > fiddled around with setting state (['pressed'] and ['focus']) but didn't > succeed accomplishing this. > I haven't delved too deeply into ttk yet, but I know how to solve your problem using Python Megawidgets (Pmw) instead. PMW example: from Tkinter import * import Pmw root = Tk() c = Pmw.ComboBox(root, scrolledlist_items=['1','2','3']) c.pack() c.selectitem('1') def dropdown(): c.invoke() b = Button(root, text='test', command=dropdown) b.pack() root.mainloop() Worked it out in ttk. You need to generate a button 1 event on the combobox. ttk example: from Tkinter import * import ttk root = Tk() c = ttk.Combobox(root) c.pack() c['values'] = ['1','2','3'] def dropdown(): c.event_generate('') b = Button(root, text='test', command=dropdown) b.pack() root.mainloop() Regards, John -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. From klappnase at web.de Wed Sep 7 11:03:35 2011 From: klappnase at web.de (Michael Lange) Date: Wed, 7 Sep 2011 11:03:35 +0200 Subject: [Tkinter-discuss] Programmatic control of a ttk combobox In-Reply-To: <21df96ab-3706-4b08-a6ee-1803fb3e1449@zms01.zcs> References: <21df96ab-3706-4b08-a6ee-1803fb3e1449@zms01.zcs> Message-ID: <20110907110335.08970b15.klappnase@web.de> Hi Trevor, Thus spoketh Trevor J Christensen unto us on Tue, 06 Sep 2011 18:07:49 -0600 (MDT): > How could/would one programmatically open/close a ttk combobox (i.e. > present/hide the list of values) without requiring the user to click on > combobox down arrow? > > In other words, I want to programmatically change focus (from where > ever it is) to the combobox and have the combobox list of values > displayed (just as if I had clicked on the combobox down arrow > control). I fiddled around with setting state (['pressed'] and > ['focus']) but didn't succeed accomplishing this. there seems to be no "post()" method or something like that for the ttk.Combobox, but what you want can be done with a little trickery: from Tkinter import * import ttk class ComboBox(ttk.Combobox): def __init__(self, *args, **kw): ttk.Combobox.__init__(self, *args, **kw) def post(self, event=None): self.update_idletasks() x, y = self.winfo_x(), self.winfo_y() self.event_generate('<1>', x=x+self.winfo_width()-3, y=y+3) root = Tk() c = ComboBox(root, values=('foo', 'bar', 'baz')) c.set('foo') c.pack(padx=50, pady=50) e = Entry(root) e.pack(pady=(0,50)) e.focus() root.bind('', c.post) root.mainloop() I hope this helps Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. No one can guarantee the actions of another. -- Spock, "Day of the Dove", stardate unknown From alexxx.magni at gmail.com Wed Sep 7 12:11:56 2011 From: alexxx.magni at gmail.com (Alessandro Magni) Date: Wed, 7 Sep 2011 12:11:56 +0200 Subject: [Tkinter-discuss] embedding in Tkinter Message-ID: > On 06/09/11 22:24, Alessandro Magni wrote: > > Hi everybody, > > I hope somebody here can give me a hand - I'm not so expert in GUI programming. > > I tried - in a Tkinter program I'm writing - to embed a terminal > > (linux here) in the main window - the program is a simple wiki, and I > > believe it's useful to have a small terminal handy... > > Optionally, I would like also to be able to let my program interact > > with the terminal - at a minimum I'd like to read the current working > > directory, and to set it. > I've modified your little example above with some success: > > from Tkinter import * > import os > > root = Tk() > termf = Frame(root, height=200, width=400) > termf.pack(fill=BOTH, expand=YES) > wid = termf.winfo_id() > os.system('xterm -into %d -geometry 400x200 -e /root/.bashrc&' % wid) > > root.mainloop() . . > Alessandro, when you write "Optionally, I would like also to be > able to let my program interact with the terminal - at a minimum > I'd like to read the current working directory, and to set it" > and "... it doesn't work", I am unsure of your meaning. John > answered what I understand of your question about Tkinter coding > well; do you also want help communicating between the xterm's > $SHELL and the Python application, or do you have what you need > for that aspect, already? John, Cameron, thank you so much for your help... I feel a bit stupid, what was happening was a problem in the launch of xterm (I mistakenly wrote an option), Tkinter works flawlessly... Anyway I'm glad we talked about it since the general mood on stackoverflow was - as I said - that a) it was a very complex problem and b) you could not hope to solve it with such a joke as Tkinter. Serve them right! I answered them with your help, let's see if they can do it in so few lines with pyGTK :-) Anyway I'm still working on the interaction between the program and the terminal: I dont know if it can be done internally by python, but I found this program http://www.thrysoee.dk/xtermcontrol/ that could help, I'm working on it... thank you again alessandro