本文整理汇总了Python中wx.EVT_TOOL属性的典型用法代码示例。如果您正苦于以下问题:Python wx.EVT_TOOL属性的具体用法?Python wx.EVT_TOOL怎么用?Python wx.EVT_TOOL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类wx
的用法示例。
在下文中一共展示了wx.EVT_TOOL属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _init_toolbar
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_TOOL [as 别名]
def _init_toolbar(self):
DEBUG_MSG("_init_toolbar", 1, self)
self._parent = self.canvas.GetParent()
self.wx_ids = {}
for text, tooltip_text, image_file, callback in self.toolitems:
if text is None:
self.AddSeparator()
continue
self.wx_ids[text] = wx.NewId()
if text in ['Pan', 'Zoom']:
self.AddCheckTool(self.wx_ids[text], _load_bitmap(image_file + '.png'),
shortHelp=text, longHelp=tooltip_text)
else:
self.AddSimpleTool(self.wx_ids[text], _load_bitmap(image_file + '.png'),
text, tooltip_text)
bind(self, wx.EVT_TOOL, getattr(self, callback), id=self.wx_ids[text])
self.Realize()
示例2: _init_toolbar
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_TOOL [as 别名]
def _init_toolbar(self):
DEBUG_MSG("_init_toolbar", 1, self)
self._parent = self.canvas.GetParent()
self.wx_ids = {}
for text, tooltip_text, image_file, callback in self.toolitems:
if text is None:
self.AddSeparator()
continue
self.wx_ids[text] = (
self.AddTool(
-1,
bitmap=_load_bitmap(image_file + ".png"),
bmpDisabled=wx.NullBitmap,
label=text, shortHelp=text, longHelp=tooltip_text,
kind=(wx.ITEM_CHECK if text in ["Pan", "Zoom"]
else wx.ITEM_NORMAL))
.Id)
self.Bind(wx.EVT_TOOL, getattr(self, callback),
id=self.wx_ids[text])
self.Realize()
示例3: _init_toolbar
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_TOOL [as 别名]
def _init_toolbar(self):
DEBUG_MSG("_init_toolbar", 1, self)
self._parent = self.canvas.GetParent()
self.wx_ids = {}
for text, tooltip_text, image_file, callback in self.toolitems:
if text is None:
self.AddSeparator()
continue
self.wx_ids[text] = wx.NewId()
wxc._AddTool(self, self.wx_ids, text,
_load_bitmap(image_file + '.png'),
tooltip_text)
self.Bind(wx.EVT_TOOL, getattr(self, callback),
id=self.wx_ids[text])
self.Realize()
示例4: add_toolitem
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_TOOL [as 别名]
def add_toolitem(
self, name, group, position, image_file, description, toggle):
before, group = self._add_to_group(group, name, position)
idx = self.GetToolPos(before.Id)
if image_file:
bmp = _load_bitmap(image_file)
kind = wx.ITEM_NORMAL if not toggle else wx.ITEM_CHECK
tool = self.InsertTool(idx, -1, name, bmp, wx.NullBitmap, kind,
description or "")
else:
size = (self.GetTextExtent(name)[0]+10, -1)
if toggle:
control = wx.ToggleButton(self, -1, name, size=size)
else:
control = wx.Button(self, -1, name, size=size)
tool = self.InsertControl(idx, control, label=name)
self.Realize()
def handler(event):
self.trigger_tool(name)
if image_file:
self.Bind(wx.EVT_TOOL, handler, tool)
else:
control.Bind(wx.EVT_LEFT_DOWN, handler)
self._toolitems.setdefault(name, [])
group.insert(position, tool)
self._toolitems[name].append((tool, handler))
示例5: add_toolitem
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_TOOL [as 别名]
def add_toolitem(
self, name, group, position, image_file, description, toggle):
before, group = self._add_to_group(group, name, position)
idx = self.GetToolPos(before.Id)
if image_file:
bmp = _load_bitmap(image_file)
kind = wx.ITEM_NORMAL if not toggle else wx.ITEM_CHECK
tool = self.InsertTool(idx, -1, name, bmp, wx.NullBitmap, kind,
description or "")
else:
size = (self.GetTextExtent(name)[0]+10, -1)
if toggle:
control = wx.ToggleButton(self, -1, name, size=size)
else:
control = wx.Button(self, -1, name, size=size)
tool = self.InsertControl(idx, control, label=name)
self.Realize()
def handler(event):
self.trigger_tool(name)
if image_file:
self.Bind(wx.EVT_TOOL, handler, tool)
else:
control.Bind(wx.EVT_LEFT_DOWN, handler)
self._last = tool
self._toolitems.setdefault(name, [])
group.insert(position, tool)
self._toolitems[name].append((tool, handler))
示例6: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_TOOL [as 别名]
def __init__(self, canvas, cankill):
NavigationToolbar.__init__(self, canvas)
# for simplicity I'm going to reuse a bitmap from wx, you'll
# probably want to add your own.
self.AddTool(self.ON_CUSTOM, 'Click me', _load_bitmap('back.png'),
'Activate custom contol')
self.Bind(wx.EVT_TOOL, self._on_custom, id=self.ON_CUSTOM)
示例7: check_for_bom_button
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_TOOL [as 别名]
def check_for_bom_button():
# From Miles McCoo's blog
# https://kicad.mmccoo.com/2017/03/05/adding-your-own-command-buttons-to-the-pcbnew-gui/
def find_pcbnew_window():
windows = wx.GetTopLevelWindows()
pcbneww = [w for w in windows if "pcbnew" in w.GetTitle().lower()]
if len(pcbneww) != 1:
return None
return pcbneww[0]
def callback(_):
plugin.Run()
path = os.path.dirname(__file__)
while not wx.GetApp():
time.sleep(1)
bm = wx.Bitmap(path + '/icon.png', wx.BITMAP_TYPE_PNG)
button_wx_item_id = 0
from pcbnew import ID_H_TOOLBAR
while True:
time.sleep(1)
pcbnew_window = find_pcbnew_window()
if not pcbnew_window:
continue
top_tb = pcbnew_window.FindWindowById(ID_H_TOOLBAR)
if button_wx_item_id == 0 or not top_tb.FindTool(button_wx_item_id):
top_tb.AddSeparator()
button_wx_item_id = wx.NewId()
top_tb.AddTool(button_wx_item_id, "iBOM", bm,
"Generate interactive BOM", wx.ITEM_NORMAL)
top_tb.Bind(wx.EVT_TOOL, callback, id=button_wx_item_id)
top_tb.Realize()
示例8: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_TOOL [as 别名]
def __init__(self, *args, **kwds):
# begin wxGlade: MyFrame.__init__
kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.SetSize((400, 300))
self.SetTitle("frame")
# Menu Bar
self.frame_menubar = wx.MenuBar()
wxglade_tmp_menu = wx.Menu()
self.frame_menubar.item1 = wxglade_tmp_menu.Append(wx.ID_ANY, "My Menu Item 1", "")
self.Bind(wx.EVT_MENU, self.on_menu_item1, id=self.frame_menubar.item1.GetId())
item = wxglade_tmp_menu.Append(wx.ID_ANY, "My Menu Item 1", "without attribute name")
self.Bind(wx.EVT_MENU, self.on_menu_item2, id=item.GetId())
self.frame_menubar.Append(wxglade_tmp_menu, "Menu 1")
self.SetMenuBar(self.frame_menubar)
# Menu Bar end
# Tool Bar
self.frame_toolbar = wx.ToolBar(self, -1)
tool = self.frame_toolbar.AddLabelTool(wx.ID_ANY, "My Tool", wx.Bitmap("..\\..\\icons\\button.xpm", wx.BITMAP_TYPE_ANY), wx.NullBitmap, wx.ITEM_NORMAL, "", "")
self.Bind(wx.EVT_TOOL, self.on_my_tool, id=tool.GetId())
self.SetToolBar(self.frame_toolbar)
self.frame_toolbar.Realize()
# Tool Bar end
sizer_1 = wx.BoxSizer(wx.VERTICAL)
sizer_1.Add((0, 0), 0, 0, 0)
self.SetSizer(sizer_1)
self.Layout()
# end wxGlade
示例9: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_TOOL [as 别名]
def __init__(self, *args, **kwds):
# begin wxGlade: MyFrame.__init__
kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.SetSize((400, 300))
self.SetTitle("frame")
# Menu Bar
self.frame_menubar = wx.MenuBar()
wxglade_tmp_menu = wx.Menu()
self.frame_menubar.item1 = wxglade_tmp_menu.Append(wx.ID_ANY, "My Menu Item 1", "")
self.Bind(wx.EVT_MENU, self.on_menu_item1, id=self.frame_menubar.item1.GetId())
item = wxglade_tmp_menu.Append(wx.ID_ANY, "My Menu Item 1", "without attribute name")
self.Bind(wx.EVT_MENU, self.on_menu_item2, id=item.GetId())
self.frame_menubar.Append(wxglade_tmp_menu, "Menu 1")
self.SetMenuBar(self.frame_menubar)
# Menu Bar end
# Tool Bar
self.frame_toolbar = wx.ToolBar(self, -1)
tool = self.frame_toolbar.AddTool(wx.ID_ANY, "My Tool", wx.Bitmap("..\\..\\icons\\button.xpm", wx.BITMAP_TYPE_ANY), wx.NullBitmap, wx.ITEM_NORMAL, "", "")
self.Bind(wx.EVT_TOOL, self.on_my_tool, id=tool.GetId())
self.SetToolBar(self.frame_toolbar)
self.frame_toolbar.Realize()
# Tool Bar end
sizer_1 = wx.BoxSizer(wx.VERTICAL)
sizer_1.Add((0, 0), 0, 0, 0)
self.SetSizer(sizer_1)
self.Layout()
# end wxGlade
示例10: AddToMenuToolBar
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_TOOL [as 别名]
def AddToMenuToolBar(self, items):
MenuToolBar = self.Panes["MenuToolBar"]
if MenuToolBar.GetToolsCount() > 0:
MenuToolBar.AddSeparator()
for toolbar_item in items:
if toolbar_item is None:
MenuToolBar.AddSeparator()
else:
id, bitmap, help, callback = toolbar_item
MenuToolBar.AddSimpleTool(id=id, shortHelpString=help, bitmap=GetBitmap(bitmap))
if callback is not None:
self.Bind(wx.EVT_TOOL, callback, id=id)
MenuToolBar.Realize()
self.AUIManager.GetPane("MenuToolBar").BestSize(MenuToolBar.GetBestSize())
示例11: _create_controls
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_TOOL [as 别名]
def _create_controls(self, can_kill):
"""
Creates the button controls, and links them to event handlers
"""
DEBUG_MSG("_create_controls()", 1, self)
# Need the following line as Windows toolbars default to 15x16
self.SetToolBitmapSize(wx.Size(16,16))
self.AddSimpleTool(_NTB_X_PAN_LEFT, _load_bitmap('stock_left.xpm'),
'Left', 'Scroll left')
self.AddSimpleTool(_NTB_X_PAN_RIGHT, _load_bitmap('stock_right.xpm'),
'Right', 'Scroll right')
self.AddSimpleTool(_NTB_X_ZOOMIN, _load_bitmap('stock_zoom-in.xpm'),
'Zoom in', 'Increase X axis magnification')
self.AddSimpleTool(_NTB_X_ZOOMOUT, _load_bitmap('stock_zoom-out.xpm'),
'Zoom out', 'Decrease X axis magnification')
self.AddSeparator()
self.AddSimpleTool(_NTB_Y_PAN_UP,_load_bitmap('stock_up.xpm'),
'Up', 'Scroll up')
self.AddSimpleTool(_NTB_Y_PAN_DOWN, _load_bitmap('stock_down.xpm'),
'Down', 'Scroll down')
self.AddSimpleTool(_NTB_Y_ZOOMIN, _load_bitmap('stock_zoom-in.xpm'),
'Zoom in', 'Increase Y axis magnification')
self.AddSimpleTool(_NTB_Y_ZOOMOUT, _load_bitmap('stock_zoom-out.xpm'),
'Zoom out', 'Decrease Y axis magnification')
self.AddSeparator()
self.AddSimpleTool(_NTB_SAVE, _load_bitmap('stock_save_as.xpm'),
'Save', 'Save plot contents as images')
self.AddSeparator()
bind(self, wx.EVT_TOOL, self._onLeftScroll, id=_NTB_X_PAN_LEFT)
bind(self, wx.EVT_TOOL, self._onRightScroll, id=_NTB_X_PAN_RIGHT)
bind(self, wx.EVT_TOOL, self._onXZoomIn, id=_NTB_X_ZOOMIN)
bind(self, wx.EVT_TOOL, self._onXZoomOut, id=_NTB_X_ZOOMOUT)
bind(self, wx.EVT_TOOL, self._onUpScroll, id=_NTB_Y_PAN_UP)
bind(self, wx.EVT_TOOL, self._onDownScroll, id=_NTB_Y_PAN_DOWN)
bind(self, wx.EVT_TOOL, self._onYZoomIn, id=_NTB_Y_ZOOMIN)
bind(self, wx.EVT_TOOL, self._onYZoomOut, id=_NTB_Y_ZOOMOUT)
bind(self, wx.EVT_TOOL, self._onSave, id=_NTB_SAVE)
bind(self, wx.EVT_TOOL_ENTER, self._onEnterTool, id=self.GetId())
if can_kill:
bind(self, wx.EVT_TOOL, self._onClose, id=_NTB_CLOSE)
bind(self, wx.EVT_MOUSEWHEEL, self._onMouseWheel)
示例12: SetupToolBar
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_TOOL [as 别名]
def SetupToolBar(self):
"""Create the toolbar for common actions"""
tb = self.CreateToolBar(self.TBFLAGS)
tsize = (24, 24)
tb.ToolBitmapSize = tsize
open_bmp = wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_TOOLBAR,
tsize)
tb.AddLabelTool(ID_OPEN, "Open", open_bmp, shortHelp="Open",
longHelp="Open a (c)Profile trace file")
if not osx:
tb.AddSeparator()
# self.Bind(wx.EVT_TOOL, self.OnOpenFile, id=ID_OPEN)
self.rootViewTool = tb.AddLabelTool(
ID_ROOT_VIEW, _("Root View"),
wx.ArtProvider.GetBitmap(wx.ART_GO_HOME, wx.ART_TOOLBAR, tsize),
shortHelp=_("Display the root of the current view tree (home view)")
)
self.rootViewTool = tb.AddLabelTool(
ID_BACK_VIEW, _("Back"),
wx.ArtProvider.GetBitmap(wx.ART_GO_BACK, wx.ART_TOOLBAR, tsize),
shortHelp=_("Back to the previously activated node in the call tree")
)
self.upViewTool = tb.AddLabelTool(
ID_UP_VIEW, _("Up"),
wx.ArtProvider.GetBitmap(wx.ART_GO_UP, wx.ART_TOOLBAR, tsize),
shortHelp=_("Go one level up the call tree (highest-percentage parent)")
)
if not osx:
tb.AddSeparator()
# TODO: figure out why the control is sizing the label incorrectly on Linux
self.percentageViewTool = wx.CheckBox(tb, -1, _("Percent "))
self.percentageViewTool.SetToolTip(wx.ToolTip(
_("Toggle display of percentages in list views")))
tb.AddControl(self.percentageViewTool)
wx.EVT_CHECKBOX(self.percentageViewTool,
self.percentageViewTool.GetId(), self.OnPercentageView)
self.viewTypeTool= wx.Choice( tb, -1, choices= getattr(self.loader,'ROOTS',[]) )
self.viewTypeTool.SetToolTip(wx.ToolTip(
_("Switch between different hierarchic views of the data")))
wx.EVT_CHOICE( self.viewTypeTool, self.viewTypeTool.GetId(), self.OnViewTypeTool )
tb.AddControl( self.viewTypeTool )
tb.Realize()
示例13: _build_tool_bar
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_TOOL [as 别名]
def _build_tool_bar(self):
size = wx.the_app.config['toolbar_size']
self.tool_bar = DownloaderToolBar(self, ops=[self.extra_ops, self.torrent_ops])
self.search_bar = BTToolBar(self)
i = wx.the_app.theme_library.get(('search',), size)
bmp = wx.BitmapFromImage(i)
assert bmp.Ok(), "The image (%s) is not valid." % i
tid = wx.NewId()
self.search_bar.AddLabelTool(tid, _("Search"), bmp, shortHelp=_("Search"))
self.search_field = SearchField(self.search_bar, _("Search for torrents"),
wx.the_app.visit_url)
self.search_bar.AddControl(self.search_field)
# HACK -- we should find some better spacer and then a StaticText
#self.search_bar.AddControl(ElectroStaticText(self.search_bar, label=" "))
self.search_bar.Realize()
self.Bind(wx.EVT_TOOL, self.search_field.search, id=tid)
if '__WXMAC__' in wx.PlatformInfo:
self.tool_sizer.Add(self.tool_bar)
else:
self.tool_sizer.Add(self.tool_bar, flag=wx.GROW)
self.tool_sizer.Add(self.search_bar, flag=wx.ALIGN_CENTER_VERTICAL)
s = self.search_bar.GetClientSize()
if '__WXMSW__' in wx.PlatformInfo:
# this makes the first toolbar size correct (on win2k, etc). icon
# resizes after that make it go too far to the left on XP.
# wtf?
#self.tool_sizer.SetItemMinSize(self.search_bar, s.width/2, s.height)
# HACK
w = s.width/2 # ish
if self.search_bar.size == 16:
w = 175
elif self.search_bar.size == 24:
w = 185
elif self.search_bar.size == 32:
w = 195
if wx.the_app.config['toolbar_text']:
w += 25
self.tool_sizer.SetItemMinSize(self.search_bar, w, s.height)
elif '__WXMAC__' in wx.PlatformInfo:
self.tool_sizer.SetItemMinSize(self.search_bar, 186, s.height)
def OnSize(event):
x = event.GetSize().GetWidth() - 185
x2 = self.tool_bar.GetSize().GetWidth()
x = max(x, x2)
self.search_bar.SetPosition((x, 0))
event.Skip()
self.Bind(wx.EVT_SIZE, OnSize)
示例14: create_toolbar
# 需要导入模块: import wx [as 别名]
# 或者: from wx import EVT_TOOL [as 别名]
def create_toolbar(self):
# new, open, save, generate, add, delete, re-do, Layout 1, 2, 3, pin, help
# insert slot/page?
# Layout: Alt + 1,2,3
self.toolbar = tb = wx.ToolBar(self, -1)
self.SetToolBar(tb)
size = (21,21)
add = functools.partial(self._add_label_tool, tb, size)
t = add( wx.ID_NEW, "New", wx.ART_NEW, wx.ITEM_NORMAL, "Open a new file (Ctrl+N)")
self.Bind(wx.EVT_TOOL, self.new_app, t)
t = add( wx.ID_OPEN, "Open", wx.ART_FILE_OPEN, wx.ITEM_NORMAL, "Open a file (Ctrl+O)")
self.Bind(wx.EVT_TOOL, self.open_app, t)
t = add( wx.ID_SAVE, "Save", wx.ART_FILE_SAVE, wx.ITEM_NORMAL, "Save file (Ctrl+S)")
self.Bind(wx.EVT_TOOL, self.save_app, t)
if config.debugging and hasattr(wx, "ART_PLUS"):
t = add( wx.ID_SAVE, "Add", wx.ART_PLUS, wx.ITEM_NORMAL, "Add widget (Ctrl+A)")
t.Enable(False)
# XXX switch between wx.ART_DELETE for filled slots and wx.ART_MINUS for empty slots
t = add( wx.ID_SAVE, "Remove", wx.ART_MINUS, wx.ITEM_NORMAL, "Add widget (Ctrl+A)")
t.Enable(False)
tb.AddSeparator()
self._tool_redo = t = add( wx.ID_SAVE, "Re-do", wx.ART_REDO, wx.ITEM_NORMAL, "Re-do (Ctrl+Y)" )
t.Enable(False)
self._tool_repeat = t = add( wx.ID_SAVE, "Repeat", wx.ART_REDO, wx.ITEM_NORMAL, "Repeat (Ctrl+R)" )
t.Enable(False)
tb.AddSeparator()
t = add(-1, "Generate Code", wx.ART_EXECUTABLE_FILE, wx.ITEM_NORMAL, "Generate Code (Ctrl+G)" )
self.Bind(wx.EVT_TOOL, lambda event: common.root.generate_code(), t)
tb.AddSeparator()
t1 = add(-1, "Layout 1", "layout1.xpm", wx.ITEM_RADIO, "Switch layout: Tree",
"Switch layout: Palette and Properties left, Tree right")
self.Bind(wx.EVT_TOOL, lambda event: self.switch_layout(0), t1)
t2 = add(-1, "Layout 2", "layout2.xpm", wx.ITEM_RADIO,"Switch layout: Properties",
"Switch layout: Palette and Tree top, Properties bottom")
self.Bind(wx.EVT_TOOL, lambda event: self.switch_layout(1), t2)
t3 = add(-1, "Layout 3", "layout3.xpm", wx.ITEM_RADIO, "Switch layout: narrow",
"Switch layout: Palette, Tree and Properties on top of each other")
self.Bind(wx.EVT_TOOL, lambda event: self.switch_layout(2), t3)
self._layout_tools = [t1,t2,t3]
tb.AddSeparator()
t = add(-1, "Pin Design Window", "pin_design.xpm", wx.ITEM_CHECK, "Pin Design Window",
"Pin Design Window to stay on top")
self.Bind(wx.EVT_TOOL, lambda event: self.pin_design_window(), t)
self._t_pin_design_window = t
tb.AddSeparator()
t = add(wx.ID_HELP, "Help", wx.ART_HELP_BOOK, wx.ITEM_NORMAL, "Show manual (F1)")
self.Bind(wx.EVT_TOOL, self.show_manual, t)
self.toolbar.Realize()