【发布时间】:2015-01-12 01:36:39
【问题描述】:
所以我有两个框架,第一个框架包含所有标题元素,第二个框架包含一个带有两个按钮的图像。这是我第一个屏幕的内容。现在,当我单击按钮时,第二帧中的内容应替换为具有属性列表的 .py 文件。第一帧内容在所有屏幕中都相同,只有第二帧应该改变。这是我在第一个屏幕上的代码:
import sys
import os
import taurus
from PyQt4 import QtCore, QtGui, uic
from taurus.external.qt import Qt
from taurus.qt.qtgui.panel import TaurusForm
from taurus.qt.qtgui.application import TaurusApplication
form_class = uic.loadUiType("FirstScreen.ui")[0] # Load the UI
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
_fromUtf8 = lambda s: s
class MyWindowClass(QtGui.QMainWindow, form_class):
def __init__(self, parent=None):
QtGui.QMainWindow.__init__(self, parent)
self.setupUi(self)
#self.editValue.clicked.connect(self.openForm_clicked)
self.setWindowTitle('FirstScreen')
self.button1.setStyleSheet("QPushButton { background-color:#00FFFF;}")
self.dateTime.setText(QtCore.QDate.currentDate().toString())
self.timeLabel.setText(QtCore.QTime.currentTime().toString())
self.button2.setStyleSheet("QPushButton { background-color:#00FFFF;}")
myPixmap = QtGui.QPixmap(_fromUtf8('Sample.png'))
myPixmap=myPixmap.scaledToHeight(100)
self.pic.setPixmap(myPixmap)
app = QtGui.QApplication(sys.argv)
myWindow = MyWindowClass(None)
myWindow.show()
app.exec_()
您能否告诉我如何在单击按钮时使用 .py 文件加载第二帧。我尝试加载的另一个 .py 文件也是使用 Pyqt 创建的。
【问题讨论】: