def makeOtherFrame(self, helpctrl): """ See long comment above, with the CallAfter line. This is code from Robin Dunn. """ # Get the control's Frame parent = helpctrl.GetFrame() # Create another frame with the HelpCtrl as the parent. This provides a Top Level # Window that is never shown but still prevents the program from exiting when the # Search Dialog is closed. Because it has the HelpCtrl as a parent, it will close # automatically. otherFrame = wx.Frame(parent) # Now that we have access to the Frame (because this is in a CallAfter situation), # we can change the size of the Help Window. Yea! if parent != None: # Load the Config Data. wxConfig automatically uses the Registry on Windows and the appropriate file on Mac. # Program Name is Transana, Vendor Name is Verception to remain compatible with Transana 1.0. config = wx.Config('Transana', 'Verception') # Load the Primary Screen setting primaryScreen = config.ReadInt('/2.0/PrimaryScreen', 0) # Get the size of the screen rect = wx.Display(primaryScreen).GetClientArea() # wx.ClientDisplayRect() # Set the top to 10% of the screen height (rect[1] is for secondary monitors) top = int(0.1 * rect[3]) + rect[1] # Set the height so that the top and bottom will have equal boundaries height = rect[3] - (2 * top) # Set the window width to 80% of the screen or 1000 pixels, whichever is smaller width = min(int(rect[2] * 0.8), 1000) # Set the left margin so that the window is centered (rect[0] is for secondary monitors) left = int(rect[2] / 2) - int(width / 2) + rect[0] # Position the window based on the calculated position parent.SetPosition(wx.Point(left, top)) # Size the window based on the calculated size parent.SetSize(wx.Size(width, height))
def __init__(self, parent, id, title): # nb.AddPage(self.sheet1, "Sheet1") # nb.AddPage(self.sheet2, "Sheet2") # nb.AddPage(self.sheet3, "Sheet3") # nb = wx.Notebook(self, -1, style=wx.NB_TOP) self.cfg = wx.Config('myconfig') if self.cfg.Exists('width'): w, h = self.cfg.ReadInt('width'), self.cfg.ReadInt('height') else: (w, h) = (250, 250) wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(w, h)) wx.StaticText(self, -1, 'Width:', (20, 20)) wx.StaticText(self, -1, 'Height:', (20, 70)) self.sc1 = wx.SpinCtrl(self, -1, str(w), (80, 15), (60, -1), min=200, max=500) self.sc2 = wx.SpinCtrl(self, -1, str(h), (80, 65), (60, -1), min=200, max=500) wx.Button(self, 1, 'Save', (20, 120)) self.Bind(wx.EVT_BUTTON, self.OnSave, id=1) self.statusbar = self.CreateStatusBar() self.Centre()
def __init__(self,parent,title): wx.Frame.__init__(self,parent,title=title,size=(600,-1)) self.lang_config = wx.Config() self.__lang_init() self.img_cont = None self.img_style = None self.model = None self.model_path = r'../models/squeezenet1_0-a815701f.pth' self.img_out = None self.num_steps = 300 self.style_weight = 1000 self.content_weight = 1 self.timer = wx.Timer(self) filemenu = wx.Menu() self.menuExit = filemenu.Append(wx.ID_EXIT, item = _("E&xit \tCtrl+Q"), helpString = _("exit program")) setmenu = wx.Menu() self.menuhyper = setmenu.Append(wx.ID_ANY, item = _("hyper parameter"), helpString = _("set hyper-parameter")) self.menulang = setmenu.Append(wx.ID_ANY, item = _("Language"), helpString = _("set GUI language")) helpmenu = wx.Menu() self.menuhelpdoc = helpmenu.Append(wx.ID_HELP, item = _("Help \tF1"), helpString = _("Help")) menuBar = wx.MenuBar() menuBar.Append(filemenu, title = _("&File")) menuBar.Append(setmenu, title = _("&Preferences")) menuBar.Append(helpmenu, title = _("&Help")) self.SetMenuBar(menuBar) self.__DoLayout() self.__Binds()
def test_Config4(self): null = wx.LogNull() name = cfgFilename + '_4' cfg0 = wx.Config('unittest_ConfigTests', localFilename=name) wx.Config.Set(cfg0) cfg = wx.Config.Get(False) #self.assertTrue(cfg is cfg0) self.writeStuff(cfg) del cfg cfg = wx.Config.Get() cfg.SetPath('/one/two/three') self.assertTrue(cfg.GetPath() == '/one/two/three') self.assertTrue(cfg.GetNumberOfEntries() == 4) self.assertTrue(cfg.Read('key') == 'value') self.assertTrue(cfg.ReadInt('int') == 123) self.assertTrue(cfg.ReadFloat('float') == 123.456) self.assertTrue(cfg.ReadBool('bool') == True) self.assertTrue(cfg.Read('no-value', 'defvalue') == 'defvalue') wx.Config.Set(None) self.myYield() if os.path.exists(name): os.remove(name)
def __init__(self, parent, player_number): """ Constructor :param parent: The parent ui element :param player_number: The number of the player to select e.G. [0, 1] """ super(SelectPlayerPanel, self).__init__(parent) self.SetBackgroundColour(COLORS.SETTINGS_DETAILS_BG) self.SetSize(parent.Size) self.player_number = player_number self.config = wx.Config("NimGame") self.cur_ptype_selection = self.config.ReadInt( "player" + str(player_number), 0) # The events self.evt_back = Event() # Get the playertype data for the list box self.player_texts = [player.name for player in ALL_PLAYERS] self.info_text = [player.description for player in ALL_PLAYERS] # Init the ui elements self.build_ui(parent)
def _OnClose(self, event): position = self.GetPosition() size = self.GetSize() cfg = wx.Config() cfg.Write('pos', repr(position.Get())) cfg.Write('size', repr(size.Get())) event.Skip()
def get_config(): global __is_headless,__headless_config if __is_headless: return __headless_config import wx try: config = wx.Config.Get(False) except wx.PyNoAppError: app = wx.App(0) config = wx.Config.Get(False) if not config: wx.Config.Set(wx.Config('CellProfiler','BroadInstitute','CellProfilerLocal.cfg','CellProfilerGlobal.cfg',wx.CONFIG_USE_LOCAL_FILE)) config = wx.Config.Get() if not config.Exists(PREFERENCES_VERSION): for key in ALL_KEYS: if config.Exists(key) and config.GetEntryType(key) == 1: v = config.Read(key) config_write(key, v) config_write(PREFERENCES_VERSION, str(PREFERENCES_VERSION_NUMBER)) else: try: preferences_version_number = int(config_read(PREFERENCES_VERSION)) if preferences_version_number != PREFERENCES_VERSION_NUMBER: logger.warning( "Preferences version mismatch: expected %d, at %d" % ( PREFERENCES_VERSION_NUMBER, preferences_version_number)) except: logger.warning( "Preferences version was %s, not a number. Resetting to current version" % preferences_version_number) config_write(PREFERENCES_VERSION, str(PREFERENCES_VERSION)) return config
def loadConfig(self): self.loc = libitl.Location() self.loc.setLatitude(libitl.dms2Decimal(35, 50, 0, 'N')) self.loc.setLongitude(libitl.dms2Decimal(10, 38, 0, 'N')) self.loc.setGmt(1.0) self.loc.setDST(0.0) self.loc.setSeaLevel(0) self.loc.setPressure(1010) self.loc.setTemperature(10) self.loc.setCountryName(u'Tunisie') self.loc.setTownName(u'Sousse') location = self.toHex(pickle.dumps(self.loc)) self.conf = libitl.Method(libitl.EGYPT_SURVEY) self.conf.setRoundMethod(0) config = self.toHex(pickle.dumps(self.conf)) cfg = wx.Config(self.GetAppName()) if cfg.HasEntry('loc') and cfg.HasEntry('conf'): location = cfg.Read('loc') config = cfg.Read('conf') else: self.saveConfig(location, config) self.loc = pickle.loads(self.fromHex(location)) self.conf = pickle.loads(self.fromHex(config))
def __init__(self, parent, pos, size, model): """View object of the epoch selection GUI Parameters ---------- parent : wx.Frame Parent window. others : See TerminalInterface constructor. """ config = wx.Config("Eelbrain Testing" if TEST_MODE else "Eelbrain") config.SetPath(self._name) if pos is None: pos = (config.ReadInt("pos_horizontal", -1), config.ReadInt("pos_vertical", -1)) if size is None: size = (config.ReadInt("size_width", 800), config.ReadInt("size_height", 600)) super(FileFrame, self).__init__(parent, -1, self._title, pos, size) self.config = config self.model = model self.doc = model.doc self.history = model.history # Bind Events --- self.doc.callbacks.subscribe('path_change', self.UpdateTitle) self.history.callbacks.subscribe('saved_change', self.UpdateTitle) self.Bind(wx.EVT_CLOSE, self.OnClose)
def __init__(self, parent, id, title): self.taskwin = None # set later wx.Frame.__init__(self, parent, id, title, style=wx.RESIZE_BORDER | wx.SYSTEM_MENU | wx.CAPTION) sys.excepthook = self.excepthook self.authinfo = {} # updated by config panel self.icacache = {} # used by IsConnectionAllowed # Establish config stuff cfgstr = 'bitfling' if guihelper.IsMSWindows(): cfgstr = "BitFling" # nicely capitalized on Windows self.config = wx.Config(cfgstr, style=wx.CONFIG_USE_LOCAL_FILE) # self.config.SetRecordDefaults(True) # for help to save prefs wx.GetApp().SetAppName(cfgstr) wx.GetApp().SetVendorName(cfgstr) self.setuphelp() wx.EVT_CLOSE(self, self.CloseRequested) panel = wx.Panel(self, -1) bs = wx.BoxSizer(wx.VERTICAL) self.nb = wx.Notebook(panel, -1) bs.Add(self.nb, 1, wx.EXPAND | wx.ALL, 5) bs.Add(wx.StaticLine(panel, -1), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) gs = wx.GridSizer(1, 4, 5, 5) for name in ("Rescan", "Hide", "Help", "Exit"): but = wx.Button(panel, wx.NewId(), name) setattr(self, name.lower(), but) gs.Add(but) bs.Add(gs, 0, wx.ALIGN_CENTRE | wx.ALL, 5) panel.SetSizer(bs) panel.SetAutoLayout(True) # the notebook pages self.configpanel = ConfigPanel(self, self.nb) self.nb.AddPage(self.configpanel, "Configuration") self.lw = guihelper.LogWindow(self.nb) self.nb.AddPage(self.lw, "Log") wx.EVT_BUTTON(self, self.hide.GetId(), self.OnHideButton) wx.EVT_BUTTON(self, self.help.GetId(), self.OnHelpButton) wx.EVT_BUTTON(self, self.exit.GetId(), self.OnExitButton) EVT_XMLSERVER(self, self.OnXmlServerEvent) self.xmlrpcserver = None wx.CallAfter(self.StartIfICan)
def require_addon_version(name, version=[], canBeNewer=True): # Check the install receipt to see if we've got an appropriate version config = wx.Config("wxaddons-receipts") needs_update = True if config.HasGroup(name): config.SetPath(name) current_version = config.Read("version", "0.0").split(".") needs_update = version_greater_than_or_equal(version, current_version) if needs_update: comp_xml = s.getComponent(name) if not comp_xml: raise comp = xmlrpclib.loads(comp_xml)[0][0] comp_version = comp["version"].split(".") update_comp = False if canBeNewer: update_comp = version_greater_than_or_equal(comp_version, version) else: update_comp = (version == comp_version) if update_comp: url = get_url(name, version) should_install = prompt_install(name, comp_version) if should_install: dl_and_install_addon(name, comp_version, url)
def OnExit(self): print "here i am exiting and saving settings" # write out window config options self.cfg = wx.Config('hubcade_gui_config') self.cfg.WriteInt("width", self.mainFrame.Size[0]) self.cfg.WriteInt("height", self.mainFrame.Size[1]) self.cfg.WriteInt("left_splitter_location", self.mainFrame.sash_left.GetSashPosition()) self.cfg.WriteInt("right_splitter_location", self.mainFrame.sash_right.GetSashPosition()) self.cfg.WriteInt("center_splitter_location", self.mainFrame.sash_middle.GetSashPosition()) self.cfg.WriteInt("mainframe_position_x", self.mainFrame.GetPositionTuple()[0]) self.cfg.WriteInt("mainframe_position_y", self.mainFrame.GetPositionTuple()[1]) self.cfg.WriteInt("mainframe_width", self.mainFrame.Size[0]) self.cfg.WriteInt("mainframe_height", self.mainFrame.Size[1]) self.cfg.Flush() self.quit = True self.timer.Stop() self.mainFrame.clock_timer.Stop() self.mainFrame.ping_timer.Stop() if Client_GlobalData.os_video_playback == True: self.mainFrame.timer_slider.Stop() # close the sqlite3 db's #CloseDatabase() - This is done in client_main.py and exit of program return 0
def __init__(self): self.my_dialog_acceso_vcenter = dialogos.Dialogo_acceso_vcenter( None, -1, 'Datos de conexión') # precarga de fichero config self.cfg = wx.Config('appconfig') if self.cfg.Exists('vcenter'): self.my_dialog_acceso_vcenter.nombre_vcenter.SetValue( self.cfg.Read('vcenter')) self.my_dialog_acceso_vcenter.login_vcenter.SetValue( self.cfg.Read('login')) self.my_dialog_acceso_vcenter.passwor_vcenter.SetValue( self.cfg.Read('pwd')) self.my_dialog_acceso_vcenter.puert_vcenter.SetValue( self.cfg.Read('port')) else: self.my_dialog_acceso_vcenter.nombre_vcenter.SetValue( self.cfg.Read('vcenter.host.com')) self.my_dialog_acceso_vcenter.login_vcenter.SetValue( self.cfg.Read('*****@*****.**')) self.my_dialog_acceso_vcenter.passwor_vcenter.SetValue( self.cfg.Read('estanoes')) self.my_dialog_acceso_vcenter.puert_vcenter.SetValue( self.cfg.Read('443')) self.si = None
def __init__(self): self.w = WIDTH self.h = WIDTH + BARH self.cfg = wx.Config('svinfo_conf') if self.cfg.Exists('width'): self.w = int(self.cfg.Read('width')) self.h = int(self.cfg.Read('height')) wx.Frame.__init__(self, id=-1, parent=None, name=u'SVInfoFrame', size=wx.Size(self.w, self.h), title=u'SV Info') if self.cfg.Exists('left'): self.x = int(self.cfg.Read('left')) self.y = int(self.cfg.Read('top')) self.SetPosition(wx.Point(self.x, self.y), wx.SIZE_USE_EXISTING) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_SIZE, self.OnSize) self.Bind(wx.EVT_MOVE, self.OnMove) self.Bind(wx.EVT_CLOSE, self.OnClose) ico = wx.Icon(PPRZ_SRC + "/sw/ground_segment/python/svinfo/svinfo.ico", wx.BITMAP_TYPE_ICO) self.SetIcon(ico) self.sv = {} self.interface = IvyMessagesInterface("svinfoframe") self.interface.subscribe(self.message_recv)
def __init__(self, parent, id, title): self.cfg = wx.Config('myconfig') if self.cfg.Exists('width'): w, h = self.cfg.ReadInt('width'), self.cfg.ReadInt('height') else: (w, h) = (250, 250) wx.Frame.__init__(self, parent, id, title, size=(w, h)) wx.StaticText(self, -1, 'Width:', (20, 20)) wx.StaticText(self, -1, 'Height:', (20, 70)) self.sc1 = wx.SpinCtrl(self, -1, str(w), (80, 15), (60, -1), min=200, max=500) self.sc2 = wx.SpinCtrl(self, -1, str(h), (80, 65), (60, -1), min=200, max=500) wx.Button(self, 1, 'Save', (20, 120)) self.Bind(wx.EVT_BUTTON, self.OnSave, id=1) self.statusbar = self.CreateStatusBar() self.Centre() self.Show(True)
def main(): print("FlexDoppler!") print("") radios = flexdoppler_radios.Radios() app = wx.App(False) #todo: implement config, maybe a more generic lib than wx #todo: sub xvtr all, pan all, slice all config = wx.Config("flexdoppler") selected_radio_serial = config.Read("selected_radio_serial") app.SetAppDisplayName("FlexDoppler") app.SetAppName("FlexDoppler") FDTrayIcon(radios) app.SetClassName("FlexDoppler") app.SetVendorDisplayName("FlexDoppler") app.SetVendorName("FlexDoppler") listener = reactor.listenMulticast( 4992, flexradio_network.RadioDiscovery(radios), listenMultiple=True) mdlistener = reactor.listenMulticast(9932, macdoppler_network.listener(), listenMultiple=True) reactor.registerWxApp(app) reactor.run()
def initialize(self, *args, **kwargs): context = self.context try: # pyinstaller internal location _resource_path = os.path.join(sys._MEIPASS, "locale") wx.Locale.AddCatalogLookupPathPrefix(_resource_path) except Exception: pass try: # Mac py2app resource _resource_path = os.path.join(os.environ["RESOURCEPATH"], "locale") wx.Locale.AddCatalogLookupPathPrefix(_resource_path) except Exception: pass wx.Locale.AddCatalogLookupPathPrefix( "locale") # Default Locale, prepended. Check this first. context._kernel.run_later = self.run_later context._kernel.translation = wx.GetTranslation context._kernel.set_config(wx.Config(context._kernel.profile)) context.app = self # Registers self as kernel.app context.setting(int, "language", None) language = context.language if language is not None and language != 0: self.update_language(language)
def loadPrefs(self): """Loads user preferences into self.config, setting up defaults if none are set.""" sc = self.config = wx.Config('Twine') for k, v in { 'savePath': os.path.expanduser('~'), 'fsTextColor': '#afcdff', 'fsBgColor': '#100088', 'fsFontFace': metrics.face('mono'), 'fsFontSize': metrics.size('fsEditorBody'), 'fsLineHeight': 120, 'windowedFontFace': metrics.face('mono'), 'monospaceFontFace': metrics.face('mono2'), 'windowedFontSize': metrics.size('editorBody'), 'monospaceFontSize': metrics.size('editorBody'), 'flatDesign': False, 'storyFrameToolbar': True, 'storyPanelSnap': False, 'fastStoryPanel': False, 'imageArrows': True, 'displayArrows': True, 'createPassagePrompt': True, 'importImagePrompt': True, 'passageWarnings': True }.items(): if not sc.HasEntry(k): if type(v) == str: sc.Write(k, v) elif type(v) == int: sc.WriteInt(k, v) elif type(v) == bool: sc.WriteBool(k, v)
def loadPrefs(self): """Loads user preferences into self.config, setting up defaults if none are set.""" self.config = wx.Config('Twine') monoFont = wx.SystemSettings.GetFont(wx.SYS_ANSI_FIXED_FONT) if not self.config.HasEntry('savePath'): self.config.Write('savePath', os.path.expanduser('~')) if not self.config.HasEntry('fsTextColor'): self.config.Write('fsTextColor', '#afcdff') if not self.config.HasEntry('fsBgColor'): self.config.Write('fsBgColor', '#100088') if not self.config.HasEntry('fsFontFace'): self.config.Write('fsFontFace', metrics.face('mono')) if not self.config.HasEntry('fsFontSize'): self.config.WriteInt('fsFontSize', metrics.size('fsEditorBody')) if not self.config.HasEntry('fsLineHeight'): self.config.WriteInt('fsLineHeight', 120) if not self.config.HasEntry('windowedFontFace'): self.config.Write('windowedFontFace', metrics.face('mono')) if not self.config.HasEntry('monospaceFontFace'): self.config.Write('monospaceFontFace', metrics.face('mono2')) if not self.config.HasEntry('windowedFontSize'): self.config.WriteInt('windowedFontSize', metrics.size('editorBody')) if not self.config.HasEntry('monospaceFontSize'): self.config.WriteInt('monospaceFontSize', metrics.size('editorBody')) if not self.config.HasEntry('storyFrameToolbar'): self.config.WriteBool('storyFrameToolbar', True) if not self.config.HasEntry('storyPanelSnap'): self.config.WriteBool('storyPanelSnap', False) if not self.config.HasEntry('fastStoryPanel'): self.config.WriteBool('fastStoryPanel', False)
def __load(self): self.cfg = wx.Config('rtlsdr-scanner') self.cfg.RenameGroup('Devices', 'DevicesRTL') self.display = self.cfg.ReadInt('display', self.display) self.saveWarn = self.cfg.ReadBool('saveWarn', self.saveWarn) self.fileHistory.Load(self.cfg) self.dirScans = self.cfg.Read('dirScans', self.dirScans) self.dirExport = self.cfg.Read('dirExport', self.dirExport) self.annotate = self.cfg.ReadBool('annotate', self.annotate) self.peaks = self.cfg.ReadBool('peaks', self.peaks) self.peaksThres = self.cfg.ReadInt('peaksThres', self.peaksThres) self.retainScans = self.cfg.ReadBool('retainScans', self.retainScans) self.fadeScans = self.cfg.ReadBool('fadeScans', self.fadeScans) self.lineWidth = self.cfg.ReadFloat('lineWidth', self.lineWidth) self.retainMax = self.cfg.ReadInt('retainMax', self.retainMax) self.colourMapUse = self.cfg.ReadBool('colourMapUse', self.colourMapUse) self.colourMap = self.cfg.Read('colourMap', self.colourMap) self.background = self.cfg.Read('background', self.background) self.wireframe = self.cfg.ReadBool('wireframe', self.wireframe) self.pointsLimit = self.cfg.ReadBool('pointsLimit', self.pointsLimit) self.pointsMax = self.cfg.ReadInt('pointsMax', self.pointsMax) self.grid = self.cfg.ReadBool('grid', self.grid) self.plotFunc = self.cfg.ReadInt('plotFunc', self.plotFunc) self.smoothFunc = self.cfg.Read('smoothFunc', self.smoothFunc) self.smoothRatio = self.cfg.ReadInt('smoothRatio', self.smoothRatio) self.clickTune = self.cfg.ReadBool('clickTune', self.clickTune) self.precisionFreq = self.cfg.ReadInt('precisionFreq', self.precisionFreq) self.precisionLevel = self.cfg.ReadInt('precisionLevel', self.precisionLevel) self.compareOne = self.cfg.ReadBool('compareOne', self.compareOne) self.compareTwo = self.cfg.ReadBool('compareTwo', self.compareTwo) self.compareDiff = self.cfg.ReadBool('compareDiff', self.compareDiff) self.start = self.cfg.ReadInt('start', self.start) self.stop = self.cfg.ReadInt('stop', self.stop) self.mode = self.cfg.ReadInt('mode', self.mode) self.dwell = self.cfg.ReadFloat('dwell', self.dwell) self.nfft = self.cfg.ReadInt('nfft', self.nfft) self.overlap = self.cfg.ReadFloat('overlap', self.overlap) self.winFunc = self.cfg.Read('winFunc', self.winFunc) self.startOption = self.cfg.ReadInt('startOption', self.startOption) self.stopOption = self.cfg.ReadInt('stopOption', self.stopOption) self.liveUpdate = self.cfg.ReadBool('liveUpdate', self.liveUpdate) self.calFreq = self.cfg.ReadFloat('calFreq', self.calFreq) self.autoF = self.cfg.ReadBool('autoF', self.autoF) self.autoL = self.cfg.ReadBool('autoL', self.autoL) self.autoT = self.cfg.ReadBool('autoT', self.autoT) self.showMeasure = self.cfg.ReadBool('showMeasure', self.showMeasure) self.alert = self.cfg.ReadBool('alert', self.alert) self.alertLevel = self.cfg.ReadFloat('alertLevel', self.alertLevel) self.gps = self.cfg.ReadBool('gps', self.gps) self.exportWidth = self.cfg.ReadFloat('exportWidth', self.exportWidth) self.exportHeight = self.cfg.ReadFloat('exportHeight', self.exportHeight) self.exportDpi = self.cfg.ReadInt('exportDpi', self.exportDpi) self.indexRtl = self.cfg.ReadInt('index', self.indexRtl) self.indexRtl = self.cfg.ReadInt('indexRtl', self.indexRtl) self.indexGps = self.cfg.ReadInt('indexGps', self.indexGps) self.__load_devices_rtl() self.__load_devices_gps()
def OnAuiBaseClose(self, event): """Save perspective on exit""" appName = wx.GetApp().GetAppName() assert appName, "No App Name Set!" config = wx.Config(appName) perspective = self._mgr.SavePerspective() config.Write("perspective", perspective) event.Skip() # Allow event to propagate
def OnMenuEditItems1Menu(self, event): # Delete the entries in the registry/file cfg = wx.Config("QuickUsbDiagPy", "Bitwise Systems") cfg.DeleteAll() cfg.Flush() # Update the controls self.LoadConf()
def setPositionAndSize(self): config = wx.Config(wx.App.Get().AppName) x = config.ReadInt(Const.CONFIG_WINDOW_X, 0) y = config.ReadInt(Const.CONFIG_WINDOW_Y, 0) self.Position = (x, y) width = config.ReadInt(Const.CONFIG_WINDOW_WIDTH, 320) height = config.ReadInt(Const.CONFIG_WINDOW_HEIGHT, 240) self.Size = (width, height)
def test_Config1(self): null = wx.LogNull() name = cfgFilename + '_1' cfg = wx.Config('unittest_ConfigTests', localFilename=name) self.writeStuff(cfg) del cfg if os.path.exists(name): os.remove(name)
def OnChoice(self, event): sel = self.langch.GetSelection() config = wx.Config() if sel == 0: val = 'LANGUAGE_ENGLISH' else: val = 'LANGUAGE_JAPANESE' config.Write('lang', val)
def set(self, value): debug("%s.%s = %r" % (class_name(self), my_name(), value)) from time import time if not hasattr(self, "config"): self.config = wx.Config(class_name(self)) self.config.last_read = time() self.config.Write(my_name(), repr(value)) self.config.Flush()
def save_properties(self): ''' @brief Save the current proprieties of the graphical elements. ''' try: configHandle = wx.Config(CONFIG_FILE) # Sweep all elements in `self()` to find the grafical ones # instance of the wxPython and salve the specific configuration. for wxElement_name, wxElement_handle in self.__dict__.items(): try: # Each wxPython object have a specific parameter value # to be saved and restored in the software initialization. if isinstance(wxElement_handle, wx._core.TextCtrl ) and wxElement_name != 'm_textCtrlMessages': # Save each TextCtrl (TextBox) that is not the status messages. configHandle.Write(wxElement_name, wxElement_handle.GetValue()) elif isinstance(wxElement_handle, wx._core.CheckBox): configHandle.Write( wxElement_name, ('True' if wxElement_handle.GetValue() else 'False')) elif isinstance(wxElement_handle, wx._core.CheckListBox): value = [ wxElement_handle.GetString(idx) for idx in wxElement_handle.GetCheckedItems() ] configHandle.Write(wxElement_name, ','.join(value)) elif isinstance( wxElement_handle, wx._core.SpinCtrl) or isinstance( wxElement_handle, wx._core.SpinCtrlDouble): configHandle.Write(wxElement_name, str(wxElement_handle.GetValue())) elif isinstance(wxElement_handle, wx._core.ComboBox): value = [ wxElement_handle.GetString(idx) for idx in range(wxElement_handle.GetCount()) ] configHandle.Write(wxElement_name, ','.join(value)) elif isinstance(wxElement_handle, wx._core.ListBox): configHandle.Write( wxElement_name, wxElement_handle.GetStringSelection()) elif isinstance(wxElement_handle, wx._core.Notebook): configHandle.Write( wxElement_name, str(wxElement_handle.GetSelection())) # Others wxWidgets graphical elements with not saved configurations. #elif isinstance(wxElement_handle, wx._core.):configHandle #elif isinstance(wxElement_handle, wx._core.StaticBitmap): #elif isinstance(wxElement_handle, wx._core.Panel): #elif isinstance(wxElement_handle, wx._core.Button): #elif isinstance(wxElement_handle, wx._core.StaticText): except KeyError: continue del configHandle # Close the file / Windows registry sock. except: print('Configurations not saved.')
def cluster_setup_script(): cnfg = wx.Config('CPRynner') if cnfg.Exists('setup_script'): setup_script = cnfg.Read('setup_script') else: setup_script = """\ module load cellprofiler; module load java;""" return setup_script
def LoadConfiguration(self): """ Load Configuration Data from the Registry or Config File """ # Load the Config Data. wxConfig automatically uses the Registry on Windows and the appropriate file on Mac. # Program Name is Transana, Vendor Name is Verception to remain compatible with Transana 1.0. config = wx.Config('Transana', 'Verception') self.sFTPServer = config.Read('/2.0/sFTP/sFTPServer', 'ftp.wcer.wisc.edu') self.sFTPPort = config.Read('/2.0/sFTP/sFTPPort', '22') self.sFTPPublicKeyType = config.Read('/2.0/sFTP/sFTPPublicKeyType', 'ssh-rsa') self.sFTPPublicKey = config.Read('/2.0/sFTP/sFTPPublicKey', 'AAAAB3NzaC1yc2EAAAABIwAAAQEAzi+1CH0qa4UwRgxf2J4cQE6HNJYSTYaDlionweNWmRBBXG5mu2L7bAXYx32QnRwukbZNJAF/APm80aLbQo/m6nn8Do5eSWDkel0J1GeXOFd/yfINrcNMN2UD2r7J0o6PMBtZVQq2logm1Ckbu2UDhW8HWDMKC1YsfU4y5HTd09qvduEGMCW7YsKECiqlBBX8/Pg0GuThi0h5IOuyufpCpTPaUxL0tBoIo7pRH2Dax5ivtAaxO+xWP8mMnOCLjzxHknD0z3h/bmr8QJ4o9vR8xjXab/Skrtmd1FSqei4cdWFYW8jDdbPMS14sOTj0pk58/8I7h838kQ7WkYwNcC4fEQ==')
def onQuit(self, _event=None): config = wx.Config(wx.App.Get().AppName) config.WriteInt(Const.CONFIG_WINDOW_X, self.Position.x) config.WriteInt(Const.CONFIG_WINDOW_Y, self.Position.y) config.WriteInt(Const.CONFIG_WINDOW_WIDTH, self.Size.Width) config.WriteInt(Const.CONFIG_WINDOW_HEIGHT, self.Size.Height) if self.helpForm: self.helpForm.Destroy() self.Destroy()