【发布时间】:2016-03-09 10:10:40
【问题描述】:
<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 文件中有两个小部件: - HomePage - 这继承自 Screen 并具有 screen.manager 属性,用于管理屏幕转换 - LowerBoxNav - 这是一个盒子布局。本质上,我希望在每一页上都有这种布局。框布局中有 2 个按钮 - LoginButtonsApp 和 NextButtonsApp。
我的问题如下: - 使用上面的代码,我得到错误 AttributeError: 'LowerBoxNav' object has no attribute 'manager' - 我还尝试为 HomePage 屏幕中 LowerBoxNav 小部件中的每个按钮添加 on_press - 在这种情况下,我每个按钮都有 2 个
如果能在我的应用程序的每个屏幕上基本上拥有相同的 LowerBoxNav,我们将不胜感激。
【问题讨论】: