Sunday, October 6, 2013

Python 2.5 get text string dialog box

Research from trying to figure out how to write something in python 2.5 to create a dialog box for inputting a text string that I can then parse. Shouldn't be too hard you'd think. But, I don't seem to have access to any Tk libraries and am pretty sure that installing them isn't an option in my environment. So far I have a lot of stubby leads and no answers. What I've tried so far:

Things would be so easy if I could just use wxPython:

http://www.wxpython.org/what.php
http://wiki.wxpython.org/MessageBoxes
http://www.yolinux.com/TUTORIALS/PyGTK.html
http://stackoverflow.com/questions/13470927/taking-many-inputs-from-user-to-receive-input-as-string-like-file-names-directo


Python 2.5 has a built-in text entry prompt called raw_input() (changed to just input() in python 3). The problem is that running it in the GSEOS python console gets me an error "EOFError: EOF when reading a line". The best that I've been able to figure out is that if my python is configured a certain way, raw_input will open a console window for the new input, or something like that, but I don't know how to get there. Apparently a text file can be piped into raw_input(), which doesn't help me but is interesting. In my case, I won't be running python in what is normally entitled a "python window" anyhow, I really want a pop-up dialog box.

http://stackoverflow.com/questions/10044413/python-console-better-than-raw-input-how-to-offer-editable-default-values

http://stackoverflow.com/questions/4280889/raw-input-causing-eoferror-after-creating-exe-with-py2exe

This thread had a fascinating example where the win32console functions were directly manipulated, there must be some clues in that, but I couldn't import win32console in my python.
http://stackoverflow.com/questions/2533120/show-default-value-for-editing-on-python-input-possible


I also learned that ctypes() can be used to access the windows win32dll which has basic prompt boxes accessible, very nice but I can't seem to find a text input dialog, just various OK/Cancel boxes.

http://stackoverflow.com/questions/2963263/how-can-i-create-a-simple-message-box-in-python

http://stackoverflow.com/questions/4485610/python-message-box-without-huge-library-dependancy

http://stackoverflow.com/questions/14648448/string-problems-with-python

http://bytes.com/topic/python/answers/164237-simple-dialogs

http://win32com.goermezer.de/content/view/288/243/

http://techietrivia.blogspot.com/2012/07/python-message-box-in-windows.html

Here's M$'s own manual on MessageBoxA:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms645505%28v=vs.85%29.aspx

Root of the above article with more directions to read:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms632588(v=vs.85).aspx

This article has a lot of technical stuff that may contain an important clue:
http://docs.python.org/release/2.5.2/lib/ctypes-function-prototypes.html