我正在尝试制作一个简单的数学测验游戏,显示数字,当我按空格键显示结果时,首先使用QTdyalog GUI启动应用程序,在完成配置游戏后,应显示Kivy屏幕和游戏开始直到用户按下escape它返回到配置GUI 这是程序框架
import kivy
from kivy.app import App
from kivy.uix.label import Label
import sys
from PyQt4 import QtCore, QtGui, uic
qtCreatorFile = "ConfigForm.ui" # Enter file here.
Ui_MainWindow, QtBaseClass = uic.loadUiType(qtCreatorFile)
class Playy(App): #the Kivy app
def build(self):
l = Label(text='Hello world')
return l
class Conf(QtGui.QDialog, Ui_MainWindow): #the COnfiguration Gui
def __init__(self):
QtGui.QMainWindow.__init__(self)
Ui_MainWindow.__init__(self)
self.setupUi(self)
self.buttonBox.accepted.connect(self.oky)
self.buttonBox.rejected.connect(self.notok)
def oky(self):
print "OK OK OK OK" #creating a Kivy app instance and running it
ins = Playy()
ins.run()
def notok(self):
print "cancel cancel"
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
window = Conf()
window.show()
sys.exit(app.exec_())
我只有在Kivy应用程序类中创建函数并将参数传递给它们以及处理诸如标签文本之类的对象属性的问题这是我的第一个Kivy实验告诉我你的想法