From chao.albert at gmail.com Thu Dec 3 04:25:32 2009 From: chao.albert at gmail.com (chachachacha) Date: Wed, 2 Dec 2009 19:25:32 -0800 (PST) Subject: [Tkinter-discuss] Python with Snack Message-ID: <26620448.post@talk.nabble.com> Hi everyone, I have been trying to install the Snack library (so I can run it with Python 2.5.4). I have Windows Vista and have been trying to install through the command line. I have downloaded the source release for Snack Version 2.2.10 from the page http://www.speech.kth.se/snack/download.html The downloaded folder is on my desktop in a folder called snack. Through the command line, I tried to install the program: C:\Users\user\Desktop\snack\python\setup.py install It returns with: running install running build running build_py file tkSnack.py (for module tkSnack) not found file tkSnack.py (for module tkSnack) not found running install_lib warning: install_lib: 'build\lib' does not exist --no Python modules to install running install_egg_info Writing C:\Python25\Lib\site-packages\tkSnack-2.2.10-py2.5.egg-info I've also just tried to do: C:\Users\user\Desktop\snack\python\python.py install This didn't work either I am very inexperienced in programming but am very eager to learn. I know this is something really simple but it would be great if someone could point out what I am doing wrong. Thanks! -Al -- View this message in context: http://old.nabble.com/Python-with-Snack-tp26620448p26620448.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From klappnase at web.de Thu Dec 3 16:40:14 2009 From: klappnase at web.de (Michael Lange) Date: Thu, 3 Dec 2009 16:40:14 +0100 Subject: [Tkinter-discuss] Python with Snack In-Reply-To: <26620448.post@talk.nabble.com> References: <26620448.post@talk.nabble.com> Message-ID: <20091203164014.b55eb018.klappnase@web.de> Hi, On Wed, 2 Dec 2009 19:25:32 -0800 (PST) chachachacha wrote: > > Hi everyone, > > I have been trying to install the Snack library (so I can run it with > Python 2.5.4). I have Windows Vista and have been trying to install > through the command line. I have downloaded the source release for > Snack Version 2.2.10 from the page > http://www.speech.kth.se/snack/download.html > > The downloaded folder is on my desktop in a folder called snack. > Through the command line, I tried to install the program: > C:\Users\user\Desktop\snack\python\setup.py install > > It returns with: > running install > running build > running build_py > file tkSnack.py (for module tkSnack) not found > file tkSnack.py (for module tkSnack) not found > running install_lib > warning: install_lib: 'build\lib' does not exist --no Python modules > to install > > running install_egg_info > Writing C:\Python25\Lib\site-packages\tkSnack-2.2.10-py2.5.egg-info > > I've also just tried to do: > C:\Users\user\Desktop\snack\python\python.py install > This didn't work either > > I am very inexperienced in programming but am very eager to learn. I > know this is something really simple but it would be great if someone > could point out what I am doing wrong. > I don't know what's going wrong here, but I think it should be fine to simply copy the tkSnack module into Python's site-packages folder. I hope this helps Michael From kw at codebykevin.com Thu Dec 3 16:54:49 2009 From: kw at codebykevin.com (Kevin Walzer) Date: Thu, 03 Dec 2009 10:54:49 -0500 Subject: [Tkinter-discuss] Python with Snack In-Reply-To: <20091203164014.b55eb018.klappnase@web.de> References: <26620448.post@talk.nabble.com> <20091203164014.b55eb018.klappnase@web.de> Message-ID: <4B17DF49.4030906@codebykevin.com> On 12/3/09 10:40 AM, Michael Lange wrote: >> > > I don't know what's going wrong here, but I think it should be fine to > simply copy the tkSnack module into Python's site-packages folder. > Will distutils/setuptools actually build the binary Snack library? It's a Tcl/Tk library, not a Python library. tkSnack.py is just a wrapper. The OP is probably better off downloading the Windows binary, installing it in the appropriate directory (wherever the other Tcl/Tk libs are on his system), and then trying to install tkSnack.py. -- Kevin Walzer Code by Kevin http://www.codebykevin.com From rowen at uw.edu Thu Dec 3 22:32:23 2009 From: rowen at uw.edu (Russell E. Owen) Date: Thu, 03 Dec 2009 13:32:23 -0800 Subject: [Tkinter-discuss] Python with Snack References: <26620448.post@talk.nabble.com> <20091203164014.b55eb018.klappnase@web.de> <4B17DF49.4030906@codebykevin.com> Message-ID: In article <4B17DF49.4030906 at codebykevin.com>, Kevin Walzer wrote: > On 12/3/09 10:40 AM, Michael Lange wrote: > > > > I don't know what's going wrong here, but I think it should be fine to > > simply copy the tkSnack module into Python's site-packages folder. > > > > Will distutils/setuptools actually build the binary Snack library? It's > a Tcl/Tk library, not a Python library. tkSnack.py is just a wrapper. > The OP is probably better off downloading the Windows binary, installing > it in the appropriate directory (wherever the other Tcl/Tk libs are on > his system), and then trying to install tkSnack.py. I agree. I am pretty sure distutils will not build the snack library. I used to install it on Windows by downloading the binary release for windows with python (but it only goes up to Python 2.3). Then follow the instructions on the web site: "Installation (with Python)". But...I recommend not using snack at all. It appears to have been abandoned. I used to use it, but switched to pygame. I chose pygame because (like snack, except snack is no longer maintained): - It is fully cross-platform (Mac, unix and windows) - It plays sounds asynchronously - It is released and well maintained - It is easy to use and easy to install Note that pygame does much more than play sounds. But you can ignore the extra capabilities if you don't need them. There are a number of sound packages, but I found none that were cross-platform, fully released (version 1.0 or later) and still actively maintained. -- Russell From jmcmonagle at velseis.com.au Fri Dec 4 02:24:43 2009 From: jmcmonagle at velseis.com.au (John McMonagle) Date: Fri, 04 Dec 2009 11:24:43 +1000 Subject: [Tkinter-discuss] Python with Snack In-Reply-To: <26620448.post@talk.nabble.com> References: <26620448.post@talk.nabble.com> Message-ID: <4B1864DB.2090509@velseis.com.au> chachachacha wrote: > Hi everyone, > > I have been trying to install the Snack library (so I can run it with Python > 2.5.4). I have Windows Vista and have been trying to install through the > command line. I have downloaded the source release for Snack Version 2.2.10 > from the page http://www.speech.kth.se/snack/download.html > > The downloaded folder is on my desktop in a folder called snack. Through > the command line, I tried to install the program: > C:\Users\user\Desktop\snack\python\setup.py install > > It returns with: > running install > running build > running build_py > file tkSnack.py (for module tkSnack) not found > file tkSnack.py (for module tkSnack) not found > running install_lib > warning: install_lib: 'build\lib' does not exist --no Python modules to > install > > running install_egg_info > Writing C:\Python25\Lib\site-packages\tkSnack-2.2.10-py2.5.egg-info > > I've also just tried to do: > C:\Users\user\Desktop\snack\python\python.py install > This didn't work either > > I am very inexperienced in programming but am very eager to learn. I know > this is something really simple but it would be great if someone could point > out what I am doing wrong. > > Thanks! > -Al Although I'm not on windows, it seems to me that you are in the wrong folder when you try to run setup.py. Try changing to the appropriate folder first: cd C:\Users\user\Desktop\snack\python setup.py install Regards, John From chao.albert at gmail.com Fri Dec 4 07:42:48 2009 From: chao.albert at gmail.com (chachachacha) Date: Thu, 3 Dec 2009 22:42:48 -0800 (PST) Subject: [Tkinter-discuss] Python with Snack In-Reply-To: References: <26620448.post@talk.nabble.com> <20091203164014.b55eb018.klappnase@web.de> <4B17DF49.4030906@codebykevin.com> Message-ID: <26635787.post@talk.nabble.com> Hi everyone. Thanks for your responses! So I did manage to get Snack installed. It turned out to be a very simple process (arg...). As Russell points out, the binaries stopped at python 2.3. However, as suggested by Michael, I was able to copy the snacklib into the Tcl folder. I then copied the tkSnack.py into the Lib folder. Problem is, as Russell points out, Snack is out of date. I was trying to use it to do audio event analysis. I wanted to use sound to detect when heaters in a building would turn on. With the help of Snack (the Wavesurfer extension of snack), I have identified the frequencies produced when the heaters turn on. However, there seems to be no way of getting the actual values of frequencies (at least, none that I could figure out)! What I need still is a way to tell the computer: Listen (as computers can do this non-stop) until you hear the heaters turn on. At this moment, record the time and date. I will take a look at pygame. Thanks again for everyone's responses! -Al Russell E. Owen-4 wrote: > > In article <4B17DF49.4030906 at codebykevin.com>, > Kevin Walzer wrote: > >> On 12/3/09 10:40 AM, Michael Lange wrote: >> > >> > I don't know what's going wrong here, but I think it should be fine to >> > simply copy the tkSnack module into Python's site-packages folder. >> > >> >> Will distutils/setuptools actually build the binary Snack library? It's >> a Tcl/Tk library, not a Python library. tkSnack.py is just a wrapper. >> The OP is probably better off downloading the Windows binary, installing >> it in the appropriate directory (wherever the other Tcl/Tk libs are on >> his system), and then trying to install tkSnack.py. > > I agree. I am pretty sure distutils will not build the snack library. > > I used to install it on Windows by downloading the binary release for > windows with python (but it only goes up to Python 2.3). Then follow the > instructions on the web site: "Installation (with Python)". > > But...I recommend not using snack at all. It appears to have been > abandoned. > > I used to use it, but switched to pygame. I chose pygame because (like > snack, except snack is no longer maintained): > - It is fully cross-platform (Mac, unix and windows) > - It plays sounds asynchronously > - It is released and well maintained > - It is easy to use and easy to install > > Note that pygame does much more than play sounds. But you can ignore the > extra capabilities if you don't need them. > > There are a number of sound packages, but I found none that were > cross-platform, fully released (version 1.0 or later) and still actively > maintained. > > -- Russell > > _______________________________________________ > 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/Python-with-Snack-tp26620448p26635787.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From Vasilis.Vlachoudis at cern.ch Fri Dec 4 16:53:56 2009 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Fri, 4 Dec 2009 16:53:56 +0100 Subject: [Tkinter-discuss] Cursor coordinates Message-ID: <4B193094.1010902@cern.ch> Hi all, I have a canvas with some editable text (with create_text) in it. How can I get the cursor coordinates x,y from the canvas? The index() function returns only the character index, is there a way to convert the position of a character into x,y coordinates or bbox? Vasilis From michael.odonnell at uam.es Fri Dec 4 19:31:07 2009 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Fri, 4 Dec 2009 19:31:07 +0100 Subject: [Tkinter-discuss] Cursor coordinates In-Reply-To: <4B193094.1010902@cern.ch> References: <4B193094.1010902@cern.ch> Message-ID: <47e491110912041031y16b55f8esfe90fe1277c09bd5@mail.gmail.com> Hi Vasilis, A general method on all widgets; w.winfo_pointerxy() Returns a tuple (x, y) containing the coordinates of the mouse pointer relative to w's root window. If the mouse pointer isn't on the same screen, returns (-1, -1). Use this method on you canvas. If you canvas is scrolled, then you need to adjust these coordinates (since the top-left corner of the visible canvas may not be (0,0) of the canvas coordinates) So do something like: x,y=canv.winfo_pointerxy() x= canv.canvasx(x) y= canv.canvasy(y) Note also you can bind methods to events (not only clicks on your canas, but also movement) When the method is called, it gets an event object as one parameter, and this event object includes the x and y of the cursor Mick I am workin from memory here, so don't tak my word for it. On Fri, Dec 4, 2009 at 4:53 PM, Vasilis Vlachoudis wrote: > Hi all, > > I have a canvas with some editable text (with create_text) in it. > How can I get the cursor coordinates x,y from the canvas? > The index() function returns only the character index, is there a way to > convert the position of a character into x,y coordinates or bbox? > > Vasilis > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From klappnase at web.de Fri Dec 4 20:39:23 2009 From: klappnase at web.de (Michael Lange) Date: Fri, 4 Dec 2009 20:39:23 +0100 Subject: [Tkinter-discuss] Cursor coordinates In-Reply-To: <47e491110912041031y16b55f8esfe90fe1277c09bd5@mail.gmail.com> References: <4B193094.1010902@cern.ch> <47e491110912041031y16b55f8esfe90fe1277c09bd5@mail.gmail.com> Message-ID: <20091204203923.6ddd86d5.klappnase@web.de> Hi, On Fri, 4 Dec 2009 19:31:07 +0100 "Michael O'Donnell" wrote: > Hi Vasilis, > > A general method on all widgets; w.winfo_pointerxy() > > Returns a tuple (x, y) containing the coordinates of the mouse > pointer relative to w's root window. > If the mouse pointer isn't on the same screen, returns (-1, -1). > (...) I think Vasilis meant how to find the coords of the text's insertion cursor, not the mouse pointer coords ? I don't know if this is possible though. Michael From Vasilis.Vlachoudis at cern.ch Fri Dec 4 20:49:01 2009 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Fri, 4 Dec 2009 20:49:01 +0100 Subject: [Tkinter-discuss] Cursor coordinates References: <4B193094.1010902@cern.ch> <47e491110912041031y16b55f8esfe90fe1277c09bd5@mail.gmail.com> Message-ID: <2AACD4EB2F123248A064A23843B3A173016CCC54@cernxchg47.cern.ch> Thank you Michael, I was looking also for that function but for another task. On my previous email I was asking to find the position (x,y) of the text-cursor or alternative the bbox of a single character from a text element inside a canvas. In my project I have created a full text editor inside the canvas for floating text elements. # create a text element txt = canvas.create_text(xt,yt,text="blahblah) # place the cursor on the fifth character canvas.focus(txt) canvas.icursor(txt, 5) # get the position print "cursor character position=",canvas.index(txt, INDEX) But how do I get the canvas x,y of the cursor? Currently I am making a binary search within the limits of the bounding box searching for the x,y corresponding to the character location returned by the index() method. I was asking if there is an existing function like the index() but to return the x,y position in the canvas. Cheers Vasilis -----Original Message----- From: micko.madrid at gmail.com on behalf of Michael O'Donnell Sent: Fri 4/12/2009 19:31 To: Vasilis Vlachoudis Cc: tkinter-discuss at python.org Subject: Re: [Tkinter-discuss] Cursor coordinates Hi Vasilis, A general method on all widgets; w.winfo_pointerxy() Returns a tuple (x, y) containing the coordinates of the mouse pointer relative to w's root window. If the mouse pointer isn't on the same screen, returns (-1, -1). Use this method on you canvas. If you canvas is scrolled, then you need to adjust these coordinates (since the top-left corner of the visible canvas may not be (0,0) of the canvas coordinates) So do something like: x,y=canv.winfo_pointerxy() x= canv.canvasx(x) y= canv.canvasy(y) Note also you can bind methods to events (not only clicks on your canas, but also movement) When the method is called, it gets an event object as one parameter, and this event object includes the x and y of the cursor Mick I am workin from memory here, so don't tak my word for it. On Fri, Dec 4, 2009 at 4:53 PM, Vasilis Vlachoudis wrote: > Hi all, > > I have a canvas with some editable text (with create_text) in it. > How can I get the cursor coordinates x,y from the canvas? > The index() function returns only the character index, is there a way to > convert the position of a character into x,y coordinates or bbox? > > Vasilis > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Fri Dec 4 21:54:46 2009 From: klappnase at web.de (Michael Lange) Date: Fri, 4 Dec 2009 21:54:46 +0100 Subject: [Tkinter-discuss] Cursor coordinates In-Reply-To: <20091204194902.GA24197@lairds.us> References: <4B193094.1010902@cern.ch> <47e491110912041031y16b55f8esfe90fe1277c09bd5@mail.gmail.com> <20091204203923.6ddd86d5.klappnase@web.de> <20091204194902.GA24197@lairds.us> Message-ID: <20091204215446.d0e5289c.klappnase@web.de> On Fri, 4 Dec 2009 19:49:02 +0000 Cameron Laird wrote: > On Fri, Dec 04, 2009 at 08:39:23PM +0100, Michael Lange wrote: > . > . > . > > I think Vasilis meant how to find the coords of the text's insertion > > cursor, not the mouse pointer coords ? I don't know if this is > > possible though. > . > . > . > I haven't kept up: is there a question about the Tkinter.INSERT > index? > > import Tkinter > a = Tkinter.Text() > a.pack() > a.index(Tkinter.INSERT) > '1.0' It's about how to find the coords (x, y) of the insertion cursor in a canvas text object. Michael From michael.odonnell at uam.es Fri Dec 4 23:39:08 2009 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Fri, 4 Dec 2009 23:39:08 +0100 Subject: [Tkinter-discuss] Cursor coordinates In-Reply-To: <2AACD4EB2F123248A064A23843B3A173016CCC54@cernxchg47.cern.ch> References: <4B193094.1010902@cern.ch> <47e491110912041031y16b55f8esfe90fe1277c09bd5@mail.gmail.com> <2AACD4EB2F123248A064A23843B3A173016CCC54@cernxchg47.cern.ch> Message-ID: <47e491110912041439g62c73717see2cde6f90da67cd@mail.gmail.com> Ok, The following code demonstrates: a) finding the char index of the insertion cursor in a text item in a Canvas b) translating that char position into pixel position c) drawing a box around the insertion cursor. Did I miss something? from Tkinter import * from tkFont import Font root=Tk() canvas=Canvas(root) canvas.pack() myFont=Font(family="Times", size=14) myText="blahblah" txt = canvas.create_text(10,10,text=myText, anchor=NW, font=myFont) # place the cursor on the fifth character canvas.focus_set() canvas.focus(txt) canvas.icursor(txt, 5) # get the position print "cursor character position=",canvas.index(txt, INSERT) # Find the pixel bounds of the insertion cursor # (assume 1 pixel width of the cursor) text=myText[0:canvas.index(txt, INSERT)] width=myFont.measure(text) bbox=canvas.bbox(txt) x1=bbox[0]+width-1 y1=bbox[1] x2=x1+3 y2=bbox[3] canvas.create_rectangle(x1,y1,x2,y2, outline="red") root.mainloop() From rowen at uw.edu Fri Dec 4 23:50:00 2009 From: rowen at uw.edu (Russell E. Owen) Date: Fri, 04 Dec 2009 14:50:00 -0800 Subject: [Tkinter-discuss] Python with Snack References: <26620448.post@talk.nabble.com> <4B1864DB.2090509@velseis.com.au> Message-ID: In article <4B1864DB.2090509 at velseis.com.au>, John McMonagle wrote: >... > Although I'm not on windows, it seems to me that you are in the wrong > folder when you try to run setup.py. Try changing to the appropriate > folder first: > > cd C:\Users\user\Desktop\snack\python > setup.py install > > Regards, > > John I'm not Windows expert, but from my limited use (building the windows version of a cross-platform package) you don't normally specify the python at all. To build my software I do this: cd setup.py py2exe I have never found a way to specify the python, though there presumably is some way to do it. -- Russell From Vasilis.Vlachoudis at cern.ch Sat Dec 5 19:49:00 2009 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Sat, 5 Dec 2009 19:49:00 +0100 Subject: [Tkinter-discuss] Cursor coordinates In-Reply-To: <47e491110912041439g62c73717see2cde6f90da67cd@mail.gmail.com> References: <4B193094.1010902@cern.ch> <47e491110912041031y16b55f8esfe90fe1277c09bd5@mail.gmail.com> <2AACD4EB2F123248A064A23843B3A173016CCC54@cernxchg47.cern.ch> <47e491110912041439g62c73717see2cde6f90da67cd@mail.gmail.com> Message-ID: <4B1AAB1C.6000100@cern.ch> Hi Michael, using your suggestions I've made the routine that works with multilines, and no binary search this time :) Vasilis # ------------------------- from Tkinter import * import tkFont import string def click(event): global canvas, font, txt canvas.focus_set() canvas.focus(txt) x = canvas.canvasx(event.x) y = canvas.canvasy(event.y) print "Clicked: ",x,y canvas.icursor(txt,"@%d,%d"%(x,y)) print "Cursor: ",cursorxy(canvas) def cursorxy(canvas): item = canvas.focus() if item: font = tkFont.nametofont(canvas.itemcget(item,"font")) x1,y1,x2,y2 = canvas.bbox(item) fontheight = font.metrics().get("linespace") index = canvas.index(item,INSERT) if index==0: return x1,y1+fontheight//2 txt = canvas.itemcget(item,"text") # count the lines before subtxt = txt[:index] print "subtxt=\"%s\""%(subtxt) lines = subtxt.count("\n") y = y1 + lines*fontheight + fontheight//2 if lines>0: x = x1 + font.measure(subtxt[subtxt.rfind("\n")+1:]) else: x = x1 + font.measure(subtxt) return (x,y) else: return (None,None) # --------------------------------------------------------------------- root = Tk() canvas = Canvas(root, background="White") canvas.pack(expand=YES, fill=BOTH) #font = tkFont.Font(font=("Helvetica",10)) canvas.bind("<1>", click) root.bind("", lambda e:root.destroy()) quotes="""Anyone who has never made a mistake has never tried anything new. Common sense is the collection of prejudices acquired by age eighteen. Education is what remains after one has forgotten everything he learned in school. Few are those who see with their own eyes and feel with their own hearts. Gravitation cannot be held responsible for people falling in love. I don't know with what weapons World War III will be fought, but World War IV will be fought with sticks and stones. I never think of the future - it comes soon enough. If A equals success, then the formula is: A = X + Y + Z, X is work. Y is play. Z is keep your mouth shut. If I have seen farther than others, it is because I was standing on the shoulders of giants. If the facts don't fit the theory, change the facts. If we knew what we were doing, it wouldn't be called research, would it? Imagination is more important than knowledge. In the middle of difficulty lies opportunity.""" txt = canvas.create_text(10,10,text=quotes,anchor=NW) root.mainloop() Michael O'Donnell wrote: > Ok, > > The following code demonstrates: > > a) finding the char index of the insertion cursor in a text item in a Canvas > b) translating that char position into pixel position > c) drawing a box around the insertion cursor. > > Did I miss something? > > > from Tkinter import * > from tkFont import Font > > root=Tk() > > canvas=Canvas(root) > canvas.pack() > myFont=Font(family="Times", size=14) > > myText="blahblah" > txt = canvas.create_text(10,10,text=myText, anchor=NW, font=myFont) > > # place the cursor on the fifth character > canvas.focus_set() > canvas.focus(txt) > canvas.icursor(txt, 5) > > # get the position > print "cursor character position=",canvas.index(txt, INSERT) > > # Find the pixel bounds of the insertion cursor > # (assume 1 pixel width of the cursor) > > text=myText[0:canvas.index(txt, INSERT)] > width=myFont.measure(text) > bbox=canvas.bbox(txt) > x1=bbox[0]+width-1 > y1=bbox[1] > x2=x1+3 > y2=bbox[3] > canvas.create_rectangle(x1,y1,x2,y2, outline="red") > > root.mainloop() > From klappnase at web.de Sat Dec 5 20:54:28 2009 From: klappnase at web.de (Michael Lange) Date: Sat, 5 Dec 2009 20:54:28 +0100 Subject: [Tkinter-discuss] withdraw() not working when changing virtual desktop Message-ID: <20091205205428.48030126.klappnase@web.de> Hi all, I encountered a strange problem here; the system is debian linux, it happens both with python-2.5.2 and with python-2.4.6 with tk-8.4.19 as well as with tk-8.5.3; I tried a few different WMs, I can only reproduce the bug with IceWM (1.2.35), on KDE and XFCE it did not occur. The problem is, that withdraw() does not work when the window in question is on another virtual desktop than the currently active. This is annoying if there is for example a dialog window with a progress bar that shows the progress of a process that takes some time, and when the process has finished the dialog should automatically disappear; if the user switches to another desktop while the process is running the dialog stays on the screen. The simplest code to exhibit the bug is something like: from Tkinter import * root = Tk() top = Toplevel() def test(): root.after(5000, top.withdraw) b = Button(root, text='test', command=test) b.pack(padx=100, pady=100) root.mainloop() When I press the button and then switch to another desktop the toplevel is not withdrawn. Has anyone ever heard about this, is this only a bug in IceWM and is there a possible workaround ? Regards Michael From marsuc666 at gmail.com Sat Dec 19 22:26:58 2009 From: marsuc666 at gmail.com (Marsel) Date: Sat, 19 Dec 2009 13:26:58 -0800 (PST) Subject: [Tkinter-discuss] How to open a file from Tkinter window? Message-ID: <26858702.post@talk.nabble.com> Hi, I'm new in python and I'm not very familiar with a lot of stuff, so please answer as simple as possible if you will :). The thing is, I would like to make connection betwen a few windows, in this case calculating programs, so I could open any of them from one window or just switch between them in tab - style. I'we also been trying to do it with a button, but in every case I've run out of ideas... I was looking for information everywhere, but as I've said, I don't understand most of the python expressions and was unable to find anything useful... So how can I "connect" or open files from inside a program? Any help would appreciated, thank you. -- View this message in context: http://old.nabble.com/How-to-open-a-file-from-Tkinter-window--tp26858702p26858702.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From michael.odonnell at uam.es Sat Dec 19 23:44:20 2009 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Sat, 19 Dec 2009 23:44:20 +0100 Subject: [Tkinter-discuss] How to open a file from Tkinter window? In-Reply-To: <26858702.post@talk.nabble.com> References: <26858702.post@talk.nabble.com> Message-ID: <47e491110912191444j7380ebfag892ba63e23750f93@mail.gmail.com> Hi Marsel, The following code allows you to use buttons on one window to bring another window to the top: from Tkinter import * windows=dict() windows[1]=Toplevel() windows[2]=Toplevel() windows[3]=Toplevel() for wid1 in (1,2,3): windows[wid1].title("Window "+str(wid1)) windows[wid1].minsize(width=280, height=20) fr=Frame(windows[wid1]) fr.pack(side=TOP) for wid2 in (1,2,3): if wid1==wid2: continue Button(fr, text=str(wid2), command=lambda w=windows[wid2]: w.focus_set()).pack(side=LEFT) Is that what you wanted? You also say: > So how can I "connect" or open files from inside a program? Is this a different question? I thought you were talking about connecting windows? Mick On Sat, Dec 19, 2009 at 10:26 PM, Marsel wrote: > > Hi, > I'm new in python and I'm not very familiar with a lot of stuff, so please > answer as simple as possible if you will :). > > The thing is, I would like to make connection betwen a few windows, in this > case calculating programs, so I could open any of them from one window or > just switch between them in tab - style. > I'we also been trying to do it with a button, but in every case I've run out > of ideas... I was looking for information everywhere, but as I've said, I > don't understand most of the python expressions and was unable to find > anything useful... > > So how can I "connect" or open files from inside a program? > > Any help would appreciated, > > thank you. > -- > View this message in context: http://old.nabble.com/How-to-open-a-file-from-Tkinter-window--tp26858702p26858702.html > Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From gonatan at gmx.de Sun Dec 20 00:55:44 2009 From: gonatan at gmx.de (=?ISO-8859-1?Q?Marcus_Gna=DF?=) Date: Sun, 20 Dec 2009 00:55:44 +0100 Subject: [Tkinter-discuss] How to open a file from Tkinter window? In-Reply-To: <26858702.post@talk.nabble.com> References: <26858702.post@talk.nabble.com> Message-ID: <4B2D6800.7070008@gmx.de> Marsel wrote: > Hi, > I'm new in python and I'm not very familiar with a lot of stuff, so please > answer as simple as possible if you will :). > > The thing is, I would like to make connection betwen a few windows, in this > case calculating programs, so I could open any of them from one window or > just switch between them in tab - style. > I'we also been trying to do it with a button, but in every case I've run out > of ideas... I was looking for information everywhere, but as I've said, I > don't understand most of the python expressions and was unable to find > anything useful... > > So how can I "connect" or open files from inside a program? > > Any help would appreciated, > > thank you. Cause your asking on the Tkinter list I assume you're looking for the following article I wrote. http://tkinter.unpythonic.net/wiki/tkFileDialog If you have further questions which have to be clarified ... don't hesitate to ask. Marcus From marsuc666 at gmail.com Sun Dec 20 10:23:00 2009 From: marsuc666 at gmail.com (Marsel) Date: Sun, 20 Dec 2009 01:23:00 -0800 (PST) Subject: [Tkinter-discuss] How to open a file from Tkinter window? In-Reply-To: <47e491110912191444j7380ebfag892ba63e23750f93@mail.gmail.com> References: <26858702.post@talk.nabble.com> <47e491110912191444j7380ebfag892ba63e23750f93@mail.gmail.com> Message-ID: <26861922.post@talk.nabble.com> Hi, The code you gave me is ok, but I would like to open files from such programs: (I'm Slovenian, don't get confused by strange names) from Tkinter import * from math import * def izracunaj(): po=float(vnos.get()) v=float(vnos1.get()) P=(2*pi*po*po)+(2*pi*po*v) V=pi*po*po*v r.set(str(P)) re.set(str(V)) okno = Tk() okno.title("Valj") radij = Label(okno, text="r=") radij.grid(row=0, column=0, sticky=W) visina = Label(okno, text="v=") visina.grid(row=1, column=0, sticky=W) ploscina = Label(okno, text="P=") ploscina.grid(row=2, column=0, sticky=W) volumen = Label(okno, text="V=") volumen.grid(row=3, column=0, sticky=W) vnos=Entry(okno) vnos.grid(row=0, column=1) vnos1=Entry(okno) vnos1.grid(row=1, column=1) r=StringVar() re=StringVar() rezultat=Label(okno, textvariable=r) rezultat.grid(row=2, column=1) rezultat1=Label(okno, textvariable=re) rezultat1.grid(row=3, column=1) gumb=Button(okno, text=u"Izracunaj!", command=izracunaj) gumb.grid(row=4, column=1) w=LabelFrame(okno, text="Valji") w.grid(row=5, column=0) okno.mainloop() This is one of my programs, others are similar and I would like to open them on a way that another window would open as I press the button. The code you gave me switches between already existing windows, but how do I open a certain file with a button (in this case another program)? Marsel Mick O'Donnell wrote: > > Hi Marsel, > > The following code allows you to use buttons > on one window to bring another window to the top: > > from Tkinter import * > > windows=dict() > windows[1]=Toplevel() > windows[2]=Toplevel() > windows[3]=Toplevel() > > for wid1 in (1,2,3): > windows[wid1].title("Window "+str(wid1)) > windows[wid1].minsize(width=280, height=20) > fr=Frame(windows[wid1]) > fr.pack(side=TOP) > for wid2 in (1,2,3): > > if wid1==wid2: continue > Button(fr, text=str(wid2), > command=lambda w=windows[wid2]: > w.focus_set()).pack(side=LEFT) > > Is that what you wanted? > > You also say: >> So how can I "connect" or open files from inside a program? > > Is this a different question? I thought you were talking about > connecting windows? > > Mick > > On Sat, Dec 19, 2009 at 10:26 PM, Marsel wrote: >> >> Hi, >> I'm new in python and I'm not very familiar with a lot of stuff, so >> please >> answer as simple as possible if you will :). >> >> The thing is, I would like to make connection betwen a few windows, in >> this >> case calculating programs, so I could open any of them from one window or >> just switch between them in tab - style. >> I'we also been trying to do it with a button, but in every case I've run >> out >> of ideas... I was looking for information everywhere, but as I've said, I >> don't understand most of the python expressions and was unable to find >> anything useful... >> >> So how can I "connect" or open files from inside a program? >> >> Any help would appreciated, >> >> thank you. >> -- >> View this message in context: >> http://old.nabble.com/How-to-open-a-file-from-Tkinter-window--tp26858702p26858702.html >> Sent from the Python - tkinter-discuss mailing list archive at >> Nabble.com. >> >> _______________________________________________ >> Tkinter-discuss mailing list >> Tkinter-discuss at python.org >> http://mail.python.org/mailman/listinfo/tkinter-discuss >> > _______________________________________________ > 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/How-to-open-a-file-from-Tkinter-window--tp26858702p26861922.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From teh_sh_meister at yahoo.com Tue Dec 22 14:56:19 2009 From: teh_sh_meister at yahoo.com (Nemes Andrei) Date: Tue, 22 Dec 2009 05:56:19 -0800 (PST) Subject: [Tkinter-discuss] Animation using image sequence Message-ID: <336735.41308.qm@web59916.mail.ac4.yahoo.com> Hi! I'm trying to make an animation using a sequence of gif images and the canvas widget, but all I see when I compile is a black screen. What I'm trying to do is delete the previous image and create the next one each frame. Am I doing it wrong? Is it do-able at all? Help would be greatly appreciated. Thank you. #Working on window interface of soundAsleep #Tkinter will handle the GUI from Tkinter import * import time root = Tk() root.title("soundAsleep beta") frame=[] currentframe=0 #Importing the images. They are named w1.gif, w2.gif...w7.gif for i in range(1,7): fname="core/working/w"+str(i)+".gif" frame+=[PhotoImage(file=fname)] wrap = Canvas(root, width=200, height=120) wrap.pack() #trying to make the animation while True: ani=wrap.create_image(100,70,image=frame[currentframe]) time.sleep(5) wrap.update_idletasks() #Force redraw wrap.delete(ani) if (currentframe==5): currentframe=0 else: currentframe+=1 root.mainloop() -------------- next part -------------- An HTML attachment was scrubbed... URL: From david.giesen at kodak.com Tue Dec 22 19:42:11 2009 From: david.giesen at kodak.com (david.giesen at kodak.com) Date: Tue, 22 Dec 2009 13:42:11 -0500 Subject: [Tkinter-discuss] Animation using image sequence In-Reply-To: <336735.41308.qm@web59916.mail.ac4.yahoo.com> References: <336735.41308.qm@web59916.mail.ac4.yahoo.com> Message-ID: Hello Nemes: The issue with the code as written is that the infinite while loop begins execution before the root.mainloop() ever gets called (so root.mainloop never gets called....). To start the animation AFTER the root.mainloop() call, I've moved the animation work into a function and used the after method to call that function after the mainloop initiates. Also, instead of using a while loop with a sleep call (which hangs the program while waiting), I've changed the animation function to call itself each time it finishes. This way the program doesn't hang while animating the picture, which is useful if you want this to be part of a larger program. Hope this is helpful! Dave Giesen #Working on window interface of soundAsleep #Tkinter will handle the GUI from Tkinter import * root = Tk() root.title("soundAsleep beta") frame=[] #Importing the images. They are named w1.gif, w2.gif...w7.gif for i in range(1,7): fname="core/working/w"+str(i)+".gif" frame+=[PhotoImage(file=fname)] wrap = Canvas(root, width=200, height=120) wrap.pack() def do_animation(currentframe): def do_image(): wrap.create_image(100,70,image=frame[currentframe], tag='ani') # Delete the current picture if one exists wrap.delete('ani') try: do_image() except IndexError: # End of image list reached, start over at the first image - works for an arbitrary number of images currentframe = 0 do_image() wrap.update_idletasks() #Force redraw currentframe = currentframe + 1 # Call myself again to keep the animation running in a loop root.after(5000, do_animation, currentframe) # Start the animation loop just after the Tkinter loop begins root.after(10, do_animation, 0) root.mainloop() David J. Giesen | Research Scientist | FPEG US Display OLED Materials R+D | Eastman Kodak Company | 2/83/KRL MC02216 | Rochester, NY 14650 | david.giesen at kodak.com | 1-585-588-0480 Office | www.kodak.com From: Nemes Andrei To: tkinter-discuss at python.org Date: 12/22/2009 10:47 AM Subject: [Tkinter-discuss] Animation using image sequence Sent by: tkinter-discuss-bounces+david.giesen=kodak.com at python.org Hi! I'm trying to make an animation using a sequence of gif images and the canvas widget, but all I see when I compile is a black screen. What I'm trying to do is delete the previous image and create the next one each frame. Am I doing it wrong? Is it do-able at all? Help would be greatly appreciated. Thank you. #Working on window interface of soundAsleep #Tkinter will handle the GUI from Tkinter import * import time root = Tk() root.title("soundAsleep beta") frame=[] currentframe=0 #Importing the images. They are named w1.gif, w2.gif...w7.gif for i in range(1,7): fname="core/working/w"+str(i)+".gif" frame+=[PhotoImage(file=fname)] wrap = Canvas(root, width=200, height=120) wrap.pack() #trying to make the animation while True: ani=wrap.create_image(100,70,image=frame[currentframe]) time.sleep(5) wrap.update_idletasks() #Force redraw wrap.delete(ani) if (currentframe==5): currentframe=0 else: currentframe+=1 root.mainloop() _______________________________________________ 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: -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/gif Size: 826 bytes Desc: not available URL: