| | |
Error?
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2009
Posts: 6
Reputation:
Solved Threads: 0
My error is ">>>
Traceback (most recent call last):
File "C:\Python25\Books_per_month1AP.py", line 203, in <module>
Window()
File "C:\Python25\Books_per_month1AP.py", line 7, in __init__
wxFrame.__init__ ( self, None, -1, 'Audit', size = ( 300, 300 ) )
File "C:\Python25\lib\site-packages\wx-2.8-msw-unicode\wx\_windows.py", line 505, in __init__
_windows_.Frame_swiginit(self,_windows_.new_Frame(*args, **kwargs))
PyNoAppError: The wx.App object must be created first!
>>> "
What is wrong with this!?
Traceback (most recent call last):
File "C:\Python25\Books_per_month1AP.py", line 203, in <module>
Window()
File "C:\Python25\Books_per_month1AP.py", line 7, in __init__
wxFrame.__init__ ( self, None, -1, 'Audit', size = ( 300, 300 ) )
File "C:\Python25\lib\site-packages\wx-2.8-msw-unicode\wx\_windows.py", line 505, in __init__
_windows_.Frame_swiginit(self,_windows_.new_Frame(*args, **kwargs))
PyNoAppError: The wx.App object must be created first!
>>> "
What is wrong with this!?
Python Syntax (Toggle Plain Text)
from wxPython.wx import * class Window ( wxFrame ): def __init__ ( self ): wxFrame.__init__ ( self, None, -1, 'Audit', size = ( 300, 300 ) ) # Create a status bar self.CreateStatusBar() # Create a panel self.panel = wxPanel ( self, -1 ) # Create a label self.label = wxStaticText ( self.panel, -1, 'Nation Audit:' ) # Define a list of items to place in the wxCheckListBox self.trade = [ 'Trade' ] self.bonus = [ 'Bonus Resources' ] self.tech15 = [ 'Technology above 15' ] self.tech51 = [ 'Tech ratio better than 5:1' ] self.soldier = [ 'Soldiers greater than 20%' ] self.soldier60 = [ 'Soldiers less than 60%' ] self.defcon = [ 'Defcon 5 (unless in war)' ] self.peace = [ 'Not in peace mode' ] self.government = [ 'Government' ] self.tank = [ 'Tanks' ] self.cm = [ 'Cruise Missles' ] # Create a wxCheckListBox self.box = wxCheckListBox ( self.panel, 100, size = ( 250, 200 ), choices = self.trade, style = wxLB_HSCROLL ) self.box = wxCheckListBox ( self.panel, 100, size = ( 250, 200 ), choices = self.bonus, style = wxLB_HSCROLL ) self.box = wxCheckListBox ( self.panel, 100, size = ( 250, 200 ), choices = self.tech15, style = wxLB_HSCROLL ) self.box = wxCheckListBox ( self.panel, 100, size = ( 250, 200 ), choices = self.tech51, style = wxLB_HSCROLL ) self.box = wxCheckListBox ( self.panel, 100, size = ( 250, 200 ), choices = self.soldier, style = wxLB_HSCROLL ) self.box = wxCheckListBox ( self.panel, 100, size = ( 250, 200 ), choices = self.soldier60, style = wxLB_HSCROLL ) self.box = wxCheckListBox ( self.panel, 100, size = ( 250, 200 ), choices = self.defcon, style = wxLB_HSCROLL ) self.box = wxCheckListBox ( self.panel, 100, size = ( 250, 200 ), choices = self.peace, style = wxLB_HSCROLL ) self.box = wxCheckListBox ( self.panel, 100, size = ( 250, 200 ), choices = self.government, style = wxLB_HSCROLL ) self.box = wxCheckListBox ( self.panel, 100, size = ( 250, 200 ), choices = self.tank, style = wxLB_HSCROLL ) self.box = wxCheckListBox ( self.panel, 100, size = ( 250, 200 ), choices = self.cm, style = wxLB_HSCROLL ) # Hook up an event handling method EVT_CHECKLISTBOX ( self.panel, 100, self.clickHandler ) # Create a button self.button = wxButton ( self.panel, 200, 'Audit' ) # Hook up an event handling method EVT_BUTTON ( self.panel, 200, self.buttonHandler ) # Create two sizers to make everything pretty # The usual self.vertical = wxBoxSizer ( wxVERTICAL ) self.vertical.Add ( ( 0, 0 ), 1 ) self.vertical.Add ( self.label, 0, wxALIGN_CENTER ) self.vertical.Add ( ( 5, 5 ), 0 ) self.vertical.Add ( self.box, 0, wxALIGN_CENTER ) self.vertical.Add ( ( 5, 5 ), 0 ) self.vertical.Add ( self.button, 0, wxALIGN_CENTER ) self.vertical.Add ( ( 0, 0 ), 1 ) self.horizontal = wxBoxSizer ( wxHORIZONTAL ) self.horizontal.Add ( ( 0, 0 ), 1 ) self.horizontal.Add ( self.vertical, 0, wxALIGN_CENTER ) self.horizontal.Add ( ( 0, 0 ), 1 ) # Attach the sizer self.panel.SetSizerAndFit ( self.horizontal ) self.Show ( True ) # This method is called when an item is clicked def clickHandler ( self, event ): if self.box.IsChecked ( event.GetSelection() ): message = '' else: message = '' # Update the status bar of the window self.SetStatusText ( self.box.GetString ( event.GetSelection() ) + message ) # This method will be called when the button is clicked def buttonHandler ( self, event ): message = 'Nation Audit Final:' # Check to see what has been selected and what has not x = 0 for choice in self.trade: if self.box.IsChecked ( x ): else: print 'Find More Trades' for choice in self.bonus: if self.box.IsChecked ( x ): else: print 'Restructure your trades' for choice in self.tech15: if self.box.IsChecked ( x ): else: print 'You should always have more than 15 tech' for choice in self.tech51: if self.box.IsChecked ( x ): else: print 'Buy tech till ratio is over 5:1' for choice in self.soldier: if self.box.IsChecked ( x ): else: print 'Buy more soldiers until it is 20% of pop' for choice in self.soldier60: if self.box.IsChecked ( x ): else: print 'Sell soldiers' for choice in self.defcon: if self.box.IsChecked ( x ): else: print 'Change defcon level to 5 unless in war' for choice in self.peace: if self.box.IsChecked ( x ): else: print 'Make war an option' for choice in self.government: if self.box.IsChecked ( x ): else: print 'Change government type' for choice in self.tank: if self.box.IsChecked ( x ): print 'Decommission tanks' else: for choice in self.cm: if self.box.IsChecked ( x ): print 'Decommission CM' else: message = message + '\n' + choice x = x + 1 # Display a dialog dialog = wxMessageDialog ( self, message, 'The audit is complete', style = wxOK ) dialog.ShowModal() dialog.Destroy() application = wxPySimpleApp() Window() application.MainLoop()
•
•
Join Date: Jun 2008
Posts: 128
Reputation:
Solved Threads: 31
Google is your friend.
http://www.google.hu/search?q=wxPySi...ient=firefox-a
First url I get:
http://www.wxpython.org/docs/api/wx....App-class.html
which says in the example:
So that in your code the last lines will look like:
I hope this helps.
Please post the minimal code which produces the problem.
Please don't make topic with titles like 'I need help', 'Error?', 'Dunno what to do' etc...
Please use google, or any other search tool.
http://www.google.hu/search?q=wxPySi...ient=firefox-a
First url I get:
http://www.wxpython.org/docs/api/wx....App-class.html
which says in the example:
Python Syntax (Toggle Plain Text)
app = wx.PySimpleApp() frame = wx.Frame(None, title='Hello World') frame.Show() app.MainLoop()
So that in your code the last lines will look like:
Python Syntax (Toggle Plain Text)
application = wxPySimpleApp() w=Window() w.Show() application.MainLoop()
I hope this helps.
Please post the minimal code which produces the problem.
Please don't make topic with titles like 'I need help', 'Error?', 'Dunno what to do' etc...
Please use google, or any other search tool.
![]() |
Similar Threads
- Code 19 Registry Error (Windows NT / 2000 / XP)
- Error Loading operating System (Windows NT / 2000 / XP)
- svchost.exe error (Windows NT / 2000 / XP)
- New Hardware Causing Error (Windows NT / 2000 / XP)
- office 2000 install error (Windows NT / 2000 / XP)
- VMWare Unrecoverable Error (*nix Software)
- Error in Wrox Book (Perl)
Other Threads in the Python Forum
- Previous Thread: A recipe for simple file transfer between computers?
- Next Thread: Python speed issue.
Views: 223 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for Python
accessdenied address ansi backend beginner changecolor class code conversion coordinates copy corners curves customdialog dan08 dictionary directory dynamic edit examples excel feet file float font format ftp function generator getvalue gui halp homework i/o iframe images import info input ip java line linux list lists loop mouse mysql newb number numbers output panel parsing path port prime print program programming projects py2exe pygame pyqt python queue random rational recursion recursive screensaverloopinactive scrolledtext server ssh stamp statictext string strings sudokusolver table terminal text thread threading time tkinter tlapse tuple tutorial type ubuntu unicode url urllib urllib2 variable whileloop windows write wxpython





