日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python精要(80)-wxpython(2)-helloworld

發布時間:2025/3/12 python 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python精要(80)-wxpython(2)-helloworld 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Feb 22 08:35:42 2021 @author: myhaspl """import wx class MyHelloFrame(wx.Frame):"""框架"""def __init__(self, *args, **kw):# 調用父類構造函數super(MyHelloFrame, self).__init__(*args, **kw)# 在frame中創建Panel面板pnl = wx.Panel(self)# 使用較大的粗體字體設置靜態文本控件st = wx.StaticText(pnl, label="粗體,較大字體!")font = st.GetFont()font.PointSize += 10font = font.Bold()st.SetFont(font)# 創建一個sizer管理子widget層sizer = wx.BoxSizer(wx.VERTICAL)sizer.Add(st, wx.SizerFlags().Border(wx.TOP|wx.LEFT, 25))pnl.SetSizer(sizer)# 創建菜單欄self.makeMenuBar()# 創建狀態欄self.CreateStatusBar()self.SetStatusText("歡迎學習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 calledwhen the menu item is selected."""# Make a file menu with Hello and Exit itemsfileMenu = wx.Menu()# The "\t..." syntax defines an accelerator key that also triggers# the same eventhelloItem = 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# labelexitItem = fileMenu.Append(wx.ID_EXIT)# Now a help menu for the about itemhelpMenu = 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 frameself.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 = MyHelloFrame(None, title='復雜的hello,world')frm.Show()app.MainLoop()

wx.Panel面板是放置控件的窗口

總結

以上是生活随笔為你收集整理的python精要(80)-wxpython(2)-helloworld的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。