def set_listboxColOrder_values(self, selItemPos=-1):
     listbox = self.dlgCtrls.listboxColOrder
     selectedValue = ""
     if selItemPos >= 0 and selItemPos < listbox.getItemCount():
         selectedValue = self.columnOrder.getTitle(selItemPos)
     dutil.fill_list_ctrl(
         listbox, self.columnOrder.getTitles(), selectedValue)
    def loadValues(self, paraStyleDispNames, charStyleDispNames, fileItem,
                   typesList, fileTypeDict, fillFieldList):
        """Set default values of controls."""
        self.fileControl.setText(fileItem.filepath)

        self.listboxFileType.addItems(typesList, 0)
        if fileItem.filetype in fileTypeDict:
            title = fileTypeDict[fileItem.filetype]
            self.listboxFileType.selectItem(title, True)
            fillFieldList()

        self.txtWS.setText(fileItem.writingSystem)

        self.comboParaStyle.addItems(paraStyleDispNames, 0)
        self.comboCharStyle.addItems(charStyleDispNames, 0)
        dutil.fill_list_ctrl(self.comboFont,
                             styles.getListOfFonts(self.unoObjs))

        self.checkboxMiss.setState(fileItem.includeMisspellings)
        self.checkboxSkipRow.setState(fileItem.skipFirstRow)
        self.checkboxSplit.setState(fileItem.splitByWhitespace)

        stringList = [str(df) for df in fileItem.thingsToGrab]
        logger.debug("len(thingsToGrab) = %d", len(fileItem.thingsToGrab))
        logger.debug("Adding %d data field(s).", len(stringList))
        self.listboxFields.addItems(tuple(stringList), 0)
        self.addRemainingListeners()
    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()
Ejemplo n.º 4
0
 def refresh(self):
     """Redraw the list and select the same item."""
     dutil.fill_list_ctrl(self.list_ctrl,
                          [str(item) for item in self.app.styleItemList])
     if len(self.app.styleItemList) > 0:
         if self._get_app_index() == -1:
             self._set_app_index(0)
         dutil.select_index(self.list_ctrl, self._get_app_index())
 def load_values(self):
     family = 'ParagraphStyles'
     if self.styleType == StyleType.CHAR:
         family = 'CharacterStyles'
     namesList = styles.getListOfStyles(family, self.unoObjs)
     self.styleNames.update(dict(namesList))
     displayNames = tuple([dispName for dispName, dummy_name in namesList])
     dutil.fill_list_ctrl(self.ctrl, displayNames)
Ejemplo n.º 6
0
 def setContents(self, textFound, suggestions, context):
     self.buttonPressed = ""
     self.changeTo = textFound
     self.dlgCtrls.lblFoundText.setText(textFound)
     self.dlgCtrls.lblContext.setText(context)
     self.dlgCtrls.txtChangeTo.setText(textFound)
     logger.debug(repr(suggestions))
     dutil.fill_list_ctrl(self.dlgCtrls.listSuggestions, suggestions)
     logger.debug(util.funcName('end'))
