Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

wxPyton not working in mac osx

Status
Not open for further replies.

linuxgyro

Programmer
Apr 13, 2005
9
US
i am trying to make a gui for the first time in python on a mac running osx.  it has python 2.3 installed and i downloaded the binary install for wxPython, the tcl/tk, and others but the modules never seem to install.
here is a program i am trying in wxPython:

from wxPython import *

class MyApp(wxApp):
    def OnInit(self):
        frame = wxFrame(NULL, -1, "Hello from wxPython")
        frame.Show(true)
        self.SetTopWindow(frame)
        return true

app = MyApp(0)
app.MainLoop()

i also tryed to import wxPython, import wxPython.wx but it is no use.
it comes up with:
NameError: name 'wxApp' is not defined.
traceback (innermost last)
file "wxPython.py", line 3, in ?
class MyApp(wxApp):

can anybody help me?
 
If the module weren't installing you would get an error from the import line.

I don't know how to program wxPython, the only application I ever wrote was several years ago.

You can test if the module is loading with this from the python interactive prompt:
Code:
>>> import wxPython.wx
>>> dir( wxPython.wx )
>>> dir( wxPython.wx.wxApp )
 
i tryed that and it worked out just fine once i ran it in terminal using the pythonw command. But when i try to run the program...

>>> from wxPython import *
>>> class MyApp(wxApp):
... def OnInit(self):
... frame = wxFrame(NULL, -l, "hello world")
... frame.Show(true)
... self.SetTopWindow(frame)
... return true
...
Traceback (most recent call last):
File "<stdin>", line 1, in ?
NameError: name 'wxApp' is not defined

so i try this:
>>> class MyApp(wxPython.wx.wxApp):
... def OnInit(self):
... frame = wxFrame(NULL, -l, "hello world")
... frame.Show(true)
... self.SetTopWindow(frame)
... return true
...
>>> app = MyApp(0)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "//Library/Python/2.3/wx-2.5.5-mac-unicode/wx/_core.py", line 5691, in __init__
self._BootstrapApp()
File "//Library/Python/2.3/wx-2.5.5-mac-unicode/wx/_core.py", line 5343, in _BootstrapApp
return _core_.PyApp__BootstrapApp(*args, **kwargs)
File "<stdin>", line 3, in OnInit
NameError: global name 'wxFrame' is not defined
>>>


although i know a lot about computers, this one has me stumpted. thanks in advance!!
 
Try wxPython.wx.wxFrame, also try reading the manual section on namespaces.

I'm not sure why you can't access wxApp and other bare symbols after "from wxPython.wx import *", but I doubt if you've found a bug in the interpreter, so I'm guessing you're doing something wrong.

Clearly, if wxPython.wx.wxApp works then the right symbol should be wxPython.wx.wxFrame.

 
ok i tryed that and it worked further. then i got the error NULL is undefined or something like that so i replace NULL wiht 0 and that passes, but the -l does not work, and it will not work without something being there. I am looking to fill the gap but i have no clue what to put in there.
 
That's a wx problem and not a python issue. You might try a wxWindows forum somewhere.
 
ok i got it to make a window, but the window has error messages in it. this is the program so far:
>>> class MyApp(wxPython.wx.wxApp):
... def OnInit(self):
... frame = wxPython.wx.wxFrame(0, -1, "hello")
... frame.show(true)
... self.SetTopWindow(frame)
... return true
...
>>> app = MyApp(1)

i was about to enter: app.MainLoop()
but a window poped up with this in it:
TraceBack
file "<stdin>", line1, in ?
file "//Library/Python/2.3/wx-2.5.5-mac-unicode/wx/_core.py",
line 5692, in __init__
self._BootstrapApp()
file "//Library/Python/2.3/wx-2.5.5-mac-unicode/wx/_core.py",
line 5343, in _BootstrapApp
return _core_.PyApp__BootstrapApp(*args, **kwargs)
file "<stdin>", line 3, in OnInit
file "//Library/Python/2.3/wx-2.5.5-mac-unicode/wx/
_windows.py", line 484, in __init__
newobj = _windows_new_Frame(*args, **kwargs)
TypeError: argument number 1: a 'wxWindow *' is expected, 'int(0)'
is receved

i had to type all that in becuase that bechball thingy pops up when within the borders of the window so i cannot select anything.
any help is appreciated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top