This is my code: The thing is it brings up the check boxes. But every time, no matter which ones I check, it says decommission tanks, and decommission cm's. That's all it says, no matter which combination of them I push? what's wrong with it?

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 = ["trade",'Bonus Resources','Technology above 15', 'Tech ratio better than 5:1','Soldiers greater than 20%', 'Soldiers less than 60%','Defcon 5 (unless in war)','Not in peace mode', 'Government', 'Tanks', 'Cruise Missles'], 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 ):
            print 
         else:
            print 'Find More Trades'

      for choice in self.bonus:
         if self.box.IsChecked ( x ):
            print
         else:
            print 'Restructure your trades'

            
      for choice in self.tech15:
         if self.box.IsChecked ( x ):
            print
         else:
            print 'You should always have more than 15 tech'

      for choice in self.tech51:
         if self.box.IsChecked ( x ):
            print
         else:
            print 'Buy tech till ratio is over 5:1'

      for choice in self.soldier:
         if self.box.IsChecked ( x ):
            print
         else:
            print 'Buy more soldiers until it is 20% of pop'

      for choice in self.soldier60:
         if self.box.IsChecked ( x ):
            print
         else:
            print 'Sell soldiers'
               
      for choice in self.defcon:
         if self.box.IsChecked ( x ):
            print
         else:
            print 'Change defcon level to 5 unless in war'
            

      for choice in self.peace:
         if self.box.IsChecked ( x ):
            print
         else:
            print 'Make war an option'

      for choice in self.government:
         if self.box.IsChecked ( x ):
            print
         else:
            print 'Change government type'

      for choice in self.tank:
         if self.box.IsChecked ( x ):
            print 'Decommission tanks'
         else:
            print

      for choice in self.cm:
         if self.box.IsChecked ( x ):
            print 'Decommission CM'
         else:
            print

            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()

Just a word of advice, instead of using

from wxpython.wx import *

Use

import wx

And then you just refer to things like wx.TextCtrl, rather then wxTextCtrl. So just add a dot.

And i cant find a fault on my computer, or i am not looking in the right place, what is meant to show up when you click audit? Can you give a tad more info?

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.