Ejemplo n.º 7
0
    def loadValues(self, userVars, paraStyleDispNames, charStyleDispNames):
        converter = ConverterSettings(userVars)
        converter.loadUserVars()
        self.txtConverterName.setText(converter.convName)
        self.chkDirectionReverse.setState(not converter.forward)
        self.chkVerify.setState(
            userVars.getInt('AskEachChange'))

        ## Option buttons

        dutil.selectRadio(self.radiosWhichScope, userVars.get('WhichScope'))
        dutil.selectRadio(self.radiosWhichTarget, userVars.get('WhichTarget'))
        dutil.selectRadio(self.radiosScopeFont, userVars.get('ScopeFontType'))
        dutil.selectRadio(
            self.radiosTargetFont, userVars.get('TargetFontType'))

        ## Combo box lists

        ComboTuple = collections.namedtuple(
            'ComboTuple', ['ctrl', 'varname', 'data'])
        self.combos = [
            ComboTuple(ctrl=self.comboScopeParaStyle,
                       varname='ScopeParaStyle',
                       data=paraStyleDispNames),
            ComboTuple(ctrl=self.comboScopeCharStyle,
                       varname='ScopeCharStyle',
                       data=charStyleDispNames),
            ComboTuple(ctrl=self.comboScopeFont,
                       varname='ScopeFont',
                       data=styles.getListOfFonts(self.unoObjs)),
            ComboTuple(ctrl=self.comboTargetParaStyle,
                       varname='TargetParaStyle',
                       data=paraStyleDispNames),
            ComboTuple(ctrl=self.comboTargetCharStyle,
                       varname='TargetCharStyle',
                       data=charStyleDispNames)]
        for combo in self.combos:
            dutil.fill_list_ctrl(
                combo.ctrl, combo.data, userVars.get(combo.varname))

        dutil.fill_list_ctrl(
            self.listTargetStyleFont,
            styles.getListOfFonts(self.unoObjs, addBlank=True))
        logger.debug("Finished populating font and styles lists.")

        ## Other fields

        varname = 'SFM_Markers'
        if userVars.isEmpty(varname):
            defaultCtrlText = "\\tx \\mb"
            userVars.store(varname, defaultCtrlText)
            userVarVal = defaultCtrlText
        else:
            userVarVal = userVars.get(varname)
        self.txtSFM.setText(userVarVal)
        self.addRemainingListeners()
Ejemplo n.º 8
0
 def refreshListAndSelectItem(self, selItem):
     logger.debug(util.funcName('begin'))
     dutil.fill_list_ctrl(self.dlgCtrls.listboxFiles,
                          self.fileItems.getItemTextList(), str(selItem))
     try:
         self.selectedIndex = dutil.get_selected_index(
             self.dlgCtrls.listboxFiles)
         logger.debug("self.selectedIndex %d", self.selectedIndex)
         self.viewFile(False)
     except exceptions.ChoiceProblem:
         return
     logger.debug(util.funcName('end'))
Ejemplo n.º 9
0
 def addXpath(self):
     logger.debug(util.funcName('begin'))
     newValue = self.dlgCtrls.txtXpath.getText()
     newValue = newValue.strip()
     stringList = dutil.listbox_items(self.dlgCtrls.listXpaths)
     logger.debug(repr(stringList))
     if newValue in stringList:
         self.msgbox.display("This expression is already in the list.")
         return
     stringList.append(newValue)
     stringList.sort()
     dutil.fill_list_ctrl(self.dlgCtrls.listXpaths, stringList, newValue)
Ejemplo n.º 10
0
 def loadValues(self, userVars):
     selItem = userVars.get("EXREFNUM")
     all_refnums = self.evtHandler.app.getAllRefnums()
     dutil.fill_list_ctrl(self.comboRefnum, all_refnums, selItem)
     dutil.fill_list_ctrl(self.listboxRefnum, all_refnums, selItem)
     varname = "SearchFor"
     if not userVars.isEmpty(varname):
         if userVars.get(varname) == "RefNum":
             self.optSearchRefNum.setState(True)
         else:
             self.optSearchExisting.setState(True)
     self.addRemainingListeners()
 def addFile(self, filepath):
     newItem = BulkFileItem(self.app.userVars)
     newItem.filepath = filepath
     logger.debug("Adding item")
     try:
         self.fileItems.addItem(newItem)
     except exceptions.ChoiceProblem as exc:
         self.app.msgbox.displayExc(exc)
         return
     logger.debug("Successfully added.")
     dutil.fill_list_ctrl(listCtrl=self.listboxFiles,
                          values=self.fileItems.getItemTextList(),
                          selectedValue=str(newItem))
     if not self.outputTo.read():
         self.outputTo.fill(os.path.dirname(filepath))
