https://wiki.wxpython.org/How to install wxPython

  1. pip install -U wxPython

  

验证版本

  1. D:\python>python
  2. Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:14:34) [MSC v.1900 32 bit (Intel)] on win32
  3. Type "help", "copyright", "credits" or "license" for more information.
  4. >>> import wx
  5. >>> wx.VERSION_STRING
  6. '4.0.0a3'
  7. >>> exit
  8. Use exit() or Ctrl-Z plus Return to exit
  9. >>> exit()

  

Hello World

https://www.wxpython.org/pages/overview/

  1. #!/bin/python
  2. """
  3. Hello World, but with more meat.
  4. """
  5.  
  6. import wx
  7.  
  8. class HelloFrame(wx.Frame):
  9. """
  10. A Frame that says Hello World
  11. """
  12.  
  13. def __init__(self, *args, **kw):
  14. # ensure the parent's __init__ is called
  15. super(HelloFrame, self).__init__(*args, **kw)
  16.  
  17. # create a panel in the frame
  18. pnl = wx.Panel(self)
  19.  
  20. # and put some text with a larger bold font on it
  21. st = wx.StaticText(pnl, label="Hello World!", pos=(25,25))
  22. font = st.GetFont()
  23. font.PointSize += 10
  24. font = font.Bold()
  25. st.SetFont(font)
  26.  
  27. # create a menu bar
  28. self.makeMenuBar()
  29.  
  30. # and a status bar
  31. self.CreateStatusBar()
  32. self.SetStatusText("Welcome to wxPython!")
  33.  
  34. def makeMenuBar(self):
  35. """
  36. A menu bar is composed of menus, which are composed of menu items.
  37. This method builds a set of menus and binds handlers to be called
  38. when the menu item is selected.
  39. """
  40.  
  41. # Make a file menu with Hello and Exit items
  42. fileMenu = wx.Menu()
  43. # The "\t..." syntax defines an accelerator key that also triggers
  44. # the same event
  45. helloItem = fileMenu.Append(-1, "&Hello...\tCtrl-H",
  46. "Help string shown in status bar for this menu item")
  47. fileMenu.AppendSeparator()
  48. # When using a stock ID we don't need to specify the menu item's
  49. # label
  50. exitItem = fileMenu.Append(wx.ID_EXIT)
  51.  
  52. # Now a help menu for the about item
  53. helpMenu = wx.Menu()
  54. aboutItem = helpMenu.Append(wx.ID_ABOUT)
  55.  
  56. # Make the menu bar and add the two menus to it. The '&' defines
  57. # that the next letter is the "mnemonic" for the menu item. On the
  58. # platforms that support it those letters are underlined and can be
  59. # triggered from the keyboard.
  60. menuBar = wx.MenuBar()
  61. menuBar.Append(fileMenu, "&File")
  62. menuBar.Append(helpMenu, "&Help")
  63.  
  64. # Give the menu bar to the frame
  65. self.SetMenuBar(menuBar)
  66.  
  67. # Finally, associate a handler function with the EVT_MENU event for
  68. # each of the menu items. That means that when that menu item is
  69. # activated then the associated handler function will be called.
  70. self.Bind(wx.EVT_MENU, self.OnHello, helloItem)
  71. self.Bind(wx.EVT_MENU, self.OnExit, exitItem)
  72. self.Bind(wx.EVT_MENU, self.OnAbout, aboutItem)
  73.  
  74. def OnExit(self, event):
  75. """Close the frame, terminating the application."""
  76. self.Close(True)
  77.  
  78. def OnHello(self, event):
  79. """Say hello to the user."""
  80. wx.MessageBox("Hello again from wxPython")
  81.  
  82. def OnAbout(self, event):
  83. """Display an About Dialog"""
  84. wx.MessageBox("This is a wxPython Hello World sample",
  85. "About Hello World 2",
  86. wx.OK|wx.ICON_INFORMATION)
  87.  
  88. if __name__ == '__main__':
  89. # When this module is run (not imported) then create the app, the
  90. # frame, show it, and start the event loop.
  91. app = wx.App()
  92. frm = HelloFrame(None, title='Hello World 2')
  93. frm.Show()
  94. app.MainLoop()

 

