{"id":1649,"date":"2018-05-22T23:26:00","date_gmt":"2018-05-22T21:26:00","guid":{"rendered":"http:\/\/yarogniew.net\/arduino\/?p=1649"},"modified":"2018-05-23T13:00:19","modified_gmt":"2018-05-23T11:00:19","slug":"python-i-okienka-biblioteka-wxpython","status":"publish","type":"post","link":"https:\/\/arduino.net.pl\/index.php\/python-i-okienka-biblioteka-wxpython\/","title":{"rendered":"Python i okienka, biblioteka wxPython"},"content":{"rendered":"<p>Moje pierwsze okienko:<\/p>\n<pre class=\"brush: python; light: false; title: Kod:; toolbar: true; notranslate\" title=\"Kod:\">\r\nimport wx\r\n\r\napp = wx.App()\r\nframe = wx.Frame(None, -1, &quot;Tytul&quot;)\r\nframe.Show()\r\napp.MainLoop()\r\n<\/pre>\n<p>Drugie okienko z potwierdzeniem wyj\u015bcia<\/p>\n<pre class=\"brush: python; light: false; title: Kod:; toolbar: true; notranslate\" title=\"Kod:\">\r\nimport wx\r\n\r\ndef OnClose(event):\r\n    dlg = wx.MessageDialog(top,\r\n        &quot;Naprawd\u0119 chcesz to, kurna, zamkn\u0105\u0107?&quot;,\r\n        &quot;Co jest?!&quot;, wx.OK|wx.CANCEL|wx.ICON_QUESTION)\r\n    result = dlg.ShowModal()\r\n    dlg.Destroy()\r\n    if result == wx.ID_OK:\r\n        top.Destroy()\r\n\r\napp = wx.App(redirect=True)\r\ntop = wx.Frame(None, title=&quot;Hello World&quot;, size=(300,200))\r\ntop.Bind(wx.EVT_CLOSE, OnClose)\r\ntop.Show()\r\napp.MainLoop()\r\n<\/pre>\n<p>Trzecie okno z klas\u0105<\/p>\n<pre class=\"brush: python; light: false; title: Kod:; toolbar: true; notranslate\" title=\"Kod:\">\r\nimport wx\r\n\r\nclass windowClass(wx.Frame):\r\n\r\n    def __init__(self, parent, title):\r\n        super(windowClass, self).__init__(parent, title=title, size=(400, 300))\r\n\r\n        self.Move(100, 500)  # pozycja okna 100, 500\r\n        self.Center()   # pozycja okna w \u015brodku\r\n\r\n        self.Show()\r\n\r\n\r\napp = wx.App()\r\nwindowClass(None, title=&quot;Jo\u0142, jo\u0142&quot;)\r\napp.MainLoop()\r\n<\/pre>\n<p>Okno z menu<\/p>\n<pre class=\"brush: python; light: false; title: Kod:; toolbar: true; notranslate\" title=\"Kod:\">\r\n#!\/usr\/bin\/env python3\r\n# -*- coding: utf-8 -*-\r\n\r\n&quot;&quot;&quot;\r\nZetCode wxPython tutorial\r\n\r\nThis example shows a simple menu.\r\n\r\nauthor: Jan Bodnar\r\nwebsite: www.zetcode.com\r\nlast modified: April 2018\r\n&quot;&quot;&quot;\r\n\r\nimport wx\r\n\r\n\r\nclass Example(wx.Frame):\r\n\r\n    def __init__(self, *args, **kwargs):\r\n        super(Example, self).__init__(*args, **kwargs)\r\n\r\n        self.InitUI()\r\n\r\n    def InitUI(self):\r\n\r\n        menubar = wx.MenuBar()\r\n        fileMenu = wx.Menu()\r\n        fileItem = fileMenu.Append(wx.ID_EXIT, 'Quit', 'Quit application')\r\n        menubar.Append(fileMenu, '&amp;File')\r\n        self.SetMenuBar(menubar)\r\n\r\n        self.Bind(wx.EVT_MENU, self.OnQuit, fileItem)\r\n\r\n        self.SetSize((300, 200))\r\n        self.SetTitle('Simple menu')\r\n        self.Centre()\r\n\r\n    def OnQuit(self, e):\r\n        self.Close()\r\n\r\n\r\ndef main():\r\n\r\n    app = wx.App()\r\n    ex = Example(None)\r\n    ex.Show()\r\n    app.MainLoop()\r\n\r\n\r\nif __name__ == '__main__':\r\n    main()\r\n\r\n<\/pre>\n<p><a href=\"http:\/\/zetcode.com\/wxpython\/\">wxPython tutorial &#8211; Jan Bodnar<\/a><\/p>\n<blockquote><p>You can check your virtual environment in PyCharm -&gt; Preferences -&gt; Project -&gt; Project Interpreter. There you can also press the + symbol at the bottom left to install wxpython there. (Which will basically pip install the package inside the virtualenv your project uses.)<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Moje pierwsze okienko: import wx app = wx.App() frame = wx.Frame(None, -1, &quot;Tytul&quot;) frame.Show() app.MainLoop() Drugie okienko z potwierdzeniem wyj\u015bcia import wx def OnClose(event): dlg = wx.MessageDialog(top, &quot;Naprawd\u0119 chcesz to,&#8230;<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[59],"tags":[],"class_list":["post-1649","post","type-post","status-publish","format-standard","hentry","category-python"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/posts\/1649","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/comments?post=1649"}],"version-history":[{"count":8,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/posts\/1649\/revisions"}],"predecessor-version":[{"id":1657,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/posts\/1649\/revisions\/1657"}],"wp:attachment":[{"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/media?parent=1649"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/categories?post=1649"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/tags?post=1649"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}