[PythonCE] weird Tkinter
Progor
dpwhittaker at gmail.com
Thu Mar 1 05:46:20 CET 2007
Well, adding the paths didn't help, but I just went ahead and put import
_tkinter in my libs.pth file and now my Tkinter programs work like everybody
else's at least.
Thanks for the pointer on .pth files.
Bandung wrote:
>
> Here is a link explaining what *.pth files do. they are just text files
> with path statements. Python reads them when it first loads and
> effectively adds any path statements that it sees, into the PYTHONPATH
> environment. Really cool for permitting you to type in just the file's
> name rather than the whole path sttement when you wantto import a script
> somewhere on your system.
>
> You can use them to import modules as well I think. for the most part, I
> simply put path statements in them.
>
>
> http://bob.pythonmac.org/archives/2005/02/06/using-pth-files-for-python-development/
> *.pth files
>
> If you want your gui to load faster. give your script a *.pyw extension.
> But other than that, well, yes, its a bit slow to load. (hows that for an
> understatement)
>
>
>
>
> Progor wrote:
>>
>> Hmmm, the only thing I'm not sure about is your (d) created a file which
>> I call "pathextender.pth" file where I added all of the directories where
>> my scripts are. In addition to adding all of my script directories (they
>> are on storage cards), I then added the path to my python25\lib directory
>> where my Tkinter.py and Tkinter.pyc resides.
>>
>> What is this pathextender.pth file, what format is it in, and how does
>> python know what to do with it?
>>
>> Either way, I guess it's not that big of a deal. Adding import _tkinter
>> doesn't seem to have any adverse effects, and it makes at least one
>> machine more stable :)
>>
>> I'm almost finished making my Tkinter-based "almost native looking" App
>> class. It's complete with no visible border or title bar, a menu at the
>> bottom that leaves room for the SIP button, and a main frame that
>> automatically resizes itself when the SIP appears. I just have to do a
>> little bit more work to make it recognize hi-res devices and landscape
>> orientation, and resize it's main frame and menus as needed. I may be
>> reinventing a wheel, but I didn't find anything on this list like that.
>> I'll post my files when I'm done.
>>
>> By the way, it's taking several seconds (5ish) to load my App (i.e. from
>> the time the python interpreter appears to the time the GUI is
>> displayed)... is that Tkinter taking so long, or should I look at some of
>> my other imports and/or code?
>>
>>
>> Bandung wrote:
>>>
>>> I've been through all of those permutations and combinations myself.
>>> What I settled on was this;
>>>
>>> a) left the original python.zip file intact. that is to say, didn'tt
>>> remove anything, didn't replace anything
>>> b) added the latest Tkinter.py that I could find for python25 and placed
>>> it in my Python2.5\lib directory.
>>> c) clicked on the Tkinter.py file in my Lib directory to get it to
>>> create a Tkinter.pyc If yours is anything like mine, it will not be the
>>> same size as the one within python25.zip. This is good. Why? I don't
>>> know.
>>> d) created a file which I call "pathextender.pth" file where I added all
>>> of the directories where my scripts are. In addition to adding all of
>>> my script directories (they are on storage cards), I then added the path
>>> to my python25\lib directory where my Tkinter.py and Tkinter.pyc
>>> resides.
>>> e) soft reset.
>>>
>>> Occasionally, I get that dll not found message. Particularly if the
>>> unit goes into it's "hybernation" mode. Soft reset always brings it
>>> back. Well on rare occasions, I have had to do numerous soft resets.
>>> (even removed the battery one time and then did the "1 stylus salute"
>>> thingy)
>>>
>>> Assuming that your files are all in the correct place, soft reset should
>>> work. My python is on the storage card. Don't know if that makes a
>>> difference but someone else was struggling to get their install working
>>> within main memory and it worked so...
>>>
>>>
>>>
>>> Progor wrote:
>>>>
>>>> I wish it were that easy. This process included 20-something soft
>>>> resets, none of which were able to solve this problem. I am pretty new
>>>> to python, so if you can help me understand why:
>>>>
>>>> import _tkinter
>>>> import Tkinter
>>>>
>>>> works, but:
>>>>
>>>> import Tkinter
>>>>
>>>> alone doesn't work, then maybe we can find a solution to the whole
>>>> problem.
>>>>
>>>> I assume import _tkinter is asking it to import the dll itself, and
>>>> somehow the Tkinter package isn't making it that far.
>>>>
>>>> Ok. I made it a bit further. I found a Tkinter.py and Tkinter.pyc
>>>> file in one of the threads on this topic a bit back and added them to
>>>> my Lib directory. That did nothing, but then I renamed Tkinter.pyc in
>>>> python25.zip/lib-tk to Tkinterold.pyc (Resco File Explorer ftw) so
>>>> python would be sure to use the one in Lib, and finally, it works.
>>>> Oddly enough, clicking on the .py version gives a could not find TCL
>>>> DLL message (on the import _tkinter line), but clicking on the .pyc
>>>> gives the little demo window. Even weirder, moving that .pyc file into
>>>> the zip under lib-tk takes me back to the original problem (not finding
>>>> TK DLL). Yes, I soft reset between every file move operation and test.
>>>>
>>>> Well, dangit, I must have gotten lucky on a soft reset here or there or
>>>> still had the DLL loaded into memory from something else or... who
>>>> knows... I'm still getting the "could not find TK DLL" message, with
>>>> either version or location of Tkinter.pyc... most of the time.
>>>>
>>>>
>>>> Bandung wrote:
>>>>>
>>>>> A soft reset is your friend. Do it and your python install/tkinter
>>>>> will return to normal. I don't know why at times "stuff" happens but
>>>>> it does.
>>>>>
>>>>>
>>>>> Progor wrote:
>>>>>>
>>>>>> So, I think I might have my install kinda borked. I finally got it
>>>>>> working, but I had to jump through some hoops to make it work.
>>>>>>
>>>>>> First, I installed PythonCE with CABINSTL directly into /Python (I
>>>>>> switch SD cards all the time, wanted it in main memory (for speed
>>>>>> too), but with as few spaces as possible for command line stuff).
>>>>>>
>>>>>> Then, I tried just doing an import Tkinter from the console, but it
>>>>>> gave me the notorious missing TK DLL message.
>>>>>>
>>>>>> So, I found the dlls (celib, tk84, tcl84) and put them in /Windows,
>>>>>> but it still gave me the error.
>>>>>>
>>>>>> So, I played around with it a bit. I found out if I import _tkinter
>>>>>> first, then it doesn't give me the message... but that's an extra
>>>>>> line in all my programs and may be weird if I ever want to give out
>>>>>> my programs.
>>>>>>
>>>>>> I kept looking around on this mailing list and finally figured out I
>>>>>> needed to install tcl as well, did that, but I still have to import
>>>>>> _tkinter before I can import Tkinter without getting the "Could not
>>>>>> find TK DLL" error.
>>>>>>
>>>>>> It sounds like some people have gotten it to work on their systems
>>>>>> without the weird "import _tkinter" extra line. Have I done
>>>>>> something wrong? Or is Tkinter just that persnickity?
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
--
View this message in context: http://www.nabble.com/weird-Tkinter-tf3297520.html#a9243936
Sent from the Python - pythonce mailing list archive at Nabble.com.
More information about the PythonCE
mailing list