本文整理汇总了Python中kivy.uix.stacklayout.StackLayout.size_hint方法的典型用法代码示例。如果您正苦于以下问题:Python StackLayout.size_hint方法的具体用法?Python StackLayout.size_hint怎么用?Python StackLayout.size_hint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.uix.stacklayout.StackLayout
的用法示例。
在下文中一共展示了StackLayout.size_hint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build
# 需要导入模块: from kivy.uix.stacklayout import StackLayout [as 别名]
# 或者: from kivy.uix.stacklayout.StackLayout import size_hint [as 别名]
def build(self):
main_layout = BoxLayout(orientation='vertical', padding=20) # create a main layout object called "main_layout"
header_layout = StackLayout() # create a StackLayout called header_layout
# add a size_hint attribute to the header_layout, this will tell the parent layout which
# proportions it should use when sizing the header_layout with respect to it's neighbors
header_layout.size_hint = (1, .2)
title = Label(text='KIVY MPC') # create a Label called title with the text "KIVY MPC"
header_layout.add_widget(title) # add title to header_layout
main_layout.add_widget(header_layout) # add the header_layout to the main_layout
grid_layout = GridLayout(cols=4) # create a grid layout to contain the drum pads
generate_buttons(grid_layout) # pass the grid_layout to the generate_buttons function in order to create the 16 buttons
main_layout.add_widget(grid_layout) # add the grid layout
return main_layout # return the main_layout to the kivy environment