{"id":3762,"date":"2018-06-09T18:14:36","date_gmt":"2018-06-09T09:14:36","guid":{"rendered":"https:\/\/www.ws-meguro.com\/\/?p=3762"},"modified":"2018-06-09T19:16:29","modified_gmt":"2018-06-09T10:16:29","slug":"youtube%e3%81%a7derek%e3%81%95%e3%82%93%e3%81%ab%e3%82%88%e3%82%8bkivy-tutorial%e3%82%92%e5%ad%a6%e3%81%b6%e2%91%a1%ef%bc%88kivy-uix-boxlayout%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.wsmeguro.jp\/wp\/?p=3762","title":{"rendered":"YouTube\u3067Derek\u3055\u3093\u306b\u3088\u308bKivy Tutorial\u3092\u5b66\u3076\u2461\uff08kivy.uix.boxlayout\uff09"},"content":{"rendered":"<p>\u5f15\u304d\u7d9a\u304d\u3001\uff12\u56de\u76ee\u3001kivy.uix.boxlayout\u306b\u3064\u3044\u3066\u3068\u306a\u308a\u307e\u3059\u3002<br \/>\n<div class=\"lyte-wrapper fourthree\" title=\"Kivy Tutorial 2\" style=\"width:480px;max-width:100%;margin:5px;\"><div class=\"lyMe\" id=\"WYL_j9PqNe3J_Cc\" itemprop=\"video\" itemscope itemtype=\"https:\/\/schema.org\/VideoObject\"><div><meta itemprop=\"thumbnailUrl\" content=\"https:\/\/i.ytimg.com\/vi\/j9PqNe3J_Cc\/hqdefault.jpg\" \/><meta itemprop=\"embedURL\" content=\"https:\/\/www.youtube.com\/embed\/j9PqNe3J_Cc\" \/><meta itemprop=\"duration\" content=\"PT20M40S\" \/><meta itemprop=\"uploadDate\" content=\"2016-10-08T11:31:52.000Z\" \/><\/div><div id=\"lyte_j9PqNe3J_Cc\" data-src=\"https:\/\/i.ytimg.com\/vi\/j9PqNe3J_Cc\/hqdefault.jpg\" class=\"pL\"><div class=\"tC\"><div class=\"tT\" itemprop=\"name\">Kivy Tutorial 2<\/div><\/div><div class=\"play\"><\/div><div class=\"ctrl\"><div class=\"Lctrl\"><\/div><div class=\"Rctrl\"><\/div><\/div><\/div><noscript><a href=\"https:\/\/youtu.be\/j9PqNe3J_Cc\" rel=\"nofollow\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i.ytimg.com\/vi\/j9PqNe3J_Cc\/0.jpg\" alt=\"Kivy Tutorial 2\" width=\"480\" height=\"340\" \/><br \/>\u3053\u306e\u52d5\u753b\u3092 YouTube \u3067\u8996\u8074<\/a><\/noscript><meta itemprop=\"description\" content=\"Code &amp; Transcript : https:\/\/goo.gl\/iBjKjm Best Kivy Book : http:\/\/amzn.to\/2duPAFD Support me on Patreon : https:\/\/www.patreon.com\/derekbanas In part 2 of my Kivy tutorial series we&#039;ll explore much of what we need to know before we start making apps in the next video. We&#039;ll cover creating custom widgets, setting default attributes, and 6 layouts being : Absolute Positioning, Floating Layout, Grid Layout, Box Layout, Stack Layout, and Page Layout. If you missed any of the previous Python videos, the series starts here : https:\/\/www.youtube.com\/playlist?list=PLGLfVvz_LVvTn3cK5e6LjhgGiSeVlIRwt Thank you to Patreon supports like the following for helping me make this video https:\/\/www.facebook.com\/cottageindustriesbuild\/ @kyleaisho @thetwistedhat vjFaLk\"><\/div><\/div><div class=\"lL\" style=\"max-width:100%;width:480px;margin:5px;\"><\/div><br \/>\n\u305d\u306e\u307e\u307e\u8f09\u305b\u3066\u3082\u3064\u307e\u3093\u306a\u3044\u306e\u3067\u3001\u3061\u3087\u3063\u3068\u3060\u3051\u624b\u3092\u5165\u308c\u305f\u753b\u9762\u306f\u3053\u3093\u306a\u611f\u3058\u3067\u3059\u3002<br \/>\n<a href=\"https:\/\/www.wsmeguro.jp\/\/wp\/wp-content\/uploads\/2018\/06\/a59fc2a6545452ea8c0f7b356cbc4b70.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.wsmeguro.jp\/\/wp\/wp-content\/uploads\/2018\/06\/a59fc2a6545452ea8c0f7b356cbc4b70.png\" alt=\"\" width=\"798\" height=\"626\" class=\"aligncenter size-full wp-image-3765\" srcset=\"https:\/\/www.wsmeguro.jp\/wp\/wp-content\/uploads\/2018\/06\/a59fc2a6545452ea8c0f7b356cbc4b70.png 798w, https:\/\/www.wsmeguro.jp\/wp\/wp-content\/uploads\/2018\/06\/a59fc2a6545452ea8c0f7b356cbc4b70-300x235.png 300w, https:\/\/www.wsmeguro.jp\/wp\/wp-content\/uploads\/2018\/06\/a59fc2a6545452ea8c0f7b356cbc4b70-768x602.png 768w\" sizes=\"auto, (max-width: 798px) 100vw, 798px\" \/><\/a><br \/>\n<!--more--><br \/>\nmain.py\u306f\u3001\u3053\u3093\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n<pre class=\"lang:python decode:true \" ># main.py\r\n# -*- coding: utf-8 -*-\r\n\r\nimport kivy\r\nkivy.require(\"1.9.1\")\r\n\r\nfrom kivy.app import App\r\nfrom kivy.core.text import LabelBase, DEFAULT_FONT\r\nfrom kivy.resources import resource_add_path\r\nfrom kivy.uix.widget import Widget\r\nfrom kivy.uix.label import Label\r\nfrom kivy.uix.boxlayout import BoxLayout\r\n\r\n\r\nresource_add_path('..\/fonts')\r\n# \u30d9\u30fc\u30b9\u30d5\u30a9\u30f3\u30c8\u3092\u5909\u66f4\u3059\u308b\r\nLabelBase.register(DEFAULT_FONT, 'komorebi-gothic.ttf')\r\n\r\nclass BoxApp(App):\r\n    def build(self):\r\n        return BoxLayout()\r\n\r\nif __name__ == \"__main__\":\r\n    BoxApp().run()<\/pre>\n<p>\u7279\u306b\u3001\u3053\u308c\u3063\u3066\u3044\u3046\u306e\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u7d9a\u3044\u3066\u3001box.kv\u306f\u3053\u3061\u3089\u3067\u3059\u3002<\/p>\n<pre class=\"lang:python decode:true \" ># box.kv\r\n\r\n# Orientation defines whether widgets are stacked (vertical)\r\n# or are placed side by side (horizontal)\r\n# padding is the space between the widgets and the\r\n# surrounding window\r\n# orientation\u306f\u3001\u7bb1\u306e\u4e26\u3076\u65b9\u5411\u3067\u5782\u76f4\uff08vertical\uff09\u304b\u6c34\u5e73\uff08horizontal\uff09\u3067\u6307\u5b9a\u3057\u307e\u3059\u3002\r\n# padding\u3068spacng\u306f\u3001GridLayout\u3068\u540c\u3058\u3067\u3059\u3002\r\n\r\n&lt;BoxLayout&gt;:\r\n    orientation: \"vertical\"\r\n    padding: 5\r\n \r\n    # size_hint defines the percentage of space taken on the\r\n    # x access and the percentage of space left over by the\r\n    # other widgets\r\n    # size_hint\u3092\u4f7f\u3048\u3070\u3001\u7279\u5b9a\u306e\u7bb1\u306e\u30b5\u30a4\u30ba\u3092\u5909\u3048\u3089\u308c\u307e\u3059\u3002\r\n    Label:\r\n        font_size: 32\r\n        text: \"This is BoxLayout.\"\r\n        size_hint: 1, None\r\n        height: 50\r\n    Button:\r\n        text: \"2nd\"\r\n    Button:\r\n        text: \"3rd\"<\/pre>\n<p>\u3053\u3053\u307e\u3067\u304f\u308b\u3068\u3001\u3055\u3089\u306b\u3001\u4e00\u637b\u308a\u3057\u3066\u3001\u5165\u308c\u5b50\uff08nested\uff09\u69cb\u9020\u306b\u3057\u3066\u898b\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002vertical\u306eBoxLayout\u306e\uff13\u6bb5\u3067\u3001\u4e00\u756a\u4e0a\u306b\u30e1\u30cb\u30e5\u30fc\u30dc\u30bf\u30f3\u3092\u6a2a\u306b\u4e26\u3079\u3001\uff12\u3064\u76ee\u3092\u30c6\u30ad\u30b9\u30c8\u5165\u529b\u3092\u5165\u308c\u3066\u3001\uff13\u6bb5\u76ee\u306f\u30e9\u30d9\u30eb\u3068\u3044\u3046\u611f\u3058\u3067\u3059\u3002<br \/>\n<a href=\"https:\/\/www.wsmeguro.jp\/\/wp\/wp-content\/uploads\/2018\/06\/07a13b7dca7ab4743200d6bb5410ad5d.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.wsmeguro.jp\/\/wp\/wp-content\/uploads\/2018\/06\/07a13b7dca7ab4743200d6bb5410ad5d.png\" alt=\"\" width=\"816\" height=\"639\" class=\"aligncenter size-full wp-image-3767\" srcset=\"https:\/\/www.wsmeguro.jp\/wp\/wp-content\/uploads\/2018\/06\/07a13b7dca7ab4743200d6bb5410ad5d.png 816w, https:\/\/www.wsmeguro.jp\/wp\/wp-content\/uploads\/2018\/06\/07a13b7dca7ab4743200d6bb5410ad5d-300x235.png 300w, https:\/\/www.wsmeguro.jp\/wp\/wp-content\/uploads\/2018\/06\/07a13b7dca7ab4743200d6bb5410ad5d-768x601.png 768w\" sizes=\"auto, (max-width: 816px) 100vw, 816px\" \/><\/a><br \/>\n\u3084\u308a\u65b9\u3092\u3044\u308d\u3044\u308d\u3068\u8abf\u3079\u305f\u3089\u3001\u3053\u3093\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n<pre class=\"lang:python decode:true \" ># main.py\r\n# -*- coding: utf-8 -*-\r\n\r\nimport kivy\r\nkivy.require(\"1.9.1\")\r\n\r\nfrom kivy.app import App\r\nfrom kivy.core.text import LabelBase, DEFAULT_FONT\r\nfrom kivy.resources import resource_add_path\r\nfrom kivy.lang import Builder\r\n \r\nresource_add_path('..\/fonts')\r\n# \u30d9\u30fc\u30b9\u30d5\u30a9\u30f3\u30c8\u3092\u5909\u66f4\u3059\u308b\r\nLabelBase.register(DEFAULT_FONT, 'komorebi-gothic.ttf')\r\n \r\nclass BoxApp(App):\r\n    def build(self):\r\n#        return BoxLayout()\r\n        self.root = Builder.load_file('box.kv')\r\n        return self.root \r\n\r\nif __name__ == \"__main__\":\r\n    BoxApp().run()<\/pre>\n<p>\u306a\u3093\u304b\u3001\u9055\u3044\u307e\u3059\u3088\u306d\u3002Builder\u3068\u3044\u3046\u306e\u304c\u3042\u3063\u3066\u3001box.kv\u3092\u660e\u793a\u7684\u306b\u8aad\u307f\u8fbc\u3093\u3067\u3044\u308b\u3002BoxLayout\u3082Label\u3082import\u3057\u3066\u3044\u306a\u3044\u3002box.kv\u306f\u3069\u3046\u304b\u3063\u3066\u3044\u3046\u3068\u3002<\/p>\n<pre class=\"lang:python decode:true \" ># box.kv\r\n\r\nBoxLayout:\r\n    orientation: 'vertical'\r\n    BoxLayout:\r\n        orientation: 'horizontal'\r\n\t\tsize_hint: None, None\r\n\t\theight: 40\r\n        ToggleButton:\r\n            text: 'File'\r\n        ToggleButton:\r\n            text: 'Edit'\r\n        ToggleButton:\r\n            text: 'Help'\r\n\tTextInput:\r\n\t\ttext: 'Default Text2'\r\n    Label:\r\n\t\tsize_hint_y: None\r\n\t\theight: 70\r\n        text: 'This is Nested BoxLayout.'\r\n<\/pre>\n<p>\u306a\u3093\u3067\u3001\u3053\u308c\u3067\u52d5\u304f\u306e\u304b\u7406\u89e3\u3067\u304d\u3066\u3044\u306a\u3044\u3002\u3002\u3002kivy\u3092\u7d9a\u3051\u308b\u3053\u3068\u304c\u8f9b\u304f\u306a\u3063\u3066\u304d\u305f\u306a\u3041\u30fb\u30fb<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f15\u304d\u7d9a\u304d\u3001\uff12\u56de\u76ee\u3001kivy.uix.boxlayout\u306b\u3064\u3044\u3066\u3068\u306a\u308a\u307e\u3059\u3002 Kivy Tutorial 2\u3053\u306e\u52d5\u753b\u3092 YouTube \u3067\u8996\u8074 \u305d\u306e\u307e\u307e\u8f09\u305b\u3066\u3082\u3064\u307e\u3093\u306a\u3044\u306e\u3067\u3001\u3061\u3087\u3063\u3068\u3060\u3051\u624b\u3092\u5165\u308c\u305f\u753b\u9762\u306f\u3053\u3093\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"categories":[526,508],"tags":[563,527,513],"class_list":["post-3762","post","type-post","status-publish","format-standard","hentry","category-python","category-508","tag-kivy","tag-python","tag-513"],"_links":{"self":[{"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=\/wp\/v2\/posts\/3762","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3762"}],"version-history":[{"count":4,"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=\/wp\/v2\/posts\/3762\/revisions"}],"predecessor-version":[{"id":3769,"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=\/wp\/v2\/posts\/3762\/revisions\/3769"}],"wp:attachment":[{"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3762"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3762"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3762"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}