Tkinter in PyRun_SimpleString(char* s)

Torsten Mohr tmohr at
Sun Sep 15 06:29:34 CEST 2002


it doesn't seem to be as easy as i thought to load a script
from a C program and execute it, if i import Tkinter, it fails:

Traceback (most recent call last):
  File "<string>", line 31, in ?
  File "<string>", line 27, in __init__
  File "/usr/lib/python2.1/lib-tk/", line 2249, in __init__
    Widget.__init__(self, master, 'frame', cnf, {}, extra)
  File "/usr/lib/python2.1/lib-tk/", line 1750, in __init__
    BaseWidget._setup(self, master, cnf)
  File "/usr/lib/python2.1/lib-tk/", line 1725, in _setup
    _default_root = Tk()
  File "/usr/lib/python2.1/lib-tk/", line 1476, in __init__
    baseName = os.path.basename(sys.argv[0])
AttributeError: 'sys' module has no attribute 'argv'

The script i try to run is the example from the latest library
documentation of Tkinter.

The C program looks like this, it is also a slightly changed

It seems there are some initialisations missing, what do i need
to do to set it all up properly?

Best regards,

int main(int argc, char** argv) {
        // routine to load a file
        f = slFileLoad("", 0);





        return EXIT_SUCCESS;

More information about the Python-list mailing list