Tkinter in PyRun_SimpleString(char* s)
Torsten Mohr
tmohr at s.netic.de
Sun Sep 15 11:57:45 EDT 2002
Hi,
thanks for that hint.
> As you can see, the problem is with sys.argv, which you have
> not set. You can set it up from the Python code you execute,
> before you import Tkinter, or with C-API call PySys_SetArgv.
I've now added that call but still when i try to exec the script:
Fatal Python error: PyThreadState_Get: no current thread
Is there any rule what needs to be initialized/called before
executing a python script? The simplest example works fine,
but i seems that that's not all that needs to be done when
i try to import Tkinter. I didn't find anything in the docs,
maybe i missed it?
Best regards,
Torsten.
# python code
from Tkinter import *
class Application(Frame):
def say_hi(self):
print "hi there, everyone!"
def createWidgets(self):
self.QUIT = Button(self)
self.QUIT["text"] = "QUIT"
self.QUIT["fg"] = "red"
self.QUIT["command"] = self.quit
self.QUIT.pack({"side": "left"})
self.hi_there = Button(self)
self.hi_there["text"] = "Hello",
self.hi_there["command"] = self.say_hi
self.hi_there.pack({"side": "left"})
def __init__(self, master=None):
Frame.__init__(self, master)
self.pack()
self.createWidgets()
app = Application()
app.mainloop()
/* C code */
Py_SetProgramName(argv[0]);
PySys_SetArgv(argc, argv);
Py_Initialize();
PyRun_SimpleString(script);
Py_Finalize();
More information about the Python-list
mailing list