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"
Full Script
Thanks in advance to anyone trying to help me!
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!