473,394 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

wxPython crashes when run

50
Hi,

My GUI keeps crashing on the second time it runs. It doesn't come up with any useful error messages, just says "there was a problem". I've narrowed the offending code to the following.

I'm running wxpython on windows xp.

cheers

Expand|Select|Wrap|Line Numbers
  1.  
  2. import wx
  3.  
  4. class myFrame(wx.Frame):
  5.     def __init__(self, parent, id, title):
  6.         wx.Frame.__init__(self, parent, id, title, size=(250, 150))
  7.  
  8.         menubar = wx.MenuBar()
  9.         file = wx.Menu()
  10.         quit = wx.MenuItem(file, 1, '&Quit\tCtrl+Q')
  11.         file.AppendItem(quit)
  12.  
  13.         self.Bind(wx.EVT_MENU, self.OnQuit, id=1)
  14.  
  15.         menubar.Append(file, '&File')
  16.         self.SetMenuBar(menubar)
  17.  
  18.         self.Centre()
  19.         self.Show(True)
  20.  
  21.     def OnQuit(self, event):
  22.         self.Close()
  23.  
  24. class MyApp(wx.App):
  25.     def OnInit(self):
  26.         frame =myFrame(None,-1,"frame test")
  27.         self.SetTopWindow(frame)
  28.  
  29.         print "Print statements go to this stdout window by default."
  30.  
  31.         frame.Show(True)
  32.         return True
  33.  
  34. app = MyApp(False) 
  35. app.MainLoop()
  36.  
  37.  
Sep 26 '07 #1
2 1653
bartonc
6,596 Expert 4TB
I ran this successfully on my machine many times in a row with no errors.
The only thing that I see as a "mistake" is using a literal for the ID of the menu item. A better method would be to have wx give you IDs at the module level:
Expand|Select|Wrap|Line Numbers
  1. wxID_MYMENUITEMS0 = wx.NewId()
The create the menu item and Bind() using that ID.

The reason that it is a mistake to use literals as IDs is that many IDs are used internally by wx. wx.NewId() will always return a usable ID.
Sep 27 '07 #2
kdt
50
I ran this successfully on my machine many times in a row with no errors.
The only thing that I see as a "mistake" is using a literal for the ID of the menu item. A better method would be to have wx give you IDs at the module level:
Expand|Select|Wrap|Line Numbers
  1. wxID_MYMENUITEMS0 = wx.NewId()
The create the menu item and Bind() using that ID.

The reason that it is a mistake to use literals as IDs is that many IDs are used internally by wx. wx.NewId() will always return a usable ID.
Thanks Bartonc, resolved now. :)
Sep 27 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: achrist | last post by:
I've just installed the new wxPython, version 2.4.2.4 (under Windows NT, sp6, python 2.3.2) and tried to create an exe using the McMillan installer. Seems to be a new problem ... I've got the...
4
by: Simon Dahlbacka | last post by:
I'm "exefying" an application that uses wxpython, some com to control excel and word and want to distribute this application. after creating the executable with py2exe, it still works fine (at...
2
by: Pekka Karjalainen | last post by:
I'm using WinXP (Finnish), Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on win32 and wxPython 2.6.0.1. When I go to the Process and Events section in the wxDemo and run the Process demo, bad things...
2
by: Jason | last post by:
How do I form a new wxPython date using day, month and year? I've tried the wx.DateTimeFromDMY but it crashes in Pythonwin when I test it out and I get all manner of complaints when I try it from...
3
by: Jerry | last post by:
I have created an application using wxPython and compiled it using py2exe. When I put setup(console=) in my setup.py file, the resulting application runs just fine. But when I change it to...
5
by: Andrew P | last post by:
Hello, I am new (very) to Python and have just down loaded the latest version of Python (2.5) and WXPython (2.8). For some reason I cannot get the WXPython demo to run at all. I run windows...
19
by: [david] | last post by:
I'd like to refresh the display before I start the main loop. I have code like this: app = App() app.Show() app.long_slow_init() app.MainLoop()
1
by: [david] | last post by:
What am I doing wrong? I'm trying to capture stdErr in a multi-threaded program. This code crashes wxPython with /Py Assertion Error: C++ assertion "m_count=-1 || m_count=-2" failed/ What I'm...
3
by: SMALLp | last post by:
Hy. I'm new in linux (Ubuntu 7.10) as well as in python. I installed IDLE, and i installed package python-wxgtkX. I start IDLE and when i want co compile my aplication all windows close. Also when...
17
by: NoelByron | last post by:
Hello! We are thinking about writing a project for several customers in Python. This project would include (among others) wxPython, a C/C++ module. But what happens if this application generates...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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,...
0
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...

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.