def initWorkSpace(self): workspace = kalamconfig.get("workspace")(self) workspace.setBackgroundColor(kalamconfig.get("mdibackground")) self.connect(qApp, PYSIGNAL("sigmdibackgroundChanged"), workspace.setBackgroundColor) self.setCentralWidget(workspace) return workspace
def __init__(self, parent, doc, *args): apply(QWidget.__init__, (self, parent) + args) self.layout = QHBoxLayout(self) self.editor = KalamMultiLineEdit(self) self.editor.setFont(kalamconfig.get("textfont")) self.setWordWrap(kalamconfig.get("wrapmode")) self.setBackgroundColor(kalamconfig.get("textbackground")) self.setTextColor(kalamconfig.get("textforeground")) self.layout.addWidget(self.editor) self.doc = doc self.editor.setText(self.doc.text()) self.connect(self.doc, PYSIGNAL("sigDocTitleChanged"), self.setCaption) self.connect(self.doc, PYSIGNAL("sigDocTextChanged"), self.setText) self.connect(self.editor, SIGNAL("textChanged()"), self.changeDocument) # Note connecting a signal to a python signal self.connect(self.editor, SIGNAL("returnPressed()"), self, PYSIGNAL("returnPressed")) self.connect(qApp, PYSIGNAL("siglinewidthChanged"), self.editor.setWrapColumnOrWidth) self.connect(qApp, PYSIGNAL("sigwrapmodeChanged"), self.setWordWrap) self.connect(qApp, PYSIGNAL("sigtextfontChanged"), self.editor.setFont) self.connect(qApp, PYSIGNAL("sigtextforegroundChanged"), self.setTextColor) self.connect(qApp, PYSIGNAL("sigtextbackgroundChanged"), self.setBackgroundColor) self._propagateChanges = TRUE self.editor.setFocus()
def runStartup(self): """Run a Python script using the macro manager. Which script is run is defined in the configuration variables macrodir and startup. """ startupScript = os.path.join(kalamconfig.get("macrodir"), kalamconfig.get("startupscript")) startup = open(startupScript).read() self.createMacro("startup", startup) self.macroManager.executeMacro("startup")
def __init__(self, parent=None, name=None, modal=0, fl=0): FrmSettings.__init__(self, parent, name, modal, fl) self.textFont = kalamconfig.get("textfont") self.textBackgroundColor = kalamconfig.get("textbackground") self.textForegroundColor = kalamconfig.get("textforeground") self.MDIBackgroundColor = kalamconfig.get("mdibackground") self.initEditorTab() self.initInterfaceTab() self.initDocumentTab()
def initEditorTab(self): self.txtEditorPreview.setFont(self.textFont) pl = self.txtEditorPreview.palette() pl.setColor(QColorGroup.Base, self.textBackgroundColor) pl.setColor(QColorGroup.Text, self.textForegroundColor) self.cmbLineWrapping.setCurrentItem(kalamconfig.get("wrapmode")) self.spinLineWidth.setValue(kalamconfig.get("linewidth")) self.connect(self.bnBackgroundColor, SIGNAL("clicked()"), self.slotBackgroundColor) self.connect(self.bnForegroundColor, SIGNAL("clicked()"), self.slotForegroundColor) self.connect(self.bnFont, SIGNAL("clicked()"), self.slotFont)
def setWordWrap(self, wrapmode): if wrapmode == 0: self.editor.setWordWrap(QMultiLineEdit.NoWrap) elif wrapmode == 1: self.editor.setWordWrap(QMultiLineEdit.WidgetWidth) else: self.editor.setWordWrap(QMultiLineEdit.FixedColumnWidth) self.editor.setWrapColumnOrWidth(kalamconfig.get("linewidth"))
def initEncodingCombo(self): self.cmbEncoding.clear() encodings = kalamconfig.codecsDictionary.keys() encodings.sort() try: currentIndex = encodings.index(kalamconfig.get("encoding")) except: currentIndex = 0 Config.encoding = encodings[0] self.cmbEncoding.insertStrList(encodings) self.cmbEncoding.setCurrentItem(currentIndex)
def main(args): app = QApplication(args) translator = QTranslator(app) translator.load("kalam_" + locale.getlocale()[0] + ".qm", kalamconfig.get("libdir", ".")) app.installTranslator(translator) kalam = KalamApp() app.setMainWidget(kalam) kalam.show() if len(args) > 1: for arg in args[1:]: document = KalamDoc() document.open(arg) kalam.docManager.addDocument(document, KalamView) app.exec_loop()
def save(self, fileName=None, format=None): if fileName is not None and fileName <> "": self.setPathName(fileName) if self.pathName() == None: raise IOError("Could not save document: no filename.") if isinstance(self.pathName(), QString): self.setPathName(str(self.pathName())) s = str(self.text()) f = open(self.pathName(), "w") f.write(s) if kalamconfig.get("forcenewline"): if s[-1:] != "\n": f.write("\n") f.flush() self._modified = FALSE
def initSettings(self): qApp.setStyle(kalamconfig.get("style")()) self.setGeometry(kalamconfig.get("app_x"), kalamconfig.get("app_y"), kalamconfig.get("app_w"), kalamconfig.get("app_h"))
def slotHelpAbout(self): QMessageBox.about( self, "About...", "Kalam Unicode Editor\n" + "Version: " + kalamconfig.get("APPVERSION") + "\n\n" + "(c) 2001 by Boudewijn Rempt")
def initDocumentTab(self): self.initEncodingCombo() self.chkAddNewLine.setChecked(kalamconfig.get("forcenewline"))
def setStyle(self, style): kalamconfig.set("style", str(style)) qApp.setStyle(kalamconfig.get("style")())