I am learning PyQt and coming from webdesign, so excuse this question, which should have a very obvious answer. Therefore, I am creating a PyQt application, and I would like to extend the methods to multiple files to fit different parts of the GUI. How can I access the text field located in the A..py file from the file.
import sys
from PyQt4 import QtGui, QtCore
from gui1 import Ui_MainWindow
import fileB
class MyApp(QtGui.QMainWindow, Ui_MainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
Ui_MainWindow.__init__(self)
self.setupUi(self)
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
window = MyApp()
window.show()
def pressed():
window.plainTextEdit.appendPlainText("Hello")
window.pushButton.pressed.connect(pressed)
window.button2.pressed.connect(fileB.func3)
sys.exit(app.exec_())
Now in this file I would like to use the text box from file.pp
import fileA
def func3():
print "hello"
fileA.window.plainTextEdit.appendPlainText("Hello")
What am I doing wrong? What would be the best way to extend functionality to multiple files if not for this?
Thanks for taking the time to read this.
source
share