Hi,
I don't know if my issue is Python or wx or what, but I don't seem to
have issues when I don't import wx so I'm going to ask here. Maybe
someone can point me in the right direction.
I am new to Python and I am using IDLE for Python 2.6.4 on Ubuntu
9.10.
I have a simple program that I learned from a tutorial that creates a
panel and a button. When I run it, it works once and only once. If I
exit out of Python and re-open it works only once, again.
The error I get is this:
Traceback (most recent call last):
File "/home/imiller/Wx Test.py", line 20, in <module>
frame=miller(parent=None,id=-1)
File "/home/imiller/Wx Test.py", line 6, in __init__
wx.Frame.__init__(self,parent,id,'Frame aka window',
size=(300,200))
File "/usr/lib/python2.6/dist-packages/wx-2.6-gtk2-unicode/wx/
_windows.py", line 485, in __init__
newobj = _windows_.new_Frame(*args, **kwargs)
PyNoAppError: The wx.App object must be created first!
Can somebody tell me what I'm doing wrong? Like I said, it runs fine
once and then I get this error. I apologize if this is a stupid
question or if I'm asking in the wrong place. I'm new to all of this.
Thanks.
Hi,
Hi,
I don't know if my issue is Python or wx or what, but I don't seem to
have issues when I don't import wx so I'm going to ask here. Maybe
someone can point me in the right direction.
I am new to Python and I am using IDLE for Python 2.6.4 on Ubuntu
9.10.
I have a simple program that I learned from a tutorial that creates a
panel and a button. When I run it, it works once and only once. If I
exit out of Python and re-open it works only once, again.
The error I get is this:
Traceback (most recent call last):
File "/home/imiller/Wx Test.py", line 20, in <module>
frame=miller(parent=None,id=-1)
File "/home/imiller/Wx Test.py", line 6, in __init__
wx.Frame.__init__(self,parent,id,'Frame aka window',
size=(300,200))
File "/usr/lib/python2.6/dist-packages/wx-2.6-gtk2-unicode/wx/
_windows.py", line 485, in __init__
newobj = _windows_.new_Frame(*args, **kwargs)
PyNoAppError: The wx.App object must be created first!
Can somebody tell me what I'm doing wrong? Like I said, it runs fine
once and then I get this error. I apologize if this is a stupid
question or if I'm asking in the wrong place. I'm new to all of this.
Thanks.
If you're using IDLE to write and run your code in, then that's your
problem. IDLE is written in Tkinter and has its own main loop. When
you start wx, it starts its own main loop and the two don't get along
very well. I think the same problem happens with other GUI toolkits
like pyGTK or pyQT. When you have two main loops fighting each other,
you end up with IDLE doing weird things like the above.
The solution is to run your program from command line (i.e. python
myscript.py) or an IDE that actually starts the script in a separate
process. I use Wingware IDE, but I think PyDev + Eclipse works too.
There are lots of other IDEs to choose from though.
···
On Mar 9, 7:50 pm, Sike Zero <isaacmiller2...@gmail.com> wrote:
-------------------
Mike Driscoll
Blog: http://blog.pythonlibrary.org
Mike and Steve,
Thank you both for your help. I really appreciate it.
I took your advice and installed PyDev and Eclipse. It was a little
tricky to get PyDev installed correctly with Eclipse, but once I did,
my stupid little program runs over and over without any issues. I
can't even believe it. I'm not going to mess around with IDLE
anymore.
Thanks again for setting me straight, guys.
Isaac
···
On Mar 10, 10:13 am, Mike Driscoll <kyoso...@gmail.com> wrote:
Hi,
On Mar 9, 7:50 pm, Sike Zero <isaacmiller2...@gmail.com> wrote:
> Hi,
> I don't know if my issue is Python or wx or what, but I don't seem to
> have issues when I don't import wx so I'm going to ask here. Maybe
> someone can point me in the right direction.
> I am new to Python and I am using IDLE for Python 2.6.4 on Ubuntu
> 9.10.
> I have a simple program that I learned from a tutorial that creates a
> panel and a button. When I run it, it works once and only once. If I
> exit out of Python and re-open it works only once, again.
> The error I get is this:
> Traceback (most recent call last):
> File "/home/imiller/Wx Test.py", line 20, in <module>
> frame=miller(parent=None,id=-1)
> File "/home/imiller/Wx Test.py", line 6, in __init__
> wx.Frame.__init__(self,parent,id,'Frame aka window',
> size=(300,200))
> File "/usr/lib/python2.6/dist-packages/wx-2.6-gtk2-unicode/wx/
> _windows.py", line 485, in __init__
> newobj = _windows_.new_Frame(*args, **kwargs)
> PyNoAppError: The wx.App object must be created first!
> Can somebody tell me what I'm doing wrong? Like I said, it runs fine
> once and then I get this error. I apologize if this is a stupid
> question or if I'm asking in the wrong place. I'm new to all of this.
> Thanks.
If you're using IDLE to write and run your code in, then that's your
problem. IDLE is written in Tkinter and has its own main loop. When
you start wx, it starts its own main loop and the two don't get along
very well. I think the same problem happens with other GUI toolkits
like pyGTK or pyQT. When you have two main loops fighting each other,
you end up with IDLE doing weird things like the above.
The solution is to run your program from command line (i.e. python
myscript.py) or an IDE that actually starts the script in a separate
process. I use Wingware IDE, but I think PyDev + Eclipse works too.
There are lots of other IDEs to choose from though.
-------------------
Mike Driscoll
Blog: http://blog.pythonlibrary.org