{"id":62,"date":"2021-09-09T12:37:23","date_gmt":"2021-09-09T04:37:23","guid":{"rendered":"http:\/\/139.155.46.233\/?p=62"},"modified":"2021-09-09T12:37:23","modified_gmt":"2021-09-09T04:37:23","slug":"%e4%b8%8b%e6%8b%89%e8%8f%9c%e5%8d%95combo%e7%9a%84%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/www.lucas88.cn\/?p=62","title":{"rendered":"\u4e0b\u62c9\u83dc\u5355Combo\u7684\u4ecb\u7ecd"},"content":{"rendered":"\n<pre class=\"wp-block-preformatted\">\u8f93\u5165\u6846\u548c\u4e0b\u62c9\u83dc\u5355\u7684\u4e00\u4e2a\u7ec4\u5408\u90e8\u4ef6\uff0c\n<span class=\"has-inline-color has-vivid-red-color\">sg.Combo()<\/span> or <span class=\"has-inline-color has-vivid-red-color\">sg.InputCombo()<\/span> OR <span class=\"has-inline-color has-vivid-red-color\">sg.DropDown()<\/span> or <span class=\"has-inline-color has-vivid-red-color\">sg.Drop()<\/span><\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\nCombo(\n    values,\n            #list&#x5B;any] or tuple&#x5B;Any]\n            #\u663e\u793a\u4e0b\u62c9\u83dc\u5355\u4fe1\u606f\uff0c\u5217\u8868\u6216\u8005\u5143\u7956\n    default_value=None,\n            #initial value\n            #\u9ed8\u8ba4\u9009\u4e2d\n    key=None,\n            #\u5143\u7d20\u7684\u552f\u4e00\u6807\u8bc6\u7b26\n            #\u4e66\u5199\u89c4\u8303'-COMBO-'\n    enable_events=False,\n            #\u5143\u7d20\u7684\u4e8b\u4ef6\u5c5e\u6027\n            #\u5982\u679c\u8bbe\u5b9a\u4e3aTrue\uff0c\u5143\u7d20\u5217\u8868\u9879\u76ee\u88ab\u9009\u4e2d\u65f6\u4f1a\u53d1\u751f\u4e8b\u4ef6\n    size=(None, None),\n            # \u8bbe\u7f6e\u5143\u7d20\u5c3a\u5bf8\uff08\u5bbd\uff0c\u9ad8\uff09\n    disabled=False,\n            # bool:\u5143\u7d20\u7981\u7528\n            # \u4e3aTure\u65f6\u5143\u7d20\u7981\u7528\uff0c\u65e0\u6cd5\u70b9\u51fb\n    auto_size_text=None,\n            # bool \u5143\u7d20\u81ea\u52a8\u6839\u636e\u5185\u5bb9\u5927\u5c0f\u8c03\u6574\n    font=None,\n            # \u5b57\u4f53\u540d\u79f0\uff0c\u5b57\u4f53\u5927\u5c0f\uff08\u2018\u9ed1\u4f53\u2019\uff0c16\uff09\n    background_color=None,\n            #str  \u8bbe\u7f6e\u80cc\u666f\u989c\u8272\n    text_color=None,\n            #str \u8bbe\u7f6e\u6587\u672c\u989c\u8272\n    tooltip=None,\n            #\u60ac\u6d6e\u6587\u672c\n    readonly=False,\n            #\u5143\u7d20\u53ea\u8bfb\u5c5e\u6027\uff0c\u53ea\u80fd\u9009\u62e9\uff0c\u4e0d\u80fd\u8f93\u5165\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    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\"><strong><span class=\"has-inline-color has-pale-pink-color\">\u548clistbox\u6700\u5927\u7684\u533a\u522b\u5728\u4e8e\uff0c\u53ef\u4ee5\u8f93\u5165\uff0c\u4f46\u662f\u4e0d\u80fd\u591a\u9009\u3002ListBox\u53d6\u5f97\u7684\u503c\u662f\n\u5b58\u653e\u5728\u5217\u8868\u91cc\u9762\u7684\uff0c\u800cCombo\u53d6\u5f97\u7684\u503c\u662f\u5bf9\u8c61\u672c\u8eab<\/span><\/strong>\n\u5143\u7d20\u53ef\u4ee5\u66f4\u65b0\u7684\u5c5e\u6027\u53ea\u6709\u4ee5\u4e0b\u51e0\u79cd\uff1a\n<span class=\"has-inline-color has-vivid-red-color\">window[key].update()<\/span><\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\nupdate(\n    value=None,\n            #\u66f4\u65b0\u9ed8\u8ba4\u9009\u4e2d\u7684\u9009\u9879\n    values=None,\n            #\u66f4\u65b0\u663e\u793a\u7684\u6240\u6709\u4e0b\u62c9\u83dc\u5355\u6587\u672c\n    disabled=False,\n            # bool:\u5143\u7d20\u7981\u7528\n            # \u4e3aTure\u65f6\u5143\u7d20\u7981\u7528\uff0c\u65e0\u6cd5\u70b9\u51fb\n    set_to_index=None,\n            #\u9ad8\u4eae\u663e\u793a\u8bbe\u5b9a\u7684\u7d22\u5f15\uff0cUnion&#x5B;int,list,tuple],\u4e3e\u4f8b\u5982\u4e0b\n            #set_to_index =1\n            # set_to_index =&#x5B;1,2]\n            # set_to_index =(1,2)\n            #\u6ce8\u610f\uff1a\uff1a\u5355\u51fb\u53ea\u662f\u9ad8\u4eae\u663e\u793a\uff0c\u5e76\u672a\u9009\u4e2d\uff0c\u53cc\u51fb\u624d\u662f\u9ad8\u4eae\u663e\u793a+\u9009\u4e2d\n            #\u5355\u51fb\u83b7\u53d6\u503c\u65f6\uff0c\u4e0d\u7528valuse\uff08key\uff09\uff0c\u800c\u662f\u7528window&#x5B;key].get()\n    font=None,\n            #\uff08\u2018\u5b8b\u4f53\u2019\uff0c11\uff09\uff08\u5b57\u4f53\u540d\u79f0\uff0c\u5b57\u53f7\uff09\n    readonly=None,\n            #BOOL \u53ea\u8bfb\u5c5e\u6027\n    visible=None,\n            #bool \u66f4\u65b0\u5143\u7d20\u7684\u53ef\u89c1\u6027\n)\n<\/pre><\/div>\n\n\n<p>\u5c0f\u7ec3\u4e60<\/p>\n\n\n\n<p>\u4f7f\u7528Combo\u5b8c\u6210listbox\u4e00\u6837\u7684\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-2.png\" alt=\"\" class=\"wp-image-60\" width=\"373\" height=\"404\"\/><\/figure>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\nimport PySimpleGUI as sg\naccounts={\n    '\u8d26\u53f71':&quot;TYEGFVFGSDFH999&quot;,\n    '\u8d26\u53f72':&quot;SADFSFA23SDF333&quot;,\n    '\u8d26\u53f73':&quot;R43TWERWR3RFEWE&quot;,\n    '\u8d26\u53f74':&quot;FSGSGWEGW442TRR&quot;,\n    '\u8d26\u53f75':&quot;BYHKJTLLTREGEG4&quot;,\n    '\u8d26\u53f76':&quot;9U34NSMFNSDASKF&quot;,\n    '\u8d26\u53f77':&quot;0934JH234H523UH&quot;\n}\nlist_zh =&#x5B;]\nfor i in accounts:\n    list_zh.append(i)\nlayout = &#x5B;\n    &#x5B;sg.Combo(list_zh,default_value='\u8d26\u53f71',enable_events=True,size=(30,3))],\n    &#x5B;sg.T('\u5bc6\u7801\uff1a'),sg.In(size=(25,1),key='-PW-')]\n]\nwindow = sg.Window('Window Title', layout)\nwhile True:\n    event, values = window.read()\n    if event == None:\n        break\n    if event==0:\n        window&#x5B;'-PW-'].SetFocus()\n        window&#x5B;'-PW-'].update(accounts&#x5B;values&#x5B;0]])\n        window&#x5B;'-PW-'].update(select=True)\nwindow.close()\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>\u8f93\u5165\u6846\u548c\u4e0b\u62c9\u83dc\u5355\u7684\u4e00\u4e2a\u7ec4\u5408\u90e8\u4ef6\uff0c sg.Combo() or sg.InputCombo() OR sg.Dr&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/www.lucas88.cn\/?p=62\">\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-62","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/posts\/62","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=62"}],"version-history":[{"count":1,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/posts\/62\/revisions"}],"predecessor-version":[{"id":63,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/posts\/62\/revisions\/63"}],"wp:attachment":[{"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=62"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=62"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=62"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}