使用指导 https://wiki.wxpython.org/Getting Started

 

API参考 https://docs.wxpython.org/

wxPython安装使用的更多相关文章

  1. wxpython安装,demo下载

    wxPython介绍      wxPython是Python语言的一套优秀的GUI图形库.wxPython可以很方便的创建完整的.功能键全的GUI用户界面. wxPython安装 本安装采用pip自 ...

  2. wxPython安装错误问题:No module named wx

    今天心血来潮安装wxPython,本机win7,且已经安装Python,版本为2.7.3,然后IDE使用的PyCharm,然后wxPython下载的版本为:wxPython2.8-win32-unic ...

  3. wxpython 安装教程

    wxpython在windows 上的安装,需要在wxpython官网上下载对应的版本:Python分为32和64位系统不是系统的32位和64位 所以可以先在IDE 下输入Python看下当前是32还 ...

  4. 26-python图形化插件 wxpython安装时的问题

    最实在而又最实用的的安装方式pip,且必须习惯使用的方式,会同步安装相关的依赖包: pip install -U wxPython 总是包超时的错误:于是更新了pip 之后还是不行,于是改为了下面的命 ...

  5. wxPython 安装 及参考文档

    三种操作平台上的安装方法 1.windows 和 mac pip install -U wxPython 2.linux pip install -U -f https://extras.wxpyth ...

  6. 配置Robot Framework 环境时如何查看wxPython是否成功安装

    配置Robot Framework,win10系统,安装版本分别如下:

  7. RobotFramework 安装配置(一)

    服务器接口的测试框架的选择,最后选中了 RobotFramework ,原因一:能有效的管理测试用例,,支持批量执行,能实现关键字驱动或者数据驱动.原因二:支持测试人员可以使用Python和java创 ...

  8. 解决mac-osx10.11下无法安装wxPython2.8-osx-unicode-2.8.12.1的问题

    在mac-osx10.11版本下,安装RIDE前提需要装wxPython2.8-osx-unicode-2.8.12.1库,但在安装wxPython过程中,会提示安装失败,以下提供一种解决方案 这里我 ...

  9. RIDE安装操作

    转载参考https://www.cnblogs.com/Ming8006/p/4998492.html 一.python安装 1.访问Python官网:https://www.python.org/  ...

随机推荐

  1. IE 下 input 不响应 change 事件的处理

    很多时候,我们都需要通过 input 来上传文件,通过 change 事件获取用户上传的文件,然后做一些额外的处理,最后上传到服务器. 可是事情往往就是没有那么美好.是的,IE 下 input 在选择 ...

  2. TreeView 拖拽 增删改

    using Endv.Tools; using System; using System.Data; using System.Drawing; using System.IO; using Syst ...

  3. 微信小程序 - 多地点标识(map)

    演示如下: wxml <map id="map" scale="{{scale}}" controls="{{controls}}" ...

  4. ssh只读事务的管理

    概念:从这一点设置的时间点开始(时间点a)到这个事务结束的过程中,其他事务所提交的数据,该事务将看不见!(查询中不会出现别人在时间点a之后提交的数据) 应用场合: 如果你一次执行单条查询语句,则没有必 ...

  5. 利用velocity.js将svg动起来

    关于velocity.js Velocity.js是一款jquery动画引擎插件,它拥有与jquery中的$.animate()相同的API,还打包了颜色动画,转换,循环,easing效果,类动画.滚 ...

  6. DirectShow控制台输出和保存视频设备名称

    #include "windows.h" #include "TCHAR.h" #include <dshow.h> #include <ve ...

  7. unity, write/read txt file

    在Assets下新建文件夹StreamingAssets.然后下面代码可在其中生成test.txt文件,并读写: using UnityEngine;using System.Collections; ...

  8. springboot+thymeleaf打war包在外部tomcat运行

    工程目录 pom文件注意点 <packaging>war</packaging> <dependency> <groupId>org.springfra ...

  9. Codeforces Round #240 (Div. 1)B---Mashmokh and ACM(水dp)

    Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university ...

  10. Android解决button反复点击问题

    public class BaseActivity extends Activity { protected boolean isDestroy; //防止反复点击设置的标志.涉及到点击打开其它Act ...