Ejemplo n.º 12
0
    def loadValues(self, userVars, fileItems):

        ## Initialize checkboxes

        logger.debug("Initializing checkboxes")
        self.verifyCheckboxVarList()
        for ctrl, varname in self.CHECKBOX_VAR_LIST:
            if not userVars.isEmpty(varname):
                ## TESTME: does setting value to e.g. 5 make it crash?
                ctrl.setState(userVars.getInt(varname))

        ## Initialize list of files

        logger.debug("Initializing list of files")
        fileItems.loadUserVars()
        dutil.fill_list_ctrl(self.listboxFiles, fileItems.getItemTextList())

        ## Numbering column width

        logger.debug("Numbering column width")
        varname = "NumberingColWidth"
        if userVars.isEmpty(varname):
            userVars.store(varname, str(self.origNumColWidth))
        else:
            self.origNumColWidth = userVars.getInt(varname)
        self.txtNumColWidth.setText(self.origNumColWidth)

        ## Hidden options

        varname = "ComparisonDoc"
        if userVars.isEmpty(varname):
            userVars.store(varname, "1")  # default is True

        varname = "TableBottomMargin"
        if userVars.isEmpty(varname):
            userVars.store(varname, "0.13")

        ## Output method

        method = userVars.get("Method")
        if method == "tables":
            self.optTables.setState(True)

        self.addRemainingListeners()
    def gotoRow(self):
        """Go to a particular row in the spreadsheet and display its
        information in the dialog.
        """
        logger.debug(util.funcName('begin'))
        txtVal = self.dlgCtrls.txtRowNum.getText()
        lightRedColor = int("FF8888", 16)
        if txtVal.strip() == '':
            self.dlgCtrls.txtRowNum.getModel().BackgroundColor = lightRedColor
            return
        try:
            rowNum = int(txtVal)
        except ValueError:
            logger.warning("Couldn't parse '%s' as integer.", txtVal)
            self.dlgCtrls.txtRowNum.getModel().BackgroundColor = lightRedColor
            return
        if rowNum < 2 or rowNum > self.maxRow:
            self.dlgCtrls.txtRowNum.getModel().BackgroundColor = lightRedColor
            return
        self.dlgCtrls.txtRowNum.getModel().setPropertyToDefault(
            "BackgroundColor")
        if self.scrollbarAlreadyMoved:
            self.scrollbarAlreadyMoved = False
        else:
            self.dlgCtrls.scrollbarRow.setValue(rowNum)

        wordInList = self.app.gotoRow(rowNum)
        self.userVars.store("CurrentRow", str(rowNum))
        self.dlgCtrls.lblWordText.setText(wordInList.text)
        self.dlgCtrls.lblConvertedText.setText(wordInList.converted1)
        if wordInList.correction:
            self.dlgCtrls.txtCorrection.setText(wordInList.correction)
        else:
            self.dlgCtrls.txtCorrection.setText(wordInList.text)
        dutil.set_tristate_checkbox(self.dlgCtrls.chkIsCorrect,
                                    wordInList.isCorrect)
        dutil.fill_list_ctrl(self.dlgCtrls.listSimilarWords,
                             wordInList.similarWords)
        suggestions = []
        if self.app.wantSuggestions:
            suggestions = self.app.getSuggestions(wordInList.similarWords)
        dutil.fill_list_ctrl(self.dlgCtrls.listSuggestions, suggestions)
        logger.debug(util.funcName('end'))
    def loadValues(self, userVars, fileItems, disposeWhenFinished):
        logger.debug("Initializing list of files")
        fileItems.loadUserVars()
        dutil.fill_list_ctrl(self.listboxFiles, fileItems.getItemTextList())

        varname = 'Punctuation'
        if userVars.isEmpty(varname) and len(fileItems) == 0:
            punctToRemove = u" ".join(letters.PUNCTUATION)
            userVars.store(varname, punctToRemove)
        else:
            punctToRemove = userVars.get(varname)
        self.txtRemovePunct.setText(punctToRemove)

        varname = 'NormForm'
        if userVars.isEmpty(varname):
            userVars.store(varname, DEFAULT_NORM_FORM)

        if len(fileItems) == 0:
            self.btnMakeList.Label = theLocale.getText("Make Empty List")
        if not disposeWhenFinished:
            self.btnMakeList.Label = theLocale.getText("Get words")
    def loadValues(self, userVars):
        converter = ConverterSettings(userVars)
        converter.loadUserVars()
        self.txtConverterName.setText(converter.convName)
        self.chkDirectionReverse.setState(not converter.forward)
        self.chkVerify.setState(
            userVars.getInt('AskEachChange'))

        ## Option buttons

        dutil.selectRadio(self.radiosWhichScope, userVars.get('WhichScope'))
        dutil.selectRadio(self.radiosWhichTarget, userVars.get('WhichTarget'))
        dutil.selectRadio(self.radiosScopeFont, userVars.get('ScopeFontType'))
        dutil.selectRadio(
            self.radiosTargetFont, userVars.get('TargetFontType'))

        ## Combo box lists

        ComboTuple = collections.namedtuple(
            'ComboTuple', ['ctrl', 'varname', 'data'])
        self.combos = [
            ComboTuple(ctrl=self.comboScopeFont,
                       varname='ScopeFont',
                       data=styles.getListOfFonts(self.unoObjs))]
        for combo in self.combos:
            logger.debug("Filling Scope Font list.")
            #XXX: Sometimes hangs here.
            dutil.fill_list_ctrl(
                combo.ctrl, combo.data, userVars.get(combo.varname))

        logger.debug("Filling Target Font list.")
        dutil.fill_list_ctrl(
            self.listTargetFont,
            styles.getListOfFonts(self.unoObjs, addBlank=True))
        logger.debug("Finished populating font and styles lists.")

        ## Other fields

        self.addRemainingListeners()
    def addWhatToGrab(self, newObj):
        """Add newObj to the list."""
        logger.debug(
            util.funcName('begin',
                          args="len(self.thingsToGrab) = %d" %
                          len(self.thingsToGrab)))
        newObj.whichOne = newObj.whichOne.strip()
        for whatToGrab in self.thingsToGrab:
            if str(whatToGrab) == str(newObj):
                self.msgbox.display("%s is already in the list.",
                                    str(whatToGrab))
                return
        self.thingsToGrab.append(newObj)
        self.thingsToGrab.sort(key=str)

        stringList = [str(df) for df in self.thingsToGrab]
        dutil.fill_list_ctrl(self.dlgCtrls.listboxFields, stringList,
                             str(newObj))
        logger.debug(
            util.funcName('end',
                          args="len(self.thingsToGrab) = %d" %
                          len(self.thingsToGrab)))
 def fileAdd(self):
     logger.debug(util.funcName('begin'))
     newItem = WordListFileItem(self.userVars)
     dlgFile = DlgWordListFile(newItem, self.unoObjs, self.userVars)
     dlgFile.showDlg()
     ok = dlgFile.getResult()
     dlgFile.dlgDispose()
     if ok:
         logger.debug("Adding item text %s", newItem)
         try:
             self.fileItems.addItem(newItem)
         except exceptions.ChoiceProblem as exc:
             self.msgbox.displayExc(exc)
             return
         self.fileItems.storeUserVars()
         logger.debug("Successfully added.")
         dutil.fill_list_ctrl(
             self.dlgCtrls.listboxFiles, self.fileItems.getItemTextList(),
             str(newItem))
         if self.disposeWhenFinished:
             self.dlgCtrls.btnMakeList.Label = theLocale.getText(
                 "Make List")
     logger.debug("FileAdd end")
