{"id":53,"date":"2021-09-09T12:29:40","date_gmt":"2021-09-09T04:29:40","guid":{"rendered":"http:\/\/139.155.46.233\/?p=53"},"modified":"2021-09-09T12:29:40","modified_gmt":"2021-09-09T04:29:40","slug":"%e5%8d%95%e8%a1%8c%e8%be%93%e5%85%a5%e6%a1%86inputtext","status":"publish","type":"post","link":"https:\/\/www.lucas88.cn\/?p=53","title":{"rendered":"\u5355\u884c\u8f93\u5165\u6846InputText"},"content":{"rendered":"\n<pre class=\"wp-block-preformatted\">\u5355\u884c\u8f93\u5165\u6846\u5143\u7d20\u4ecb\u7ecd\n\u76f8\u5f53\u4e8e<span class=\"has-inline-color has-vivid-red-color\">tkinter<\/span>\u4e2d\u7684\u90e8\u4ef6<span class=\"has-inline-color has-vivid-red-color\">Entry<\/span>\n<span class=\"has-inline-color has-vivid-red-color\">sg.InputText<\/span>()\u652f\u6301\u7b80\u5199<span class=\"has-inline-color has-vivid-red-color\">sg.In()<\/span><\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\nInputText(\n    default_text='',\n            #\u9ed8\u8ba4\u503c\u8bbe\u5b9a\uff0c\u53ef\u4ee5\u4e3a\u7a7a\u5b57\u7b26\u4e32\u3002\n            #\u53ef\u4ee5\u8bbe\u7f6e\u4e3a\u4efb\u610f\u7c7b\u578b\u7684\u503c\n    key=None,\n            #\u5143\u7d20\u7684\u552f\u4e00\u6807\u8bc6\u7b26\n            #\u4e66\u5199\u89c4\u8303'-INPUT-'\n    size=(None,None),\n            #\u5bbd\uff0c\u9ad8\uff08\u5355\u884c\u65f6\u8bbe\u7f6e\u9ad8\u5ea6\u65e0\u610f\u4e49\u3002\u53ef\u8bbe\u7f6e\u4e3a1\uff09\n    disabled=False,\n            #bool:\u5143\u7d20\u7981\u7528\n            #\u4e3aTure\u65f6\u5143\u7d20\u7981\u7528\uff0c\u65e0\u6cd5\u8f93\u5165\u5185\u5bb9\n    password_char='',\n            #\u5bc6\u7801\u5b57\u7b26\uff0c\u4e00\u822c\u8bbe\u7f6e\u4e3a*\u53f7\n    justification=None,\n            #\u5bf9\u9f50\u65b9\u5f0f\u2018r\u2019\uff0c\u2018l\u2019\uff0c\u2018c\u2019\n    background_color=None,\n            #\u80cc\u666f\u989c\u8272\u8bbe\u7f6e\n    text_color=None,\n            #\u6587\u672c\u989c\u8272\u8bbe\u7f6e\n    font=None,\n            #\u5b57\u4f53\u540d\u79f0\u6216\u8005\u5927\u5c0f\u7684\u8bbe\u7f6e\uff08\u2018\u9ed1\u4f53\u2019\uff0c16\uff09\n    tooltip=None,\n            #\u60ac\u6d6e\u6587\u672cstr\n            #\u5f53\u5149\u6807\u7f6e\u4e8e\u8be5\u5143\u7d20\u4e0a\u65b9\u65f6\uff0c\u8bbe\u7f6e\u7684\u6587\u672c\u4f1a\u663e\u793a\n    broder_width=None,\n            #\u8f93\u5165\u6846\u8fb9\u754c\u7ebf\u7684\u5bbd\u5ea6\u8bbe\u7f6e\n    enable_events=False,\n            #bool \u8f93\u5165\u6846\u7684\u4e8b\u4ef6\u5c5e\u6027\uff0c\n            #\u5982\u679c\u8bbe\u7f6e\u4e3aTure\uff0c\u8f93\u5165\u503c\u65f6\u4f1a\u53d1\u751f\u4e00\u4e2a\u4e8b\u4ef6\u3002\n    do_not_clear=True,\n            #bool \u8f93\u5165\u6846\u5185\u5bb9\u6e05\u9664\n            #\u5982\u679c\u8bbe\u7f6e\u4e3aFalse\uff0c\u53d1\u751f\u4e8b\u4ef6\u65f6\uff0c\u8be5\u8f93\u5165\u6846\u5185\u7684\u503c\u5c06\u88ab\u6e05\u7a7a\n    focus=False,\n            #bool \u8bbe\u5b9a\u7126\u70b9\n            #\u5982\u679c\u4e3aTure \u5219\u5149\u6807\u663e\u793a\u5728\u6b64\u8f93\u5165\u6846\n    pad=None,\n            #(int,int)or((int,int),(int,int))\n            #or (int,(int,int))or ((int.int),int)\n            #((\u5de6,\u53f3),(\u4e0a,\u4e0b))or ((\u5de6\/\u53f3),(\u4e0a,\u4e0b))or((\u5de6,\u53f3),(\u4e0a\/\u4e0b))\n    disable_readonly_background_color=None,\n            #str \u5143\u7d20\u7981\u7528\u65f6\u7684\u80cc\u666f\u989c\u8272\n    disable_readonly_text_color=None,\n            #str  \u5143\u7d20\u7981\u7528\u65f6\u7684\u6587\u672c\u989c\u8272\u8bbe\u7f6e\n    visible=True\n            #\u5143\u7d20\u7684\u53ef\u89c1\u72b6\u6001\n            #\u5982\u679c\u8bbe\u7f6e\u4e3aFalse\uff0c\u5219\u5143\u7d20\u4e0d\u53ef\u89c1\n)\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\"><span class=\"has-inline-color has-vivid-red-color\">SetFocus<\/span>\u65b9\u6cd5\uff0c\u7528\u4e8e\u5143\u7d20\u7126\u70b9\u7684\u8bbe\u7f6e\u3002\n\n<span class=\"has-inline-color has-vivid-red-color\">window[key].SetFocus()\nwindow[key].set_focus()<\/span>\n\n<span class=\"has-inline-color has-vivid-red-color\">Update<\/span>\u65b9\u6cd5\uff0c\u7528\u4e8e\u5143\u7d20\u7684\u66f4\u65b0\u3002\n\n<span class=\"has-inline-color has-vivid-red-color\">window[key].update()\nwindow[key].Update()<\/span>\n\u5143\u7d20\u53ef\u4ee5\u66f4\u65b0\u7684\u5c5e\u6027\u53ea\u6709\u4ee5\u4e0b\u51e0\u79cd\uff1a<\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\nupdate(\n    value=None,\n            #str \u66f4\u65b0\u8f93\u5165\u6846\u5185\u7684\u6587\u672c\n    disable=None,\n            #bool \u66f4\u65b0\u5143\u7d20\u7684\u7981\u7528\u72b6\u6001\n    select=None,\n            #bool \u5143\u7d20\u9009\u4e2d\n            #\u5982\u679c\u4e3aTrue\uff0c\u8f93\u5165\u6846\u5185\u7684\u6587\u672c\u88ab\u5168\u9009\u4e2d\n            #\u548cfocus\u6216\u8005set_focus\u4e00\u8d77\u4f7f\u7528\n    visible=None,\n            #bool \u66f4\u65b0\u5143\u7d20\u7684\u53ef\u89c1\u6027\n    text_color=None,\n    background_color=None,\n    move_cursor_to='end'\n            #\u5149\u6807\u79fb\u52a8\u5230\u6587\u672c\u6700\u540e\n            #\u548cvalue,focus\u4e00\u8d77\u4f7f\u7528\n)\n<\/pre><\/div>\n\n\n<p><span class=\"has-inline-color has-vivid-red-color\">SetTooltip<\/span>\u65b9\u6cd5\uff0c\u7528\u4e8e\u5143\u7d20\u60ac\u6d6e\u6587\u672c\u7684\u8bbe\u5b9a\u3002<\/p>\n\n\n\n<p><span class=\"has-inline-color has-vivid-red-color\">window[key].SetTooltip(&#8221;)<br>window[key].set_tooltip(&#8221;)<\/span><\/p>\n\n\n\n<p>\u7ec3\u4e60<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/139.155.46.233\/wp-content\/uploads\/2021\/09\/\u5fae\u4fe1\u622a\u56fe_20201121113742.png\" alt=\"\" class=\"wp-image-54\" width=\"592\" height=\"256\" srcset=\"https:\/\/www.lucas88.cn\/wp-content\/uploads\/2021\/09\/\u5fae\u4fe1\u622a\u56fe_20201121113742.png 365w, https:\/\/www.lucas88.cn\/wp-content\/uploads\/2021\/09\/\u5fae\u4fe1\u622a\u56fe_20201121113742-300x130.png 300w\" sizes=\"auto, (max-width: 592px) 100vw, 592px\" \/><\/figure>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\nimport PySimpleGUI as sg\nlayout = &#x5B;\n    &#x5B;sg.T('\u8f93\u5165\u6846\u5c0f\u7ec3\u4e60',size=(30,1))],\n    &#x5B;sg.T('\u8bf7\u8f93\u51653\u4f4d\u6570\u7684\u5bc6\u7801',size=(30,1))],\n    &#x5B;sg.I('',key='-PW-',password_char='*',do_not_clear=False)],\n    &#x5B;sg.B('OK')]\n]\nwindow= sg.Window('Python GUI',layout)\n\nwhile True:\n    event,values=window.read()\n    print(event,values)\n    if event==None:\n        break\n    if event=='OK':\n        if values&#x5B;'-PW-']=='124':\n            sg.Popup('\u5bc6\u7801\u6b63\u786e')\n\n        else:\n            sg.Popup('\u5bc6\u7801\u9519\u8bef\uff0c\u5bc6\u7801\u4e0d\u662f'+values&#x5B;'-PW-'])\n            window&#x5B;'-PW-'].SetTooltip('\u63d0\u793a\uff1a\u5bc6\u7801\u662f12*')\nwindow.close()\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>\u5355\u884c\u8f93\u5165\u6846\u5143\u7d20\u4ecb\u7ecd \u76f8\u5f53\u4e8etkinter\u4e2d\u7684\u90e8\u4ef6Entry sg.InputText()\u652f\u6301\u7b80\u5199sg.In()&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/www.lucas88.cn\/?p=53\">\u9605\u8bfb\u66f4\u591a<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,8],"tags":[],"class_list":["post-53","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/posts\/53","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=53"}],"version-history":[{"count":1,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/posts\/53\/revisions"}],"predecessor-version":[{"id":55,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/posts\/53\/revisions\/55"}],"wp:attachment":[{"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=53"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=53"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=53"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}