当前位置: 首页>>代码示例>>Python>>正文


Python StackLayout.size_hint方法代码示例

本文整理汇总了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
开发者ID:alexgustafson,项目名称:kivy_mpc,代码行数:22,代码来源:main.py


注:本文中的kivy.uix.stacklayout.StackLayout.size_hint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。