{"id":865,"date":"2020-03-15T00:00:56","date_gmt":"2020-03-15T09:00:56","guid":{"rendered":"https:\/\/www.ishikawasekkei.com\/?p=865"},"modified":"2020-03-16T06:38:55","modified_gmt":"2020-03-16T15:38:55","slug":"tkinter-how-to-layout-with-geometry-manager","status":"publish","type":"post","link":"https:\/\/www.ishikawasekkei.com\/index.php\/2020\/03\/15\/tkinter-how-to-layout-with-geometry-manager\/","title":{"rendered":"Tkinter\u306e\u30ec\u30a4\u30a2\u30a6\u30c8\u65b9\u6cd5\u306f3\u7a2e\u985e"},"content":{"rendered":"\n<p>\u3000\u4eca\u65e5\u3082\u898b\u306b\u6765\u3066\u304f\u3060\u3055\u3063\u3066\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059\u3002\u7740\u3005\u3068\u8aad\u8005\u304c\u5897\u3048\u3066\u3044\u308b\u3088\u3046\u3067\u3046\u308c\u3057\u3044\u3067\u3059\u3002\u304c\u3093\u3070\u3063\u3066\u66f8\u3044\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3000\u3053\u3053\u306e\u3068\u3053\u308dtkinter\u3067\u904a\u3093\u3067\u3044\u307e\u3059\u3002tkinter\u3067\u306f\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u3068\u547c\u3070\u308c\u308b\u90e8\u54c1\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u305d\u308c\u3092\u30a6\u30a3\u30f3\u30c9\u30a6\u5185\u306e\u9069\u5207\u306a\u4f4d\u7f6e\u306b\u914d\u7f6e\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002tkinter\u3067\u306f\u305d\u306e\u914d\u7f6e\u3059\u308b\u65b9\u6cd5\u304c\u3001pack\u3001grid\u3001place\u306e3\u7a2e\u985e\u3042\u308a\u307e\u3059\u3002\u5168\u90e8\u4f7f\u3063\u3066\u307f\u307e\u3057\u305f\u3001\u3068\u3044\u3046\u4f8b\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002\u3061\u306a\u307f\u306b\u3053\u308c\u3089\u306f\u3001\u30b8\u30aa\u30e1\u30c8\u30ea\u30de\u30cd\u30fc\u30b8\u30e3\uff08geometry manager\uff09\u3068\u547c\u3070\u308c\u3066\u3044\u307e\u3059\u3002\u914d\u7f6e\u3092\u7ba1\u7406\u3059\u308b\u305f\u3081\u306e\u4ed5\u7d44\u307f\u3067\u3059\u306d\u3002\u3053\u308c\u3089\u304c\u7d44\u307f\u5408\u308f\u305b\u3089\u308c\u308b\u304b\u3001\u304a\u8a66\u3057\u3067\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"488\" height=\"615\" src=\"https:\/\/www.ishikawasekkei.com\/wp-content\/uploads\/2020\/03\/image-24.png\" alt=\"\" class=\"wp-image-866\" srcset=\"https:\/\/www.ishikawasekkei.com\/wp-content\/uploads\/2020\/03\/image-24.png 488w, https:\/\/www.ishikawasekkei.com\/wp-content\/uploads\/2020\/03\/image-24-238x300.png 238w\" sizes=\"auto, (max-width: 488px) 100vw, 488px\" \/><\/figure>\n\n\n\n<p>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306f\u3001\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\n\nclass App(tk.Tk):\n    def __init__(self):\n        super().__init__()\n        self.title(\"geometry manager test\")\n\n        gridframe = tk.LabelFrame(self, text=\"\u30b0\u30ea\u30c3\u30c9\u306e\u30d5\u30ec\u30fc\u30e0\")\n        gridframe.pack()\n        g = GridFrame(gridframe)\n        g.pack()\n        \n        packframe = tk.LabelFrame(self, text=\"\u30d1\u30c3\u30af\u306e\u30d5\u30ec\u30fc\u30e0\")\n        packframe.pack()\n        pa = PackFrame(packframe)\n        pa.pack()\n\n        placeframe = tk.LabelFrame(self, text=\"\u30d7\u30ec\u30fc\u30b9\u306e\u30d5\u30ec\u30fc\u30e0\")\n        placeframe.pack(ipadx=10, ipady=5, expand=True, fill=tk.BOTH)\n        pl = PlaceFrame(placeframe)\n        pl.pack()\n\n        label = tk.Label(text=\"\u30e9\u30d9\u30eb\")\n        button = tk.Button(text=\"\u30dc\u30bf\u30f3\",command=self.destroy)\n        label.pack()\n        button.pack()\n\nclass GridFrame(tk.Frame):\n    def __init__(self, master=None):\n        super().__init__(master)\n        label = tk.Label(self,text=\"grid\u306e\u30e9\u30d9\u30eb\")\n        label.grid(column=0,row=0,padx=10,pady=10)\n        button = tk.Button(self,text=\"grid\u306e\u30dc\u30bf\u30f3\")\n        button.grid(column=1,row=1,padx=10,pady=10)\n\nclass PackFrame(tk.Frame):\n    def __init__(self, master=None):\n        super().__init__(master)\n        label = tk.Label(self, text=\"pack\u306e\u30e9\u30d9\u30eb\")\n        button = tk.Button(self, text=\"pack\u306e\u30dc\u30bf\u30f3\")\n        label.pack(padx=20,pady=20)\n        button.pack(padx=20,pady=20)\n        \nclass PlaceFrame(tk.Frame):\n    def __init__(self, master=None):\n        super().__init__(master,width=300,height=50)\n        label = tk.Label(self, text=\"place\u306e\u30e9\u30d9\u30eb\")\n        button = tk.Button(self, text=\"place\u306e\u30dc\u30bf\u30f3\")\n        label.place(relwidth=0.25, relheight=0.25)\n        button.place(anchor=tk.N, x=200, y=20, width=80, height=30)\n\nif __name__ == \"__main__\":\n    app = App()\n    app.mainloop()\n<\/pre>\n\n\n\n<p>grid\u306f\u683c\u5b50\u72b6\u306b\u5206\u3051\u305f\u5834\u6240\u306b\u90e8\u54c1\u3092\u914d\u7f6e\u3059\u308b\u30a4\u30e1\u30fc\u30b8\u3067\u3059\u3002\u884c\u3068\u5217\u3067\u4f4d\u7f6e\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u307e\u305f\u3001<code>columnspan<\/code>\u3084<code>rowspan<\/code>\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u5e45\u3084\u9ad8\u3055\u3092\u5897\u3084\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002pack\u306f\u771f\u7a7a\u30d1\u30c3\u30af\u306e\u30a4\u30e1\u30fc\u30b8\u3067\u3057\u3087\u3046\u304b\u3002\u90e8\u54c1\u3092\u3064\u304f\u3063\u3066\u3001\u8a70\u3081\u308b\u611f\u3058\u3067\u3059\u3002place\u306f\u4f4d\u7f6e\u3084\u5927\u304d\u3055\u3092\u76f4\u63a5\u6307\u5b9a\u3059\u308b\u30a4\u30e1\u30fc\u30b8\u3067\u3059\u306d\u3002\u305d\u308c\u305e\u308c\u306e\u8a73\u7d30\u306f\u307e\u305f\u3044\u305a\u308c\u3069\u3053\u304b\u3067\u307e\u3068\u3081\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3072\u3068\u3064\u306e\u30b3\u30f3\u30c6\u30ca\u306e\u4e2d\u3067\u7570\u306a\u308b\u65b9\u6cd5\u3092\u6df7\u305c\u3066\u4f7f\u3046\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3002\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u3066\u51e6\u7406\u304c\u4e2d\u65ad\u3057\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u4eca\u56de\u306e\u3053\u306e\u4f8b\u306e\u3088\u3046\u306bFrame\u3092\u7d99\u627f\u3057\u305f\u30b3\u30f3\u30c6\u30ca\u306e\u4e2d\u306b\u90e8\u54c1\u3092\u914d\u7f6e\u3057\u3066\u3001\u305d\u308c\u3089\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u3001\u3068\u3044\u3046\u306e\u304c\u30b3\u30c4\u306e\u3088\u3046\u3067\u3059\u3002\u3053\u3046\u3059\u308b\u3053\u3068\u3067\u3001\u305d\u308c\u305e\u308c\u304c\u72ec\u7acb\u3057\u3066\u5f71\u97ff\u3092\u53ca\u307c\u3055\u306a\u3044\u3088\u3046\u306b\u3064\u304f\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u305f\u3063\u305f\u3053\u308c\u3060\u3051\u306e\u90e8\u54c1\u3092\u4e26\u3079\u308b\u306e\u306b\u3001\u3053\u3093\u306a\u306b\u66f8\u304b\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u306e\u306f\u3001\u3051\u3063\u3053\u3046\u9762\u5012\u3067\u3059\u3088\u306d\u3002\u3067\u3082\u307e\u3042\u3001\u3064\u304f\u3063\u3066\u3001\u4e26\u3079\u3066\u3001\u3064\u304f\u3063\u3066\u3001\u4e26\u3079\u3066\u3001\u3068\u3001\u3053\u308c\u3088\u308a\u77ed\u304f\u3059\u308b\u306e\u306f\u304b\u306a\u308a\u96e3\u3057\u3044\uff08\u30e0\u30ea\uff09\u3067\u3057\u3087\u3046\u306d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3000\u4eca\u65e5\u3082\u898b\u306b\u6765\u3066\u304f\u3060\u3055\u3063\u3066\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059\u3002\u7740\u3005\u3068\u8aad\u8005\u304c\u5897\u3048\u3066\u3044\u308b\u3088\u3046\u3067\u3046\u308c\u3057\u3044\u3067\u3059\u3002\u304c\u3093\u3070\u3063\u3066\u66f8\u3044\u3066\u3044\u304d\u307e\u3059\u3002 \u3000\u3053\u3053\u306e\u3068\u3053\u308dtkinter\u3067\u904a\u3093\u3067\u3044\u307e\u3059\u3002tkinter\u3067\u306f\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u3068\u547c\u3070\u308c\u308b\u90e8\u54c1\u304c\u7528\u610f\u3055\u308c\u3066\u3044 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.ishikawasekkei.com\/index.php\/2020\/03\/15\/tkinter-how-to-layout-with-geometry-manager\/\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Tkinter\u306e\u30ec\u30a4\u30a2\u30a6\u30c8\u65b9\u6cd5\u306f3\u7a2e\u985e&#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-865","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\/865","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=865"}],"version-history":[{"count":2,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/posts\/865\/revisions"}],"predecessor-version":[{"id":868,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/posts\/865\/revisions\/868"}],"wp:attachment":[{"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/media?parent=865"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/categories?post=865"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/tags?post=865"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}