python:wxpython

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
python:wxpython [2021/06/11 21:07] – [最小のwxPythonアプリケーション] ともやんpython:wxpython [2021/06/12 12:32] (現在) – [distutils.msvc9compiler の find_vcvarsall() の実装 (Python 3.8)] ともやん
行 1: 行 1:
- 
 ====== wxPython ====== ====== wxPython ======
 {{python:wxpython_logo.png?309|wxPython Logo}}\\ {{python:wxpython_logo.png?309|wxPython Logo}}\\
行 16: 行 15:
 **wxPython Phoenix 4**系\\ **wxPython Phoenix 4**系\\
 <code powershell> <code powershell>
-PS > pip install wxpython+pip install wxpython
 </code> </code>
 <WRAP prewrap 100% #result> <WRAP prewrap 100% #result>
 <code> <code>
 Collecting wxpython Collecting wxpython
-  Downloading wxPython-4.0.7.post2-cp38-cp38-win_amd64.whl (22.MB) +  Downloading wxPython-4.1.1-cp39-cp39-win_amd64.whl (18.MB) 
-     |████████████████████████████████| 22.MB 819 kB/s+     |████████████████████████████████| 18.1 MB 2.MB/s
 Collecting six Collecting six
-  Downloading six-1.14.0-py2.py3-none-any.whl (10 kB) +  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
-Collecting numpy; python_version >= "3.0" +
-  Downloading numpy-1.18.1-cp38-cp38-win_amd64.whl (12.8 MB) +
-     |████████████████████████████████| 12.8 MB 1.3 MB/s+
 Collecting pillow Collecting pillow
-  Downloading Pillow-7.0.0-cp38-cp38-win_amd64.whl (2.MB) +  Downloading Pillow-8.2.0-cp39-cp39-win_amd64.whl (2.MB) 
-     |████████████████████████████████| 2.MB 1.3 MB/s +     |████████████████████████████████| 2.MB 3.3 MB/s 
-Installing collected packages: six, numpy, pillow, wxpython +Collecting numpy; python_version >= "3.0" 
-Successfully installed numpy-1.18.pillow-7.0.0 six-1.14.0 wxpython-4.0.7.post2+  Downloading numpy-1.20.3-cp39-cp39-win_amd64.whl (13.7 MB) 
 +     |████████████████████████████████| 13.7 MB 3.3 MB/s 
 +Installing collected packages: six, pillow, numpy, wxpython 
 +Successfully installed numpy-1.20.pillow-8.2.0 six-1.16.0 wxpython-4.1.1
 </code> </code>
 </WRAP> </WRAP>
行 186: 行 185:
  
 ==== distutils.msvccompiler の get_build_version() の実装 (Python 3.8) ==== ==== distutils.msvccompiler の get_build_version() の実装 (Python 3.8) ====
-<WRAP prewrap 100% #result>+<WRAP prewrap 100% #result_long>
 <code python> <code python>
 def get_build_version(): def get_build_version():
行 239: 行 238:
  
 ==== distutils.msvc9compiler の find_vcvarsall() の実装 (Python 3.8) ==== ==== distutils.msvc9compiler の find_vcvarsall() の実装 (Python 3.8) ====
-<WRAP prewrap 100% #result>+<WRAP prewrap 100% #result_long>
 <code python> <code python>
 def find_vcvarsall(version): def find_vcvarsall(version):
行 278: 行 277:
 </WRAP> </WRAP>
  
