The latest toolbar, Status Bar, and menu implementation in wxPython

Source: Internet
Author: User

WxPython is a good module in python visual programming. The following code mainly describes the implementation of toolbar, status bar, menu, menu events (refer to: http://www.czug.org/python/wxpythoninaction ):

#! /Usr/bin/env python #-*-coding: UTF-8-*-import wximport wx. py. imagesclass ToolbarFrame (wx. frame): def _ init _ (self, parent, id): wx. frame. _ init _ (self, parent, id, 'toolbars', size = (600,400) panel = wx. panel (self) panel. setBackgroundColour ('white') # create the status bar statusBar = self. createStatusBar () # create toolbar = self. createmedilbar () # Add a tool toolbar. addSimpleTool (wx. newId (), wx. py. images. getPyBitmap (), "New", "Long help for 'new'") toolbar. addSimpleTool (wx. newId (), wx. py. images. getPyBitmap (), "Edit", "Long help for 'edit'") # Prepare to display the toolbar. realize () # create menu menuBar = wx. menuBar () menu1 = wx. menu () menuBar. append (menu1, u "& file") # menu item 1 self. close = menu1.Append (wx. newId (), u "exit (& X)", "") menu2 = wx. menu () # Menu content & indicates that subsequent characters are hotkeys, and parameter 3 indicates the Menu item description self displayed on the status bar. copy = menu2.Append (wx. newId (), "& Copy", "Copy in status bar") self. cut = menu2.Append (wx. newId (), "C & ut", "") self. paste = menu2.Append (wx. newId (), "Paste", "") menu2.AppendSeparator () self. options = menu2.Append (wx. newId (), "& Options... "," Display Options ") self. edit = menuBar. append (menu2, "& Edit") self. setMenuBar (menuBar) # Call the menu drop-down exit event self. bind (wx. EVT_MENU, self. onClose, self. close) def OnClose (self, event): # exit the event self. close () if _ name _ = '_ main _': app = wx. pySimpleApp () frame = ToolbarFrame (parent = None, id =-1) frame. show () app. mainLoop ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.