Example #1
0
 def __init__(self, parent, form, tag, parser, *args, **kwargs):
     self.value = GetParam(tag, "VALUE", "1")
     fnt = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
     if tag.HasParam('FONTSIZE'):
         try:
             fntsz = GetParam(tag, 'FONTSIZE').strip()
             if fntsz.startswith('+'):
                 fnt.SetPointSize(fnt.GetPointSize() + int(fntsz))
             elif fntsz.startswith('-'):
                 fnt.SetPointSize(fnt.GetPointSize() - int(fntsz))
             else:
                 fnt.SetPointSize(int(fntsz))
         except:
             import traceback
             traceback.print_exc(500)
     if tag.HasParam('FONTWEIGHT'):
         try:
             w = {'bold': wx.FONTWEIGHT_BOLD, 
                  'normal': wx.FONTWEIGHT_NORMAL, 
                  'max': wx.FONTWEIGHT_MAX,
                  'light': wx.FONTWEIGHT_LIGHT}
             fnt.SetWeight(w.get(GetParam(tag, 'FONTWEIGHT'), wx.FONTWEIGHT_NORMAL))
         except:
             import traceback
             traceback.print_exc(500)
     parentFont = parent.GetFont()
     parent.SetFont(fnt)
     wx.RadioButton.__init__(self, parent, label=self.value, *args, **kwargs)
     FormControlMixin.__init__(self, form, tag)
     if tag.HasParam("CHECKED"):
         self.SetValue(True)
     self.SetLabel(self.value)
     parent.SetFont(parentFont)
Example #2
0
 def __init__(self, parent, form, tag, parser, *args, **kwargs):
     label = ''
     if tag.HasParam("LABEL"):
         label = UnpackParam(GetParam(tag, "LABEL"))
     if tag.HasParam("STATE3"):
         style = wx.CHK_3STATE | wx.CHK_ALLOW_3RD_STATE_FOR_USER
     else:
         style = wx.CHK_2STATE             
     fnt = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
     if tag.HasParam('FONTSIZE'):
         try:
             fntsz = GetParam(tag, 'FONTSIZE').strip()
             if fntsz.startswith('+'):
                 fnt.SetPointSize(fnt.GetPointSize() + int(fntsz))
             elif fntsz.startswith('-'):
                 fnt.SetPointSize(fnt.GetPointSize() - int(fntsz))
             else:
                 fnt.SetPointSize(int(fntsz))
         except:
             import traceback
             traceback.print_exc(500)
     if tag.HasParam('FONTWEIGHT'):
         try:
             w = {'bold': wx.FONTWEIGHT_BOLD, 
                  'normal': wx.FONTWEIGHT_NORMAL, 
                  'max': wx.FONTWEIGHT_MAX,
                  'light': wx.FONTWEIGHT_LIGHT}
             fnt.SetWeight(w.get(GetParam(tag, 'FONTWEIGHT'), wx.FONTWEIGHT_NORMAL))
         except:
             import traceback
             traceback.print_exc(500)
     parentFont = parent.GetFont()
     parent.SetFont(fnt)
     wx.CheckBox.__init__(self, parent, label=label, style=style, *args, **kwargs)
     FormControlMixin.__init__(self, form, tag)
     if tag.HasParam('BGCOLOR'):
         try:
             self.SetBackgroundColour(GetParam(tag, 'BGCOLOR', 'WHITE'))
         except:
             import traceback
             traceback.print_exc(500)
     self.value = GetParam(tag, "VALUE", "1")
     if self.Is3State():
         self.value3 = GetParam(tag, "VALUE3", "2")
         if tag.HasParam("CHECKED"):
             self.Set3StateValue(wx.CHK_CHECKED)
         elif tag.HasParam("UNDETERMINED"):
             self.Set3StateValue(wx.CHK_UNDETERMINED)
     else:
         if tag.HasParam("CHECKED"):
             self.SetValue(True)
     if GetParam(tag, 'ONCLICK', '').lower().strip() == 'enter':
         self.Bind(wx.EVT_CHECKBOX, self.OnEnter)
     elif GetParam(tag, 'ONCLICK', '').lower().strip() == 'submit':
         self.Bind(wx.EVT_CHECKBOX, lambda e: self._onclicked(form, self))
     parent.SetFont(parentFont)