Advertisement
Guest User

checkboxes

a guest
Aug 29th, 2011
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.26 KB | None | 0 0
  1. import wx
  2.  
  3. class CheckBoxFrame(wx.Frame):
  4.     def __init__(self):
  5.         wx.Frame.__init__(self, None, -1, 'Export Sequences', size=(500, 700))
  6.         self.panel = wx.Panel(self, -1)
  7.  
  8.         mainSizer = wx.BoxSizer(wx.VERTICAL)
  9.         self.panel.sizer = wx.GridBagSizer(hgap=5, vgap=5)
  10.  
  11.         # Check boxes for output formats
  12.         formats = ["Seperate Fasta File", "Multiple Fasta File", "Seperate CSV File",
  13.                   "Multiple CSV File"]
  14.  
  15.         row = 1
  16.         for lable in formats:
  17.             self.make_widgets(lable, row, id=row)
  18.             row += 1
  19.  
  20.         mainSizer.Add(self.panel.sizer, 0, wx.ALL, 10)
  21.         self.panel.SetSizer(mainSizer)
  22.         mainSizer.Fit(self.panel)
  23.         mainSizer.SetSizeHints(self.panel)
  24.  
  25.     def EvtCheckBox(self, evt):
  26.         # CB conditions
  27.         cb_single_fas = self.panel.FindWindowByLabel("Seperate Fasta File")
  28.         cb_multi_fas = self.panel.FindWindowByLabel("Multiple Fasta File")
  29.         cb_single_csv = self.panel.FindWindowByLabel("Seperate CSV File")
  30.         cb_multi_csv = self.panel.FindWindowByLabel("Multiple CSV File")
  31.  
  32.         if cb_single_fas.GetValue() == True:
  33.             cb_multi_fas.Enable(False)
  34.             cb_single_csv.Enable(False)
  35.             cb_multi_csv.Enable(False)
  36.         elif cb_single_fas.GetValue() == False:
  37.             cb_multi_fas.Enable(True)
  38.             cb_single_csv.Enable(True)
  39.             cb_multi_csv.Enable(True)
  40.         elif cb_single_csv.GetValue() == True:
  41.             cb_multi_fas.Enable(False)
  42.             cb_single_fas.Enable(False)
  43.             cb_multi_csv.Enable(False)
  44.         elif cb_single_csv.GetValue() == False:
  45.             cb_multi_fas.Enable(True)
  46.             cb_single_fas.Enable(True)
  47.             cb_multi_csv.Enable(True)
  48.  
  49.  
  50.     def make_widgets(self, lable, row, id):
  51.         """Function to create text and cb widgets."""
  52.         # Widgets
  53.         cb = wx.CheckBox(self.panel, id, lable, (90, 50), (-1, -1))
  54.         self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, cb)
  55.  
  56.         # Fonts
  57.         cb.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL))
  58.         # Sizers
  59.         self.panel.sizer.Add(cb, pos=(row, 3))
  60.  
  61.  
  62. if __name__ == '__main__':
  63.     app = wx.PySimpleApp()
  64.     CheckBoxFrame().Show()
  65.     app.MainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement