Hi everyone, My students have used IDLE for all their editing to this point. Now we're getting to the point of playing with Tkinter a bit and I find that many, if not all, of the Tkinter apps I try don't exit cleaning and end up hanging IDLE. We're using Python 2.2 on Win95, but the same thing happend with Win98. Running the programs from the DOS shell seems to work fine. Is this a known problem with IDLE? I'm including a short script below that exemplifies the problem. The code is from Wesley Chun's Core Python book. from Tkinter import * def resize(ev=None): label.config(font='Helvetica -%d bold' % scale.get()) top = Tk() top.geometry('250x150') label= Label(top, text="Hello World!", font='Helvetica -12 bold') label.pack(fill=Y, expand=1) scale = Scale(top, from_=10, to=40, orient=HORIZONTAL, command=resize) scale.set(12) scale.pack(fill=X, expand=1) quit = Button(top, text="Quit", command=top.quit, activebackground='red', activeforeground='white') quit.pack() mainloop() Thanks for any input anyone can provide. -Tim -- Tim Wilson | Visit Sibley online: | Check out: Henry Sibley HS | http://www.isd197.org | http://www.zope.com W. St. Paul, MN | | http://slashdot.org wilson@visi.com | <dtml-var pithy_quote> | http://linux.com
I think that the version of IDLE that comes with Python doesn't run programs in their own thread. This was fixed in the version which comes with VPython, and lead to the Idle Fork. VPython: http://www.vpython.org/ Idle Fork: http://idlefork.sourceforge.net/ Note: I still do my python development with vim, not an IDE, so my comments could be way off base here. --Dethe On Thursday, February 21, 2002, at 10:07 PM, Tim Wilson wrote:
Hi everyone,
My students have used IDLE for all their editing to this point. Now we're getting to the point of playing with Tkinter a bit and I find that many, if not all, of the Tkinter apps I try don't exit cleaning and end up hanging IDLE. We're using Python 2.2 on Win95, but the same thing happend with Win98. Running the programs from the DOS shell seems to work fine.
Is this a known problem with IDLE? I'm including a short script below that exemplifies the problem. The code is from Wesley Chun's Core Python book.
from Tkinter import *
def resize(ev=None): label.config(font='Helvetica -%d bold' % scale.get())
top = Tk() top.geometry('250x150')
label= Label(top, text="Hello World!", font='Helvetica -12 bold') label.pack(fill=Y, expand=1)
scale = Scale(top, from_=10, to=40, orient=HORIZONTAL, command=resize) scale.set(12) scale.pack(fill=X, expand=1)
quit = Button(top, text="Quit", command=top.quit, activebackground='red', activeforeground='white') quit.pack()
mainloop()
Thanks for any input anyone can provide.
-Tim
-- Tim Wilson | Visit Sibley online: | Check out: Henry Sibley HS | http://www.isd197.org | http://www.zope.com W. St. Paul, MN | | http://slashdot.org wilson@visi.com | <dtml-var pithy_quote> | http://linux.com
_______________________________________________ Edu-sig mailing list Edu-sig@python.org http://mail.python.org/mailman/listinfo/edu-sig
-- Dethe Elza (delza@burningtiger.com) Chief Mad Scientist Burning Tiger Technologies (http://www.burningtiger.com) Weblog: http://livingcode.manilasites.com/
In regard to what Tim Wilson wrote:
...Now we're getting to the point of playing with Tkinter a bit and I find that many, if not all, of the Tkinter apps I try don't exit cleaning and end up hanging IDLE. We're using Python 2.2 on Win95, but the same thing happend with Win98. Running the programs from the DOS shell seems to work fine.
Is this a known problem with IDLE?
...
Yes, it is a known problem (to me anyway). In the release notes for Python on the Mac there is the following info. I recommend you check the release notes on your installation. ---------------------------- Known problems -------------- This list is probably incomplete, more problems may be listed on the MacPython homepage, http://www.cwi.nl/~jack/macpython.html. ... - The IDE and Tkinter do not work together. Run tkinter programs under PythonInterpreter. - Tkinter file events do not work, unless you have opened the file through Tcl (but then you cannot access it from Python). ... - PythonInterpreter used interactively will eat a lot of processor cycles. You should use PythonIDE for interactive work and PythonInterpreter for scripts only. This is especially true under OSX. ------------------------------- I and my kids in my Middle School club where we run Python on Windows NT tend to use the editor for what I think is IDLE and then run the script using the run option under the edit menu. That seems to work ok for the kinds of Tkinter and Python things we have been doing. We don't use the interactive window at all. Perhaps, we just haven't run into things yet though.
Thanks for any input anyone can provide.
-Tim
-- Tim Wilson | Visit Sibley online: | Check out: Henry Sibley HS | http://www.isd197.org | http://www.zope.com W. St. Paul, MN | | http://slashdot.org wilson@visi.com | <dtml-var pithy_quote> | http://linux.com
You are welcome... --D. -- Dr. David J. Ritchie, Sr. djrassoc01@mindspring.com http://home.mindspring.com/~djrassoc01/
Is this a known problem with IDLE?
Yes. Despite of this I use IDLE with my students interactivly. Here an example session:
from Tkinter import * root = Tk() cv = Canvas(root, width=300, height=250, bg='yellow') cv.pack() cv.pack_forget() cv.pack(expand=1, fill=BOTH) from Canvas import * r = Rectangle(cv, 50,20, 250,220) k = Oval(cv, 70,40,230,200, fill='pink') l1 = Line(cv, 120,150,180,150, fill='red', width=6) l1.move(0,20) l1.coords() [120.0, 170.0, 180.0, 170.0] l2=Line(cv,150,120,160,162) l2['fill']='brown' l2['width']=4 e1=Oval(cv,110,90,140,105,fill='blue') e2=Oval(cv,159,89,191,106,fill='lightblue') k['fill']='orange'
Works fine and you can observe the construction of the graphics on the canvas. (In a similar way it's possible to add Buttons and other widgets etc.) Students (age of 15) have much fun with this approach. For them this is a way to explore Tkinter, (which is very poorly documented in German.) To turn it into a program we copy (as usual) the appropriate statements into an edit-window of IDLE and in this case we got: from Tkinter import * from Canvas import * root = Tk() cv = Canvas(root, width=300, height=250, bg='yellow') cv.pack(expand=1, fill=BOTH) r = Rectangle(cv, 50,20, 250,220) k = Oval(cv, 70,40,230,200, fill='orange') l1 = Line(cv, 120,170,180,170, fill='red', width=6) l2=Line(cv,150,120,160,162) l2['fill']='brown' l2['width']=4 e1=Oval(cv,110,90,140,105,fill='blue') e2=Oval(cv,159,89,191,106,fill='lightblue') this can be run as usual via File/Save and Edit/Run script Another Tk-window pops up and we see our graphics again. To run this program as a script one only has to add root.mainloop() Shortly this means: as long as there is no mainloop() in your script it runs correctly from IDLE. If later we want to use it as a script, we add mainloop() Hope you found this interesting Gregor Lingl
participants (4)
-
Dethe Elza -
Dr. David J. Ritchie, Sr. -
Gregor Lingl -
Tim Wilson