def loadValues(self, userVars):
        scriptNames = sorted(list(unicode_data.SCRIPT_LETTERS.keys()))
        selectedValue = userVars.get("Script")
        if not selectedValue:
            selectedValue = "DEVANAGARI"
        dutil.fill_list_ctrl(self.comboScript, scriptNames, selectedValue)

        selectedValue = userVars.get("Font")
        if selectedValue:
            self.comboFont.setText(selectedValue)
        else:
            self.comboFont.setText("")
        self.chkKnownFonts.setState(userVars.getInt("OnlyKnownFonts"))
        self.setFontList()

        fontSize = FontSize(default=DEFAULT_FONT_SIZE)
        fontSize.loadUserVar(userVars, 'FontSize')
        fontSize.changeCtrlVal(self.txtFontSize)

        for chk in self.checkboxVarList:
            if userVars.isEmpty(chk.varname):
                chk.ctrl.setState(True)
            else:
                chk.ctrl.setState(userVars.getInt(chk.varname))

        self.addRemainingListeners()
Beispiel #2
0
 def selectTargetFont(self, control, styleType):
     """Selects the font based on the value specified in the control.
     If control is None (for initialization or testing), gets values from
     user variables instead.
     """
     logger.debug(util.funcName('begin'))
     listCtrl = self.dlgCtrls.listTargetStyleFont  # shorthand variable
     listValues = listCtrl.Items
     if control:
         fontType = 'Western'
         if self.dlgCtrls.optTargetFontComplex.getState() == 1:
             fontType = 'Complex'
         elif self.dlgCtrls.optTargetFontAsian.getState() == 1:
             fontType = 'Asian'
         displayName = control.getText()
         try:
             if styleType == 'Paragraph':
                 styleName = self.paraStyleNames[displayName]
             elif styleType == 'Character':
                 styleName = self.charStyleNames[displayName]
         except KeyError:
             # Perhaps a new style to be created
             logger.debug("%s is not a known style.", displayName)
             return
         fontName, fontSize = self.styleFonts.getFontOfStyle(
             styleType, fontType, styleName)
     else:
         fontName = self.userVars.get('TargetFontName')
         fontSize = FontSize()
         fontSize.loadUserVar(self.userVars, 'TargetFontSize')
     if fontName and fontName in listValues:
         listCtrl.selectItem(fontName, True)
     else:
         listCtrl.selectItemPos(0, True)
     fontSize.changeCtrlVal(self.dlgCtrls.txtFontSize)
 def selectTargetFont(self):
     """Selects the font from user variables."""
     logger.debug(util.funcName('begin'))
     listCtrl = self.dlgCtrls.listTargetFont  # shorthand variable
     listValues = listCtrl.Items
     fontName = self.userVars.get('TargetFontName')
     fontSize = FontSize()
     fontSize.loadUserVar(self.userVars, 'TargetFontSize')
     if fontName and fontName in listValues:
         listCtrl.selectItem(fontName, True)
     else:
         listCtrl.selectItemPos(0, True)
     fontSize.changeCtrlVal(self.dlgCtrls.txtFontSize)
Beispiel #4
0
    def loadValues(self, userVars, questions):
        logger.debug(util.funcName('begin'))
        if not userVars.isEmpty("CharSet"):
            self.script.setCharsetFromInput(userVars.get("CharSet"))
            self.charsetAlreadySet = True

        ## Option buttons

        whichSource = userVars.get("WhichSource")
        if whichSource == "Generate":
            self.optGenerate.setState(True)
        elif whichSource == "Wordlist":
            self.optWordlist.setState(True)

        whenToCheck = userVars.get("WhenToCheck")
        if whenToCheck == "Space":
            self.optCheckTypeSpace.setState(True)
            questions.waitForSpace = True
        elif whenToCheck == "LastChar":
            self.optCheckAtLastChar.setState(True)
            questions.waitForSpace = False

        ## Combo box lists

        logger.debug("Populating script and fonts lists")
        varname = "OnlyKnownFonts"
        if userVars.isEmpty(varname):
            self.chkKnownFonts.setState(True)
        else:
            self.chkKnownFonts.setState(userVars.getInt(varname))

        scriptNames = sorted(list(unicode_data.SCRIPT_LETTERS.keys()))
        selectedValue = userVars.get("Script")
        if not selectedValue:
            selectedValue = "LATIN"
        dutil.fill_list_ctrl(self.comboScript, scriptNames, selectedValue)
        self.changeScript()

        selectedValue = userVars.get("Font")
        if selectedValue:
            self.comboFont.setText(selectedValue)
        self.changeFont()

        ## Other fields

        logger.debug("Loading other field values from user vars")
        syllableSize = userVars.getInt("SyllableSize")
        if syllableSize < 1 or syllableSize > 3:
            syllableSize = 2
        self.listSyllableSize.selectItem(str(syllableSize), True)

        numSyllables = userVars.getInt("NumSyllables")
        if numSyllables < 1 or numSyllables > 9:
            numSyllables = 1
        self.txtNumSyllables.setText(str(numSyllables))

        numWords = userVars.getInt("NumWords")
        if numWords < 1 or numWords > 50:
            numWords = 1
        self.txtNumWords.setText(str(numWords))

        fontSize = FontSize(default=30.0)
        fontSize.loadUserVar(userVars, 'FontSize')
        fontSize.changeCtrlVal(self.txtFontSize)
        self.changeFontSize()

        self.enableDisable()

        self.addRemainingListeners()
        logger.debug(util.funcName('end'))