Run Python script in command line 
Author Message
 Run Python script in command line

Dear All,

I am newbie of python and  have installed Python 2.2 and wxPython.  When
I run "python.exe test.py", an error about MainLoop is not an attribute
of "NoneType".  While running "pythonw.exe test.py", nothing comes up.
Everything works fine under pyShell.  Is there any idea?

My test.py is as follow:

import os, sys
from wxPython.wx import *

def MyApp(wxApp):
   def OnInit(self):
     mainWindow = wxFrame(NULL, -1, "Testing")
     mainWindow.Show(true)
     self.setTopWindow(mainWindow)
     return true

app = MyApp(0)
app.MainLoop()

Regards,

Reid Lai



Mon, 30 May 2005 23:59:08 GMT  
 Run Python script in command line
If it runs under pyShell and doesn't run at the command line,
I'd suspect that your path or PythonPath isn't set up correctly.
It's likely to be subtle because the import worked. Check where
you put the compiled objects (the .dll for wxWindows and
the interface module.)
The immediate error is because MyApp(0) is returning
a None object instead of an application object.

HTH.

John Roth


Quote:
> Dear All,

> I am newbie of Python and  have installed Python 2.2 and wxPython.
When
> I run "python.exe test.py", an error about MainLoop is not an
attribute
> of "NoneType".  While running "pythonw.exe test.py", nothing comes up.
> Everything works fine under pyShell.  Is there any idea?

> My test.py is as follow:

> import os, sys
> from wxPython.wx import *

> def MyApp(wxApp):
>    def OnInit(self):
>      mainWindow = wxFrame(NULL, -1, "Testing")
>      mainWindow.Show(true)
>      self.setTopWindow(mainWindow)
>      return true

> app = MyApp(0)
> app.MainLoop()

> Regards,

> Reid Lai



Tue, 31 May 2005 01:02:43 GMT  
 Run Python script in command line
Quote:

> Dear All,

> I am newbie of Python and  have installed Python 2.2 and wxPython.  When
> I run "python.exe test.py", an error about MainLoop is not an attribute
> of "NoneType".  While running "pythonw.exe test.py", nothing comes up.
> Everything works fine under pyShell.  Is there any idea?

> My test.py is as follow:

> import os, sys
> from wxPython.wx import *

> def MyApp(wxApp):

This ^ may be your problem. I think you mean:
  class MyApp(wxApp):

I'm assuming you want to subclass wxApp. At the moment, MyApp is a
function taking wxApp as an argument.

However, if this was the case, I'm fairly certain it wouldn't work
anywhere. Are you sure it was working as expected in pyShell?

HTH,
Paul

Quote:
>    def OnInit(self):
>      mainWindow = wxFrame(NULL, -1, "Testing")
>      mainWindow.Show(true)
>      self.setTopWindow(mainWindow)
>      return true

> app = MyApp(0)
> app.MainLoop()

> Regards,

> Reid Lai



Tue, 31 May 2005 17:44:08 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. python-mode - running a script that takes command line arguments

2. Odd problem running command-line python scripts (win2k)

3. how do I run a script with a command line

4. running tcl script from command line

5. trouble running an expect script in cron versus command line

6. How to run TCL Scripts on Open VMS from the DCL Command Line

7. Running an external command from within a Python script

8. Execute python script via C API line-by-line

9. Question on CW app as an NT service, running Command Line PGP

10. Running Print Manager from command line

11. Running 2 reports with one command line

12. Running Rexx programs from command line with 2.1 Workbench installed

 

 
Powered by phpBB® Forum Software