【发布时间】:2016-09-24 17:35:36
【问题描述】:
我正在尝试使用一些菜单切换按钮创建屏幕,然后创建一个嵌套的屏幕管理器,我只能在容器内切换屏幕管理器,并将菜单留在容器外。当我使用 Boxlayouts 和 Gridlayouts 的组合时,一切都在彼此之上。
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.label import Label
from kivy.graphics.context_instructions import Color
from kivy.uix.screenmanager import Screen, ScreenManager
class ScreenManagement(FloatLayout):
pass
class IomApp(App):
def build(self):
return ScreenManagement()
if __name__ == '__main__':
IomApp().run()
基维文件:
<LabelCases@Label>:
height: '40dp'
font_size: 18
<TextInputCases@TextInput>:
height: '40dp'
size_hint_y: None
font_size: 18
write_tab: False
multiline: False
on_text_validate: root.foo()
<ScreenManagement>:
BoxLayout:
orientation: "vertical"
BoxLayout:
height: "80dp"
size_hint_y: None
Label:
text: 'Patient info Label'
BoxLayout:
orientation: 'horizontal'
BoxLayout:
orientation: 'vertical'
size_hint_x: 20
ToggleButton:
text: 'Case Info'
group: 'g1'
on_screen:
ToggleButton:
text: 'Modalities'
group: 'g1'
ToggleButton:
text: 'Report Editing'
group: 'g1'
ToggleButton:
text: 'Printing/Exporting'
group: 'g1'
ToggleButton:
text: 'Settings'
group: 'g1'
BoxLayout:
orientation: 'vertical'
size_hint_x: 80
ScreenManager:
id: "Screen1"
Screen:
name: "Case_info_screen"
BoxLayout:
orientation: 'vertical'
spacing: 20
orientation: 'vertical'
size_hint: (.5, .5)
pos_hint: {'center_x':.5, 'center_y':.5}
Label:
text: "Case Info"
size_hint_y: 25
GridLayout:
cols: 2
padding: 50
spacing: 15
size_hint_y: 50
LabelCases:
text: 'First Name: '
TextInputCases:
LabelCases:
text: 'Last Name: '
TextInputCases:
LabelCases:
text: 'MRN: '
TextInputCases:
LabelCases:
text: 'Date of Birth: '
TextInputCases:
LabelCases:
text: 'Hospital: '
TextInputCases:
LabelCases:
text: 'Diagnosis: '
TextInputCases:
Label:
text: "Surgical and Techical Staff"
size_hint_y: 25
BoxLayout:
Button:
height: "40dp"
size_hint_y: None
text: "Back"
Button:
height: "40dp"
size_hint_y: None
text: "Next"
【问题讨论】:
标签: python-3.x kivy