我在“DataClass”中有主窗口。如何在另一个类(HelloClass)中创建小部件
测试.py
import sys
import label
from PyQt4 import QtGui, QtCore
class DataClass(QtGui.QMainWindow):
def __init__(self):
super(DataClass, self).__init__()
self.window()
def window(self):
ex=label.HelloClass(self)
ex.print_label()
def main():
app = QtGui.QApplication(sys.argv)
ob=DataClass()
ob.show()
sys.exit(app.exec_())
if __name__=='__main__':
main()
这是'label.py'文件:
import sys
from PyQt4 import QtGui, QtCore
class HelloClass(QtGui.QMainWindow):
def print_label(self):
self.la=QtGui.QLabel("hello",self)
self.la.move(300,100)
self.la.show()
import sys
from PyQt4 import QtGui, QtCore
class HelloClass(QtGui.QMainWindow):
def print_label(self):
self.la=QtGui.QLabel("hello",self)
self.la.move(300,100)
self.la.show()