Ejemplo n.º 18
0
    def loadValues(self, userVars):
        exportType = userVars.get("ExportType")
        if exportType == "ReplacementCCT":
            self.optReplacementCCT.setState(True)
        elif exportType == "SFM_CCT":
            self.optSFM_CCT.setState(True)
        elif exportType == "XSLT":
            self.optXSLT.setState(True)

        self.txtXpath.setText("//gloss")
        varname = "XSLT_MatchPartial"
        if not userVars.isEmpty(varname):
            self.chkMatchPartial.setState(userVars.getInt(varname))

        ## Initialize list of Xpath expressions

        logger.debug("Initializing list of Xpath exprs")
        stringList = []
        num_exprs = userVars.getInt("XpathCount")
        for exprNum in range(0, num_exprs):
            varname = "XpathExpr%02d" % exprNum
            if not userVars.isEmpty(varname):
                stringList.append(userVars.get(varname))
        dutil.fill_list_ctrl(self.listXpaths, stringList)

        ## Other fields

        self.txtFilePath.setText(userVars.get("Filepath"))
        varname = "SFM_Markers"
        if userVars.isEmpty(varname):
            defaultCtrlText = "\\lx \\cf \\xv"
            userVars.store(varname, defaultCtrlText)
            userVarVal = defaultCtrlText
        else:
            userVarVal = userVars.get(varname)
        self.txtSFM.setText(userVarVal)
        self.addRemainingListeners()
