473,797 Members | 3,183 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

wxPython code giving strange errors.

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.F rame):
def __init__(self,p arent,id,title) :
wx.Frame.__init __(self,parent, wx.ID_ANY,title ,size=(200,100) )
self.control = wx.TextCtrl(sel f,1,style=wx.TE _MULTILINE)
self.CreateStat usBar()

filemenu = wx.Menu()
filemenu.Append (ID_ABOUT,"&Abo ut"," Information about this
program.")
filemenu.Append Separator()
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:\Documen ts 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:\Documen ts 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\Li b\site-packages\wx-2.8-msw-unicode\wx
\_windows.py", line 501, in __init__
_windows_.Frame _swiginit(self, _windows_.new_F rame(*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?
Jul 13 '08 #1
3 2694
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.F rame):
def __init__(self,p arent,id,title) :
wx.Frame.__init __(self,parent, wx.ID_ANY,title ,size=(200,100) )
self.control = wx.TextCtrl(sel f,1,style=wx.TE _MULTILINE)
self.CreateStat usBar()

filemenu = wx.Menu()
filemenu.Append (ID_ABOUT,"&Abo ut"," Information about this
program.")
filemenu.Append Separator()
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:\Documen ts 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:\Documen ts 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\Li b\site-packages\wx-2.8-msw-unicode\wx
\_windows.py", line 501, in __init__
_windows_.Frame _swiginit(self, _windows_.new_F rame(*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.Sho w( True)
self.SetTopWind ow( self._frame)
return True
def Run():
app = App()
app.MainLoop()
if __name__ == '__main__':
Run()
HTH
Thin

Jul 13 '08 #2
On Jul 13, 10:18*am, teh_sAbEr <teh.sa...@gmai l.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.F rame):
* * def __init__(self,p arent,id,title) :
* * * * wx.Frame.__init __(self,parent, wx.ID_ANY,title ,size=(200,100) )
* * * * self.control = wx.TextCtrl(sel f,1,style=wx.TE _MULTILINE)
* * * * self.CreateStat usBar()

* * * * filemenu = wx.Menu()
* * * * filemenu.Append (ID_ABOUT,"&Abo ut"," Information about this
program.")
* * * * filemenu.Append Separator()
* * * * 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:\Documen ts 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:\Documen ts 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\Li b\site-packages\wx-2.8-msw-unicode\wx
\_windows.py", line 501, in __init__
* * _windows_.Frame _swiginit(self, _windows_.new_F rame(*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
Jul 13 '08 #3
In article
<c2************ *************** *******@34g2000 hsh.googlegroup s.com>,
Mike Driscoll <ky******@gmail .comwrote:
On Jul 13, 10:18*am, teh_sAbEr <teh.sa...@gmai l.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
Jul 18 '08 #4

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

Similar topics

3
1117
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 left over from v1.1: Me.SqlSelectCommand1.CommandType = CommandType.StoredProcedure Compiler Error Message: BC30451: Name 'CommandType' is not declared. Where should I look for how to fix this, or, do I have to refactor the code
4
7356
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 ********************************************************************************************* 2006-02-23-17.53.12.253000 Instance:DB2 Node:000 PID:1600(db2syscs.exe) TID:440 Appid:AC10E010.J70A.00E883122250 base sys utilities sqleagnt_sigsegvh Probe:1 Database:DEVM_DB Error in agent...
4
3724
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 Dev C++ 4.9.9.2) #include<iostream> #include<set> #include<string> #include <algorithm>
3
2333
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 and I dragged it into DIV on my .aspx page. It's just a panel with a few textboxes. When I try to access some textbox, the above errors show up. What is the remedy - I want to reuse this control on different pages. Using VB.NET all works fine but...
37
2411
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 pages without problems. Has anybody used and had problems with this Firebug? It keeps saying that my cursor:hand command is invalid. I thought this was standard CSS2?
0
1015
gundarap
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 the help of Jython applets. But I want to work with wxpython. I'm sure that some of them would have experienced the same problem. Can you people suggest me some valuable solutions. Thank you in advance.
2
1336
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 that I could get line-number information. But I'm still at a loss. I've posted an error below, and the code below that. Somehow, grdWorkout.DataKeys is causing an ArgumentOutOfRangeException, even though I had tested for SelectedIndex == -1.
2
1600
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 collecting/eating coins(in my while loop, I used the random generator). As the turtle collects a coin, the turtle gets bigger and the coins should dissapear from the screen(also in my while loop, I made the shapesize increase,the coin it contacted...
0
9537
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
10469
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10246
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
10209
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
10023
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...
1
7560
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4135
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 we have to send another system
3
2934
bsmnconsultancy
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.