我是 Kivy 的新手,但能够创建一个单屏应用程序。在我需要添加更多屏幕之前,一切看起来都不错。一页应用程序显示正确,但是当我添加屏幕时,BoxLayouts 不再按我预期的那样工作。所有小部件都在屏幕底部相互叠加。我的问题是我在实施 ScreenManager 时做错了什么?单屏应用程序如下所示:我决定将其设为多屏,但是当我添加 ScreenManager 逻辑时,生成的屏幕如下所示:我的 main.py 文件如下所示:from kivy.app import Appfrom kivy.uix.boxlayout import BoxLayoutfrom kivy.uix.label import Labelfrom kivy.uix.button import Buttonfrom kivy.uix.popup import Popupfrom kivy.properties import ObjectPropertyfrom kivy.uix.screenmanager import ScreenManager, Screen, FadeTransitionclass Pay_screen(Screen): passclass Survey_screen(Screen): passclass Finish_screen(Screen): passclass Sm(ScreenManager): passclass Next_root(BoxLayout): passclass Nq_disagree_label(Label): passclass Nq_question_label(Label): passclass Nq_button(Button): passclass 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()
添加回答
举报
0/150
提交
取消