def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, pos=(100, 100)) self.tbicon = wx.TaskBarIcon() ##self.tbicon.SetIcon(res.cs_icon.GetIcon(), "Earth Wallpaper") self.tbicon.SetIcon( wx.Icon('graphics/monitor-wallpaper.png', wx.BITMAP_TYPE_PNG), "Earth Wallpaper") # Bind some events to it wx.EVT_TASKBAR_LEFT_DCLICK(self.tbicon, self.OnMenuCheck) # left click wx.EVT_TASKBAR_RIGHT_UP(self.tbicon, self.ShowMenu) # single left click wx.EVT_CLOSE( self, self.OnClose ) # triggered when the app is closed, which deletes the icon from tray # build the menu that we'll show when someone right-clicks self.menu = wx.Menu() # the menu object self.menu.Append(103, 'About...') # About wx.EVT_MENU(self, 103, self.OnMenuShowAboutBox) # Bind a function to it self.menu.Append(104, 'Close') # Close wx.EVT_MENU(self, 104, self.OnMenuClose) # Bind a function to it self.quotes = get_mqotd() cfg = None configFile = os.path.abspath('settings.cfg') if not os.path.exists(configFile): f = file("configFile", 'wb') f.close() cfg = wx.FileConfig(localFilename=configFile, style=wx.CONFIG_USE_LOCAL_FILE) cfg.Write("PHOTO_PATH", "['']") else: cfg = wx.FileConfig(localFilename=configFile, style=wx.CONFIG_USE_LOCAL_FILE) PHOTO_PATH = readPyValFromConfig(cfg, "PHOTO_PATH") DATE_FORMAT = cfg.Read("DATE_FORMAT", '%d/%m/%Y %H:%M') print PHOTO_PATH self.filelist = [] for base in PHOTO_PATH: if base != '': srcpath = path.path(base) for thispath in srcpath.walkfiles(): thatpath = srcpath.relpathto(thispath) ext = thatpath.lower()[-4:] if ext in ['.jpg']: self.filelist.append(os.path.join(base, thatpath)) self.timer = wx.Timer(self, -1) self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer) self.timer.Start(600 * 1000) self.OnTimer(evt=True)
def __init__(self, utility): self.utility = utility filename = self.utility.config.Read('language_file') langpath = os.path.join(self.utility.getPath(), LIBRARYNAME, "Lang") sys.stdout.write("Setting up languages\n") print >> sys.stderr, "Language file:", langpath, filename # Set up user language file (stored in user's config directory) self.user_lang = None user_filepath = os.path.join(self.utility.getConfigPath(), 'user.lang') self.user_lang = ConfigReader(user_filepath, "ABC/language") # Set up local language file self.local_lang_filename = None self.local_lang = None local_filepath = os.path.join(langpath, filename) if filename != 'english.lang' and existsAndIsReadable(local_filepath): self.local_lang_filename = filename # Modified self.local_lang = wx.FileConfig(localFilename=local_filepath) self.local_lang.SetPath("ABC/language") #self.local_lang = ConfigReader(local_filepath, "ABC/language") # Set up english language file self.english_lang = None english_filepath = os.path.join(langpath, 'english.lang') if existsAndIsReadable(english_filepath): self.english_lang = ConfigReader(english_filepath, "ABC/language") self.cache = {} self.langwarning = False
def load_from_config_file(self): fc=wx.FileConfig(localFilename=self.CONFIG_FILE) sync_host_cnt=fc.ReadInt("sync_host_cnt", 0) for i in range(1, sync_host_cnt+1): host, path=fc.Read("sync_host_"+str(i), "").split(":", 1) filename=self.file.GetValue() self.hostlist.Append((host, path, filename))
def SetupApplicationConfiguration(self): user_dir = Path(wx.StandardPaths.Get().GetUserDataDir()) user_dir.mkdir(exist_ok = True) config = wx.FileConfig(localFilename = str(user_dir / "nlv.ini")) config.Write("/NLV/DataDir", str(user_dir)) wx.ConfigBase.Set(config) return user_dir
def __init__(self, wammu_cfg, path=None): ''' Reads gammu configuration and prepares it for use. ''' self.wammu_cfg = wammu_cfg if path is not None: self.filename = path else: self.filename = self.wammu_cfg.Read('/Gammu/Gammurc') self.config = wx.FileConfig(localFilename=self.filename, style=wx.CONFIG_USE_LOCAL_FILE) self.list = [] cont, val, idx = self.config.GetFirstGroup() matcher = re.compile('gammu(\d*)') while cont: match = matcher.match(val) if match is not None: index = match.groups(1)[0] if index == '': index = 0 else: index = int(index) name = self.config.Read('%s/name' % val, val) self.list.append({'Id': index, 'Name': name, 'Path': val}) cont, val, idx = self.config.GetNextGroup(idx)
def createDefaultVisualizers(self): manager = self.getManager() config_path = rostools.packspec.get_pkg_dir( "ogre_visualizer") + "/configs/pr2.vcg" config = wx.FileConfig(localFilename=config_path) manager.loadConfig(config)
def __init__(self, app_name, parent_menu, pos, history_len=10): self._history_len = history_len self._parent_menu = parent_menu self._pos = pos self.file_requested = Signal("RecentFilesMenu.FileRequested") self._filehistory = wx.FileHistory(maxFiles=history_len) # Recent files path stored in GRASS GIS config dir in the # .recent_files file in the group by application name self._config = wx.FileConfig( style=wx.CONFIG_USE_LOCAL_FILE, localFilename=os.path.join( utils.GetSettingsPath(), self.recent_files, ), ) self._config.SetPath(strPath=app_name) self._filehistory.Load(self._config) self.RemoveNonExistentFiles() self.recent = wx.Menu() self._filehistory.UseMenu(self.recent) self._filehistory.AddFilesToMenu() # Show recent files menu if count of items in menu > 0 if self._filehistory.GetCount() > 0: self._insertMenu()
def delete_host(self, event): sel=self.hostlist.GetFirstSelected() if sel>=0: # doppelt pruefen schadet nix host=self.hostlist.GetItem(sel, 0).GetText() path=self.hostlist.GetItem(sel, 1).GetText() self.hostlist.DeleteItem(sel) # aus Liste loeschen # aus CONFIG_FILE loeschen und ggf. keys umbenennen fc=wx.FileConfig(localFilename=self.CONFIG_FILE) sync_host_cnt=fc.ReadInt("sync_host_cnt", 0) ren=False # ueber alle gespeicherten Hosts for i in range(1, sync_host_cnt+1): h, p=fc.Read("sync_host_"+str(i), "").split(":", 1) if ren==True: # wenn ein Host geloescht wurde, die folgenden Hosts # bzgl. Nummerierung um eins "ranziehen" fc.RenameEntry("sync_host_"+str(i), "sync_host_"+str(i-1)) if h==host and p==path: # der zu loeschende Host ist gefunden fc.DeleteEntry("sync_host_"+str(i)) ren=True # counter korrigieren fc.WriteInt("sync_host_cnt", sync_host_cnt-1) fc.Flush()
def Run(self): self.topWindow = None self.SetAppName(self.__class__.__name__) if self.vendorName is not None: self.SetVendorName(self.vendorName) if sys.platform == "win32": self.settings = wx.ConfigBase.Get() else: standardPaths = wx.StandardPaths.Get() dir = standardPaths.GetUserDataDir() fileName = os.path.join(dir, "settings.cfg") self.settings = wx.FileConfig(localFilename = fileName) wx.ConfigBase.Set(self.settings) self.StartLogging() sys.excepthook = self._ExceptionHandler self.copyAttributes = set(self.copyAttributes.split()) self.config = self.GetConfig() self.copyAttributes.add("settings") self.copyAttributes.add("config") if self.OnStartup(): self.topWindow = self.GetTopWindow() if self.topWindow is not None: self.SetTopWindow(self.topWindow) if self.showTopWindowOnInit: self.topWindow.Show() self.MainLoop()
def updateLanguage(self, lang): # if an unsupported language is requested default to Porteguese if lang in appC.supLang: selLang = appC.supLang[lang] # if is supporte update default config to new language self.appConfig = wx.FileConfig(appName=self.appName, localFilename=os.path.join( self.configLoc, "AppConfig")) self.appConfig.Write(key=u'Language', value=lang) self.appConfig.Flush() else: selLang = wx.LANGUAGE_PORTUGUESE_BRAZILIAN if self.locale: assert sys.getrefcount(self.locale) <= 2 del self.locale # create a locale object for this language self.locale = wx.Locale(selLang) if self.locale.IsOk(): self.locale.AddCatalog(appC.langDomain) else: self.locale = None
def CreateWidgets(self): self.icon = wx.EmptyIcon() self.icon.CopyFromBitmap(wx.Bitmap(resource_path(settings.ICON_RELATIVE_PATH), wx.BITMAP_TYPE_ANY)) self.SetIcon(self.icon) self.box_sizer = wx.BoxSizer(wx.VERTICAL) self.box_sizer_horizontal = wx.BoxSizer(wx.HORIZONTAL) self.SetBackgroundColour(wx.NullColour) # for a nice gray window background color self.Center() self.Bind(wx.EVT_CLOSE, self.OnClose) self.nb = MainNotebook(self) self.box_sizer.Add(self.box_sizer_horizontal, proportion=1, flag=wx.EXPAND|wx.ALL, border=3) self.box_sizer_horizontal.Add(self.nb, proportion=1, flag=wx.EXPAND) filemenu = wx.Menu() item_new = filemenu.Append(wx.ID_NEW, "&New") item_open = filemenu.Append(wx.ID_OPEN, "&Open") item_save = filemenu.Append(wx.ID_SAVE, "&Save") item_save_as = filemenu.Append(wx.ID_SAVEAS, "Save &As") filemenu.AppendSeparator() item_close = filemenu.Append(wx.ID_EXIT, "Exit") settingsmenu = wx.Menu() self.item_search_foxes_start = settingsmenu.Append(settings.ID_SETTINGS_SEARCH_FOXES_START, "Search Connected Foxes at Start", kind=wx.ITEM_CHECK) helpmenu = wx.Menu() item_user_manual = helpmenu.Append(settings.ID_HELP_USER_MANUAL, "User Manual (German)") item_about = helpmenu.Append(settings.ID_HELP_ABOUT, "About") self.Bind(wx.EVT_MENU, self.OnClose, item_close) self.Bind(wx.EVT_MENU, self.Save, item_save) self.Bind(wx.EVT_MENU, self.SaveAs, item_save_as) self.Bind(wx.EVT_MENU, self.Open, item_open) self.Bind(wx.EVT_MENU, self.New, item_new) self.Bind(wx.EVT_MENU, self.SearchFoxesAtStart, self.item_search_foxes_start) self.Bind(wx.EVT_MENU, self.HelpAbout, item_about) self.Bind(wx.EVT_MENU, self.HelpUserManual, item_user_manual) menuBar = wx.MenuBar() menuBar.Append(filemenu, "&File") menuBar.Append(settingsmenu, "&Settings") menuBar.Append(helpmenu, "&Help") self.SetMenuBar(menuBar) self.SetSizerAndFit(self.box_sizer) self.status_bar = wx.StatusBar(self, style=wx.SB_RAISED) self.status_bar.PushStatusText("Software ready") self.SetStatusBar(self.status_bar) self.file_config = wx.FileConfig(settings.APP_NAME, style=wx.CONFIG_USE_LOCAL_FILE) self.last_save_string = "" self.ReadSettings() self.last_save_string = self.Saving(with_saving_to_file=False)
def __init__(self, utility, system_default_locale='en_EN'): self.utility = utility default_filename = 'en_EN.lang' langpath = os.path.join(self.utility.getPath(), 'data', 'lang') sys.stdout.write('Setting up languages\n') sys.stdout.write('Default: ' + str(default_filename) + '\n') sys.stdout.write('System: ' + str(system_default_locale) + '\n') self.user_lang = None user_filepath = os.path.join(self.utility.getConfigPath(), 'user.lang') if existsAndIsReadable(user_filepath): self.user_lang = ConfigReader(user_filepath, 'ABC/language') parsed_locale = self.parse_locale(system_default_locale) self.local_lang_filename = parsed_locale + '.lang' self.local_lang = None local_filepath = os.path.join(langpath, self.local_lang_filename) if self.local_lang_filename != default_filename and existsAndIsReadable( local_filepath): if globalConfig.get_mode() == 'client_wx': import wx self.local_lang = wx.FileConfig(localFilename=local_filepath) self.local_lang.SetPath('ABC/language') else: self.local_lang = ConfigReader(local_filepath, 'ABC/language') self.default_lang = None default_filepath = os.path.join(langpath, default_filename) if existsAndIsReadable(default_filepath): self.default_lang = ConfigReader(default_filepath, 'ABC/language') self.cache = {} self.langwarning = False
def initHelp(calledAtStartup=False): jn = os.path.join docsDir = jn(Preferences.pyPath, 'Docs') global _hc if use_standard_controller: _hc = wx.html.HtmlHelpController(wxHF_ICONS_BOOK_CHAPTER | \ wxHF_DEFAULT_STYLE | (Preferences.flatTools and wxHF_FLAT_TOOLBAR or 0)) else: _hc = wxHtmlHelpControllerEx(wxHF_ICONS_BOOK | \ wxHF_DEFAULT_STYLE | (Preferences.flatTools and wxHF_FLAT_TOOLBAR or 0)) cf = wx.FileConfig(localFilename=os.path.normpath( jn(Preferences.rcPath, 'helpfrm.cfg')), style=wx.CONFIG_USE_LOCAL_FILE) _hc.UseConfig(cf) cacheDir = getCacheDir() _hc.SetTempDir(cacheDir) conf = Utils.createAndReadConfig('Explorer') books = eval(conf.get('help', 'books'), {}) for book in books: if calledAtStartup: print 'Help: loading %s' % os.path.basename(book) bookPath = os.path.normpath(jn(docsDir, book)) if os.path.exists(bookPath): _hc.AddBook( bookPath, not os.path.exists( jn(cacheDir, os.path.basename(book) + '.cached')) or not calledAtStartup)
def __init__(self, model): self.model = model self.log = logging.getLogger("ConfigView") self.cfg = wx.FileConfig(appName="ApplicationName", vendorName="VendorName", localFilename=".squeezetray.cfg", style=wx.CONFIG_USE_LOCAL_FILE)
def InitUI(self): mainpanel=wx.Panel(self,-1) #the Panel is just another kind of widget, as far as I know, derives from frame, is more suitable for #graphical changes self.time_list=[str(x) for x in range(7,24)] self.time_list_support=[None for x in range(7,24)] self.time_dict=dict(zip(self.time_list, self.time_list_support)) self.filename="calender.ini" stream=open(self.filename, "w") stream.close() self.config=wx.FileConfig("MyCalender","Whatever",self.filename) #I could have created the calendar as an object on its own, not as an attribute of the mainframe, but I think its more clever to do, #because if you use functions that access methods and attributes of the calendar, it will be much easier that way self.cal2 = wxcal.GenericCalendarCtrl(mainpanel, -1, wx.DateTime.Today(),pos=(0,150),size=(165,150),style=wxcal.CAL_MONDAY_FIRST) #^# Inheritance of graphical widgets, does also hint at, on top of what this widget appears # If I would chose to inherit from Menu_Main(aka self) instead, the calendar might not even be visible #or some other weird thing might happen self.cal2.Bind(wxcal.EVT_CALENDAR_SEL_CHANGED, self.update_date) #Just a simple Static Text Box, most things should be pretty clear, just a reminder, for most arguments there are default values #you just have to declare the parent, and the label self.txtstr=str(self.cal2.GetDate())[:8] self.st1 = wx.StaticText(mainpanel, label=str(self.txtstr),pos=(300,150)) #First attempt to create list of times, maybe I should split it in two columns self.time1=wx.StaticText(mainpanel, label=self.time_list[0], pos=(300, 170)) self.tc1 = wx.TextCtrl(mainpanel,size=(180, -1),pos=(350,170)) self.tc1.SetValue(self.config.Read(self.time_list[0]+str(self.cal2.GetDate())[:8])) self.button1=wx.Button(mainpanel, label="Save", pos=(500,200)) self.button1.Bind(wx.EVT_BUTTON, self.save) self.Centre() self.Show()
def getConfig(configFile): if not os.path.exists(configFile): raise Exception, 'Config file %s not found' % configFile cfg = wx.FileConfig(localFilename=configFile, style=wx.CONFIG_USE_LOCAL_FILE) # cfg.SetExpandEnvVars(False) # read in all group names for this language groupNames = [] cont, val, idx = cfg.GetFirstGroup() while cont: groupNames.append(val) cont, val, idx = cfg.GetNextGroup(idx) # read in common elements # uname = readPyValFromConfig(cfg, "USERNAME") # assert type(uname) is type({}), \ # 'Common definitions (%s) not a valid dict'%commonDefsFile # read in predefined settings settingsGroups = {} for group in groupNames: settingsGroups[group] = readSettingsFromConfig(cfg, group) return (cfg, settingsGroup)
def GetConfig(): if not os.path.exists(GetDataDir()): os.makedirs(GetDataDir()) config = wx.FileConfig( localFilename=os.path.join(GetDataDir(), "options")) return config
def __init__(self): """""" wx.Frame.__init__(self,parent=None,title="Sample Translation Raster", size=(410,460)) # Menus menuBar = wx.MenuBar() menu = wx.Menu() menu.Append (121,"E&xit","Closes this window.") self.Bind (wx.EVT_MENU,self.OnClose,id=121) menuBar.Append (menu,"&File") menu = wx.Menu() menu.Append (402,"&Setup...","Parameters for sample alignment") self.Bind (wx.EVT_MENU,self.OnSetup,id=402) menuBar.Append (menu,"&More") menu = wx.Menu() menu.Append (501,"&About...","Version information") self.Bind (wx.EVT_MENU,self.OnAbout,id=501) menuBar.Append (menu,"&Help") self.SetMenuBar (menuBar) from ComboBox import ComboBox # A customized Combo Box control self.panel = wx.Panel(self) self.Image = Image(self.panel) choices = ["1000","500","200","100","50","20","10","5","2","1"] self.ScaleFactorControl = wx.ComboBox(self.panel, choices=choices,size=(88,-1))##,style=wx.TE_PROCESS_ENTER) self.ScaleFactorControl.Value = "%g" % self.Image.ScaleFactor self.Bind (wx.EVT_COMBOBOX,self.OnChangeScaleFactor,self.ScaleFactorControl) self.Bind (wx.EVT_TEXT,self.OnTypeScaleFactor,self.ScaleFactorControl) self.PointerFunctionControl = wx.Choice(self.panel, choices=["Info","Go to","Calibrate"],size=(88,-1)) self.Bind (wx.EVT_CHOICE,self.OnPointerFunction, self.PointerFunctionControl) self.CreateStatusBar() # Layout self.layout = wx.BoxSizer(wx.VERTICAL) self.layout.Add (self.Image,proportion=1,flag=wx.EXPAND) # growable self.Controls = wx.BoxSizer(wx.HORIZONTAL) self.Controls.AddSpacer((5,5)) self.Controls.Add(self.ScaleFactorControl,flag=wx.ALIGN_CENTER) self.Controls.AddSpacer((5,5)) self.Controls.Add(self.PointerFunctionControl,flag=wx.ALIGN_CENTER) self.layout.Add (self.Controls,flag=wx.EXPAND) self.panel.SetSizer(self.layout) self.panel.Layout() self.Bind(wx.EVT_CLOSE,self.OnClose) self.Show() # Restore last saved settings. name = "SampleTranslationRaster" self.config_file=wx.StandardPaths.Get().GetUserDataDir()+"/"+name+".py" self.config = wx.FileConfig (localFilename=self.config_file) state = self.config.Read('State') if state: try: self.State = eval(state) except Exception,exception: print "Restore failed: %s: %s" % (exception,state)
def fileLoad(self, fn): wx.BeginBusyCursor() wx.Yield() gl = self.file.listGameNames() gl2 = [] gl3 = {} for i in range(len(gl)): pg = self.file.loadGame(i) if pg == []: gl2.append(str(i + 1) + " <<< illegal playground >>>") gl3.update({ i + 1: (i + 1, "<<< illegal playground >>>", 0, 0, "", 0) }) continue pg2 = self.prep.getLines(pg) sz = self.prep.getSize(pg2) md5 = self.prep.getMD5(pg2) sl, sb = self.db.getSolutionLength(md5) if sl != "": gl2.append( str(i + 1) + " (" + str(sl) + ", " + sb + ") " + gl[i]) gl3.update({i + 1: (i + 1, gl[i], sz[0], sz[1], sb, sl)}) else: gl2.append(str(i + 1) + " ( - ? - ) " + gl[i]) gl3.update({i + 1: (i + 1, gl[i], sz[0], sz[1], "?", 0)}) wx.EndBusyCursor() wx.Yield() if len(gl2) > 1: # dlg=wx.SingleChoiceDialog(self, "select a game", "selection", gl2) sz = self.GetSizeTuple() dlg = SokoDialogs.MeinSingleChoiceDialog(self, gl3, size=(450, sz[1])) if dlg.ShowModal() != wx.ID_OK: dlg.Destroy() return self.game_number = dlg.GetSelection() dlg.Destroy() self.filename = fn # Dateiname mit Pfad self.gamesList = gl self.gamename = self.gamesList[self.game_number] fc = wx.FileConfig(localFilename=CONFIG_FILE) fc.Write("filename", self.filename) fc.WriteInt("gameidx", self.game_number) fc.Flush() else: self.game_number = 0 self.filename = fn self.gamesList = gl if self.gamesList != []: self.gamename = self.gamesList[self.game_number] self.load(self.game_number)
def ReadGuiSetting(self, setting_name, default=None, do_json=True): fileconfig = wx.FileConfig(appName="Tribler", localFilename=os.path.join(self.frame.utility.session.get_state_dir(), "gui_settings")) setting_value = fileconfig.Read(setting_name) if do_json and setting_value: setting_value = json.loads(setting_value) elif not setting_value: setting_value = default return setting_value
def load_settings(self): try: pickle_data = b64decode(wx.FileConfig(CONSTANTS.UI.CATEGORY_NAME).Read(CONSTANTS.UI.CONFIG_PARAM, "")) self.app.settings = pickle.loads(pickle_data) except (TypeError, binascii.Error, ModuleNotFoundError, EOFError) as msg: logging.exception(msg) self.app.settings = Settings() self.app.settings = self.app.settings.init()
def GetValues(self, CONFIG_FILE): col_dict = {} fc = wx.FileConfig(localFilename=CONFIG_FILE) for i in range(len(self.cpc)): cs = self.cpc[i].GetColour().GetAsString(wx.C2S_HTML_SYNTAX) col_dict.update({self.col[i][1]: cs}) fc.Write(self.col[i][1], cs) fc.Flush() return (col_dict)
def __init__(self, parent, id=wx.ID_ANY, title='', pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE | wx.SUNKEN_BORDER | wx.CLIP_CHILDREN | wx.NO_FULL_REPAINT_ON_RESIZE, *args, **kwargs): self.window_title = { } # title will be set based on manufacturer, customer info self.proposed_filename_data = { } # a dict holding the info for a proposed file name self.appConfig = None # the full config self.locale = None wx.Frame.__init__(self, parent, id, title, pos, size, style, *args, **kwargs) # reading the config and applying it self.SetName(APP_LONG_NAME) # # # controls that will be defined later self.treectrl = None self.levellist = None self.loglist = None self.settingspanel = None # setting up the window self.SetMinSize(size) self.Centre(wx.BOTH) # creating the main components of the GUI self.BuildMainStructure() # splitters, panels self.sb = self.CreateStatusBar() # menu bar self.menubar = MenuBar() self.SetMenuBar(self.menubar) # timer watch self.watch = Watch() # AppConfig stuff self.appConfig = wx.FileConfig(appName=APP_NAME, vendorName='JakabGabor', localFilename=CONFIGFILE_PATH) # sending out a message telling init is finished # logger.debug('Config file name set to {}'.format(self.appConfig.GetLocalFileName(APP_NAME))) pub.subscribe(self.clear_all, 'logviewer.clear.all') pub.subscribe(self.show_logsummary, 'logviewer.statusbar.logsummary') pub.subscribe(self.set_time, 'logviewer.time') self.Bind(wx.EVT_CLOSE, self.OnClose)
def LoadSettings(self): """ 加载配置 """ fileName = os.path.join(CONF_DIR, 'config.ini') self.config = wx.FileConfig(localFilename=fileName) self.config.SetRecordDefaults(True) self.bottomPane.LoadSettings(self.config)
def StoreConfig(FilePath, squeezeConMdle): cfg = wx.FileConfig(appName="ApplicationName", vendorName="VendorName", localFilename=FilePath, style=wx.CONFIG_USE_LOCAL_FILE) cfg.Write("squeezeServerHost", squeezeConMdle.host.get()) cfg.WriteInt("squeezeServerPort", squeezeConMdle.port.get()) cfg.Flush()
def __init__(self, parent, flow, **kwargs): """ Args: parent: Parent window. flow: `AbinitFlow` with the list of `Workflow` objects. """ if "title" not in kwargs: kwargs["title"] = self.codename super(FlowViewerFrame, self).__init__(parent, -1, **kwargs) # This combination of options for config seems to work on my Mac. self.config = wx.FileConfig(appName=self.codename, localFilename=self.codename + ".ini", style=wx.CONFIG_USE_LOCAL_FILE) # Build menu, toolbar and status bar. self.SetMenuBar(self.makeMenu()) self.makeToolBar() self.statusbar = self.CreateStatusBar() self.Centre() self.flow = flow # Disable launch mode if we already executing the flow with the scheduler. self.check_launcher_file() # Build UI self.panel = panel = wx.Panel(self, -1) self.main_sizer = main_sizer = wx.BoxSizer(wx.VERTICAL) # Here we create a panel and a notebook on the panel self.notebook = FlowNotebook(panel, self.flow) main_sizer.Add(self.notebook, 1, wx.EXPAND, 5) submit_button = wx.Button(panel, -1, label='Submit') submit_button.Bind(wx.EVT_BUTTON, self.OnSubmitButton) text = wx.StaticText(panel, -1, "Max nlaunch:") text.Wrap(-1) text.SetToolTipString("Maximum number of tasks that can be submitted. Use -1 for unlimited launches.") self.max_nlaunch = wx.SpinCtrl(panel, -1, value=str(get_ncpus()), min=-1) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(submit_button, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5) hsizer.Add(text, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5) hsizer.Add(self.max_nlaunch, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5) main_sizer.Add(hsizer, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5) panel.SetSizerAndFit(main_sizer) # Register this event when the GUI is IDLE # Not used anymore since the Yaml parser # is very slow when we use the pure python version. self.last_refresh = time.time()
def _setup(self): """ Setup prior to first buffer creation. Called automatically by base class during init. """ self.notebook = EditorNotebook(parent=self) intro = 'Py %s' % version.VERSION import imp module = imp.new_module('__main__') if sys.version_info >= (3, ): import builtins module.__dict__['__builtins__'] = builtins else: import __builtin__ module.__dict__['__builtins__'] = __builtin__ namespace = module.__dict__.copy() self.config_dir = pcbnew.SETTINGS_MANAGER.GetUserSettingsPath() self.dataDir = self.config_dir self._setup_startup() self.history_file = os.path.join(self.config_dir, "PyShell_pcbnew.history") self.config_file = os.path.join(self.config_dir, "PyShell_pcbnew.cfg") self.config = wx.FileConfig(localFilename=self.config_file) self.config.SetRecordDefaults(True) self.autoSaveSettings = False self.autoSaveHistory = False self.LoadSettings() # in case of wxPhoenix we need to create a wxApp first and store it # to prevent removal by gabage collector if 'phoenix' in wx.PlatformInfo: self.theApp = wx.App() self.crust = crust.Crust(parent=self.notebook, intro=intro, locals=namespace, rootLabel="locals()", startupScript=self.startup_file, execStartupScript=self.execStartupScript) self.shell = self.crust.shell # Override the filling so that status messages go to the status bar. self.crust.filling.tree.setStatusText = self.SetStatusText # Override the shell so that status messages go to the status bar. self.shell.setStatusText = self.SetStatusText # Fix a problem with the sash shrinking to nothing. self.crust.filling.SetSashPosition(200) self.notebook.AddPage(page=self.crust, text='*Shell*', select=True) self.setEditor(self.crust.editor) self.crust.editor.SetFocus() self.LoadHistory()
def MenuNavW(self, event): if self.navigationWin != None: # wenn schon offen... self.navigationWin.Iconize( False) # ...nur in den Vordergrund holen return fc = wx.FileConfig(localFilename=CONFIG_FILE) sp = (fc.ReadInt("pos_x_nav", -1), fc.ReadInt("pos_y_nav", -1)) self.navigationWin = SokoNavigate.NavigationArea(self, pos=sp) self.clearDC = True
def Initialize(): global _config _config = wx.FileConfig() for default in _defaults.items(): (key, def_val) = default # if nothing exists for that key, set it to the default. if not get(key): set(key, str(def_val))
def MenuEditor(self, event): if self.editorWin != None: # wenn schon offen... self.editorWin.Iconize(False) # ...nur in den Vordergrund holen return fc = wx.FileConfig(localFilename=CONFIG_FILE) sp = (fc.ReadInt("pos_x_edit", -1), fc.ReadInt("pos_y_edit", -1)) ss = (fc.ReadInt("size_x_edit", -1), fc.ReadInt("size_y_edit", -1)) self.editorWin=SokoEditor.SokoEditor(self, BASE_PATH, CONFIG_FILE, \ self.playground_raw, self.size, self.col_dict, pos=sp, size=ss) self.clearDC = True