×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Problem with wxPython listbox

Problem with wxPython listbox

Problem with wxPython listbox

(OP)
Hey all. I'm trying to write a simple application, to calculate the odds for poker. However, I have run into a problem.

The idea is that the user selects both cards he/she has, use a checkbox to set if they are suited or not, and finally, press Calculate.

The strange thing however is that I can't select anything in either of the boxes!! The checkmark works fine, but the boxes just won't work correctly. Can anyone help me out?

"Pure Box Script"

CODE

        self.box1 = wx.ListBox(self, -1, size=(60,163) , choices=['Ace','King','Queen','Ten','9','8','7','6','5','4','3','2'])
        self.box2 = wx.ListBox(self, -1, size=(60,163) , choices=['Ace','King','Queen','Ten','9','8','7','6','5','4','3','2'])
...
        self.sizer.Add( self.box1   , ( 1 , 0 ) )
        self.sizer.Add( self.box2   , ( 1 , 1 ) )

Full Script

CODE

"""
To do:     * add standard header, creator, program etc
                * search for TODO (site url)
"""
import wx
ID_BUTTON = 100
ID_ABOUT=101
ID_EXIT=200
class MainWindow(wx.Frame):
    """ We simply derive a new class of Frame. """
    def __init__(self,parent,id, title):
        #Setup Frame, Panel and Sizer
        wx.Frame.__init__(self,parent,wx.ID_ANY,title,size=(150,305))
        self.panel = wx.Panel ( self, -1 )
        self.sizer = wx.GridBagSizer ( 7, 5 )
        #Setup File menu
        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)
        wx.EVT_MENU(self, ID_ABOUT, self.OnAbout)
        wx.EVT_MENU(self, ID_EXIT, self.OnExit)
        #Just a little banner
        self.label = wx.StaticText ( self.panel, -1, "Select your cards.\nDon't forget to set if\nthey are suited or not!", style = wx.TE_CENTER )
        #Boxes, to select cards
        self.box1 = wx.ListBox(self, -1, size=(60,163) , choices=['Ace','King','Queen','Ten','9','8','7','6','5','4','3','2'])
        self.box2 = wx.ListBox(self, -1, size=(60,163) , choices=['Ace','King','Queen','Ten','9','8','7','6','5','4','3','2'])
        #Checkbox, suited or unsuited
        self.suited = wx.CheckBox ( self.panel, -1, " Suited ")
        #Finally, a button to start the calculations
        self.button = wx.Button ( self.panel, ID_BUTTON, " Calculate " )
        wx.EVT_BUTTON ( self.panel, ID_BUTTON, self.Calculate )
        #Add everything to the sizer, so that it is showed in a orderly fashion
        self.sizer.Add( self.label   , ( 0 , 0 ) , ( 1 ,  2) , wx.ALIGN_CENTER  )
        self.sizer.Add( self.box1   , ( 1 , 0 ) )
        self.sizer.Add( self.box2   , ( 1 , 1 ) )
        self.sizer.Add( self.suited , ( 2 , 0 ) )
        self.sizer.Add( self.button , ( 2 , 1 ) )
        #Attach sizer to panel
        # Center everything
        self.horizontal = wx.BoxSizer ( wx.HORIZONTAL )
        self.horizontal.Add ( ( 0, 0 ), 1 )
        self.horizontal.Add ( self.sizer )
        self.horizontal.Add ( ( 0, 0 ), 1 )
        self.vertical = wx.BoxSizer ( wx.VERTICAL )
        self.vertical.Add ( ( 0, 0, ), 1 )
        self.vertical.Add ( self.horizontal, 0, wx.ALIGN_CENTER )
        self.vertical.Add ( ( 0, 0 ), 1 )
        self.panel.SetSizerAndFit ( self.vertical )
        #Show it all, you nasty bitch
        self.Show(True)

    def Calculate (self,e):
        #Calcutate everything TODO: EVERYTHING
        pass
        
    def OnAbout (self,e):
        #Simple about message TODO add site url
        d= wx.MessageDialog( self, " DisAstro's Texas Hold 'Em Calculator.\n"
                             "A Texas Hold Em Preflop Calculator\n"
                             "\n"
                             "Made by DisAstro.\n"
#                             "INSERT SITE HERE\n"
                             "\n"
                             "Copyright 2006 'The Balhaar Clan.'\n"
                             "All rights reserved"," About DA THC ", wx.OK)
        d.ShowModal()
        d.Destroy()

    def OnExit(self,e):
        #Close the frame.
        self.Close(True)
app = wx.PySimpleApp()
frame=MainWindow(None,-1,'DA THC')
app.MainLoop()

Thanks in advance to anyone trying to help me!

RE: Problem with wxPython listbox

(OP)
Some changes since yesterday:
Added ID's and binded them to a simple print selection function. No change at all. Anyone?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close