def __init__(self, parent, vnet_mgr): BaseToolbar.__init__(self, parent) self.vnet_mgr = vnet_mgr self.InitToolbar(self._toolbarData()) choices = [] for moduleName in self.vnet_mgr.GetAnalyses(): choices.append( self.vnet_mgr.GetAnalysisProperties(moduleName)["label"]) self.anChoice = ComboBox( parent=self, id=wx.ID_ANY, choices=choices, style=wx.CB_READONLY, size=(350, 30), ) # FIXME self.anChoice.SetToolTip(_("Available analyses")) self.anChoice.SetSelection(0) self.anChoiceId = self.AddControl(self.anChoice) self.parent.Bind(wx.EVT_COMBOBOX, self.parent.OnAnalysisChanged, self.anChoiceId) # workaround for Mac bug. May be fixed by 2.8.8, but not before then. self.anChoice.Hide() self.anChoice.Show() # realize the toolbar self.Realize()
def __init__( self, parent, data, pointNo, itemCap="Point No.", id=wx.ID_ANY, title=_("Edit point"), style=wx.DEFAULT_DIALOG_STYLE): """Dialog for editing item cells in list""" wx.Dialog.__init__(self, parent, id, title=_(title), style=style) self.parent = parent panel = Panel(parent=self) sizer = wx.BoxSizer(wx.VERTICAL) box = StaticBox(parent=panel, id=wx.ID_ANY, label=" %s %s " % (_(itemCap), str(pointNo + 1))) boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL) # source coordinates gridSizer = wx.GridBagSizer(vgap=5, hgap=5) self.fields = [] self.data = deepcopy(data) col = 0 row = 0 iField = 0 for cell in self.data: # Select if type(cell[2]).__name__ == "list": self.fields.append(ComboBox(parent=panel, id=wx.ID_ANY, choices=cell[2], style=wx.CB_READONLY, size=(110, -1))) # Text field else: if cell[2] == float: validator = FloatValidator() elif cell[2] == int: validator = IntegerValidator() else: validator = None if validator: self.fields.append( TextCtrl( parent=panel, id=wx.ID_ANY, validator=validator, size=(150, -1))) else: self.fields.append(TextCtrl(parent=panel, id=wx.ID_ANY, size=(150, -1))) value = cell[1] if not isinstance(cell[1], basestring): value = str(cell[1]) self.fields[iField].SetValue(value) label = StaticText( parent=panel, id=wx.ID_ANY, label=_( parent.GetColumn( cell[0]).GetText()) + ":") # name of column) gridSizer.Add(label, flag=wx.ALIGN_CENTER_VERTICAL, pos=(row, col)) col += 1 gridSizer.Add(self.fields[iField], pos=(row, col)) if col % 3 == 0: col = 0 row += 1 else: col += 1 iField += 1 boxSizer.Add(gridSizer, proportion=1, flag=wx.EXPAND | wx.ALL, border=5) sizer.Add(boxSizer, proportion=1, flag=wx.EXPAND | wx.ALL, border=5) # # buttons # self.btnCancel = Button(panel, wx.ID_CANCEL) self.btnOk = Button(panel, wx.ID_OK) self.btnOk.SetDefault() btnSizer = wx.StdDialogButtonSizer() btnSizer.AddButton(self.btnCancel) btnSizer.AddButton(self.btnOk) btnSizer.Realize() sizer.Add(btnSizer, proportion=0, flag=wx.ALIGN_RIGHT | wx.ALL, border=5) panel.SetSizer(sizer) sizer.Fit(self)