def onBtnOpen(self, btn): """ Load the levels from a file""" inFile = gui.fileChooser.openFile(self.cfgWindow, _('Load levels')) if inFile is not None: input = open(inFile, 'rt') lines = input.readlines() input.close() lvls = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] isInvalid = True if len(lines) == 10: isInvalid = False for i in xrange(10): elts = lines[i].split() try: if len(elts) == 1: lvls[i] = float(elts[0]) if lvls[i] >= -24 and lvls[i] <= 12: continue except: pass isInvalid = True break if isInvalid: gui.errorMsgBox(self.cfgWindow, _('Could not load the file'), _('The format of the file is incorrect.')) else: self.jumpToTargetLvls(lvls)
def onOk(self, btn): """ Save the new preferences """ if not os.path.isdir(os.path.dirname(self.txtFile.get_text())): gui.errorMsgBox( self.cfgWindow, _("Invalid path"), _("The path to the selected file is not valid. Please choose an existing path."), ) self.txtFile.grab_focus() else: prefs.set(__name__, "file", self.txtFile.get_text()) (start, end) = self.txtStatus.get_buffer().get_bounds() prefs.set(__name__, "status", self.txtStatus.get_buffer().get_text(start, end)) self.cfgWindow.hide()
def onModuleToggled(self, renderer, path): """ A module has been enabled/disabled """ row = self.list.getRow(path) name = row[ROW_MODINFO][modules.MODINFO_NAME] if row[ROW_ENABLED]: modules.unload(name) else: try: modules.load(name) except modules.LoadException as err: gui.errorMsgBox(self.window, _('Unable to load this module.'), str(err)) self.fillList()
def onBtnOk(self, btn): """ Check that entered information is correct before saving everything """ device = self.cfgWin.getWidget('txt-device').get_text() useCDDB = self.cfgWin.getWidget('chk-useCDDB').get_active() useCache = useCDDB and self.cfgWin.getWidget('chk-useCache').get_active() if not os.path.exists(device): error = _('Invalid path') errorMsg = _('The path to the CD-ROM device is not valid. Please choose an existing path.') gui.errorMsgBox(self.cfgWin, error, errorMsg) self.cfgWin.getWidget('txt-device').grab_focus() else: prefs.set(__name__, 'device', device) prefs.set(__name__, 'use-cddb', useCDDB) prefs.set(__name__, 'use-cache', useCache) self.cfgWin.hide()
def on_add_dir(self, widget): path = fileChooser.openDirectory(None, _('Choose a directory')) if path is None: return if os.path.isdir(path): if path in self.static_paths: errorMsgBox(None, _('Invalid Folder'), _('You cannot add your root or home folder to the music directories')) return self.add_dir(path) music_paths = self.get_music_paths_from_tree() modules.postMsg(consts.MSG_EVT_MUSIC_PATHS_CHANGED, {'paths': music_paths}) self.set_info_text() else: errorMsgBox(None, _('This path does not exist'), '"%s"\n' % path + _('Please select an existing directory.'))
def onBtnOpen(self, btn): """ Load the levels from a file""" inFile = gui.fileChooser.openFile(self.cfgWindow, _('Load levels')) if inFile is not None: input = open(inFile, 'rt') lines = input.readlines() input.close() lvls = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] isInvalid = True if len(lines) == 10: isInvalid = False for i in range(10): elts = lines[i].split() try: if len(elts) == 1: lvls[i] = float(elts[0]) if lvls[i] >= -24 and lvls[i] <= 12: continue except: pass isInvalid = True break if isInvalid: gui.errorMsgBox(self.cfgWindow, _('Could not load the file'), _('The format of the file is incorrect.')) else: self.jumpToTargetLvls(lvls) # Add a 'custom' entry to the presets if needed if self.preset is not None: self.preset = None prefs.set(__name__, 'preset', self.preset) self.combo.handler_block_by_func(self.onPresetChanged) self.comboStore.insert(0, (False, _('Custom'), None)) self.comboStore.insert(1, (True, '', None)) self.combo.set_active(0) self.combo.handler_unblock_by_func(self.onPresetChanged)
def onBtnOpen(self, btn): """ Load the levels from a file""" inFile = gui.fileChooser.openFile(self.cfgWindow, _('Load levels')) if inFile is not None: input = open(inFile, 'rt') lines = input.readlines() input.close() lvls = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] isInvalid = True if len(lines) == 10: isInvalid = False for i in xrange(10): elts = lines[i].split() try: if len(elts) == 1: lvls[i] = float(elts[0]) if lvls[i] >= -24 and lvls[i] <= 12: continue except: pass isInvalid = True break if isInvalid: gui.errorMsgBox(self.cfgWindow, _('Could not load the file'), _('The format of the file is incorrect.')) else: self.jumpToTargetLvls(lvls) # Add a 'custom' entry to the presets if needed if self.preset is not None: self.preset = None prefs.set(__name__, 'preset', self.preset) self.combo.handler_block_by_func(self.onPresetChanged) self.comboStore.insert(0, (False, _('Custom'), None)) self.comboStore.insert(1, (True, '', None)) self.combo.set_active(0) self.combo.handler_unblock_by_func(self.onPresetChanged)
def onBtnOk(self, btn): """ Check that entered information is correct before saving everything """ device = self.cfgWin.getWidget("txt-device").get_text() useCDDB = self.cfgWin.getWidget("chk-useCDDB").get_active() useCache = useCDDB and self.cfgWin.getWidget("chk-useCache").get_active() readSpeed = self.cfgWin.getWidget("combo-read-speed").get_model()[ self.cfgWin.getWidget("combo-read-speed").get_active() ][1] if not os.path.exists(device): error = _("Invalid path") errorMsg = _("The path to the CD-ROM device is not valid. Please choose an existing path.") gui.errorMsgBox(self.cfgWin, error, errorMsg) self.cfgWin.getWidget("txt-device").grab_focus() else: prefs.set(__name__, "device", device) prefs.set(__name__, "use-cddb", useCDDB) prefs.set(__name__, "use-cache", useCache) prefs.set(__name__, "read-speed", readSpeed) self.cfgWin.hide() # CD-ROM drive read speed modules.postMsg(consts.MSG_CMD_SET_CD_SPEED, {"speed": readSpeed})
def onCheckDlgResponse(self, dialog, response, *args): """ Prevent clicking on the OK button if values are not correct """ if response == gtk.RESPONSE_OK: name = self.txtName.get_text() path = self.txtPath.get_text() if not os.path.isdir(path): gui.errorMsgBox(dialog, _('This path does not exist'), _('Please select an existing directory.')) dialog.stop_emission('response') elif name in self.forbiddenNames: gui.errorMsgBox(dialog, _('The name is incorrect'), _('This name is not allowed.\nPlease use another one.')) dialog.stop_emission('response') else: for ch in name: if ch in self.forbiddenChars: gui.errorMsgBox(dialog, _('The name is incorrect'), _('The character %s is not allowed.\nPlease use another name.') % ch) dialog.stop_emission('response') break
def tiraLed(self): gui.errorMsgBox(self.window, _('Operação de Tira Led'), _('Sem deletar a lista dos irmão!'))