def __init__(self, parent, *args, **kw): """ Pass an initialized wx.xrc.XmlResource into res """ f = os.path.join(os.path.dirname(__file__), self.xrc) res = XmlResourceWithHandlers(f) # Figure out what Frame class (MDI, MiniFrame, etc) is actually our base... bases = set() def findbases(klass, set): for base in klass.__bases__: set.add(base) findbases(base, set) findbases(self.__class__, bases) for base in bases: if base.__name__.endswith("Frame"): break # Two stage creation (see http://wiki.wxpython.org/index.cgi/TwoStageCreation) pre = getattr(wx, "Pre%s" % base.__name__)() res.LoadOnFrame(pre, parent, "winHelp") self.PreCreate(pre) self.PostCreate(pre) # Define variables for the controls self.Subject = XRCCTRL(self, "Subject") self.Message = XRCCTRL(self, "Message") self.ShowAgain = XRCCTRL(self, "ShowAgain") if hasattr(self, "OnShowAgain"): self.Bind(wx.EVT_CHECKBOX, self.OnShowAgain, self.ShowAgain) self.Close = XRCCTRL(self, "wxID_CLOSE") if hasattr(self, "OnClose"): self.Bind(wx.EVT_BUTTON, self.OnClose, self.Close)
def __init__(self, parent, *args, **kw): """ Pass an initialized wx.xrc.XmlResource into res """ f = os.path.join(os.path.dirname(__file__), self.xrc) res = XmlResourceWithHandlers(f) # Two stage creation (see http://wiki.wxpython.org/index.cgi/TwoStageCreation) pre = wx.PrePanel() res.LoadOnPanel(pre, parent, "panelSystem") self.PreCreate(pre) self.PostCreate(pre) # Define variables for the controls self.Tree = XRCCTRL(self, "Tree") self.PrevObject = XRCCTRL(self, "PrevObject") if hasattr(self, "OnPrevObject"): self.Bind(wx.EVT_BUTTON, self.OnPrevObject, self.PrevObject) self.NextObject = XRCCTRL(self, "NextObject") if hasattr(self, "OnNextObject"): self.Bind(wx.EVT_BUTTON, self.OnNextObject, self.NextObject) self.StepInto = XRCCTRL(self, "StepInto") if hasattr(self, "OnStepInto"): self.Bind(wx.EVT_BUTTON, self.OnStepInto, self.StepInto) self.Search = XRCCTRL(self, "Search")
def browse_folders(event): tb = XRCCTRL(panel, 'path') dlg = wx.DirDialog(panel) if tb.GetValue(): dlg.SetPath(tb.GetValue()) if dlg.ShowModal() == wx.ID_OK: tb.SetValue(dlg.GetPath())
class ProgressDialog(wx.Dialog): """Dialog to show progress for certain long-running events.""" def __init__(self): wx.Dialog.__init__(self) def Init(self, res, title=None): """Method called after the dialog has been initialized.""" # Initialize controls self.SetTitle(title) self.lblProgressLabel = XRCCTRL(self, 'lblProgressLabel') self.lblProgress = XRCCTRL(self, 'lblProgress') self.gaugeProgress = XRCCTRL(self, 'gaugeProgress') self.lblProgressPercent = XRCCTRL(self, 'lblProgressPercent') def OnUpdateProgress(self, num, length, message=''): """Update the process interface elements.""" if not length: percentDone = 0 else: percentDone = int(100 * (num) / length) self.gaugeProgress.SetValue(percentDone) self.lblProgressPercent.SetLabel(str(percentDone)) self.lblProgress.SetLabel(message) # End the dialog since we are done with the import process if (message == 'Done'): self.EndModal(wx.ID_OK)
class TripLogDialog(wx.Dialog): def __init__(self): pre = wx.PreDialog() self.PostCreate(pre) def Init(self, tripexecuter): self.tripexecuter = tripexecuter self.tripexecuter.add_log_listener(self) self.txt_log = XRCCTRL(self, "txt_log") wx.EVT_BUTTON(self, XRCID("btn_ok"), self.close) self.btn_ok = XRCCTRL(self, "btn_ok") self.btn_ok.Enable(False) self.check_close = XRCCTRL(self, "check_close") def close(self, evt): self.Close() def finish(self): self.btn_ok.Enable(True) if self.check_close.IsChecked(): self.Close() def write(self, txt): self.txt_log.AppendText("%s\n" % txt)
def OnCreate(self): self.SetSize((600, 400)) #widgets self.code_stc = XRCCTRL(self, "code_stc") self.code_stc.Bind(wx.EVT_LEFT_UP, self.ContextMenuHandler) self.block_tree = XRCCTRL(self, "block_tree") self.block_tree.SetBlockstore(self.block_store) self.preview_ctrl = XRCCTRL(self, "preview_ctrl") self.block_tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelectionChanged) #buttons self.clear_button = XRCCTRL(self, "clear_button") self.Bind(wx.EVT_BUTTON, self.OnClear, self.clear_button) self.remove_button = XRCCTRL(self, "remove_button") self.Bind(wx.EVT_BUTTON, self.OnRemove, self.remove_button) self.save_button = XRCCTRL(self, "save_button") self.Bind(wx.EVT_BUTTON, self.OnSave, self.save_button) self.info_button = XRCCTRL(self, "info_button") self.Bind(wx.EVT_BUTTON, self.OnInfo, self.info_button) #fill the block_tree #tpcl.IO.LoadBlockIntoTree(self.block_tree) self.root_expression = None self.CreateQuickInsertMenu()
def Init(self, name=None, appname=""): """Method called after the panel has been initialized.""" # Hide the close button on Mac if guiutil.IsMac(): XRCCTRL(self, 'wxID_OK').Hide() # Set window icon else: self.SetIcon(guiutil.get_icon()) # Set the dialog title if name: self.SetTitle(name) # Initialize controls self.notebook = XRCCTRL(self, 'notebook') # Modify the control and font size on Mac for child in self.GetChildren(): guiutil.adjust_control(child) # Bind ui events to the proper methods self.Bind(wx.EVT_CLOSE, self.OnClose) self.Bind(wx.EVT_WINDOW_DESTROY, self.OnClose) wx.EVT_BUTTON(self, XRCID('wxID_OK'), self.OnClose) # Initialize variables self.preftemplate = [] self.values = {} self.appname = appname
def __init__(self, parent, *args, **kw): """ Pass an initialized wx.xrc.XmlResource into res """ f = os.path.join(os.path.dirname(__file__), self.xrc) res = XmlResourceWithHandlers(f) # Figure out what Frame class (MDI, MiniFrame, etc) is actually our base... bases = set() def findbases(klass, set): for base in klass.__bases__: set.add(base) findbases(base, set) findbases(self.__class__, bases) for base in bases: if base.__name__.endswith("Frame"): break # Two stage creation (see http://wiki.wxpython.org/index.cgi/TwoStageCreation) pre = getattr(wx, "Pre%s" % base.__name__)() res.LoadOnFrame(pre, parent, "IdleFinder") self.PreCreate(pre) self.PostCreate(pre) # Define variables for the controls self.base = XRCCTRL(self, "base") self.idlelist = XRCCTRL(self, "idlelist")
def OnCreate(self): self.name_field = XRCCTRL(self, "name_field") self.desc_field = XRCCTRL(self, "desc_field") self.desc_field.Bind(wx.EVT_TEXT, self.CreateAttributeMonitor('description')) self.loaded = False
def init_advanved_dose(self): self.drop_projectile = XRCCTRL(self, "drop_projectile") self.drop_projectile.Append("H") self.drop_projectile.Append("C") self.txt_dose_percent = XRCCTRL(self, "txt_dose_percent") wx.EVT_BUTTON(self, XRCID('btn_set_dosepercent'), self.set_dose_percent) wx.EVT_CHOICE(self, XRCID('drop_projectile'), self.on_projectile_changed)
def Init(self, dosecube): self.dosecube = dosecube self.txt_targetdose = XRCCTRL(self, "txt_targetdose") self.txt_targetdose.SetValue("%.1f" % self.dosecube.get_dose()) self.btn_ok = XRCCTRL(self, 'btn_ok') wx.EVT_BUTTON(self, XRCID('btn_ok'), self.save_and_close) self.btn_cancel = XRCCTRL(self, 'btn_close') wx.EVT_BUTTON(self, XRCID('btn_close'), self.close)
def __init__(self, parent, *args, **kw): """ Pass an initialized wx.xrc.XmlResource into res """ f = os.path.join(os.path.dirname(__file__), self.xrc) res = XmlResourceWithHandlers(f) # Two stage creation (see http://wiki.wxpython.org/index.cgi/TwoStageCreation) pre = wx.PrePanel() res.LoadOnPanel(pre, parent, "configConnect") self.PreCreate(pre) self.PostCreate(pre) # Define variables for the controls self.Servers = XRCCTRL(self, "Servers") self.ServerDetails = XRCCTRL(self, "ServerDetails") self.Username = XRCCTRL(self, "Username") self.GameShow = XRCCTRL(self, "GameShow") if hasattr(self, "OnGameShow"): self.Bind(wx.EVT_TOGGLEBUTTON, self.OnGameShow, self.GameShow) self.GameTitle = XRCCTRL(self, "GameTitle") self.Game = XRCCTRL(self, "Game") self.Password = XRCCTRL(self, "Password") self.AutoConnect = XRCCTRL(self, "AutoConnect") if hasattr(self, "OnAutoConnect"): self.Bind(wx.EVT_CHECKBOX, self.OnAutoConnect, self.AutoConnect) self.Debug = XRCCTRL(self, "Debug") if hasattr(self, "OnDebug"): self.Bind(wx.EVT_CHECKBOX, self.OnDebug, self.Debug)
def init_general(self): self.drop_res_tissue_type = XRCCTRL(self, "drop_res_tissue_type") rbe_list = self.data.get_rbe() for rbe in rbe_list.get_rbe_list(): self.drop_res_tissue_type.Append(rbe.get_name()) self.select_drop_by_value(self.drop_res_tissue_type, self.plan.get_res_tissue_type()) self.drop_target_tissue_type = XRCCTRL(self, "drop_target_tissue_type") for rbe in rbe_list.get_rbe_list(): self.drop_target_tissue_type.Append(rbe.get_name()) self.select_drop_by_value(self.drop_target_tissue_type, self.plan.get_target_tissue_type())
def options_ok(event): # Validate msgs = [] port = XRCCTRL(panel, 'port').GetValue().strip() if re.match('^\d+$', port): port = int(port) if not 1 <= port <= 65535: msgs.append('The port must be a number 0-65535') else: msgs.append('The port must be a number 0-65535') listen = XRCCTRL(panel, 'listen').GetValue().strip() if not re.match('^\d+\.\d+\.\d+\.\d+$', listen): msgs.append( 'The server address must be a valid ip address of an interface on this system' ) path = XRCCTRL(panel, 'path').GetValue().strip() if not all( os.path.exists(os.path.join(path, t)) for t in ('pipp.xsl', 'index.pip')): msgs.append( 'The path must point to a valid Pipp project (both pipp.xsl and index.pip must exist)' ) # Display any problems to the user if msgs: msg = wx.MessageDialog(panel, '\n'.join(msgs), 'Pipp', style=wx.OK | wx.ICON_EXCLAMATION) msg.ShowModal() return # Activate global options options.port = port options.listen = listen options.path = path _winreg.SetValueEx(regkey, 'Port', 0, _winreg.REG_SZ, str(port)) _winreg.SetValueEx(regkey, 'Listen', 0, _winreg.REG_SZ, listen) _winreg.SetValueEx(regkey, 'Path', 0, _winreg.REG_SZ, path) global server server = PippServer(options) server.start() panel.Close()
def SetErrorLabel(self, attr_name, error): """\ Marks the label of the given attribute red and provides a tooltip with the error. This function gets a resource from the XRC file, so the labels have to follow the naming convention of ATTRIBUTE-NAME_label or else an error will result when the label can't be found in the XRC file """ label = XRCCTRL(self, attr_name + "_label") label.SetForegroundColour("RED") label.SetToolTip(wx.ToolTip(error)) self.error_labels.append(label)
def __init__(self, parent, *args, **kw): """ Pass an initialized wx.xrc.XmlResource into res """ f = os.path.join(os.path.dirname(__file__), self.xrc) res = XmlResourceWithHandlers(f) # Two stage creation (see http://wiki.wxpython.org/index.cgi/TwoStageCreation) pre = wx.PrePanel() res.LoadOnPanel(pre, parent, "panelInformation") self.PreCreate(pre) self.PostCreate(pre) # Define variables for the controls self.Title = XRCCTRL(self, "Title") self.Details = XRCCTRL(self, "Details")
def Init(self, plan): self.plan = plan self.btn_ok = XRCCTRL(self, 'btn_ok') wx.EVT_BUTTON(self, XRCID('btn_ok'), self.save_and_close) self.btn_cancel = XRCCTRL(self, 'btn_close') wx.EVT_BUTTON(self, XRCID('btn_close'), self.close) self.init_general() self.init_trip_panel() self.init_opt_panel() self.init_calculation_panel() self.init_files_panel() self.init_advanved_dose()
class Panel(ObjectPanel.Panel): """ A wx.Panel for displaying and editing Categories """ def __init__(self, parent, id=wx.ID_ANY, style=wx.EXPAND): #load from XRC, need to use two-stage create pre = wx.PrePanel() res = gui.XrcUtilities.XmlResource('./gui/xrc/CategoryPanel.xrc') res.LoadOnPanel(pre, parent, "CategoryPanel") self.PostCreate(pre) ObjectPanel.Panel.Setup(self) self.OnCreate() def OnCreate(self): self.name_field = XRCCTRL(self, "name_field") self.desc_field = XRCCTRL(self, "desc_field") self.desc_field.Bind(wx.EVT_TEXT, self.CreateAttributeMonitor('description')) self.loaded = False def LoadObject(self, node): self.loading = True self.node = node self.object = node.GetObject() self.node.visible = True self.name_field.SetLabel(str(self.object.name)) self.desc_field.SetValue(str(self.object.description)) self.desc_field.attr_name = 'description' if self.object.errors.has_key('description'): print "Error in description!" self.SetErrorLabel('description', self.object.errors['description']) self.loaded = True self.loading = False self.Show() return self def cleanup(self): self.node.visible = False self.Hide() self.node.ClearObject() self.object = None self.loaded = False
class orderListBase(wx.Panel): xrc = os.path.join(location(), "windows", "xrc", 'orderList.xrc') def PreCreate(self, pre): """ This function is called during the class's initialization. Override it for custom setup before the window is created usually to set additional window styles using SetWindowStyle() and SetExtraStyle().""" pass def __init__(self, parent, *args, **kw): """ Pass an initialized wx.xrc.XmlResource into res """ f = os.path.join(os.path.dirname(__file__), self.xrc) res = XmlResourceWithHandlers(f) # Two stage creation (see http://wiki.wxpython.org/index.cgi/TwoStageCreation) pre = wx.PrePanel() res.LoadOnPanel(pre, parent, "orderList") self.PreCreate(pre) self.PostCreate(pre) # Define variables for the controls self.Choices = XRCCTRL(self, "Choices") self.Type = XRCCTRL(self, "Type") if hasattr(self, "OnType"): self.Type.Bind(wx.EVT_CHOICE, self.OnType) self.Number = XRCCTRL(self, "Number") self.Add = XRCCTRL(self, "Add") if hasattr(self, "OnAdd"): self.Bind(wx.EVT_BUTTON, self.OnAdd, self.Add) self.Delete = XRCCTRL(self, "Delete") if hasattr(self, "OnDelete"): self.Bind(wx.EVT_BUTTON, self.OnDelete, self.Delete)
def __init__(self, parent, *args, **kw): """ Pass an initialized wx.xrc.XmlResource into res """ f = os.path.join(os.path.dirname(__file__), self.xrc) res = XmlResourceWithHandlers(f) # Two stage creation (see http://wiki.wxpython.org/index.cgi/TwoStageCreation) pre = wx.PrePanel() res.LoadOnPanel(pre, parent, "orderPosition") self.PreCreate(pre) self.PostCreate(pre) # Define variables for the controls self.X = XRCCTRL(self, "X") self.Y = XRCCTRL(self, "Y") self.Z = XRCCTRL(self, "Z") self.Locate = XRCCTRL(self, "Locate") if hasattr(self, "OnLocate"): self.Bind(wx.EVT_BUTTON, self.OnLocate, self.Locate)
def bindall(self, obj): for func_name, args, keys in self.binds[hash(self)]: keys = dict(keys) if keys.has_key('event'): event = keys['event'] del keys['event'] else: event = args[0] args = list(args[1:]) control = obj if keys.has_key('id'): if isinstance(keys['id'], str): keys['id'] = XRCID(keys['id']) if keys.has_key('control'): control = keys['control'] if isinstance(control, str): control = XRCCTRL(obj, control) del keys['control'] control.Bind(event, getattr(obj, func_name), *args, **keys)
def init_calculation_panel(self): self.check_phys_dose = XRCCTRL(self, "check_phys_dose") self.check_phys_dose.SetValue(self.plan.get_out_phys_dose()) self.check_bio_dose = XRCCTRL(self, "check_bio_dose") self.check_bio_dose.SetValue(self.plan.get_out_bio_dose()) self.check_dose_mean_let = XRCCTRL(self, "check_mean_let") self.check_dose_mean_let.SetValue(self.plan.get_out_dose_mean_let()) self.check_field = XRCCTRL(self, "check_field") self.check_field.SetValue(self.plan.get_out_field())
def init_trip_panel(self): self.drop_location = XRCCTRL(self, "drop_location") if self.plan.is_remote(): self.drop_location.SetSelection(1) self.txt_working_dir = XRCCTRL(self, "txt_working_dir") self.txt_working_dir.SetValue(self.plan.get_working_dir()) wx.EVT_BUTTON(self, XRCID('btn_working_dir'), self.on_browse_working_dir) self.txt_username = XRCCTRL(self, "txt_username") self.txt_username.SetValue(self.plan.get_username()) self.txt_password = XRCCTRL(self, "txt_password") self.txt_password.SetValue(self.plan.get_password()) self.txt_server = XRCCTRL(self, "txt_server") self.txt_server.SetValue(self.plan.get_server())
def Init(self, res, title=None): """Method called after the dialog has been initialized.""" # Initialize controls self.SetTitle(title) self.lblProgressLabel = XRCCTRL(self, 'lblProgressLabel') self.lblProgress = XRCCTRL(self, 'lblProgress') self.gaugeProgress = XRCCTRL(self, 'gaugeProgress') self.lblProgressPercent = XRCCTRL(self, 'lblProgressPercent')
def Init(self, res): """Method called after the panel has been initialized.""" # Initialize the panel controls self.choiceDICOM = XRCCTRL(self, 'choiceDICOM') self.tlcTreeView = DICOMTree(self) res.AttachUnknownControl('tlcTreeView', self.tlcTreeView, self) # Bind interface events to the proper methods self.Bind(wx.EVT_CHOICE, self.OnLoadTree, id=XRCID('choiceDICOM')) self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy) # Decrease the font size on Mac font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT) if guiutil.IsMac(): font.SetPointSize(10) self.tlcTreeView.SetFont(font) # Set up pubsub pub.subscribe(self.OnUpdatePatient, 'patient.updated.raw_data')
def Init(self, rxdose): """Method called after the dialog has been initialized.""" # Set window icon if not guiutil.IsMac(): self.SetIcon(guiutil.get_icon()) # Initialize controls self.txtOriginalRxDose = XRCCTRL(self, 'txtOriginalRxDose') self.txtNewRxDose = XRCCTRL(self, 'txtNewRxDose') # Bind interface events to the proper methods wx.EVT_BUTTON(self, wx.ID_OK, self.OnOK) # Pre-select the text on the text controls due to a Mac OS X bug self.txtOriginalRxDose.SetSelection(-1, -1) self.txtNewRxDose.SetSelection(-1, -1) # Initialize variables self.txtOriginalRxDose.SetValue(str(int(rxdose))) self.txtNewRxDose.SetValue(str(int(rxdose) / 2))
def __init__(self, parent, *args, **kw): """ Pass an initialized wx.xrc.XmlResource into res """ f = os.path.join(os.path.dirname(__file__), self.xrc) res = XmlResourceWithHandlers(f) # Figure out what Frame class (MDI, MiniFrame, etc) is actually our base... bases = set() def findbases(klass, set): for base in klass.__bases__: set.add(base) findbases(base, set) findbases(self.__class__, bases) for base in bases: if base.__name__.endswith("Frame"): break # Two stage creation (see http://wiki.wxpython.org/index.cgi/TwoStageCreation) pre = getattr(wx, "Pre%s" % base.__name__)() res.LoadOnFrame(pre, parent, "FilterManager") self.PreCreate(pre) self.PostCreate(pre) # Define variables for the controls self.Panel = XRCCTRL(self, "Panel") self.AddFiltersLabel = XRCCTRL(self, "AddFiltersLabel") self.RemoveFiltersLabel = XRCCTRL(self, "RemoveFiltersLabel") self.FilterList = XRCCTRL(self, "FilterList") self.CurrentFilters = XRCCTRL(self, "CurrentFilters") self.ShowFiltered = XRCCTRL(self, "ShowFiltered") if hasattr(self, "OnShowFiltered"): self.Bind(wx.EVT_CHECKBOX, self.OnShowFiltered, self.ShowFiltered)
def __init__(self, parent, *args, **kw): """ Pass an initialized wx.xrc.XmlResource into res """ f = os.path.join(os.path.dirname(__file__), self.xrc) res = XmlResourceWithHandlers(f) # Two stage creation (see http://wiki.wxpython.org/index.cgi/TwoStageCreation) pre = wx.PrePanel() res.LoadOnPanel(pre, parent, "orderList") self.PreCreate(pre) self.PostCreate(pre) # Define variables for the controls self.Choices = XRCCTRL(self, "Choices") self.Type = XRCCTRL(self, "Type") if hasattr(self, "OnType"): self.Type.Bind(wx.EVT_CHOICE, self.OnType) self.Number = XRCCTRL(self, "Number") self.Add = XRCCTRL(self, "Add") if hasattr(self, "OnAdd"): self.Bind(wx.EVT_BUTTON, self.OnAdd, self.Add) self.Delete = XRCCTRL(self, "Delete") if hasattr(self, "OnDelete"): self.Bind(wx.EVT_BUTTON, self.OnDelete, self.Delete)
def init(self): self.coords = XRCCTRL(self, 'txt_coords') self.color = XRCCTRL(self, 'txt_color') self.scroll = XRCCTRL(self, 'box_scroll') self.image = XRCCTRL(self, 'bmp_image') self.image.Bind(wx.EVT_LEFT_DOWN, self.on_left_down) self.image.Bind(wx.EVT_RIGHT_DOWN, self.on_right_down) #self.update_image() self.which = XRCCTRL(self, 'txt_which') self.update_which() # button handlers for btn in 'btn_first btn_prev btn_next btn_last'.split(): self.Bind(wx.EVT_BUTTON, self.on_cursor_button, id=XRCID(btn)) # menu handlers self.Bind(wx.EVT_MENU, self.on_exit, id=XRCID('cmd_exit')) self.Bind(wx.EVT_MENU, self.on_open_file, id=XRCID('cmd_open_file')) self.Bind(wx.EVT_MENU, self.on_open_dir, id=XRCID('cmd_open_dir')) self.Bind(wx.EVT_CLOSE, self.on_close_window) # -- manually add pyshell panel = XRCCTRL(self, 'shell_panel') self.locals = { 'self': self, 'wx': wx, 'hook': lambda: None, 'gc': self.get_dc() } self.shell = py.shell.Shell(panel, locals=self.locals) sizer = wx.BoxSizer() sizer.Add(self.shell, 4, wx.EXPAND) self.shell.SetFocus() panel.SetSizer(sizer) sizer.Fit(panel)
class DoseDialog(wx.Dialog): def __init__(self): pre = wx.PreDialog() self.PostCreate(pre) def Init(self, dosecube): self.dosecube = dosecube self.txt_targetdose = XRCCTRL(self, "txt_targetdose") self.txt_targetdose.SetValue("%.1f" % self.dosecube.get_dose()) self.btn_ok = XRCCTRL(self, 'btn_ok') wx.EVT_BUTTON(self, XRCID('btn_ok'), self.save_and_close) self.btn_cancel = XRCCTRL(self, 'btn_close') wx.EVT_BUTTON(self, XRCID('btn_close'), self.close) def save_and_close(self, evt): self.dosecube.set_dose(self.txt_targetdose.GetValue()) self.Close() def close(self, evt): self.Close()