-===== 最小のwxPythonアプリケーション ===== +===== 最小の wxPython アプリケーション ===== 
-UTF-8で保存すること。+<wrap em>※ UTF-8 で保存すること。</wrap>\\ 
 + 
 +==== wx.Frame サンプル ==== 
 +{{:python:wxpython_minimum_app_001.png?276|wxPython minimum app 001}}\\ 
 <WRAP prewrap 100% #source_code> <WRAP prewrap 100% #source_code>
 <code python PyWxHelloMain.py> <code python PyWxHelloMain.py>
 +#!/usr/bin/env python
 +# -*- coding: utf-8 -*-
 +import wx
 + 
 +# PyWxHelloFrame クラス(wxFrame から派生)
 +class PyWxHelloFrame(wx.Frame):
 +    def __init__(self, *args, **kwds):
 +        wx.Frame.__init__(self, *args, **kwds)
 +        # Panel 生成
 +        panel = wx.Panel(self, -1)
 +        # Panel に [閉じる] ボタンを追加
 +        btnClose = wx.Button(panel, wx.NewIdRef(), u"閉じる")
 +        # ボタンの位置を設定
 +        btnClose.SetPosition((100, 35))
 +        # クリックイベントにイベントハンドラをバインド
 +        self.Bind(wx.EVT_BUTTON, self.btnClose_Click, btnClose)
 + 
 +    # [閉じる] ボタンクリック時
 +    def btnClose_Click(self, event):
 +        # 閉じる
 +        self.Close(True)
 + 
 +# PyWxHelloApp クラス(wxApp から派生)
 +class PyWxHelloApp(wx.App):
 +    def OnInit(self):
 +        # PyWxHelloFrame クラスを生成(タイトル、サイズを指定)
 +        mainFrame = PyWxHelloFrame(None, -1, "Hello wxPython!!", size=(290, 100))
 +        # トップウインドウとして設定
 +        self.SetTopWindow(mainFrame)
 +        # 表示
 +        mainFrame.Show(True)
 +        # 正常終了
 +        return True
 + 
 +# メイン処理
 +def main():
 +    # PyWxHelloApp クラスを生成
 +    app = PyWxHelloApp(False)
 +    # メインループを開始
 +    app.MainLoop()
 + 
 +# スクリプト起動時にmain()を実行
 +if __name__ == "__main__":
 +    main()
 +</code>
 +</WRAP>
 +
 +サンプルアプリケーションの実行。\\
 +<WRAP prewrap 100%>
 +<code>
 +$ python PyWxHelloMain.py
 +</code>
 +</WRAP>
 +
 +==== wx.html2.WebView サンプル ====
 +{{:python:wxpython_minimum_app_002.png?640|wxPython minimum app 002}}\\
 +
 +<WRAP prewrap 100% #source_code>
 +<code python PyWxWebView.py>
 #!/usr/bin/env python #!/usr/bin/env python
 # -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
行 319: 行 381:
     app.MainLoop()     app.MainLoop()
 </code> </code>
 +</WRAP>
 +
 +サンプルアプリケーションの実行。\\
 +<WRAP prewrap 100%>
 +<code>
 +$ python PyWxWebView.py</code>
 </WRAP> </WRAP>
  
行 382: 行 450:
 [[https://www.nuget.org/packages/Microsoft.Web.WebView2|NuGet Gallery | Microsoft.Web.WebView2 0.9.430]]\\ [[https://www.nuget.org/packages/Microsoft.Web.WebView2|NuGet Gallery | Microsoft.Web.WebView2 0.9.430]]\\
 [[https://wiki.python.org/moin/WindowsCompilers#Which_Microsoft_Visual_C.2B-.2B-_compiler_to_use_with_a_specific_Python_version_.3F|WindowsCompilers - Python Wiki]]\\ [[https://wiki.python.org/moin/WindowsCompilers#Which_Microsoft_Visual_C.2B-.2B-_compiler_to_use_with_a_specific_Python_version_.3F|WindowsCompilers - Python Wiki]]\\
 +
 +==== 付録 ====
 +[[tw>tomoyan596/status/1403202445094752264|wxPythonのWebViewはIEです😅💦💦💦 vue.jsなんて動きません🤤😇 $ pip install wxpython $ pip freeze wxPython==4.1.1 $ python / Twitter]]\\
 +
  
  • python/wxpython.1623413234.txt.gz
  • 最終更新: 2021/06/11 21:07
  • by ともやん