PYQT中的屏幕功能

时间:2017-08-30 07:11:26

标签: pyqt

import sys
from PyQt4 import QtCore, QtGui, uic
from PyQt4.QtGui  import *
from PyQt4.QtCore import *
import time
import datetime
import re
import random
import csv
from CropClass import *
from Wheat_class import *
from Potato_class import *

win1 = uic.loadUiType("MenuScreen.ui")[0]
win2 = uic.loadUiType("WheatScreen.ui")[0]
win3 = uic.loadUiType("PotatoScreen.ui") [0]
class MenuScreen(QtGui.QMainWindow, win1):
    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self, parent)            
        self.setupUi(self)
        self.BtnCreateSimulation.clicked.connect(self.changeSimulation)
    def changeSimulation(self):

        if self.RdoWheat.isChecked() ==True:
            print("Wheat is picked")
            new_crop=Wheat()   
            self.wheatSimulation()
        elif self.RdoPotato.isChecked() == True:
            print("Potato is picked")
            new_crop = Potato()
            self.PotatoSimulation()
    def wheatSimulation(self):
        print("Hello")
        self.hide()
        WheatWindow.show()
    def PotatoSimulation(self):
        self.hide()
        PotatoWindow.show()

class PotatoScreen(QtGui.QMainWindow, win3):
     def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self, parent)            
        self.setupUi(self)

        self.BtnBacktoMenu.clicked.connect(self.BackToMain)
     def BackToMain(self):
        self.hide()
        MenuWindow.show()
class WheatScreen(QtGui.QMainWindow, win2):
    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self, parent)            
        self.setupUi(self)
        new_crop = Wheat()
        self.BtnBacktoMenu.clicked.connect(self.BackToMain)
        self.BtnManual.clicked.connect(self.ManualCalculate)

    def BackToMain(self):
        self.hide()
        MenuWindow.show()
    def ManualCalculate(self):
        water = self.spBoxWater.value()
        light= self.spBoxLight.value()
        print("water", water, "light", light) 



def main():
    app = QtGui.QApplication(sys.argv)
    WheatWindow = WheatScreen(None)
    PotatoWindow = PotatoScreen(None)
    MenuWindow = MenuScreen(None)   
    MenuWindow.show()
    app.exec_()

if __name__ == "__main__":
    main()            

我用Python创建了一个模拟作物生长速度的程序。用户可以在作物是小麦或土豆之间进行选择,我正在尝试使用PYQT创建GUI。我遇到的问题是,当我尝试加载程序时,程序无法识别其他屏幕布局。主要功能应该是设置屏幕布局

0 个答案:

没有答案