I'm busy trying to learn wxPython, and i'm trying to run the following
piece of code (its from the wxPyWiki tutorial):
import wx
ID_ABOUT = 101
ID_EXIT = 110
class MainWindow(wx.Frame):
def __init__(self,parent,id,title):
wx.Frame.__init__(self,parent,wx.ID_ANY,title,size =(200,100))
self.control = wx.TextCtrl(self,1,style=wx.TE_MULTILINE)
self.CreateStatusBar()
filemenu = wx.Menu()
filemenu.Append(ID_ABOUT,"&About"," Information about this
program.")
filemenu.AppendSeparator()
filemenu.Append(ID_EXIT,"E&xit"," Terminate the program.")
menuBar = wx.MenuBar()
menuBar.Append(filemenu,"&File")
self.SetMenuBar(menuBar)
self.Show(True)
app = wx.PySimpleApp()
frame = MainWindow(None, -1, "Sample editor")
app.MainLoop()
Simple enough, but every single time I try to run it IDLE gives me
this instead of the app I was hoping for:
Traceback (most recent call last):
File "C:\Documents and Settings\Enrico Jr\My Documents\Jr's Crap
\Python Stuff\Batch Picture Converter\main.py", line 24, in <module>
frame = MainWindow(None, -1, "Sample editor")
File "C:\Documents and Settings\Enrico Jr\My Documents\Jr's Crap
\Python Stuff\Batch Picture Converter\main.py", line 9, in __init__
wx.Frame.__init__(self,parent,wx.ID_ANY,title,size =(200,100))
File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx
\_windows.py", line 501, in __init__
_windows_.Frame_swiginit(self,_windows_.new_Frame( *args,
**kwargs))
PyNoAppError: The wx.App object must be created first!
As far as I can tell, the wx.App object IS being created first. I
suspect a race condition of some sort here, but can anyone shed some
light on this? 3 2680
teh_sAbEr wrote:
I'm busy trying to learn wxPython, and i'm trying to run the following
piece of code (its from the wxPyWiki tutorial):
import wx
ID_ABOUT = 101
ID_EXIT = 110
class MainWindow(wx.Frame):
def __init__(self,parent,id,title):
wx.Frame.__init__(self,parent,wx.ID_ANY,title,size =(200,100))
self.control = wx.TextCtrl(self,1,style=wx.TE_MULTILINE)
self.CreateStatusBar()
filemenu = wx.Menu()
filemenu.Append(ID_ABOUT,"&About"," Information about this
program.")
filemenu.AppendSeparator()
filemenu.Append(ID_EXIT,"E&xit"," Terminate the program.")
menuBar = wx.MenuBar()
menuBar.Append(filemenu,"&File")
self.SetMenuBar(menuBar)
self.Show(True)
app = wx.PySimpleApp()
frame = MainWindow(None, -1, "Sample editor")
app.MainLoop()
Simple enough, but every single time I try to run it IDLE gives me
this instead of the app I was hoping for:
Traceback (most recent call last):
File "C:\Documents and Settings\Enrico Jr\My Documents\Jr's Crap
\Python Stuff\Batch Picture Converter\main.py", line 24, in <module>
frame = MainWindow(None, -1, "Sample editor")
File "C:\Documents and Settings\Enrico Jr\My Documents\Jr's Crap
\Python Stuff\Batch Picture Converter\main.py", line 9, in __init__
wx.Frame.__init__(self,parent,wx.ID_ANY,title,size =(200,100))
File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx
\_windows.py", line 501, in __init__
_windows_.Frame_swiginit(self,_windows_.new_Frame( *args,
**kwargs))
PyNoAppError: The wx.App object must be created first!
As far as I can tell, the wx.App object IS being created first. I
suspect a race condition of some sort here, but can anyone shed some
light on this?
The main frame has to be created by the app itself, e.g. like so:
class App(wx.App):
def OnInit(self):
self._frame = MainFrame( None, -1, _APP_CAPTION)
self._frame.Show( True)
self.SetTopWindow( self._frame)
return True
def Run():
app = App()
app.MainLoop()
if __name__ == '__main__':
Run()
HTH
Thin
On Jul 13, 10:18*am, teh_sAbEr <teh.sa...@gmail.comwrote:
I'm busy trying to learn wxPython, and i'm trying to run the following
piece of code (its from the wxPyWiki tutorial):
import wx
ID_ABOUT = 101
ID_EXIT = 110
class MainWindow(wx.Frame):
* * def __init__(self,parent,id,title):
* * * * wx.Frame.__init__(self,parent,wx.ID_ANY,title,size =(200,100))
* * * * self.control = wx.TextCtrl(self,1,style=wx.TE_MULTILINE)
* * * * self.CreateStatusBar()
* * * * filemenu = wx.Menu()
* * * * filemenu.Append(ID_ABOUT,"&About"," Information about this
program.")
* * * * filemenu.AppendSeparator()
* * * * filemenu.Append(ID_EXIT,"E&xit"," Terminate the program.")
* * * * menuBar = wx.MenuBar()
* * * * menuBar.Append(filemenu,"&File")
* * * * self.SetMenuBar(menuBar)
* * * * self.Show(True)
app = wx.PySimpleApp()
frame = MainWindow(None, -1, "Sample editor")
app.MainLoop()
Simple enough, but every single time I try to run it IDLE gives me
this instead of the app I was hoping for:
Traceback (most recent call last):
* File "C:\Documents and Settings\Enrico Jr\My Documents\Jr's Crap
\Python Stuff\Batch Picture Converter\main.py", line 24, in <module>
* * frame = MainWindow(None, -1, "Sample editor")
* File "C:\Documents and Settings\Enrico Jr\My Documents\Jr's Crap
\Python Stuff\Batch Picture Converter\main.py", line 9, in __init__
* * wx.Frame.__init__(self,parent,wx.ID_ANY,title,size =(200,100))
* File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx
\_windows.py", line 501, in __init__
* * _windows_.Frame_swiginit(self,_windows_.new_Frame( *args,
**kwargs))
PyNoAppError: The wx.App object must be created first!
As far as I can tell, the wx.App object IS being created first. I
suspect a race condition of some sort here, but can anyone shed some
light on this?
This code works "as is" on Windows XP. However, I have gotten this
error when trying to run it from IDLE and I've heard that that can
happen in other Tkinter-based IDEs. Try running it from the command
line and I'll bet you won't get that error.
Also, there's a great wxPython user's group you can join from the
official website: www.wxpython.org
Mike
In article
<c2**********************************@34g2000hsh.g ooglegroups.com>,
Mike Driscoll <ky******@gmail.comwrote:
On Jul 13, 10:18*am, teh_sAbEr <teh.sa...@gmail.comwrote:
I'm busy trying to learn wxPython, and i'm trying to run the following
piece of code (its from the wxPyWiki tutorial):
import wx
[...]
app = wx.PySimpleApp()
frame = MainWindow(None, -1, "Sample editor")
app.MainLoop()
[...]
This code works "as is" on Windows XP. However, I have gotten this
error when trying to run it from IDLE and I've heard that that can
happen in other Tkinter-based IDEs.
So I've heard. Just for fun I tried running it in a wxPython-based
shell - it worked fine.
Try running it from the command
line and I'll bet you won't get that error.
Also, there's a great wxPython user's group you can join from the
official website:
www.wxpython.org
Mike
--
David C. Ullrich This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: timallard |
last post by:
We have pages that were updated with vs2005beta2 from v1.1 code and ran fine
on xp-pro, but placing them on a server are blowing on .CommandType in the
init() section of designer generated code...
|
by: Praveen_db2 |
last post by:
Hi All
I am getting strange errors in my db2diag.log can any one tell me what
these errors mean??
Following is the code from my db2diag.log...
|
by: Yuri CHUANG |
last post by:
This is a example from a textbook,but there are some strange error that
I don't understand.Could anyone give me some help to realize the
operations on set.Thank you very much:-)
(I compile it with...
|
by: Eric |
last post by:
I get following errors under C#
The name 'txtName' does not exist in the current context
The name 'txtName' does not exist in the current context
This is a nightmare. I have my web user control...
|
by: Laphan |
last post by:
Hi All
Two of my friends have Firefox installed with FireBug, which I believe is an
extension to test markup, and have found oddles of errors in my CSS even
though Firefox and IE display the...
| |
by: gundarap |
last post by:
Hello all,
I was wondering whether wxpython code can be embedded in HTML code.
I saw that We can do the converse i.e., we can write HTML code in wxpython code.
Jython is doing this favour with...
|
by: Jonathan Wood |
last post by:
I'm having my site email errors to me until I get things as stable as
possible. Occasionally, I get an error that I just cannot see how it could
ever happen. I enabled debugging on the live site so...
|
by: ccgrl451 |
last post by:
Okay, so here is the exercise I'm trying to complete. Create a turtle object in turtle graphics in a coin field, with each coin an object itself. Make the turtle randomly move while simultaneously...
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
| |
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |