我是 Kivy 的新手,但能够创建一个单屏应用程序。在我需要添加更多屏幕之前,一切看起来都不错。一页应用程序显示正确,但是当我添加屏幕时,BoxLayouts 不再按我预期的那样工作。所有小部件都在屏幕底部相互叠加。我的问题是我在实施 ScreenManager 时做错了什么?
单屏应用程序如下所示:
我决定将其设为多屏,但是当我添加 ScreenManager 逻辑时,生成的屏幕如下所示:
我的 main.py 文件如下所示:
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.uix.popup import Popup
from kivy.properties import ObjectProperty
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition
class Pay_screen(Screen):
pass
class Survey_screen(Screen):
pass
class Finish_screen(Screen):
pass
class Sm(ScreenManager):
pass
class Next_root(BoxLayout):
pass
class Nq_disagree_label(Label):
pass
class Nq_question_label(Label):
pass
class Nq_button(Button):
pass
class survey_form(BoxLayout):
#dept_button = ObjectProperty()
def send_survey(self):
mypopup = MyPopup()
mypopup.show_popup('Survey', 'Survey sent!', 'OK!')
def add_comment(self):
mypopup = MyPopup()
mypopup.show_popup('Comment', 'This is where a comment is added.', 'OK!')
def close_app(self):
App.get_running_app().stop()
class MyPopup(Popup):
def show_popup(self, title_text, label_text, button_text):
mytext= label_text
content = BoxLayout(orientation="vertical")
content.add_widget(Label(text=mytext, font_size=20, text_size=(300, None)))
mybutton = Button(text="Ok!", size_hint=(1,.20), font_size=20)
content.add_widget(mybutton)
mypopup = Popup(content = content,
title = title_text,
auto_dismiss = False,
size_hint = (.5, .5)) #,
#font_size = 20)
mybutton.bind(on_press=mypopup.dismiss)
mypopup.open()
class nextqualApp(App):
icon = 'nextqual.png'
title = 'Pay / survey / join'
if __name__ == '__main__':
nextqualApp().run()
相关分类