{"id":1247,"date":"2020-05-11T00:00:00","date_gmt":"2020-05-10T15:00:00","guid":{"rendered":"https:\/\/www.ishikawasekkei.com\/?p=1247"},"modified":"2020-05-11T00:00:29","modified_gmt":"2020-05-10T15:00:29","slug":"python-tkinter-gui-programing-outline","status":"publish","type":"post","link":"https:\/\/www.ishikawasekkei.com\/index.php\/2020\/05\/11\/python-tkinter-gui-programing-outline\/","title":{"rendered":"Python tkinter GUI\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0 \u30a2\u30a6\u30c8\u30e9\u30a4\u30f3"},"content":{"rendered":"\n<p>\u3000\u4eca\u65e5\u3082\u898b\u306b\u6765\u3066\u304f\u3060\u3055\u3063\u3066\u3001\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059\u3002\u77f3\u5ddd\u3055\u3093\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3000GUI\u306e\u30a8\u30c7\u30a3\u30bf\u30fc\u3092\u4f5c\u3063\u305f\u3068\u304d\u306b\u3001\u30a2\u30a6\u30c8\u30e9\u30a4\u30f3\u3092\u8868\u793a\u3059\u308b\u65b9\u6cd5\u3092\u3061\u3087\u3063\u3068\u691c\u8a0e\u3057\u3066\u307f\u307e\u3057\u305f\u3002\u30ad\u30e3\u30f3\u30d0\u30b9\u306e\u4e2d\u306b<code>create_window()<\/code>\u3067\u30ad\u30e3\u30f3\u30d0\u30b9\u3092\u4f5c\u6210\u3057\u3066\u3001\u540c\u3058\u5185\u5bb9\u3092\u63cf\u753b\u3059\u308b\u3001\u3068\u3044\u3046\u306e\u3067\u3069\u3046\u304b\u306a\u3041\u3001\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u3061\u3087\u3063\u3068\u304a\u8a66\u3057\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u3067\u304d\u3042\u304c\u308a\u30a4\u30e1\u30fc\u30b8<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"573\" height=\"447\" src=\"https:\/\/www.ishikawasekkei.com\/wp-content\/uploads\/2020\/05\/image-2.png\" alt=\"\" class=\"wp-image-1248\" srcset=\"https:\/\/www.ishikawasekkei.com\/wp-content\/uploads\/2020\/05\/image-2.png 573w, https:\/\/www.ishikawasekkei.com\/wp-content\/uploads\/2020\/05\/image-2-300x234.png 300w\" sizes=\"auto, (max-width: 573px) 100vw, 573px\" \/><figcaption>\u53f3\u4e0b\u306b\u30a2\u30a6\u30c8\u30e9\u30a4\u30f3\uff08\u9ce5\u77b0\u56f3\uff09\u8868\u793a<\/figcaption><\/figure>\n\n\n\n<p>\u3000\u30af\u30ea\u30c3\u30af\u3057\u305f\u500b\u6240\u306b\u56db\u89d2\u5f62\u3092\u63cf\u753b\u3057\u307e\u3059\u3002\u63cf\u753b\u3068\u540c\u6642\u306b\u53f3\u4e0b\u306e\u30a2\u30a6\u30c8\u30e9\u30a4\u30f3\u306b\u3082\u63cf\u753b\u3057\u307e\u3059\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\n\nclass Application(tk.Tk):\n    def __init__(self):\n        super().__init__()\n        self.title(\"Canvas outline sample\")\n        self.outline = None\n        self.outline_item = None\n        \n        self.canvas = tk.Canvas(self, background=\"white\")\n        self.canvas.pack(fill=tk.BOTH,expand=True)\n        self.canvas.bind(\"&lt;1>\",self.update_outline)\n        self.canvas.bind(\"&lt;Configure>\",self.update_outline)\n\n    def update_outline(self, event):\n        if self.outline == None or self.outline_item == None:\n            self.outline = o = tk.Canvas(self, background=\"lightblue\")\n            c = self.canvas\n            width, height = c.winfo_width(), c.winfo_height()\n            w, h = width\/\/5, height\/\/5\n            x, y = width - w\/\/2, height - h\/\/2\n            self.outline_item = c.create_window(x, y, width=w, height=h, window=o)\n            return\n\n        if event.type == tk.EventType.Configure:\n            c = self.canvas\n            width, height = c.winfo_width(), c.winfo_height()\n            w, h = width\/\/5, height\/\/5\n            x, y = width - w\/\/2, height - h\/\/2\n            oi = self.outline_item\n            x0, y0 = c.coords(oi)\n            dx = x - x0\n            dy = y - y0\n            c.move(oi,dx,dy)\n            c.itemconfigure(oi,width=w,height=h)\n\n        elif event.type == tk.EventType.Button:\n            c = self.canvas\n            x, y = event.x, event.y\n            c.create_rectangle(x, y, x+100, y+100)\n            o = self.outline\n            o.create_rectangle(x\/\/5,y\/\/5,(x+100)\/\/5,(y+100)\/\/5)\n    \nif __name__ == \"__main__\":\n    application = Application()\n    application.mainloop()\n<\/pre>\n\n\n\n<p>\u3000\u30a6\u30a3\u30f3\u30c9\u30a6\u306e\u30b5\u30a4\u30ba\u3092\u5909\u66f4\u3057\u305f\u3089\u3001\u30a2\u30a6\u30c8\u30e9\u30a4\u30f3\u306e\u30b5\u30a4\u30ba\u3082\u5909\u66f4\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u307e\u3068\u3081<\/h2>\n\n\n\n<p>\u3000\u4eca\u56de\u306f\u3001\u30af\u30ea\u30c3\u30af\u3057\u305f\u3068\u304d\u306b\u540c\u6642\u306b\u5c0f\u3055\u3044\u30b5\u30a4\u30ba\u306e\u63cf\u753b\u3092\u3057\u307e\u3057\u305f\u3002\u5b9f\u969b\u306eGUI\u30a8\u30c7\u30a3\u30bf\u30fc\u3067\u306f\u3001\u30a2\u30a6\u30c8\u30e9\u30a4\u30f3\u306e\u8868\u793a\u3001\u975e\u8868\u793a\u306e\u5207\u308a\u66ff\u3048\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u305d\u3046\u3067\u3059\u306d\u3002\u30b9\u30af\u30ed\u30fc\u30eb\u3068\u304b\u3001\u62e1\u5927\u7e2e\u5c0f\u3082\u5bfe\u5fdc\u3057\u306a\u3051\u308c\u3070\u3044\u3051\u306a\u3044\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\u3001\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059\u3002\u77f3\u5ddd\u3055\u3093\u3067\u3059\u3002 \u3000GUI\u306e\u30a8\u30c7\u30a3\u30bf\u30fc\u3092\u4f5c\u3063\u305f\u3068\u304d\u306b\u3001\u30a2\u30a6\u30c8\u30e9\u30a4\u30f3\u3092\u8868\u793a\u3059\u308b\u65b9\u6cd5\u3092\u3061\u3087\u3063\u3068\u691c\u8a0e\u3057\u3066\u307f\u307e\u3057\u305f\u3002\u30ad\u30e3\u30f3\u30d0\u30b9\u306e\u4e2d\u306bcreate_window()\u3067\u30ad\u30e3\u30f3\u30d0\u30b9\u3092\u4f5c\u6210 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.ishikawasekkei.com\/index.php\/2020\/05\/11\/python-tkinter-gui-programing-outline\/\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Python tkinter GUI\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0 \u30a2\u30a6\u30c8\u30e9\u30a4\u30f3&#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-1247","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\/1247","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=1247"}],"version-history":[{"count":1,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/posts\/1247\/revisions"}],"predecessor-version":[{"id":1249,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/posts\/1247\/revisions\/1249"}],"wp:attachment":[{"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/media?parent=1247"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/categories?post=1247"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/tags?post=1247"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}