<LowerBoxNav>:
BoxLayout:
orientation: 'horizontal'
LoginButtonsApp:
size_hint_x:0.5
pos_hint_x: 0.2
pos_hint_y: 0.2
on_press:
root.manager.current='LoginScreen#'
NextButtonsApp:
size_hint_x:0.5
pos_hint_x: 0.2
pos_hint_y: 0.2
on_press:
root.manager.current='ScreenThree#'
<HomePage>:
LayoutsApp:
LabelsApp:
pos_hint: {'center_x': .5, 'center_y': .7}
text: root.homepageusernametext
NextButtonsApp:
pos_hint: {'center_x': .5, 'center_y': .5}
on_press:
root.manager.current='ScreenThree#'
LowerBoxNav:
我在一个.kv文件中有两个小部件: -主页-它继承自Screen并具有屏幕管理器属性,用于管理屏幕转换 -LowerBoxNav-这是一个方框布局。基本上,我希望每个页面都有这样的布局。有两个按钮-LoginButtonApp和NextButtonsApp,它们位于框布局中。在
我的问题是: -使用上面的代码,我得到错误AttributeError:'LowerBoxNav'对象没有属性'manager' -在每个小部件内都尝试了在每个小部件的主页内添加按钮
如果能在我的应用程序的每个屏幕上都有相同的LowerBoxNav,我将非常感激。在
root
表示<;>中的规则或小部件,对您来说意味着BoxLayout
,因此没有可用的manager
,您将得到AttributeError
您必须通过
Screen
小部件访问manager
属性,或者为自己制定一个规则,其中Screen在顶部,BoxLayout
在其中。而且,Screen
必须是ScreenManager
的子级,否则它将无法工作。在编辑:将
root.manager.current
更改为root.parent.manager.current
给屏幕管理器一个sm的id,然后将按钮设置为on-tu-press:app.root.ids.sm.电流=“不管怎样”。然后确保使用名称定义页面并将该名称传递给屏幕管理器。例如,在你的第三屏的kv文件中
^{pr2}$相关问题 更多 >
编程相关推荐