Py之wxPythonwxPython的簡介、安裝、使用方法之詳細(xì)攻略

      網(wǎng)友投稿 1224 2025-03-31

      Py之wxPython:wxPython的簡介、安裝、使用方法之詳細(xì)攻略


      目錄

      wxPython的簡介

      wxPython的安裝

      wxPython的使用方法

      wxPython的簡介

      wxPython是Phoenix項(xiàng)目!Phoenix是改進(jìn)的下一代wxPython,“比以前更好、更強(qiáng)、更快”。這個(gè)新的實(shí)現(xiàn)主要關(guān)注于提高速度、可維護(hù)性和可擴(kuò)展性。就像“經(jīng)典”的WXPython一樣,菲尼克斯封裝了WxWistGe+C++工具包,并提供了對(duì)WxWistGeAPI API的用戶界面部分的訪問,使Python應(yīng)用程序在Windows、MACS或UNIX系統(tǒng)上具有本地GUI,具有本地的外觀和感覺,并且需要非常少的(如果有的話)特定于平臺(tái)的代碼。

      實(shí)用工具wxdocs和wxdemo將使用wxget(如果必要)下載適當(dāng)?shù)奈募?,解壓縮它們(如果必要),并啟動(dòng)相應(yīng)項(xiàng)的適當(dāng)版本。(文檔在默認(rèn)瀏覽器中啟動(dòng),演示用python啟動(dòng))。

      wxPython是Python語言的跨平臺(tái)GUI工具箱。使用wxPython,軟件開發(fā)人員可以為他們的Python應(yīng)用程序創(chuàng)建真正的本地用戶界面,這些應(yīng)用程序在Windows、Mac和Linux或其他類unix系統(tǒng)上很少或沒有修改的情況下運(yùn)行。

      wxPython pypi

      wxPython官網(wǎng)

      wxPython的安裝

      pip install wxPython

      wxPython的使用方法

      wx.Frame.SetBackgroundColour(self,'green') ?#給窗口設(shè)置背景顏色

      1、example 一

      # First things, first. Import the wxPython package.

      import wx

      # Next, create an application object.

      app = wx.App()

      # Then a frame.

      frm = wx.Frame(None, title="Hello World")

      # Show it.

      frm.Show()

      # Start the event loop.

      app.MainLoop()

      2、example 二

      #!/bin/python

      """

      Hello World, but with more meat.

      """

      import wx

      class HelloFrame(wx.Frame):

      """

      A Frame that says Hello World

      """

      def __init__(self, *args, **kw):

      # ensure the parent's __init__ is called

      super(HelloFrame, self).__init__(*args, **kw)

      # create a panel in the frame

      pnl = wx.Panel(self)

      # and put some text with a larger bold font on it

      st = wx.StaticText(pnl, label="Hello World!", pos=(25,25))

      font = st.GetFont()

      font.PointSize += 10

      font = font.Bold()

      st.SetFont(font)

      # create a menu bar

      self.makeMenuBar()

      # and a status bar

      self.CreateStatusBar()

      self.SetStatusText("Welcome to wxPython!")

      def makeMenuBar(self):

      """

      A menu bar is composed of menus, which are composed of menu items.

      This method builds a set of menus and binds handlers to be called

      when the menu item is selected.

      """

      # Make a file menu with Hello and Exit items

      fileMenu = wx.Menu()

      # The "\t..." syntax defines an accelerator key that also triggers

      # the same event

      helloItem = fileMenu.Append(-1, "&Hello...\tCtrl-H",

      "Help string shown in status bar for this menu item")

      fileMenu.AppendSeparator()

      # When using a stock ID we don't need to specify the menu item's

      # label

      exitItem = fileMenu.Append(wx.ID_EXIT)

      # Now a help menu for the about item

      helpMenu = wx.Menu()

      aboutItem = helpMenu.Append(wx.ID_ABOUT)

      # Make the menu bar and add the two menus to it. The '&' defines

      # that the next letter is the "mnemonic" for the menu item. On the

      # platforms that support it those letters are underlined and can be

      # triggered from the keyboard.

      menuBar = wx.MenuBar()

      menuBar.Append(fileMenu, "&File")

      menuBar.Append(helpMenu, "&Help")

      # Give the menu bar to the frame

      self.SetMenuBar(menuBar)

      # Finally, associate a handler function with the EVT_MENU event for

      # each of the menu items. That means that when that menu item is

      # activated then the associated handler function will be called.

      self.Bind(wx.EVT_MENU, self.OnHello, helloItem)

      self.Bind(wx.EVT_MENU, self.OnExit, exitItem)

      self.Bind(wx.EVT_MENU, self.OnAbout, aboutItem)

      def OnExit(self, event):

      """Close the frame, terminating the application."""

      self.Close(True)

      def OnHello(self, event):

      """Say hello to the user."""

      wx.MessageBox("Hello again from wxPython")

      def OnAbout(self, event):

      """Display an About Dialog"""

      wx.MessageBox("This is a wxPython Hello World sample",

      "About Hello World 2",

      wx.OK|wx.ICON_INFORMATION)

      if __name__ == '__main__':

      # When this module is run (not imported) then create the app, the

      # frame, show it, and start the event loop.

      app = wx.App()

      frm = HelloFrame(None, title='Hello World 2')

      frm.Show()

      app.MainLoop()

      Py之wxPython:wxPython的簡介、安裝、使用方法之詳細(xì)攻略

      更多案例應(yīng)用

      Py之wxPython:利用wxPython設(shè)計(jì)GUI界面(圖片背景+簡單按鈕)

      Python

      版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請(qǐng)聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。

      版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請(qǐng)聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。

      上一篇:吸管機(jī)的未來發(fā)展將趨于規(guī)范化、體系化的方式發(fā)展
      下一篇:玩轉(zhuǎn)AppCube應(yīng)用魔方之可視化大屏動(dòng)態(tài)展示你的博客知識(shí) | 【玩轉(zhuǎn)應(yīng)用魔方】
      相關(guān)文章
      亚洲人成在线影院| 亚洲码国产精品高潮在线| 亚洲国产成人片在线观看| 国产亚洲成人在线播放va| 在线91精品亚洲网站精品成人| 亚洲国产精品成人综合色在线| 亚洲欧美日韩中文无线码| 激情综合亚洲色婷婷五月| 亚洲AV无码乱码在线观看代蜜桃| 亚洲国产成人精品无码区在线秒播| 亚洲码在线中文在线观看| 亚洲欧洲国产综合| 亚洲一级毛片免费观看| 亚洲综合色区中文字幕| 亚洲国产综合精品中文第一| 亚洲色成人网站WWW永久四虎| 亚洲日韩国产欧美一区二区三区 | 亚洲男女内射在线播放| 亚洲av无码天堂一区二区三区 | 亚洲av日韩综合一区在线观看| 亚洲av不卡一区二区三区| 亚洲精品高清久久| 亚洲日韩乱码中文无码蜜桃臀| 亚洲中文无码a∨在线观看| 亚洲高清中文字幕免费| 亚洲国产无线乱码在线观看| 一区国严二区亚洲三区| 久久国产成人精品国产成人亚洲| 色久悠悠婷婷综合在线亚洲| 亚洲爆乳无码专区| 亚洲高清视频免费| 亚洲一卡2卡3卡4卡国产网站| 亚洲七久久之综合七久久| 国产精品亚洲专区一区| 久久久久亚洲精品中文字幕| 亚洲国产精品无码成人片久久| 亚洲国产成人久久综合一| 亚洲天堂电影在线观看| 亚洲精品中文字幕| 亚洲色偷拍区另类无码专区| 亚洲成AV人片在|