Ejemplo n.º 19
0
    def loadValues(self, userVars, abbrevList):
        logger.debug(util.funcName('begin'))
        abbrevList.loadUserVars()
        dutil.fill_list_ctrl(self.listboxAbbrevs, abbrevList.getItemTextList())

        styleNames = styles.getListOfStyles("ParagraphStyles", self.unoObjs)
        displayNames = [dispName for dispName, name in styleNames]
        selectedValue = userVars.get("SearchParaStyle")
        if selectedValue == "":
            userVarsGrammar = UserVars(Prefix.GRAMMAR, self.unoObjs.document,
                                       logger)
            selectedValue = userVarsGrammar.get("StyleName_Gloss")
        dutil.fill_list_ctrl(self.cmbxSearchParaStyle, displayNames,
                             selectedValue)

        searchAffix = userVars.get("SearchAffix")
        if searchAffix == "suffix":
            self.optSearchSuffix.setState(True)
        elif searchAffix == "prefix":
            self.optSearchPrefix.setState(True)
        elif searchAffix == "any":
            self.optSearchAny.setState(True)

        varname = "MaxSearchLength"
        if userVars.isEmpty(varname):
            defaultCtrlText = "5"
            userVars.store(varname, defaultCtrlText)
            userVarVal = defaultCtrlText
        else:
            userVarVal = userVars.getInt(varname)
        self.txtMaxSearchLength.setText(userVarVal)

        if userVars.getInt("SearchUpperCase") == 1:
            self.chkSearchUpperCase.setState(True)

        self.addRemainingListeners()
        logger.debug(util.funcName('end'))
Ejemplo n.º 20
0
 def refreshList(self):
     dutil.fill_list_ctrl(self.dlgCtrls.listboxFiles,
                          self.fileItems.getItemTextList())
Ejemplo n.º 21
0
 def setFontList(self):
     logger.debug(util.funcName())
     self.script.setOnlyKnownFonts(self.chkKnownFonts.getState())
     selectedValue = self.script.getDefaultFont(self.comboFont.getText())
     dutil.fill_list_ctrl(self.comboFont, self.script.getFontList(),
                          selectedValue)
Ejemplo n.º 22
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'))
Ejemplo n.º 23
0
 def refreshList(self):
     dutil.fill_list_ctrl(self.dlgCtrls.listboxAbbrevs,
                          self.abbrevList.getItemTextList())
 def load_values(self):
     fontNames = styles.getListOfFonts(self.app.unoObjs, addBlank=True)
     dutil.fill_list_ctrl(self.comboFontName, fontNames)