def getFormResults(self): """Reads form fields and gets settings.""" logger.debug(util.funcName('begin')) charcompString = self.dlgCtrls.txtCharComp.getText() self.app.setCharCompFromInput(charcompString) self.userVars.store("CharComparison", charcompString) ## Font name and size fontName = self.dlgCtrls.comboFont.getText() if fontName == "(None)": fontName = None fontSize = FontSize(default=DEFAULT_FONT_SIZE) fontSize.loadCtrl(self.dlgCtrls.txtFontSize) self.userVars.store('Font', fontName) self.userVars.store('FontSize', fontSize.getString()) self.userVars.store("OnlyKnownFonts", str(self.dlgCtrls.chkKnownFonts.getState())) self.userVars.store("Script", self.dlgCtrls.comboScript.getText()) ## Checkbox var list for chk in self.dlgCtrls.checkboxVarList: self.userVars.store(chk.varname, str(chk.ctrl.getState())) logger.debug(util.funcName('end'))
def getFormResults(self): """Reads form fields and sets self.config and self.converter. In setAndVerifyConfig() in app layer, the settings will be checked for inconsistencies. """ logger.debug(util.funcName('begin')) ## Converter self.converter = ConverterSettings(self.userVars) self.converter.loadUserVars() # for normForm self.converter.convName = self.dlgCtrls.txtConverterName.getText() self.converter.forward = ( self.dlgCtrls.chkDirectionReverse.getState() == 0) self.converter.storeUserVars() ## Radio buttons and the corresponding combo box selection self.config = ConversionSettings() searchConfig = self.config.searchConfig # shorthand name self.config.whichScope = dutil.whichSelected( self.dlgCtrls.radiosWhichScope) self.userVars.store('WhichScope', self.config.whichScope) if self.config.whichScope == 'Font': searchConfig.fontName = self.dlgCtrls.comboScopeFont.getText() searchConfig.fontType = dutil.whichSelected( self.dlgCtrls.radiosScopeFont) self.userVars.store('ScopeFontType', searchConfig.fontType) searchConfig.load_userVars(self.userVars) self.config.whichTarget = dutil.whichSelected( self.dlgCtrls.radiosWhichTarget) self.userVars.store('WhichTarget', self.config.whichTarget) ## Target font targetFontName = self.dlgCtrls.listTargetFont.getSelectedItem() if targetFontName == "(None)": targetFontName = None targetFontSize = FontSize() targetFontSize.loadCtrl(self.dlgCtrls.txtFontSize) if self.config.whichTarget == 'Font': self.userVars.store('TargetFontName', targetFontName) self.userVars.store('TargetFontSize', targetFontSize.getString()) targetFontType = dutil.whichSelected( self.dlgCtrls.radiosTargetFont) self.userVars.store('TargetFontType', targetFontType) self.config.targetFont = styles.FontDefStruct( targetFontName, targetFontType, targetFontSize) self.config.askEach = (self.dlgCtrls.chkVerify.getState() == 1) ## Save selections for next time for combo in self.dlgCtrls.combos: self.userVars.store(combo.varname, combo.ctrl.getText()) self.userVars.store('AskEachChange', str(self.dlgCtrls.chkVerify.getState())) logger.debug(util.funcName('end'))
def changeFontSize(self): fontSize = FontSize(default=30.0) fontSize.loadCtrl(self.txtFontSize) for txctrl in (self.txtCharset, self.txtQuestion, self.txtAnswer): fontSize.changeCtrlProp(txctrl)
def getFormResults(self): """Reads form fields and sets app configuration.""" logger.debug(util.funcName('begin')) config = scriptpractice.PracticeSettings() charsetString = self.dlgCtrls.txtCharset.getText() self.script.setCharsetFromInput(charsetString) self.userVars.store("CharSet", charsetString) self.questions.setConfig(config, self.wordList) ## Radio buttons and the corresponding combo box selection self.whichSource = "" if self.dlgCtrls.optGenerate.getState(): self.whichSource = "Generate" elif self.dlgCtrls.optWordlist.getState(): self.whichSource = "Wordlist" self.userVars.store("WhichSource", config.whichSource) config.whichSource = self.whichSource ## Font name and size fontName = self.dlgCtrls.comboFont.getText() if fontName == "(None)": fontName = None fontSize = FontSize(default=30.0) fontSize.loadCtrl(self.dlgCtrls.txtFontSize) self.userVars.store('Font', fontName) self.userVars.store('FontSize', fontSize.getString()) self.userVars.store("Script", self.dlgCtrls.comboScript.getText()) self.userVars.store("OnlyKnownFonts", str(self.dlgCtrls.chkKnownFonts.getState())) ## Syllable and Word size strval = self.dlgCtrls.listSyllableSize.getSelectedItem() try: val = int(strval) except ValueError: val = 2 if val < 1 or val > 3: val = 2 config.syllableSize = val self.userVars.store("SyllableSize", str(val)) strval = self.dlgCtrls.txtNumSyllables.getText() try: val = int(strval) except ValueError: val = 1 self.dlgCtrls.txtNumSyllables.setText(str(val)) if val < 1 or val > 9: val = 1 self.dlgCtrls.txtNumSyllables.setText(str(val)) config.numSyllables = val self.userVars.store("NumSyllables", str(val)) strval = self.dlgCtrls.txtNumWords.getText() try: val = int(strval) except ValueError: val = 1 self.dlgCtrls.txtNumWords.setText(str(val)) if val < 1 or val > 50: val = 1 self.dlgCtrls.txtNumWords.setText(str(val)) config.numWords = val self.userVars.store("NumWords", str(val)) logger.debug(util.funcName('end'))
def changeFontSize(self): fontSize = FontSize(default=DEFAULT_FONT_SIZE) fontSize.loadCtrl(self.txtFontSize) fontSize.changeCtrlProp(self.txtCharComp)