{"id":1130,"date":"2020-04-20T00:00:00","date_gmt":"2020-04-19T15:00:00","guid":{"rendered":"https:\/\/www.ishikawasekkei.com\/?p=1130"},"modified":"2020-05-02T14:53:04","modified_gmt":"2020-05-02T05:53:04","slug":"python-tkinter-gui-programing-variable","status":"publish","type":"post","link":"https:\/\/www.ishikawasekkei.com\/index.php\/2020\/04\/20\/python-tkinter-gui-programing-variable\/","title":{"rendered":"Python tkinter GUI \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0 Variable"},"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>\u3000\u4eca\u65e5\u306f\u3001tkinter\u3067\u7528\u610f\u3055\u308c\u3066\u3044\u308bVariable\u306e\u6319\u52d5\u304c\u6c17\u306b\u306a\u3063\u305f\u306e\u3067\u3061\u3087\u3063\u3068\u8abf\u3079\u3066\u307f\u307e\u3057\u305f\u30024\u7a2e\u985e\u306e\u578b\u3092\u6271\u3048\u308b\u3088\u3046\u306bVariable\u3092\u7d99\u627f\u3057\u305f\u4ee5\u4e0b\u306e\u30af\u30e9\u30b9\u304c\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3057\u305f\u3002\u65e5\u4ed8\u578b\u306f\u3042\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u306d\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>StringVar\u3000\u6587\u5b57\u5217(str)\u3092\u6271\u3044\u307e\u3059<\/li><li>IntVar\u3000\u6574\u6570(int)\u3092\u6271\u3044\u307e\u3059<\/li><li>DoubleVar\u3000\u6d6e\u52d5\u5c0f\u6570\u70b9\u6570(float)\u3092\u6271\u3044\u307e\u3059<\/li><li>BooleanVar\u3000\u771f\u7406\u5024(bool)\u3092\u6271\u3044\u307e\u3059<\/li><\/ul>\n\n\n\n<p>\u3000\u3053\u308c\u307e\u3067\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3082\u3053\u3063\u305d\u308a\u4f7f\u3063\u3066\u3044\u305f\u304b\u3082\u77e5\u308c\u307e\u305b\u3093\u304c\u3001\u3056\u3063\u304f\u308a\u8a00\u3046\u3068\u3001\u3053\u306eVariable\u306f\u3001\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u306b\u5272\u308a\u5f53\u3066\u308b\u3053\u3068\u306e\u3067\u304d\u308b\u5909\u6570\u3067\u3059\u3002\u3053\u308c\u307e\u3067\u306e\u4f8b\u3067\u884c\u304f\u3068\u3001\u30e1\u30cb\u30e5\u30fc\u306e\u30e9\u30b8\u30aa\u30dc\u30bf\u30f3\u3067\u30aa\u30d7\u30b7\u30e7\u30f3\u5024\u3092\u4fdd\u6301\u3059\u308b\u305f\u3081\u306b\u4f7f\u3044\u307e\u3057\u305f\u3002\u3042\u306e\u3068\u304d\u306f\u3001\u30c1\u30a7\u30c3\u30af\u304c\u4e00\u304b\u6240\u3064\u304f\u3060\u3051\u3060\u3063\u305f\u306e\u3067\u3001\u3042\u3093\u307e\u308a\u6c17\u306b\u3057\u3066\u3044\u306a\u304b\u3063\u305f\u306e\u3067\u3059\u3051\u3069\u3001\u4e00\u3064\u306e\u5024\u3092\u8907\u6570\u306e\u5834\u6240\u3067\u8868\u793a\u3067\u304d\u308b\u306e\u304b\u3001\u3068\u3044\u3046\u70b9\u304c\u6c17\u306b\u306a\u308a\u307e\u3057\u3066\u3061\u3087\u3063\u3068\u52d5\u304d\u3092\u78ba\u8a8d\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u51fa\u6765\u4e0a\u304c\u308a\u30a4\u30e1\u30fc\u30b8<\/h2>\n\n\n\n<p>\u3000\u3053\u3093\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"377\" height=\"198\" src=\"https:\/\/www.ishikawasekkei.com\/wp-content\/uploads\/2020\/04\/image-30.png\" alt=\"\" class=\"wp-image-1131\" srcset=\"https:\/\/www.ishikawasekkei.com\/wp-content\/uploads\/2020\/04\/image-30.png 377w, https:\/\/www.ishikawasekkei.com\/wp-content\/uploads\/2020\/04\/image-30-300x158.png 300w\" sizes=\"auto, (max-width: 377px) 100vw, 377px\" \/><figcaption>\u5909\u6570\u306e\u30c6\u30b9\u30c8\u3000\u51fa\u6765\u4e0a\u304c\u308a\u30a4\u30e1\u30fc\u30b8<\/figcaption><\/figure>\n\n\n\n<p>\u3000\u30e9\u30d9\u30eb\u3001\u30a8\u30f3\u30c8\u30ea\u30fc\u3001\u30dc\u30bf\u30f3\u3001\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u4f5c\u3063\u3066\u3042\u308a\u307e\u3059\u3002\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068\u73fe\u5728\u306e\u5024\u306b&#8221;test &#8220;\u3092\u8ffd\u52a0\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<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(\"Variable Test\")\n        self.geometry(\"250x100\")\n        \n        self.str_val = tk.StringVar()\n        \n        self.label1 = tk.Label(self, textvariable=self.str_val)\n        self.entry1 = tk.Entry(self, textvariable=self.str_val)\n        self.btn = tk.Button(self, text=\"Push me!\", command=self.pushed)\n        self.entry2 = tk.Entry(self, textvariable=self.str_val)\n        \n        self.label1.pack()\n        self.entry1.pack()\n        self.btn.pack()\n        self.entry2.pack()\n\n    def pushed(self):\n        self.str_val.set(self.str_val.get()+\"test \")\n\nif __name__ == \"__main__\":\n    app = App()\n    app.mainloop()<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u8aac<\/h2>\n\n\n\n<p>\u3000\u30a6\u30a3\u30f3\u30c9\u30a6\u3092\u4f5c\u308b\u3068\u3053\u308d\u306f\u3044\u3064\u3082\u901a\u308a\u3001<code>Tk<\/code>\u3092\u7d99\u627f\u3057\u305f\u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059\u3002\u30bf\u30a4\u30c8\u30eb\u3092\u30bb\u30c3\u30c8\u3057\u3066\u3001\u30a6\u30a3\u30f3\u30c9\u30a6\u306e\u30b5\u30a4\u30ba\u3092\u6c7a\u3081\u308b\u3068\u3053\u308d\u307e\u3067\u306f\u3060\u3044\u305f\u3044\u3044\u3064\u3082\u901a\u308a\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u30009\u884c\u76ee\u3001<code>StringVar<\/code>\u3067\u5909\u6570\u3092\u5b9a\u7fa9\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u300011\uff5e14\u884c\u76ee\u3067\u3001\u30e9\u30d9\u30eb\u3001\u30a8\u30f3\u30c8\u30ea\u30fc\u3001\u30dc\u30bf\u30f3\u3001\u30a8\u30f3\u30c8\u30ea\u30fc\u306e\u9806\u756a\u306b\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059\u3002\u30e9\u30d9\u30eb\u3068\u30a8\u30f3\u30c8\u30ea\u30fc\u306f<code>textvariable<\/code>\u30d1\u30e9\u30e1\u30fc\u30bf\u3067\u5909\u6570\u3092\u5272\u308a\u5f53\u3066\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u5272\u308a\u5f53\u3066\u306b\u3088\u308a\u3001\u30a8\u30f3\u30c8\u30ea\u30fc\u3067\u5909\u66f4\u3057\u305f\u5024\u304c\u5373\u5ea7\u306b<code>self.str_val<\/code>\u306b\u53cd\u6620\u3055\u308c\u307e\u3059\u3002<code>self.str_val<\/code>\u306b\u53cd\u6620\u3055\u308c\u305f\u5024\u306f\u3001\u4ed6\u306e\u30e9\u30d9\u30eb\u3068\u30a8\u30f3\u30c8\u30ea\u30fc\u306b\u53cd\u6620\u3055\u308c\u307e\u3059\u3002\u30dc\u30bf\u30f3\u306f\u3001<code>self.str_val<\/code>\u306b<code>\"test \"<\/code>\u3092\u8ffd\u52a0\u3059\u308b\u30b3\u30de\u30f3\u30c9\u3001<code>self.pushed<\/code>\u3092\u4f5c\u6210\u3057\u3066\u3001\u3053\u308c\u3092<code>command<\/code>\u306b\u5272\u308a\u5f53\u3066\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u307e\u3068\u3081<\/h2>\n\n\n\n<p>\u3000\u671f\u5f85\u306f\u3057\u3066\u3044\u307e\u3057\u305f\u304c\u3001\u671f\u5f85\u901a\u308a\u306b\u5024\u306f\u5373\u5ea7\u306b\u53cd\u6620\u3055\u308c\u307e\u3057\u305f\u3002\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u3068\u5909\u6570\u306e\u3084\u308a\u53d6\u308a\u306e\u90e8\u5206\u306f\u3001\u4f55\u306b\u3082\u6c17\u306b\u3057\u306a\u304f\u3066\u3082\u81ea\u52d5\u7684\u306b\u8868\u793a\u304c\u66f4\u65b0\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\uff01\u7c21\u5358\u3067\u3059\u306d\u266a<\/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 \u3000\u4eca\u65e5\u306f\u3001tkinter\u3067\u7528\u610f\u3055\u308c\u3066\u3044\u308bVariable\u306e\u6319\u52d5\u304c\u6c17\u306b\u306a\u3063\u305f\u306e\u3067\u3061\u3087\u3063\u3068\u8abf\u3079\u3066\u307f\u307e\u3057\u305f\u30024\u7a2e\u985e\u306e\u578b\u3092\u6271\u3048\u308b\u3088\u3046\u306bVariable\u3092\u7d99\u627f\u3057\u305f\u4ee5 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.ishikawasekkei.com\/index.php\/2020\/04\/20\/python-tkinter-gui-programing-variable\/\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Python tkinter GUI \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0 Variable&#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-1130","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\/1130","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=1130"}],"version-history":[{"count":3,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/posts\/1130\/revisions"}],"predecessor-version":[{"id":1208,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/posts\/1130\/revisions\/1208"}],"wp:attachment":[{"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/media?parent=1130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/categories?post=1130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/tags?post=1130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}