ボタンをクリックすると、別の画面を呼び出すボタンで簡単な画面が作成されました。レイアウトを切り替える
私は多くを検索しました。しかし、私はまだこれを行うことはできません: **私は2つのレイアウトを切り替えることができますので、私はtest.pyのボタンをクリックすると、レイアウトがscherm.pyに変更されるように**
test.py
from PyQt4 import QtCore, QtGui
import subprocess
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName(_fromUtf8("Form"))
Form.resize(400, 300)
self.Button = QtGui.QPushButton(Form)
self.Button.setGeometry(QtCore.QRect(50, 40, 261, 231))
self.Button.setObjectName(_fromUtf8("Button"))
self.Button.clicked.connect(self.fun)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
Form.setWindowTitle(_translate("Form", "Form", None))
self.Button.setText(_translate("Form", "Button", None))
def fun(self):
subprocess.call(" scherm.py 1", shell=True)
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
Form = QtGui.QWidget()
ui = Ui_Form()
ui.setupUi(Form)
Form.show()
sys.exit(app.exec_())
scherm.py
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_PlaatjesScherm(object):
def setupUi(self, PlaatjesScherm):
PlaatjesScherm.setObjectName(_fromUtf8("PlaatjesScherm"))
PlaatjesScherm.resize(654, 528)
self.retranslateUi(PlaatjesScherm)
QtCore.QMetaObject.connectSlotsByName(PlaatjesScherm)
def retranslateUi(self, PlaatjesScherm):
PlaatjesScherm.setWindowTitle(_translate("PlaatjesScherm", "Plaatjes", None))
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
PlaatjesScherm = QtGui.QWidget()
ui = Ui_PlaatjesScherm()
ui.setupUi(PlaatjesScherm)
PlaatjesScherm.show()
sys.exit(app.exec_())