

Self.LOCAL_INFO_LOG( "notebook:notes:keep_open:"+_CMD ) Self.KEEP_OPEN = True if _CMD = "1" else False Self.UPDATE_TIMER.singleShot( 1000, self.UPDATE_FRAME )


For example, the user clicked in the button1, the progressBox must receive a string like 'user clicked the button1'. ('Edit this word and save to your dictionary.')įor i, d in enumerate(self.dictionaries): Add text to QPlainTextEdit in PyQT (the result is a status log) I am trying to build a StatusLog, every move that happens on an application. nnect(self.add_button, SIGNAL("clicked()"), self.save_word) Self.disconnect(self.add_button, SIGNAL("clicked()"), self.add_word) Also, to use a text browser without hypertext navigation, use QTextEdit setReadOnly() to make. ('Word %s has been added successfully.' % To use the editable rich-text editor, you must use QTextEdit. Translation=translation, phoneme=phoneme, pos=pos, Return dict(dictionary=current_dict, original=original, "'Original', 'Translation' and 'Parts of " QMessageBox.critical(self, "Error", "You must enter at least " Synonyms = unicode(()).strip()Īntonyms = unicode(()).strip()ĭescription = unicode(()).strip() nnect(self.add_button, SIGNAL("clicked()"), self.add_word)Ĭurrent_(',') if len(p) > 0])Ĭurrent_dict = nnect(self.close_button, SIGNAL("clicked()"), self.close) nnect(self.dictionary, SIGNAL("currentIndexChanged(int)"), Self.status = QLabel('Add a new word to a dictionary.') Self.close_button = QPushButton("&Close") Vbox.addWidget(QLabel("Parts of Speech")) Super(AddWordWidget, self)._init_(parent=parent)
Pyqt plain text editor code#
"File " + file_name + " written to disk", To create a GUI for your windows and dialogs in PyQt, you can take two main paths: you can use Qt Designer, or you can hand code the GUI in plain Python. ("\nRunning script:\n")įile_name = QFileDialog.getSaveFileName(self, "Save File to Disk", ".", "*.py")įile.write(str(())) Gui.button(button_box, self, "Save Script to File", callback=self.save_script, height=35) Gui.button(button_box, self, "Run Script", callback=self.execute_script, height=35) nsole = PythonConsole(self._dict_, self)Ĭonsole_box.layout().addWidget(nsole)īutton_box = oasysgui.widgetBox(script_box, "", addSpace=False, orientation="horizontal") Script_box.layout().addWidget(self.pythonScript)Ĭonsole_box = oasysgui.widgetBox(script_box, "", addSpace=False, orientation="vertical", height=150, width=750) Script_box = oasysgui.widgetBox(self, "", addSpace=False, orientation="vertical", height=545, width=750) Use setText() to display the word number on the second (False) # asked by Manolo Len (text.split()) is the number of words in text. Split() converts words in a string into a list. Text_changed method is called, the text in the text editor (self.te) is stored in the text variable using the toPlainText() method. Using a vertical box layout, place two labels and one text editor in a vertical direction. Whenever text in a text editor is modified, text_changed method is called. The label below displays the word number.

If setAcceptRichText is false, it is all recognized as plain text. I created a text editor using the QTextEdit() class. Related course: Create Desktop Apps with Python PyQt5ĭescription self.lbl1 = QLabel('Enter your sentence:') When you type text in a text editor, display the number of words below. ('The number of words is ' + str(len(text.split()))) Self.lbl2 = QLabel('The number of words is 0') Self.lbl1 = QLabel('Enter your sentence:') import sysįrom PyQt5.QtWidgets import QApplication, QWidget, QLabel, QTextEdit, QVBoxLayout Let's create a simple program that displays word numbers using two labels and one text editor. The QTextEdit class provides an editor for editing and displaying both plain text and rich text.
