473,657 Members | 2,733 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PyRun_SimpleStr ing no sys.argv[0]

iwl
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_SimpleStr ing("from easygui import *\n");
PyRun_SimpleStr ing("import sys\n");
PyRun_SimpleStr ing("msgbox()\n ");

Traceback (most recent call last):
File "<string>", line 1, in <module>
File "easygui.py ", line 148, in msgbox
reply = buttonbox(messa ge, title, choices)
File "easygui.py ", line 170, in buttonbox
root = Tk()
File "C:\Python\Pyth on25\Lib\lib-tk\Tkinter.py", line 1631, in
__init__
baseName = os.path.basenam e(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.

Dec 6 '06 #1
2 5935
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(messa ge, title, choices)
File "easygui.py ", line 170, in buttonbox
root = Tk()
File "C:\Python\Pyth on25\Lib\lib-tk\Tkinter.py", line 1631, in
__init__
baseName = os.path.basenam e(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(a rgc,
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
Dec 7 '06 #2
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
Dec 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4526
by: Link | last post by:
Hi, Have anyone know how to import the DLL in C program? Actually, I have used the statement 'PyRun_SimpleString' to import .PY, Such as, r = PyRun_SimpleString("import os"); It's be fine.
3
1640
by: Bill Orcutt | last post by:
Having seen the number of lost souls asking questions about embedding Python in the archives of this group, I hesitate to add myself to their number, but I've hit a problem I can't quite get my head around. I have a simple C program that embeds a python interpreter to execute python commands and return stdout, and to a point everything works as intended. The problem that each command seems to be executed in its own context and knows...
10
2607
by: Robin Sanderson | last post by:
Sorry in advance if this is a stupid question - I am new to C++. In the process of converting program to be run from the command line into a function to be run from another program I noticed behaviour that I do not understand. Consider the example programs below: Program 1 below is a simple program that merely outputs the command line arguments. This compiles and runs fine with Microsoft Visual C++ 6.0 and g++ 3.3.1.
28
12569
by: Charles Sullivan | last post by:
I'm working on a program which has a "tree" of command line arguments, i.e., myprogram level1 ]] such that there can be more than one level2 argument for each level1 argument and more than one level3 argument for each level2 argument, etc. Suppose I code it similar to this fragment: int main( int argc, char *argv ) {
22
2184
by: Joe Smith | last post by:
It is nothing short of embarrassing to feel the need to ask for help on this. I can't see how I would make the main control for this. What I want is a for loop and a test condition. And while I know, from things I pondered 2 decades ago, that a fella can write code without a goto, I'm stuck. /* sieve1.c */ #define whatever 20 #define N whatever
4
9787
by: interec | last post by:
Hi Folks, I am writing a c++ program on redhat linux using main(int argc, wchar_t *argv). $LANG on console is set to "en_US.UTF-8". g++ compiler version is 3.4.6. Q1. what is the encoding of data that I get in argv ? Q2. what is encoding of string constants defined in programs (for example L"--count") ?
0
1000
by: iwl | last post by:
Hi, it seems like I can't trace scripts run by PyRun_SimpleString(): a=0 def test(frame, event, arg): global a a+=1 import sys
11
6047
by: vicky | last post by:
hi all, please tell me with example, how the *argv point to the the no of strings.
3
6383
by: ShambhuHubli | last post by:
Hi all!! .. I am New member to this group. And also new to C/PYTHON API coding. I am trying to have two way communication i,e i am calling from python to C and then from C to python. I have no problem calling c func from python.... But problem is for calling C to Python I am trying to call a python function multiple times by passing one parameter 'fun(param)' from C code . I am getting segmentation fault error while executing . The...
0
8394
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8306
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4152
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.