本文整理汇总了Python中wx.MenuItem方法的典型用法代码示例。如果您正苦于以下问题:Python wx.MenuItem方法的具体用法?Python wx.MenuItem怎么用?Python wx.MenuItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wx
的用法示例。
在下文中一共展示了wx.MenuItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CreateMenuItem
# 需要导入模块: import wx [as 别名]
# 或者: from wx import MenuItem [as 别名]
def CreateMenuItem(self, menu, label, func, icon=None, id=None):
if id:
item = wx.MenuItem(menu, id, label)
else:
item = wx.MenuItem(menu, -1, label)
if icon:
item.SetBitmap(wx.Bitmap(icon))
if id:
self.Bind(wx.EVT_MENU, func, id=id)
else:
self.Bind(wx.EVT_MENU, func, id=item.GetId())
if wxgtk4 :
menu.Append(item)
else:
menu.AppendItem(item)
return item
示例2: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import MenuItem [as 别名]
def __init__(self, parent, plugin):
self.parent = parent
wx.Panel.__init__(self, parent)
if plugin.moveOnDrag:
self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
if plugin.iconizeOnDoubleClick:
self.Bind(wx.EVT_LEFT_DCLICK, self.OnCmdIconize)
self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown)
self.menu = menu = wx.Menu()
item = wx.MenuItem(menu, wx.NewId(), "Hide")
menu.AppendItem(item)
menu.Bind(wx.EVT_MENU, self.OnCmdIconize, item)
item = wx.MenuItem(menu, wx.NewId(),"Close")
menu.AppendItem(item)
menu.Bind(wx.EVT_MENU, self.OnCmdClose, item)
示例3: CreateMenuBar
# 需要导入模块: import wx [as 别名]
# 或者: from wx import MenuItem [as 别名]
def CreateMenuBar(self):
# Create menu
m_menubar = wx.MenuBar(0)
# File menu
m_menuFile = wx.Menu()
m_menuItemQuit = wx.MenuItem(m_menuFile, wx.ID_ANY, u'&Quit' + u'\t' + u'Ctrl+Q',
wx.EmptyString, wx.ITEM_NORMAL)
m_menuFile.Append(m_menuItemQuit)
m_menubar.Append(m_menuFile, u'&File')
# About menu
m_menuAbout = wx.Menu()
m_menuItemAbout = wx.MenuItem(m_menuAbout, wx.ID_ANY, u'&About' + u'\t' + u'Shift+?',
wx.EmptyString, wx.ITEM_NORMAL)
m_menuAbout.Append(m_menuItemAbout)
m_menubar.Append(m_menuAbout, u'&Help')
# Set menu
self.SetMenuBar(m_menubar)
self.Bind(wx.EVT_MENU, self.OnMenuQuit, id=m_menuItemQuit.GetId())
self.Bind(wx.EVT_MENU, self.OnMenuAbout, id=m_menuItemAbout.GetId())
示例4: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import MenuItem [as 别名]
def __init__(self, *args, **kwds):
# begin wxGlade: MainFrame.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
# Menu Bar
self.frame_2_menubar = wx.MenuBar()
wxglade_tmp_menu = wx.Menu()
self.opf = wx.MenuItem(wxglade_tmp_menu, wx.NewId(), "Open folder..", "", wx.ITEM_NORMAL)
wxglade_tmp_menu.AppendItem(self.opf)
self.opfi = wx.MenuItem(wxglade_tmp_menu, wx.NewId(), "Open file..", "", wx.ITEM_NORMAL)
wxglade_tmp_menu.AppendItem(self.opfi)
wxglade_tmp_menu.AppendSeparator()
self.ana = wx.MenuItem(wxglade_tmp_menu, wx.NewId(), "Analyze", "", wx.ITEM_NORMAL)
wxglade_tmp_menu.AppendItem(self.ana)
self.frame_2_menubar.Append(wxglade_tmp_menu, "File")
self.SetMenuBar(self.frame_2_menubar)
# Menu Bar end
self.list_ctrl_1 = wx.ListCtrl(self, -1, style=wx.LC_REPORT | wx.SUNKEN_BORDER)
for i in range(512):
self.list_ctrl_1.InsertColumn(i, str(i), width=30)
self.__set_properties()
self.__do_layout()
self.Bind(wx.EVT_MENU, self.of, self.opf)
self.Bind(wx.EVT_MENU, self.anlz, self.ana)
self.Bind(wx.EVT_MENU, self.ofi, self.opfi)
# end wxGlade
示例5: _bind_events
# 需要导入模块: import wx [as 别名]
# 或者: from wx import MenuItem [as 别名]
def _bind_events(self):
"""Bind events to varoius MenuItems."""
self.Bind(wx.EVT_MENU, self.on_quit, self.mf_close)
self.Bind(wx.EVT_MENU, self.on_zoom_fit, self.mv_zoomfit)
self.Bind(wx.EVT_MENU, self.on_toggle_crosshairs, self.mv_crosshairs)
self.Bind(wx.EVT_MENU, self.on_toggle_diecenters, self.mv_diecenters)
self.Bind(wx.EVT_MENU, self.on_toggle_outline, self.mv_outline)
self.Bind(wx.EVT_MENU, self.on_toggle_legend, self.mv_legend)
self.Bind(wx.EVT_MENU, self.on_change_high_color, self.mo_high_color)
self.Bind(wx.EVT_MENU, self.on_change_low_color, self.mo_low_color)
# If I define an ID to the menu item, then I can use that instead of
# and event source:
#self.mo_test = wx.MenuItem(self.mopts, 402, "&Test", "Nothing")
#self.Bind(wx.EVT_MENU, self.on_zoom_fit, id=402)
示例6: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import MenuItem [as 别名]
def __init__(self, window):
super(MouseMenu, self).__init__(title='Assign to class')
self.window = window
self.id_classes = {}
while len(self.ids) < self.window.max_menu_class + 1:
self.ids.append( wx.NewId())
for i in range(self.window.max_menu_class + 1):
id = self.ids[i]
self.id_classes[id] = i
print('(id, i) =', (id, i))
mi = wx.MenuItem(self, id, str(i))
self.AppendItem(mi)
self.Bind(wx.EVT_MENU, self.reassign_points, mi)
示例7: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import MenuItem [as 别名]
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, -1, title, size=(550, 350))
self.figure = Figure()
self.axes = self.figure.add_subplot(111)
self.canvas = FigureCanvas(self, -1, self.figure)
self.change_plot(0)
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.add_buttonbar()
self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
self.add_toolbar() # comment this out for no toolbar
menuBar = wx.MenuBar()
# File Menu
menu = wx.Menu()
m_exit = menu.Append(wx.ID_EXIT, "E&xit\tAlt-X", "Exit this simple sample")
menuBar.Append(menu, "&File")
self.Bind(wx.EVT_MENU, self.OnClose, m_exit)
if IS_GTK or IS_WIN:
# Equation Menu
menu = wx.Menu()
for i, (mt, func) in enumerate(functions):
bm = mathtext_to_wxbitmap(mt)
item = wx.MenuItem(menu, 1000 + i, " ")
item.SetBitmap(bm)
menu.Append(item)
self.Bind(wx.EVT_MENU, self.OnChangePlot, item)
menuBar.Append(menu, "&Functions")
self.SetMenuBar(menuBar)
self.SetSizer(self.sizer)
self.Fit()
示例8: create_menu_item
# 需要导入模块: import wx [as 别名]
# 或者: from wx import MenuItem [as 别名]
def create_menu_item(menu, label, func, *args, **kwargs):
"""Helper function to create menu items for the tray menu."""
item = wx.MenuItem(menu, -1, label, **kwargs)
menu.Bind(wx.EVT_MENU, lambda event: func(event, *args), id=item.GetId())
menu.Append(item)
return item
示例9: ConfigureViewTypeChoices
# 需要导入模块: import wx [as 别名]
# 或者: from wx import MenuItem [as 别名]
def ConfigureViewTypeChoices( self, event=None ):
"""Configure the set of View types in the toolbar (and menus)"""
self.viewTypeTool.SetItems( getattr( self.loader, 'ROOTS', [] ))
if self.loader and self.viewType in self.loader.ROOTS:
self.viewTypeTool.SetSelection( self.loader.ROOTS.index( self.viewType ))
# configure the menu with the available choices...
def chooser( typ ):
def Callback( event ):
if typ != self.viewType:
self.viewType = typ
self.OnRootView( event )
return Callback
# Clear all previous items
for item in self.viewTypeMenu.GetMenuItems():
self.viewTypeMenu.DeleteItem( item )
if self.loader and self.loader.ROOTS:
for root in self.loader.ROOTS:
item = wx.MenuItem(
self.viewTypeMenu, -1, root.title(),
_("View hierarchy by %(name)s")%{
'name': root.title(),
},
kind=wx.ITEM_RADIO,
)
item.SetCheckable( True )
self.viewTypeMenu.AppendItem( item )
item.Check( root == self.viewType )
wx.EVT_MENU( self, item.GetId(), chooser( root ))
示例10: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import MenuItem [as 别名]
def __init__(self):
super().__init__()
file_menu = wx.Menu()
new_menu_item = wx.MenuItem(file_menu, wx.ID_NEW, text="New", kind=wx.ITEM_NORMAL)
new_menu_item.SetBitmap(wx.Bitmap("new.gif"))
file_menu.Append(new_menu_item)
load_menu_item = wx.MenuItem(file_menu, wx.ID_OPEN, text="Open", kind=wx.ITEM_NORMAL)
load_menu_item.SetBitmap(wx.Bitmap("load.gif"))
file_menu.Append(load_menu_item)
file_menu.AppendSeparator()
save_menu_item = wx.MenuItem(file_menu, wx.ID_SAVE, text="Save", kind=wx.ITEM_NORMAL)
save_menu_item.SetBitmap(wx.Bitmap("save.gif"))
file_menu.Append(save_menu_item)
file_menu.AppendSeparator()
quit = wx.MenuItem(file_menu, wx.ID_EXIT, '&Quit\tCtrl+Q')
file_menu.Append(quit)
self.Append(file_menu, '&File')
drawing_menu = wx.Menu()
line_menu_item = wx.MenuItem(drawing_menu, PyDrawConstants.LINE_ID, text="Line", kind=wx.ITEM_NORMAL)
drawing_menu.Append(line_menu_item)
square_menu_item = wx.MenuItem(drawing_menu, PyDrawConstants.SQUARE_ID, text="Square", kind=wx.ITEM_NORMAL)
drawing_menu.Append(square_menu_item)
circle_menu_item = wx.MenuItem(drawing_menu, PyDrawConstants.CIRCLE_ID, text="Circle", kind=wx.ITEM_NORMAL)
drawing_menu.Append(circle_menu_item)
text_menu_item = wx.MenuItem(drawing_menu, PyDrawConstants.TEXT_ID, text="Text", kind=wx.ITEM_NORMAL)
drawing_menu.Append(text_menu_item)
self.Append(drawing_menu, '&Drawing')
示例11: _create_menu
# 需要导入模块: import wx [as 别名]
# 或者: from wx import MenuItem [as 别名]
def _create_menu(self):
menubar = wx.MenuBar()
file = wx.Menu()
edit = wx.Menu()
help = wx.Menu()
file.Append(wx.ID_OPEN, '&Open', 'Open a schematic')
file.Append(wx.ID_SAVE, '&Save', 'Save the schematic')
file.AppendSeparator()
file.Append(103, '&Export BOM as CSV', 'Export the BOM as CSV')
file.AppendSeparator()
# Create a new submenu for recent files
recent = wx.Menu()
file.AppendSubMenu(recent, 'Recent')
self.filehistory.UseMenu(recent)
self.filehistory.AddFilesToMenu()
file.AppendSeparator()
quit = wx.MenuItem(file, 105, '&Quit\tCtrl+Q', 'Quit the Application')
file.AppendItem(quit)
edit.Append(201, 'Consolidate Components', 'Consolidate duplicated components')
menubar.Append(file, '&File')
menubar.Append(edit, '&Edit')
menubar.Append(help, '&Help')
self.SetMenuBar(menubar)
self.Bind(wx.EVT_MENU, self.on_quit, id=105)
self.Bind(wx.EVT_MENU, self.on_open, id=wx.ID_OPEN)
self.Bind(wx.EVT_MENU, self.on_consolidate, id=201)
self.Bind(wx.EVT_MENU, self.on_export, id=103)
self.Bind(wx.EVT_MENU, self.on_save, id=wx.ID_SAVE)
self.Bind(wx.EVT_MENU_RANGE, self.on_file_history,
id=wx.ID_FILE1, id2=wx.ID_FILE9)
示例12: CreatePopupMenu
# 需要导入模块: import wx [as 别名]
# 或者: from wx import MenuItem [as 别名]
def CreatePopupMenu(self):
menu = wx.Menu()
if self.frame.IsShown():
toggle_label = _("Hide %s")
else:
toggle_label = _("Show %s")
if False:
toggle_item = wx.MenuItem(parentMenu=menu,
id=self.TBMENU_TOGGLE,
text=toggle_label%app_name,
kind=wx.ITEM_NORMAL)
font = toggle_item.GetFont()
font.SetWeight(wx.FONTWEIGHT_BOLD)
toggle_item.SetFont(font)
#toggle_item.SetFont(wx.Font(
# pointSize=8,
# family=wx.FONTFAMILY_DEFAULT,
# style=wx.FONTSTYLE_NORMAL,
# weight=wx.FONTWEIGHT_BOLD))
menu.AppendItem(toggle_item)
menu.AppendItem(wx.MenuItem(parentMenu=menu,
id=self.TBMENU_CLOSE,
text = _("Quit %s")%app_name,
kind=wx.ITEM_NORMAL))
else:
menu.Append(self.TBMENU_TOGGLE, toggle_label%app_name)
menu.Append(self.TBMENU_CLOSE, _("Quit %s")%app_name)
return menu
示例13: append_menu_item
# 需要导入模块: import wx [as 别名]
# 或者: from wx import MenuItem [as 别名]
def append_menu_item(menu, id, text, xpm_file_or_artid=None, **kwargs): # XXX change: move id to the end of the argument list?
if compat.IS_CLASSIC and "helpString" in kwargs:
kwargs["help"] = kwargs["helpString"]
del kwargs["helpString"]
item = wx.MenuItem(menu, id, text, **kwargs)
if xpm_file_or_artid is not None:
path = 'msw/' if wx.Platform == '__WXMSW__' else 'gtk/'
path = os.path.join(config.icons_path, path)
bmp = None
if not isinstance(xpm_file_or_artid, bytes) or not xpm_file_or_artid.startswith(b'wxART_'):
try:
bmp = _item_bitmaps[xpm_file_or_artid]
except KeyError:
f = os.path.join(path, xpm_file_or_artid)
if os.path.isfile(f):
bmp = _item_bitmaps[xpm_file_or_artid] = wx.Bitmap(f, wx.BITMAP_TYPE_XPM)
else:
bmp = None
else:
# xpm_file_or_artid is an id for wx.ArtProvider
bmp = wx.ArtProvider.GetBitmap( xpm_file_or_artid, wx.ART_MENU, (16, 16) )
if bmp is not None:
try:
item.SetBitmap(bmp)
except AttributeError:
pass
if compat.IS_CLASSIC:
menu.AppendItem(item)
else:
menu.Append(item)
return item
示例14: initMenuItems
# 需要导入模块: import wx [as 别名]
# 或者: from wx import MenuItem [as 别名]
def initMenuItems(self):
self.logs = wx.MenuItem(self, wx.ID_ANY, '&Logs\tF2', wx.EmptyString, wx.ITEM_NORMAL)
self.settings = wx.MenuItem(self, wx.ID_ANY, 'Settings', wx.EmptyString, wx.ITEM_NORMAL)
self.exit = wx.MenuItem(self, wx.ID_ANY, 'Exit', wx.EmptyString, wx.ITEM_NORMAL)
self.Append(self.logs)
self.AppendSeparator()
self.Append(self.settings)
self.AppendSeparator()
self.Append(self.exit)
示例15: initItems
# 需要导入模块: import wx [as 别名]
# 或者: from wx import MenuItem [as 别名]
def initItems(self):
self.godownload = wx.MenuItem(self, wx.ID_ANY, u'下载所选项', wx.EmptyString, wx.ITEM_NORMAL)
self.Append(self.godownload)
self.AppendSeparator()
self.copylinks = wx.MenuItem(self, wx.ID_ANY, u'复制下载链接', wx.EmptyString, wx.ITEM_NORMAL)
self.Append(self.copylinks)
# self.copylinks.Enable(False)