[PythonCE] Using Tkinter
Michael
mike at pcblokes.com
Sun Oct 26 16:03:15 EST 2003
I've been playing with some of the Tkinter examples in 'Programming Python' (O'Reilly) - and very nice it seems too, a very gentle introduction.
The straightforward examples work fine on the PocketPC when typed at the interpreter - but produce the following error when run :
Tcl_Init error: Can't find a usable init.tcl in the following directories:
/lib/tcl8.4
This probably means that Tcl wasn't installed properly.
Traceback (most recent call last):
File "\Program Files\Python\lib\pcceshell.py", line 460, in Interact
File "<input>", line 1, in ?
File "\gui1.py", line 3, in ?
widget = Button(None, text='Hello widget world', command=sys.exit)
File "\Program Files\Python\lib\Tkinter.py", line 1906, in __init__
File "\Program Files\Python\lib\Tkinter.py", line 1829, in __init__
File "\Program Files\Python\lib\Tkinter.py", line 1804, in _setup
TclError: Can't find a usable init.tcl in the following directories:
/lib/tcl8.4
This probably means that Tcl wasn't installed properly.
>>> import sys
>>> sys.path
['\\', '', '\\Windows\\python23.zip', '\\Program Files\\Python', '\\Program Files\\Python\\lib', '\\Storage Card\\Python', '\\Storage Card\\Python\\lib', '']
>>>
That '\\Windows\\python23.zip' in sys.path is interesting - does it mean python ought to work with all it's modules in one Zip ? Interesting !
But more to the point I guess sometning is wrong with the way my python is setup and it doesn't know where to look for the Tcl files...
(I also get an 'import site failed' message that flashes past on the console when I run my programs - but as everything works I haven't been too worried - they *may* be related issues though I guess)
Can anyone tell me how I need to change this ?
To the gentleman who suggested the problem with my IOerror ' 'w' is not a valid mode' that I posted on friday - Thank you. In fact the real problem was that I had wrongly specified the directory ! (odd error message though !). His suggestion ('wb' mode etc) was in fact the solution to a different problem I had with pickling ! So thanks. Sorry for not remembering your name - but I'm posting from my XDA and don't have the original email.
BTW - using the following example from 'Programming Python' - the program doesn't quit *properly* when the button is pressed. It returns control to the interpreter, but the Tk task is still running and the defunct GUI hangs around... Is this expected behaviour for root.quit ? The sys.exit one works fine - but caused a 'memory x00.... (blah) cannot be read' error under XP and caused python to crash (all on exit) - weird ? I'll try again when I'm at home and post it to comp.lang.python (if the google posting works this time) tommorrow....
from Tkinter import *
root = Tk()
Button(root, text='press', command=root.quit).pack(side=LEFT)
root.mainloop()
Thanks
Fuzzy
More information about the PythonCE
mailing list