{"id":1071,"date":"2020-04-06T00:00:00","date_gmt":"2020-04-05T15:00:00","guid":{"rendered":"https:\/\/www.ishikawasekkei.com\/?p=1071"},"modified":"2020-05-02T14:56:31","modified_gmt":"2020-05-02T05:56:31","slug":"tkinter-gui-programing-layoutmanager-pack","status":"publish","type":"post","link":"https:\/\/www.ishikawasekkei.com\/index.php\/2020\/04\/06\/tkinter-gui-programing-layoutmanager-pack\/","title":{"rendered":"Tkinter GUI\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0 \u30ec\u30a4\u30a2\u30a6\u30c8\u30de\u30cd\u30fc\u30b8\u30e3pack"},"content":{"rendered":"\n<p>\u3000\u4eca\u65e5\u3082\u898b\u306b\u6765\u3066\u304f\u3060\u3055\u3063\u3066\u3001\u3042\u308a\u304c\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059\u3002\u77f3\u5ddd\u3055\u3093\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3000Tkinter\u306e\u30ec\u30a4\u30a2\u30a6\u30c8\u30de\u30cd\u30fc\u30b8\u30e3\u306f\u4e09\u7a2e\u985e\u3042\u308b\u306e\u3067\u3059\u3051\u3069\u3001\u305d\u306e\u4e2d\u306epack\u304c\u3061\u3087\u3063\u3068\u3060\u3051\u3088\u304f\u308f\u304b\u3089\u306a\u304b\u3063\u305f\u306e\u3067\u3001\u3044\u308d\u3044\u308d\u3068\u52d5\u4f5c\u78ba\u8a8d\u3092\u3057\u3066\u307f\u307e\u3057\u305f\u306e\u3067\u307e\u3068\u3081\u307e\u3059\u3002\u304a\u5f79\u306b\u7acb\u3066\u308c\u3070\u3046\u308c\u3057\u3044\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3000pack\u3068\u3044\u3046\u304f\u3089\u3044\u306a\u306e\u3067\u3001\u7bb1\u8a70\u3081\u3059\u308b\u3093\u3060\u3088\u306d\u3047\u3001\u3068\u3044\u3046\u3068\u3053\u308d\u307e\u3067\u306f\u30a4\u30e1\u30fc\u30b8\u901a\u308a\u306a\u306e\u3067\u3059\u3051\u3069\u3001\u7bb1\u8a70\u3081\u306e\u65b9\u6cd5\u304c\u3088\u304f\u308f\u304b\u3089\u3093\u306a\u3041\u3001\u3068\u3044\u3046\u3053\u3068\u3067\u3001pack\u306e\u30bd\u30fc\u30b9\u30d5\u30a1\u30a4\u30eb\u307e\u3067\u3055\u304b\u306e\u307c\u3063\u3066\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3057\u305f\u3002\u30b3\u30e1\u30f3\u30c8\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Pack a widget in the parent widget. Use as options:\nafter=widget - pack it after you have packed widget\nanchor=NSEW (or subset) - position widget according to given direction\nbefore=widget - pack it before you will pack widget\nexpand=bool - expand widget if parent size grows\nfill=NONE or X or Y or BOTH - fill widget if widget grows\nin=master - use master to contain this widget\nin_=master - see 'in' option description\nipadx=amount - add internal padding in x direction\nipady=amount - add internal padding in y direction\npadx=amount - add padding in x direction\npady=amount - add padding in y direction\nside=TOP or BOTTOM or LEFT or RIGHT -  where to add this widget.<\/pre>\n\n\n\n<p>\u3000\u3053\u306e<code>side<\/code>\u30d1\u30e9\u30e1\u30fc\u30bf\u3067\u4f4d\u7f6e\u3092\u6c7a\u3081\u3066\u3044\u307e\u3059\u306e\u3067\u3001\u7d44\u307f\u5408\u308f\u305b\u3067\u3069\u3046\u306a\u308b\u304b\u3001\u3061\u3087\u3063\u3068\u3084\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/h2>\n\n\n\n<p>\u3000\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import tkinter as tk\nimport itertools as it\n\nSIDES = [tk.TOP,tk.BOTTOM,tk.LEFT,tk.RIGHT]\nCOLORS = [\"red\",\"green\",\"blue\",\"yellow\",\"gray\"]\n\nclass Test(tk.Toplevel):\n    def __init__(self, master, i, sides):\n        super().__init__(master)\n        self.title(str(i))\n        self.geometry(\"140x120\")\n        for i, l in enumerate(sides):\n            label = tk.Label(self,text=l, bg=COLORS[i])\n            label.pack(side=l)\n        \nclass App(tk.Tk):\n    def __init__(self):\n        super().__init__()\n        self.title(\"Pack test\")\n\n        for i, s in enumerate(it.combinations_with_replacement(SIDES,len(COLORS))):\n            print(i,s)\n            t = Test(self, i, s)\n            t.geometry(\"+\"+str(10 + (i%10)*140)+\"+\"+str(10 + (i\/\/10)*130))\n\n        self.geometry(\"300x30+900+700\")\n        \nif __name__ == \"__main__\":\n    app = App()\n    app.mainloop()\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9f\u884c\u7d50\u679c<\/h2>\n\n\n\n<p>\u3000\u4e0a\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306e\u5b9f\u884c\u7d50\u679c\u3067\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"592\" src=\"https:\/\/www.ishikawasekkei.com\/wp-content\/uploads\/2020\/04\/image-18-1024x592.png\" alt=\"\" class=\"wp-image-1074\" srcset=\"https:\/\/www.ishikawasekkei.com\/wp-content\/uploads\/2020\/04\/image-18-1024x592.png 1024w, https:\/\/www.ishikawasekkei.com\/wp-content\/uploads\/2020\/04\/image-18-300x173.png 300w, https:\/\/www.ishikawasekkei.com\/wp-content\/uploads\/2020\/04\/image-18-768x444.png 768w, https:\/\/www.ishikawasekkei.com\/wp-content\/uploads\/2020\/04\/image-18-1536x888.png 1536w, https:\/\/www.ishikawasekkei.com\/wp-content\/uploads\/2020\/04\/image-18-2048x1183.png 2048w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><figcaption>\u5b9f\u884c\u7d50\u679c<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u8aac<\/h2>\n\n\n\n<p>\u3000\u3069\u3053\u3078\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u3092\u52a0\u3048\u308b\u304b\u3092\u6c7a\u3081\u308b\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u3001<code>side<\/code>\u3067\u3059\u304c\u3001<code>TOP<\/code>\u3001<code>BOTTOM<\/code>\u3001<code>LEFT<\/code>\u3001<code>RIGHT<\/code>\u306e\u56db\u7a2e\u985e\u306e\u4f4d\u7f6e\u3092\u30bb\u30c3\u30c8\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3053\u306e\u7d44\u307f\u5408\u308f\u305b\u3067\u3069\u3046\u306a\u308b\u304b\u78ba\u8a8d\u3057\u305f\u304b\u3063\u305f\u306e\u3067\u3001<code><a href=\"https:\/\/docs.python.org\/ja\/3\/library\/itertools.html\" class=\"aioseop-link\">itertools<\/a><\/code>\u306e<code><a href=\"https:\/\/docs.python.org\/ja\/3\/library\/itertools.html#itertools.combinations_with_replacement\" class=\"aioseop-link\">combinations_with_replacement<\/a><\/code>\u3092\u4f7f\u3063\u3066\u7d44\u307f\u5408\u308f\u305b\u3092\u5b9f\u73fe\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002\u3053\u306e<a href=\"https:\/\/docs.python.org\/ja\/3\/library\/itertools.html#itertools.combinations_with_replacement\" class=\"aioseop-link\"><code>combinations_with_replacement<\/code><\/a>\u306f\u3001\u6307\u5b9a\u3055\u308c\u305f\u9577\u3055\u306e\u30bf\u30d7\u30eb\u5217\u3092\u91cd\u8907\u3042\u308a\u306e\u30bd\u30fc\u30c8\u3055\u308c\u305f\u9806\u3067\u623b\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3000\u3053\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u306f\u3001\u30af\u30e9\u30b9\u3092\u4e8c\u3064\u5b9a\u7fa9\u3057\u3066\u3044\u307e\u3059\u3002\u4e00\u3064\u306f\u3001Tk\u3092\u7d99\u627f\u3057\u305f\u672c\u4f53\u306e\u30af\u30e9\u30b9\u3067\u3001\u3082\u3046\u4e00\u3064\u306f\u65b0\u305f\u306a\u30a6\u30a3\u30f3\u30c9\u30a6\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306eToplevel\u3092\u7d99\u627f\u3057\u305fTest\u30af\u30e9\u30b9\u3067\u3059\u3002\u3053\u306eTest\u30af\u30e9\u30b9\u3067<code>side<\/code>\u3092\u3044\u308d\u3044\u308d\u3068\u8a2d\u5b9a\u3057\u3066\u307f\u3066\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u3000\u9806\u756a\u306f\u3001\u8d64\u3001\u7dd1\u3001\u9752\u3001\u9ec4\u8272\u3001\u30b0\u30ec\u30fc\u306e\u9806\u3067\u8ffd\u52a0\u3055\u308c\u3066\u3044\u307e\u3059\u3002<code>after<\/code>\u3084<code>before<\/code>\u3092\u6307\u5b9a\u3059\u308c\u3070\u9806\u756a\u304c\u5165\u308c\u66ff\u308f\u308b\u3088\u3046\u3067\u3059\u304c\u3001\u4eca\u56de\u306f\u8ffd\u52a0\u3057\u305f\u9806\u756a\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u9762\u767d\u3044\u306a\u3001\u3068\u3001\u601d\u3063\u305f\u306e\u306f\u3001<code>RIGHT<\/code>\u3068<code>BOTTOM<\/code>\u3092\u6307\u5b9a\u3057\u305f\u9806\u756a\u304c\u53f3\u304b\u3089\u9806\u756a\u3001\u4e0b\u304b\u3089\u9806\u756a\u3068\u3044\u3046\u98a8\u306b\u306a\u3063\u3066\u3044\u308b\u3068\u3053\u308d\u3067\u3059\u3002\u4f55\u3068\u306a\u304f\u3001\u4e0a\u304b\u3089\u9806\u756a\u3001\u5de6\u304b\u3089\u9806\u756a\u3068\u601d\u3063\u3066\u3044\u305f\u306e\u3067\u3001\u304a\u3084\u3063\u3001\u3068\u3001\u601d\u3044\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u307e\u3068\u3081<\/h2>\n\n\n\n<p>\u3000\u8981\u7d20\u304c\u591a\u304f\u306a\u3044\u3068\u304d\u3084\u3001\u5358\u7d14\u306a\u4e26\u3073\u306e\u6642\u306f\u3001<code>pack<\/code>\u304c\u4fbf\u5229\u306b\u4f7f\u3048\u305d\u3046\u3067\u3059\u306d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3000\u4eca\u65e5\u3082\u898b\u306b\u6765\u3066\u304f\u3060\u3055\u3063\u3066\u3001\u3042\u308a\u304c\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059\u3002\u77f3\u5ddd\u3055\u3093\u3067\u3059\u3002 \u3000Tkinter\u306e\u30ec\u30a4\u30a2\u30a6\u30c8\u30de\u30cd\u30fc\u30b8\u30e3\u306f\u4e09\u7a2e\u985e\u3042\u308b\u306e\u3067\u3059\u3051\u3069\u3001\u305d\u306e\u4e2d\u306epack\u304c\u3061\u3087\u3063\u3068\u3060\u3051\u3088\u304f\u308f\u304b\u3089\u306a\u304b\u3063\u305f\u306e\u3067\u3001\u3044\u308d\u3044\u308d\u3068\u52d5\u4f5c\u78ba\u8a8d\u3092\u3057\u3066\u307f\u307e\u3057\u305f\u306e\u3067 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.ishikawasekkei.com\/index.php\/2020\/04\/06\/tkinter-gui-programing-layoutmanager-pack\/\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Tkinter GUI\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0 \u30ec\u30a4\u30a2\u30a6\u30c8\u30de\u30cd\u30fc\u30b8\u30e3pack&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,13,2],"tags":[],"class_list":["post-1071","post","type-post","status-publish","format-standard","hentry","category-program","category-tkinter","category-blog"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/posts\/1071","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/comments?post=1071"}],"version-history":[{"count":6,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/posts\/1071\/revisions"}],"predecessor-version":[{"id":1222,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/posts\/1071\/revisions\/1222"}],"wp:attachment":[{"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/media?parent=1071"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/categories?post=1071"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/tags?post=1071"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}