{"id":2599,"date":"2022-09-05T15:19:40","date_gmt":"2022-09-05T07:19:40","guid":{"rendered":"http:\/\/cnliutz.uicp.io\/?p=2599"},"modified":"2022-09-05T15:19:40","modified_gmt":"2022-09-05T07:19:40","slug":"python-gui-wxpython%e7%aa%97%e5%8f%a3%e6%bc%94%e7%a4%ba","status":"publish","type":"post","link":"http:\/\/xc.ipyingshe.net:5347\/?p=2599","title":{"rendered":"python GUI wxpython\u7a97\u53e3\u6f14\u793a"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>import wx\nclass MyFrame(wx.Frame):\n    def __init__(self, parent, title):\n        wx.Frame.__init__(self, parent, title = title)\n        self.panel = wx.Panel(self)\n        self.panel.Bind(wx.EVT_LEFT_UP, self.OnClick)\n        self.Show(True)\n\n    def OnClick(self, event):\n        posm = event.GetPosition()\n        wx.Button(self.panel,label=\"Hi~~~\",pos = (posm.x, posm.y))\n\nif __name__=='__main__':\n    app = wx.App()\n    frame = MyFrame(None, 'Hello Python')\n    app.MainLoop()<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"http:\/\/cnliutz.uicp.io\/wp-content\/uploads\/2022\/09\/image-3.png\" alt=\"\" class=\"wp-image-2600\"\/><figcaption>\u7a0b\u5e8f\u8fd0\u884c\u7ed3\u679c<\/figcaption><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>#Filename:helloworldbtn.py\nimport wx\nclass Frame1(wx.Frame):\n    def __init__(self,superior):\n        wx.Frame.__init__(self,parent = superior,title =\"Hello World in wxPython\")\n        panel = wx.Panel(self)\n        sizer = wx.BoxSizer(wx.VERTICAL)\n        self.text1=wx.TextCtrl(panel,value =\"Let's Begin now!!\",size =(250,180),style= wx.TE_MULTILINE)\n        sizer.Add(self.text1,0,wx.ALIGN_TOP | wx.EXPAND)\n        button = wx.Button(panel,label= \"Click Me\")\n        sizer.Add(button)\n        panel.SetSizerAndFit(sizer)\n        panel.Layout()\n        self.Bind(wx.EVT_BUTTON,self.OnClick,button)\n        self.Show(True)\n    def OnClick(self,text):\n        for i in range(3):\n            self.text1.AppendText(\"\\nHello,World!\"+str(i))\n        self.text1.AppendText('\\n'+\"-\"*20)\nif __name__=='__main__':\n    app = wx.App()\n    frame = Frame1(None)\n    app.MainLoop()\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"http:\/\/cnliutz.uicp.io\/wp-content\/uploads\/2022\/09\/image-4.png\" alt=\"\" class=\"wp-image-2602\"\/><\/figure>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-2599","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"http:\/\/xc.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/2599","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/xc.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xc.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xc.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xc.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2599"}],"version-history":[{"count":0,"href":"http:\/\/xc.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/2599\/revisions"}],"wp:attachment":[{"href":"http:\/\/xc.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2599"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xc.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2599"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xc.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2599"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}