Reading Ui File And Connecting Elements Such As Buttons, Text, Etc
I'm looking at using PySide2, but reading UI files, instead of generating Python via pyside2-uic. Strangely, I can't seem to find an example of this simple connectivity. I see th
Solution 1:
According to the XML the button name is btnTest:
<widgetclass="QPushButton"name="btnTest">
So you must use that name to access the button:
import sys
from PySide2 import QtWidgets, QtUiTools
if __name__ == "__main__":
print("Program start.")
app = QtWidgets.QApplication(sys.argv)
loader = QtUiTools.QUiLoader()
window = loader.load("test.ui", None)
window.btnTest.clicked.connect(lambda: print("clicked"))
window.show()
sys.exit(app.exec_())
Post a Comment for "Reading Ui File And Connecting Elements Such As Buttons, Text, Etc"