Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > PyRun_SimpleString no sys.argv[0]

Reply
Thread Tools

PyRun_SimpleString no sys.argv[0]

 
 
iwl
Guest
Posts: n/a
 
      12-06-2006
Hello,

I'm just starting with Python - would like to embed it in my
windows-programm as an script-processor. For tests I use easygui some
easy-wrapper for the py-tck-stuff.

PyRun_SimpleString("from easygui import *\n");
PyRun_SimpleString("import sys\n");
PyRun_SimpleString("msgbox()\n");

Traceback (most recent call last):
File "<string>", line 1, in <module>
File "easygui.py", line 148, in msgbox
reply = buttonbox(message, title, choices)
File "easygui.py", line 170, in buttonbox
root = Tk()
File "C:\Python\Python25\Lib\lib-tk\Tkinter.py", line 1631, in
__init__
baseName = os.path.basename(sys.argv[0])
AttributeError: 'module' object has no attribute 'argv'

May bee makes some sence that the embedded Interpreter has no argv[0],
however tk seems not to bee ready for that.
I try to define some sys.argv[0] myself after I get out how to do that,
maybee someone other has an better idea until than.

 
Reply With Quote
 
 
 
 
Gabriel Genellina
Guest
Posts: n/a
 
      12-07-2006
At Wednesday 6/12/2006 12:23, iwl wrote:

>I'm just starting with Python - would like to embed it in my
>windows-programm as an script-processor. For tests I use easygui some
>easy-wrapper for the py-tck-stuff.


Looks a bit strange for me. If the GUI will be in Python, I think you
could do things the other way, *extending* your main Python program
with your own C code, not *embedding* Python inside your main C program.
I'm not sure if Tk can run without a mainloop.

Anyway, to answer your actual question:

>Traceback (most recent call last):
> File "<string>", line 1, in <module>
> File "easygui.py", line 148, in msgbox
> reply = buttonbox(message, title, choices)
> File "easygui.py", line 170, in buttonbox
> root = Tk()
> File "C:\Python\Python25\Lib\lib-tk\Tkinter.py", line 1631, in
>__init__
> baseName = os.path.basename(sys.argv[0])
>AttributeError: 'module' object has no attribute 'argv'
>
>May bee makes some sence that the embedded Interpreter has no argv[0],
>however tk seems not to bee ready for that.
>I try to define some sys.argv[0] myself after I get out how to do that,
>maybee someone other has an better idea until than.


From the Python/C API Reference Manual, section "Embedding Python"
(that I hope you have already read):
Py_Initialize() does not set the ``script argument list'' (sys.argv).
If this variable is needed by Python code that will be executed
later, it must be set explicitly with a call to PySys_SetArgv(argc,
argv) subsequent to the call to Py_Initialize().


--
Gabriel Genellina
Softlab SRL

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ˇgratis!
ˇAbrí tu cuenta ya! - http://correo.yahoo.com.ar
 
Reply With Quote
 
 
 
 
Gabriel Genellina
Guest
Posts: n/a
 
      12-07-2006
Please keep posting on this list, surely other people can help more than I.

At Thursday 7/12/2006 06:16, Ingo Wolf wrote:

> > At Wednesday 6/12/2006 12:23, iwl wrote:
> >
> > >I'm just starting with Python - would like to embed it in my
> > >windows-programm as an script-processor. For tests I use easygui some
> > >easy-wrapper for the py-tck-stuff.

> >
> > Looks a bit strange for me. If the GUI will be in Python, I think you
> > could do things the other way, *extending* your main Python program
> > with your own C code, not *embedding* Python inside your main C program.
> > I'm not sure if Tk can run without a mainloop.
> >

>No I have an Borland C++ GUI Windows App and should make it scriptable
>I tryed using MS ScriptControl first but have only Problems with now I
>try phyton which also have more posibillities.
>May bee I find a way to also access my script engine from outside
>my programm. Open and connecting some kind of terminal for my embedded
>phyton would also be fine.


Embedding Python into your app seems fine - but in this case, your
example (using Tk) is not a good starting point, since python wont
use a GUI (your App is the GUI).


--
Gabriel Genellina
Softlab SRL

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ˇgratis!
ˇAbrí tu cuenta ya! - http://correo.yahoo.com.ar
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
no trace of PyRun_SimpleString() ??? iwl Python 0 04-18-2007 11:52 AM
How to load the DLL with PyRun_SimpleString? Link Python 3 09-23-2003 09:59 AM
Re: PyRun_SimpleString, PyRun_File Stavros Tsolakos Python 0 08-06-2003 10:04 AM
PyRun_SimpleString, PyRun_File Sřren Johansen Python 0 08-05-2003 12:24 PM



Advertisments