This is a demo Python project using Python (of course), PyCharm and QtDesigner.
The Start button works OK but I can’t find out the proper syntax to be able to append text to the textEdit widget from the main_proc() function.
Please have a look at the notes within the code below:
import sys
from PyQt5.QtWidgets import *
from PyQt5 import uic
class PlotGUI(QMainWindow):
def __init__(self):
super(PlotGUI, self).__init__()
uic.loadUi("PlotGUI.ui", self)
self.show()
self.pushButton_Start.clicked.connect(main_proc)
self.textEdit_log.append("Hi!") # >>>>>>>>>>>>>>> This one works OK
def main_proc():
print("Appended Text") # This appends text to the 'regular' text output console (ou sort of).
# >>>>>>>>>>>>>>> I need to append text to textEdit_log from here <<<<<<<<<<<<<<<<<<<
def main():
app = QApplication([])
window = PlotGUI()
app.exec_()
if __name__ == '__main__':
main()
Could I have some help please?
I will try to upload a .rar with the all the related files, I don’t know yes if it is possible. [looks like it is not]
Thanks
H. Martins
Well, I have lots of code already written called by main_proc and I need not only to interact reading widget contents there but also in several other functions.
The code needs to read the content of several widgets (that do not change after the Start button is pressed).
At the moment I do all that changing variable content in declaration but I would like to ‘humanise’ using, say Windows style interfacing.
class PlotGUI(QMainWindow):
def __init__(self):
super(PlotGUI, self).__init__()
uic.loadUi("PlotGUI.ui", self)
self.show()
global txt_log # <<<<<<<<<<<<<< these two lines
txt_log = self.textEdit_log # <<<<<<<<<<<<<< these two lines
Then a small aggregating (append + repaint) function