def control(self, ctrlname): return xrc.XRCCTRL(self.frame, ctrlname)
def __init__(self, parent): # Two stage creation (see http://wiki.wxpython.org/index.cgi/TwoStageCreation) pre = wx.PreFrame() self.PreCreate(pre) get_resources().LoadOnFrame(pre, parent, "MainFrame") self.PostCreate(pre) # Define variables for the controls, bind event handlers self.MAIN_TOOLBAR_FILE = xrc.XRCCTRL(self, "MAIN_TOOLBAR_FILE") self.MAIN_TOOL_NEW = self.GetToolBar().FindById( xrc.XRCID("MAIN_TOOL_NEW")) self.MAIN_TOOL_OPEN = self.GetToolBar().FindById( xrc.XRCID("MAIN_TOOL_OPEN")) self.MAIN_TOOL_SAVE = self.GetToolBar().FindById( xrc.XRCID("MAIN_TOOL_SAVE")) self.MAIN_TOOL_SAVEAS = self.GetToolBar().FindById( xrc.XRCID("MAIN_TOOL_SAVEAS")) self.Menubar = self.GetMenuBar() idx = self.GetMenuBar().FindMenu("File") if idx != wx.NOT_FOUND: self.Menu_File = self.GetMenuBar().GetMenu(idx) else: self.Menu_File = self.GetMenuBar().FindItemById( xrc.XRCID("Menu_File")).GetSubMenu() self.MenuItem_New = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_New")) self.MenuItem_Open = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_Open")) self.MenuItem_Close = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_Close")) self.MenuItem_Save = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_Save")) idx = self.GetMenuBar().FindMenu("FEM") if idx != wx.NOT_FOUND: self.Menu_FEM = self.GetMenuBar().GetMenu(idx) else: self.Menu_FEM = self.GetMenuBar().FindItemById( xrc.XRCID("Menu_FEM")).GetSubMenu() self.MenuItem_GridAdd = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_GridAdd")) self.MenuItem_Grid = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_Grid")) self.MenuItem_Conn = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_Conn")) self.MenuItem_Prop = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_Prop")) self.MenuItem_Sec = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_Sec")) self.MenuItem_Set = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_Set")) idx = self.GetMenuBar().FindMenu("Utility") if idx != wx.NOT_FOUND: self.Menu_Utility = self.GetMenuBar().GetMenu(idx) else: self.Menu_Utility = self.GetMenuBar().FindItemById( xrc.XRCID("Menu_Utility")).GetSubMenu() self.MenuItem_Patch = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_Patch")) idx = self.GetMenuBar().FindMenu("Material") if idx != wx.NOT_FOUND: self.MenuItem_Material = self.GetMenuBar().GetMenu(idx) else: self.MenuItem_Material = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_Material")).GetSubMenu() self.MenuItem_Material_Interface = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_Material_Interface")) self.MenuItem_Section = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_Section")) self.MenuItem_Rebar = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_Rebar")) idx = self.GetMenuBar().FindMenu("Import") if idx != wx.NOT_FOUND: self.Menu_Import = self.GetMenuBar().GetMenu(idx) else: self.Menu_Import = self.GetMenuBar().FindItemById( xrc.XRCID("Menu_Import")).GetSubMenu() self.MenuItem_ImpMarcDat = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_ImpMarcDat")) self.MenuItem_ImpPlain = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_ImpPlain")) idx = self.GetMenuBar().FindMenu("Export") if idx != wx.NOT_FOUND: self.Menu_Export = self.GetMenuBar().GetMenu(idx) else: self.Menu_Export = self.GetMenuBar().FindItemById( xrc.XRCID("Menu_Export")).GetSubMenu() self.MenuItem_ExpMarcProc = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_ExpMarcProc")) self.MenuItem_ExpMarcDat = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_ExpMarcDat")) self.MenuItem_ExpOpenSees = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_ExpOpenSees")) idx = self.GetMenuBar().FindMenu("PostProcess") if idx != wx.NOT_FOUND: self.Menu_Post = self.GetMenuBar().GetMenu(idx) else: self.Menu_Post = self.GetMenuBar().FindItemById( xrc.XRCID("Menu_Post")).GetSubMenu() self.MenuItem_PostResults = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_PostResults")) self.MenuItem_PostMarcT16 = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_PostMarcT16")) idx = self.GetMenuBar().FindMenu("Procedure") if idx != wx.NOT_FOUND: self.Menu_Proc = self.GetMenuBar().GetMenu(idx) else: self.Menu_Proc = self.GetMenuBar().FindItemById( xrc.XRCID("Menu_Proc")).GetSubMenu() self.MenuItem_Pole = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_Pole")) idx = self.GetMenuBar().FindMenu("Macro") if idx != wx.NOT_FOUND: self.Menu_Macro = self.GetMenuBar().GetMenu(idx) else: self.Menu_Macro = self.GetMenuBar().FindItemById( xrc.XRCID("Menu_Macro")).GetSubMenu() self.MenuItem_MacroRecord = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_MacroRecord")) self.MenuItem_MacroStop = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_MacroStop")) self.MenuItem_MacroSave = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_MacroSave")) self.MenuItem_MacroLoad = self.GetMenuBar().FindItemById( xrc.XRCID("MenuItem_MacroLoad")) self.MAIN_TOOL_MODELREFRESH = xrc.XRCCTRL(self, "MAIN_TOOL_MODELREFRESH") self.MAIN_TOOL_EXPAND = xrc.XRCCTRL(self, "MAIN_TOOL_EXPAND") self.MAIN_TOOL_COLLAPSE = xrc.XRCCTRL(self, "MAIN_TOOL_COLLAPSE") self.ModelTree = xrc.XRCCTRL(self, "ModelTree") self.ModelNoteBookPanel = xrc.XRCCTRL(self, "ModelNoteBookPanel") self.MAIN_MACRO_RECORD = xrc.XRCCTRL(self, "MAIN_MACRO_RECORD") self.MAIN_MACRO_STOP = xrc.XRCCTRL(self, "MAIN_MACRO_STOP") self.MAIN_MACRO_SAVE = xrc.XRCCTRL(self, "MAIN_MACRO_SAVE") self.MAIN_MACRO_LOAD = xrc.XRCCTRL(self, "MAIN_MACRO_LOAD") self.TextMessage = xrc.XRCCTRL(self, "TextMessage") self.MAIN_STATUSBAR = xrc.XRCCTRL(self, "MAIN_STATUSBAR")
def OnBang(self, event): bang_count = xrc.XRCCTRL(self.frame, "bang_count") bangs = bang_count.GetValue() bangs = int(bangs) + 1 bang_count.SetValue(str(bangs))
def InitControlHandles(self): #self.min_ntargets_input = self.control('min_ntarets') #self.max_ntargets_input = self.control('max_ntargets') self.automatic_shape_input = self.control('automatic_bounds') self.automatic_panel = self.control('automatic_panel') self.nstd_shape_input = self.control('nstd_shape') self.nframes_shape_input = self.control('nframes_shape') self.compute_shape_input = self.control('compute_shape') self.automatic_shape_text = self.control('automatic_shape_text') self.manual_shape_input = self.control('manual_bounds') self.manual_panel = self.control('manual_panel') self.min_area_input = self.control('min_area') self.mean_area_input = self.control('mean_area') self.max_area_input = self.control('max_area') self.min_major_input = self.control('min_major') self.mean_major_input = self.control('mean_major') self.max_major_input = self.control('max_major') self.min_minor_input = self.control('min_minor') self.mean_minor_input = self.control('mean_minor') self.max_minor_input = self.control('max_minor') self.min_ecc_input = self.control('min_ecc') self.mean_ecc_input = self.control('mean_ecc') self.max_ecc_input = self.control('max_ecc') self.angle_weight_input = self.control('angle_weight') self.max_jump_input = self.control('max_jump') # KB 20120109: allow jumps of distance max_jump_split if an observation is the result of # splitting a connected component self.max_jump_split_input = self.control('max_jump_split') self.min_jump_input = self.control('min_jump') self.center_dampen_input = self.control('center_dampen') self.angle_dampen_input = self.control('angle_dampen') self.max_area_delete_input = self.control('max_area_delete') self.min_area_ignore_input = self.control('min_area_ignore') self.max_penalty_merge_input = self.control('max_penalty_merge') self.lower_thresh_input = self.control('lower_thresh') self.maxclustersperblob_input = self.control('maxclustersperblob') self.max_blobs_input = self.control('max_blobs_detect') self.done_input = self.control('done') self.img_panel = self.control('img_panel') self.frame_scrollbar = self.control('frame_scrollbar') self.frame_number_text = self.control('frame_number') self.show_img_input = self.control('show_img') self.toolbar = xrc.XRCCTRL(self.frame, 'toolbar') if self.toolbar is None: self.toolbar = self.frame.GetToolBar() self.zoomin_id = xrc.XRCID('zoomin') self.zoomout_id = xrc.XRCID('zoomout') self.info_id = xrc.XRCID('moreinfo') self.info_text = xrc.XRCCTRL(self.toolbar, "text_obsinfo") ## if 'win' in sys.platform: ## self.toolbar.AddSeparator() ## self.info_text = wx.TextCtrl(self.toolbar, -1, 'Observation Info', pos=(80,0),size=(300,20),style=wx.TE_READONLY|wx.TE_CENTRE) ## self.toolbar.AddControl(self.info_text) ## else: ## self.info_text = wx.TextCtrl(self.toolbar, -1, 'Observation Info', size=(300,20),style=wx.TE_READONLY|wx.TE_CENTRE) self.info_text.SetValue('Observation Info') #self.info_text.SetEditable(False) self.hindsight_panel = self.control('hindsight_panel') self.splitdetection_panel = self.control('splitdetection_panel') self.mergeddetection_panel = self.control('mergeddetection_panel') self.spuriousdetection_panel = self.control('spuriousdetection_panel') self.lostdetection_panel = self.control('lostdetection_panel') self.do_fix_split_input = self.control('do_fix_split') self.do_fix_merged_input = self.control('do_fix_merged') self.do_fix_spurious_input = self.control('do_fix_spurious') self.do_fix_lost_input = self.control('do_fix_lost') self.splitdetection_length_input = self.control( 'splitdetection_length') self.splitdetection_cost_input = self.control( 'splitdetection_distance') self.mergeddetection_length_input = self.control( 'mergeddetection_length') self.mergeddetection_distance_input = self.control( 'mergeddetection_distance') self.spuriousdetection_length_input = self.control( 'spuriousdetection_length') self.lostdetection_length_input = self.control('lostdetection_length') box = wx.BoxSizer(wx.VERTICAL) self.img_panel.SetSizer(box) self.img_wind = wxvideo.DynamicImageCanvas(self.img_panel, -1) self.img_wind.set_resize(True) box.Add(self.img_wind, 1, wx.EXPAND) self.img_panel.SetAutoLayout(True) self.img_panel.Layout()
def InitFrame(self): self.frame = self.res.LoadFrame(None, GUI_MAINFRAME_NAME) self.label_bed = xrc.XRCCTRL(self.frame, "label_bed") #self.label_bed.SetLabel("sdfsdf") self.label_ext1 = xrc.XRCCTRL(self.frame, "label_ext1") self.label_ext2 = xrc.XRCCTRL(self.frame, "label_ext2") self.label_ext3 = xrc.XRCCTRL(self.frame, "label_ext3") self.combo_box_profile = xrc.XRCCTRL(self.frame, "combo_box_profile") self.button_connect = xrc.XRCCTRL(self.frame, "button_connect") #notebook_main self.notebook_main = xrc.XRCCTRL(self.frame, "notebook_main") self.notebook_main_print = xrc.XRCCTRL(self.notebook_main, "notebook_main_print") #print self.label_status = xrc.XRCCTRL(self.notebook_main_print, "label_status") self.label_file = xrc.XRCCTRL(self.notebook_main_print, "label_file") self.label_timelapse = xrc.XRCCTRL(self.notebook_main_print, "label_timelapse") self.label_total_time = xrc.XRCCTRL(self.notebook_main_print, "label_total_time") self.label_print_time = xrc.XRCCTRL(self.notebook_main_print, "label_print_time") self.label_print_left = xrc.XRCCTRL(self.notebook_main_print, "label_print_left") self.button_print = xrc.XRCCTRL(self.notebook_main_print, "button_print") self.button_pause = xrc.XRCCTRL(self.notebook_main_print, "button_pause") #self.button_pause.SetLabel("sdfsdf") self.button_cancel = xrc.XRCCTRL(self.notebook_main_print, "button_cancel") #notebook_files self.notebook_files = xrc.XRCCTRL(self.notebook_main_print, "notebook_files") self.notebook_files_local = xrc.XRCCTRL(self.notebook_files, "notebook_files_local") self.notebook_files_sd = xrc.XRCCTRL(self.notebook_files, "notebook_files_sd") self.list_ctrl_local_file = xrc.XRCCTRL(self.notebook_files_local, "list_ctrl_local_file") self.list_ctrl_sd_file = xrc.XRCCTRL(self.notebook_files_sd, "list_ctrl_local_sd") self.button_refresh_file = xrc.XRCCTRL(self.notebook_main_print, "button_refresh_file") self.button_init_sd = xrc.XRCCTRL(self.notebook_main_print, "button_init_sd") self.button_eject_sd = xrc.XRCCTRL(self.notebook_main_print, "button_eject_sd") print("lkj 3")
+++ Hercules/gui/calculators.py 2011-09-29 12:56:43.000000000 +0400 @@ -4,12 +4,12 @@ import wx import wx.xrc as xrc - +from Hercules.globals import sharedir class IdealBody: """Ideal Body Measurements Calculator""" def __init__(self, parent): - self.resource = xrc.XmlResource('xrc/calculators.xrc') + self.resource = xrc.XmlResource(sharedir + 'xrc/calculators.xrc') self.dlg = self.resource.LoadDialog(parent, 'Calc01Dialog') self.wristBox = xrc.XRCCTRL(self.dlg, 'wristBox') @@ -96,7 +96,7 @@ class BMICalc: """Body Mass Index calculator for average people only""" def __init__(self, parent): - self.resource = xrc.XmlResource('xrc/calculators.xrc') + self.resource = xrc.XmlResource(sharedir + 'xrc/calculators.xrc') self.dlg = self.resource.LoadDialog(parent, 'CalcBMIDialog') self.maleRadio = xrc.XRCCTRL(self.dlg, 'maleRadio') @@ -236,7 +236,7 @@ class Cal2KJ: """Calorie KiloJoule Conversion""" def __init__(self, parent): - self.resource = xrc.XmlResource('xrc/calculators.xrc') + self.resource = xrc.XmlResource(sharedir + 'xrc/calculators.xrc')
def _PostInit(self): self.guiUtility = GUIUtility.getInstance() self.utility = self.guiUtility.utility self.defaultDLConfig = DefaultDownloadStartupConfig.getInstance() dialog = xrc.XRCCTRL(self, "settingsDialog") for element in self.elementsName: xrcElement = xrc.XRCCTRL(dialog, element) if not xrcElement: print 'settingsOverviewPanel: Error: Could not identify xrc element:',element self.elements[element] = xrcElement #Building tree self.tree = xrc.XRCCTRL(self,"settings_tree") root = self.tree.AddRoot('Root') self.tree.SelectItem(self.tree.AppendItem(root,'General',data=wx.TreeItemData(xrc.XRCCTRL(self,"general_panel"))),True) self.tree.AppendItem(root,'Connection',data=wx.TreeItemData(xrc.XRCCTRL(self,"connection_panel"))) self.tree.AppendItem(root,'Limits',data=wx.TreeItemData(xrc.XRCCTRL(self,"bandwidth_panel"))) self.tree.AppendItem(root,'Seeding',data=wx.TreeItemData(xrc.XRCCTRL(self,"seeding_panel"))) self.tree.AppendItem(root,'Misc',data=wx.TreeItemData(xrc.XRCCTRL(self,"misc_panel"))) self.tree.AppendItem(root,'Experimental',data=wx.TreeItemData(xrc.XRCCTRL(self,"exp_panel"))) self.tree.Bind(wx.EVT_TREE_SEL_CHANGING, self.OnSelectionChanging) #Bind event listeners self.elements['zeroUp'].Bind(wx.EVT_BUTTON, lambda event: self.setUp(0, event)) self.elements['fiftyUp'].Bind(wx.EVT_BUTTON, lambda event: self.setUp(50, event)) self.elements['hundredUp'].Bind(wx.EVT_BUTTON, lambda event: self.setUp(100, event)) self.elements['unlimitedUp'].Bind(wx.EVT_BUTTON, lambda event: self.setUp('unlimited', event)) self.elements['seventyfiveDown'].Bind(wx.EVT_BUTTON, lambda event: self.setDown(75, event)) self.elements['threehundredDown'].Bind(wx.EVT_BUTTON, lambda event: self.setDown(300, event)) self.elements['sixhundreddDown'].Bind(wx.EVT_BUTTON, lambda event: self.setDown(600, event)) self.elements['unlimitedDown'].Bind(wx.EVT_BUTTON, lambda event: self.setDown('unlimited', event)) self.elements['uploadCtrl'].Bind(wx.EVT_KEY_DOWN, self.removeUnlimited) self.elements['downloadCtrl'].Bind(wx.EVT_KEY_DOWN, self.removeUnlimited) self.elements['edit'].Bind(wx.EVT_BUTTON, self.EditClicked) self.elements['browse'].Bind(wx.EVT_BUTTON, self.BrowseClicked) self.elements['batchstart'].Bind(wx.EVT_BUTTON, self.OnMultiple) self.elements['batchstop'].Bind(wx.EVT_BUTTON, self.OnMultiple) self.elements['batchmove'].Bind(wx.EVT_BUTTON, self.OnMultipleMove) self.Bind(wx.EVT_BUTTON, self.saveAll, id = xrc.XRCID("wxID_OK")) self.Bind(wx.EVT_BUTTON, self.cancelAll, id = xrc.XRCID("wxID_CANCEL")) #Loading settings self.myname = self.utility.session.get_nickname() mime, data = self.utility.session.get_mugshot() if data is None: im = IconsManager.getInstance() self.mugshot = im.get_default('PEER_THUMB') else: self.mugshot = data2wxBitmap(mime, data) self.elements['myNameField'].SetValue(self.myname) self.elements['thumb'].setBitmap(self.mugshot) if self.guiUtility.frame.SRstatusbar.IsReachable(): self.elements['firewallStatus'].setSelected(2) self.elements['firewallStatusText'].SetLabel('Port is working') if self.utility.config.Read('family_filter', "boolean"): self.elements['familyFilter'].SetSelection(0) else: self.elements['familyFilter'].SetSelection(1) self.currentPopup = self.utility.config.Read('popup_player', "boolean") if self.currentPopup: self.elements['externalplayer'].SetSelection(1) else: self.elements['externalplayer'].SetSelection(0) self.currentPortValue = str(self.guiUtility.get_port_number()) self.elements['firewallValue'].SetValue(self.currentPortValue) maxdownloadrate = self.utility.config.Read('maxdownloadrate', 'int') if maxdownloadrate == 0: self.elements['downloadCtrl'].SetValue('unlimited') else: self.elements['downloadCtrl'].SetValue(str(maxdownloadrate)) maxuploadrate = self.utility.config.Read('maxuploadrate', 'int') if maxuploadrate == -1: self.elements['uploadCtrl'].SetValue('0') elif maxuploadrate == 0: self.elements['uploadCtrl'].SetValue('unlimited') else: self.elements['uploadCtrl'].SetValue(str(maxuploadrate)) self.currentDestDir = self.defaultDLConfig.get_dest_dir() self.elements['diskLocationCtrl'].SetValue(self.currentDestDir) self.elements['diskLocationChoice'].SetValue(self.defaultDLConfig.get_show_saveas()) self.elements['use_bundle_magic'].SetValue(self.utility.config.Read('use_bundle_magic', "boolean")) if sys.platform != "darwin": min_to_tray = self.utility.config.Read('mintray', "int") == 1 self.elements['minimize_to_tray'].SetValue(min_to_tray) else: self.elements['minimize_to_tray'].Enabled(False) print >> sys.stderr, self.utility.lang.get('no_leeching') self.elements['t4t0'].SetLabel(self.utility.lang.get('no_leeching')) self.elements['t4t0'].Refresh() self.elements['t4t1'].SetLabel(self.utility.lang.get('unlimited_seeding')) self.elements['t4t2'].SetLabel(self.utility.lang.get('seed_sometime')) self.elements['t4t3'].SetLabel(self.utility.lang.get('no_seeding')) self.elements['g2g0'].SetLabel(self.utility.lang.get('seed_for_large_ratio')) self.elements['g2g1'].SetLabel(self.utility.lang.get('boost__reputation')) self.elements['g2g2'].SetLabel(self.utility.lang.get('seed_sometime')) self.elements['g2g3'].SetLabel(self.utility.lang.get('no_seeding')) t4t_option = self.utility.config.Read('t4t_option', 'int') self.elements['t4t%d'%t4t_option].SetValue(True) t4t_ratio = self.utility.config.Read('t4t_ratio', 'int')/100.0 index = self.elements['t4t0choice'].FindString(str(t4t_ratio)) if index != wx.NOT_FOUND: self.elements['t4t0choice'].Select(index) t4t_hours = self.utility.config.Read('t4t_hours', 'int') t4t_minutes = self.utility.config.Read('t4t_mins', 'int') self.elements['t4t2text'].SetLabel("%d:%d"%(t4t_hours, t4t_minutes)) g2g_option = self.utility.config.Read('g2g_option', 'int') self.elements['g2g%d'%g2g_option].SetValue(True) g2g_ratio = self.utility.config.Read('g2g_ratio', 'int')/100.0 index = self.elements['g2g0choice'].FindString(str(g2g_ratio)) if index != wx.NOT_FOUND: self.elements['g2g0choice'].Select(index) g2g_hours = self.utility.config.Read('g2g_hours', 'int') g2g_mins = self.utility.config.Read('g2g_mins', 'int') self.elements['g2g2text'].SetLabel("%d:%d"%(g2g_hours, g2g_mins)) self.elements['use_webui'].SetValue(self.utility.config.Read('use_webui', "boolean")) self.elements['webui_port'].SetValue(str(self.utility.config.Read('webui_port', "int"))) wx.CallAfter(self.Refresh)
def load(self, res, parent): self._panel = res.LoadPanel(parent, 'LastFramesModule') self._list = xrc.XRCCTRL(self._panel, 'last_frames') # type: ListBox
def loadPanel(self): currentPanel = self.data[self.mode].get('panel', None) modeString = self.mode[:-4] if DEBUG: print >> sys.stderr, 'standardOverview: loadPanel: modeString=' + modeString, 'currentPanel:', currentPanel # create the panel for the first click. panel could be one of the [file,person,friend,library,profile,rss] if not currentPanel: xrcResource = os.path.join(self.guiUtility.vwxGUI_path, modeString + 'Overview.xrc') panelName = modeString + 'Overview' try: currentPanel = grid = pager = None res = xrc.XmlResource(xrcResource) # create panel currentPanel = res.LoadPanel(self, panelName) grid = xrc.XRCCTRL(currentPanel, modeString + 'Grid') pager = xrc.XRCCTRL( currentPanel, 'standardPager' ) # Jie:not really used for profile, rss and library? search = xrc.XRCCTRL(currentPanel, 'searchField') filter = xrc.XRCCTRL(currentPanel, modeString + 'Filter') if not currentPanel: raise Exception( 'standardOverview: Could not find panel, grid or pager' ) #load dummy panel dummyFile = os.path.join(self.guiUtility.vwxGUI_path, 'dummyOverview.xrc') dummy_res = xrc.XmlResource(dummyFile) currentPanel = dummy_res.LoadPanel(self, 'dummyOverview') grid = xrc.XRCCTRL(currentPanel, 'dummyGrid') pager = xrc.XRCCTRL(currentPanel, 'standardPager') if not currentPanel: # or not grid or not pager: raise Exception( 'standardOverview: Could not find panel, grid or pager' ) # Save paneldata in self.data self.data[self.mode]['panel'] = currentPanel self.data[self.mode]['grid'] = grid self.data[self.mode]['pager'] = pager self.data[self.mode]['search'] = search self.data[self.mode]['filter'] = filter #search.Bind(wx.EVT_COMMAND_TEXT_ENTER, self.OnSearchKeyDown) if search is not None: search.Bind(wx.EVT_KEY_DOWN, self.guiUtility.OnSearchKeyDown) if modeString == "files": web2on = self.utility.config.Read( 'enableweb2search', "boolean") if web2on: txt = self.utility.lang.get( 'filesdefaultsearchweb2txt') else: txt = self.utility.lang.get( 'filesdefaultsearchtxt') search.SetValue(txt) search.Bind(wx.EVT_MOUSE_EVENTS, self.guiUtility.OnSearchMouseAction) pager.setGrid(grid) if self.mode in ['filesMode', 'personsMode']: viewModeSelect = xrc.XRCCTRL(currentPanel, 'modeItems') overviewSizeSelect = xrc.XRCCTRL(currentPanel, 'numberItems') # set default values viewModeSelect.Select(0) #SetValue('thumbnails') overviewSizeSelect.Select(0) #SetValue('auto') #viewModeSelect.Bind(wx.EVT_COMBOBOX, grid.onViewModeChange) viewModeSelect.Bind(wx.EVT_CHOICE, grid.onViewModeChange) #overviewSizeSelect.Bind(wx.EVT_COMBOBOX, grid.onSizeChange) overviewSizeSelect.Bind(wx.EVT_CHOICE, grid.onSizeChange) if self.mode == 'subscriptionsMode': rssurlctrl = xrc.XRCCTRL(currentPanel, 'pasteUrl') rssurlctrl.Bind(wx.EVT_KEY_DOWN, self.guiUtility.OnSubscribeKeyDown) rssurlctrl.Bind(wx.EVT_LEFT_UP, self.guiUtility.OnSubscribeMouseAction) txt = self.utility.lang.get('rssurldefaulttxt') rssurlctrl.SetValue(txt) self.data[self.mode]['rssurlctrl'] = rssurlctrl except: if DEBUG: print >> sys.stderr, 'standardOverview: Error: Could not load panel, grid and pager for mode %s' % self.mode print >> sys.stderr, 'standardOverview: Tried panel: %s=%s, grid: %s=%s, pager: %s=%s' % ( panelName, currentPanel, modeString + 'Grid', grid, 'standardPager', pager) print_exc() return currentPanel
def __init__(self, parent, manager, test, serial): wx.Panel.__init__(self, parent) self._manager = manager self._mutex = threading.Lock() self._status_sub = None self._diags = [] # Set up test and loggers self._test = test self._serial = serial self._record = TestRecord(test, serial) # Set up panel xrc_path = os.path.join(roslib.packages.get_pkg_dir('life_test'), 'xrc/gui.xrc') self._panel = xrc.XmlResource(xrc_path).LoadPanel(self, 'test_panel') self._test_desc = xrc.XRCCTRL(self._panel, 'test_desc') self._test_desc.SetValue(self._test._desc) self._launch_button = xrc.XRCCTRL(self._panel, 'launch_test_button') self._launch_button.Bind(wx.EVT_BUTTON, self.start_stop_test) self._test_bay_ctrl = xrc.XRCCTRL(self._panel, 'test_machine_ctrl') self._test_bay_ctrl.SetItems(self._manager.room.get_bay_names(test.needs_power())) self._end_cond_type = xrc.XRCCTRL(self._panel, 'end_cond_type') self._end_cond_type.SetStringSelection('Continuous') self._end_cond_type.Bind(wx.EVT_CHOICE, self.on_end_choice) self._end_cond_type_label = xrc.XRCCTRL(self._panel, 'duration_label') self._test_duration_ctrl = xrc.XRCCTRL(self._panel, 'test_duration_ctrl') self._close_button = xrc.XRCCTRL(self._panel, 'close_button') self._close_button.Bind(wx.EVT_BUTTON, self.on_close) self._status_bar = xrc.XRCCTRL(self._panel, 'test_status_bar') self._reset_button = xrc.XRCCTRL(self._panel, 'reset_motors_button') self._reset_button.Bind(wx.EVT_BUTTON, self.on_reset_motors) self._halt_button = xrc.XRCCTRL(self._panel, 'halt_motors_button') self._halt_button.Bind(wx.EVT_BUTTON, self.on_halt_motors) self._user_log = xrc.XRCCTRL(self._panel, 'user_log_input') self._user_submit = xrc.XRCCTRL(self._panel, 'user_submit_button') self._user_submit.Bind(wx.EVT_BUTTON, self.on_user_entry) self._done_time_ctrl = xrc.XRCCTRL(self._panel, 'done_time_ctrl') self._elapsed_time_ctrl = xrc.XRCCTRL(self._panel, 'elapsed_time_ctrl') self._active_time_ctrl = xrc.XRCCTRL(self._panel, 'active_time_ctrl') self._log_ctrl = xrc.XRCCTRL(self._panel, 'test_log') self._test_log_window = xrc.XRCCTRL(self._panel, 'test_log_window') self._send_log_button = xrc.XRCCTRL(self._panel, 'send_test_log_button') self._send_log_button.Bind(wx.EVT_BUTTON, self.on_send_test_log) # Power control self._power_board_text = xrc.XRCCTRL(self._panel, 'power_board_text') self._power_board_text.SetBackgroundColour("White") self._power_board_text.SetValue("Test Not Running") self._power_run_button = xrc.XRCCTRL(self._panel, 'power_run_button') self._power_run_button.Bind(wx.EVT_BUTTON, self.on_power_run) self._power_standby_button = xrc.XRCCTRL(self._panel, 'power_standby_button') self._power_standby_button.Bind(wx.EVT_BUTTON, self.on_power_standby) self._power_reset_button = xrc.XRCCTRL(self._panel, 'power_reset_button') self._power_reset_button.Bind(wx.EVT_BUTTON, self.on_power_reset) self._power_disable_button = xrc.XRCCTRL(self._panel, 'power_disable_button') self._power_disable_button.Bind(wx.EVT_BUTTON, self.on_power_disable) # Bay data self._power_sn_text = xrc.XRCCTRL(self._panel, 'power_sn_text') self._power_breaker_text = xrc.XRCCTRL(self._panel, 'power_breaker_text') self._machine_text = xrc.XRCCTRL(self._panel, 'machine_text') # Add runtime to the panel... self._notebook = xrc.XRCCTRL(self._panel, 'test_data_notebook') wx.CallAfter(self.create_monitor) self._sizer = wx.BoxSizer(wx.HORIZONTAL) self._sizer.Add(self._panel, 1, wx.EXPAND) self.SetSizer(self._sizer) self.Layout() self._bay = None self._current_log = {} self._diag_msgs = {} self._is_running = False # Launches test, call stop to kill it self._test_launcher = None # Test log data self._test_complete = False # Timeout for etherCAT diagnostics # Don't start it here, wait until test is launched self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.on_timer, self.timer) self.last_message_time = rospy.get_time() self.timeout_interval = 5.0 self._is_stale = True # Timer for invent logging self.invent_timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.on_invent_timer, self.invent_timer) self._last_invent_time = rospy.get_time() self.invent_timeout = 600 self.invent_timer.Start(self.invent_timeout * 500) self._is_invent_stale = True self._invent_note_id = None self.update_controls() self.on_end_choice()
def OnInit(self): """ Initializes and shows frame from csv2ofx.xrc """ # load the xml resource script_dir = os.path.dirname(__file__) self.res = xrc.XmlResource("%s/csv2ofx.xrc" % script_dir) # load the frame from the resource self.frame = self.res.LoadFrame(None, "ID_CSV2OFX") # associate the MenuBar self.frame.SetMenuBar(self.res.LoadMenuBar("ID_MENUBAR")) # the grid self.grid = xrc.XRCCTRL(self.frame, "ID_GRID") self.grid.EnableEditing(False) # the mappings self.mappings = xrc.XRCCTRL(self.frame, "ID_MAPPINGS") try: try: # try current directory first if os.path.isfile('csv2ofx_custom.py'): execfile('csv2ofx_custom.py', globals()) for mapping in all_mappings: self.mappings.Append(mapping, all_mappings[mapping]) else: raise # try the home directory except: homepath = os.path.expanduser('~') cust_mappings = "%s/csv2ofx_custom.py" % homepath if os.path.isfile(cust_mappings): execfile(cust_mappings, globals()) for mapping in all_mappings: self.mappings.Append(mapping, all_mappings[mapping]) except: print_exc() # Use built in mappings as default/backup if self.mappings.IsEmpty(): print "Using Default Mappings" import mappings for mapping in mappings.all_mappings: self.mappings.Append(mapping, mappings.all_mappings[mapping]) self.mappings.SetSelection(0) # output formats self.exports = xrc.XRCCTRL(self.frame, "ID_EXPORT") # handle events self.Bind(wx.EVT_MENU, self.OnCloseBtn, id=xrc.XRCID("ID_MENU_CLOSE")) self.Bind(wx.EVT_BUTTON, self.OnCloseBtn, id=xrc.XRCID("ID_BTN_CLOSE")) self.Bind(wx.EVT_MENU, self.OnImport, id=xrc.XRCID("ID_MENU_IMPORT")) self.Bind(wx.EVT_BUTTON, self.OnImport, id=xrc.XRCID("ID_BTN_IMPORT")) self.Bind(wx.EVT_MENU, self.OnExport, id=xrc.XRCID("ID_MENU_EXPORT")) self.Bind(wx.EVT_BUTTON, self.OnExport, id=xrc.XRCID("ID_BTN_EXPORT")) self.frame.Bind(wx.EVT_CLOSE, self.OnClose) self.frame.Bind(wx.EVT_MOVE, self.OnMove) self.frame.Bind(wx.EVT_SIZE, self.OnSize) # app preferences self.config = wx.Config("csv2ofx") x = self.config.ReadInt("screenx", 100) y = self.config.ReadInt("screeny", 100) w = self.config.ReadInt("screenw", 600) h = self.config.ReadInt("screenh", 550) # show the frame self.SetTopWindow(self.frame) self.frame.SetPosition((x, y)) self.frame.SetSize((w, h)) self.frame.Show() return True