我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用wx.ToolTip()。
def InitLayout(self): """Lay out controls and add buttons.""" sizer = wx.BoxSizer(wx.HORIZONTAL) txtSizer = wx.BoxSizer(wx.VERTICAL) btnSizer = wx.BoxSizer(wx.VERTICAL) replaceSizer = wx.BoxSizer(wx.HORIZONTAL) txtSizer.Add(wx.StaticText(self, -1, "Unrecognised Word:"), 0, wx.LEFT|wx.TOP, 5) txtSizer.Add(self.error_text, 1, wx.ALL|wx.EXPAND, 5) replaceSizer.Add(wx.StaticText(self, -1, "Replace with:"), 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5) replaceSizer.Add(self.replace_text, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5) txtSizer.Add(replaceSizer, 0, wx.EXPAND, 0) txtSizer.Add(self.replace_list, 2, wx.ALL|wx.EXPAND, 5) sizer.Add(txtSizer, 1, wx.EXPAND, 0) self.buttons = [] for label, action, tip in (\ ("Ignore", self.OnIgnore, "Ignore this word and continue"), ("Ignore All", self.OnIgnoreAll, "Ignore all instances of this word and continue"), ("Replace", self.OnReplace, "Replace this word"), ("Replace All", self.OnReplaceAll, "Replace all instances of this word"), ("Add", self.OnAdd, "Add this word to the dictionary"), ("Done", self.OnDone, "Finish spell-checking and accept changes"), ): btn = wx.Button(self, -1, label) btn.SetToolTip(wx.ToolTip(tip)) btnSizer.Add(btn, 0, wx.ALIGN_RIGHT|wx.ALL, 4) btn.Bind(wx.EVT_BUTTON, action) self.buttons.append(btn) sizer.Add(btnSizer, 0, wx.ALL|wx.EXPAND, 5) self.SetAutoLayout(True) self.SetSizer(sizer) sizer.Fit(self)
def set_textctrl_background_color(textctrl, mode, tooltip=None): if mode == 'ok': color = (255,255,255) elif mode == 'enter-needed': color = (200,255,200) elif mode == 'invalid': color = (255,200,200) textctrl.SetBackgroundColour(color) textctrl.Refresh() if tooltip is not None and not isinstance(tooltip, wx.ToolTip): tooltip = wx.ToolTip(tooltip) textctrl.SetToolTip(tooltip) force_textctrl_color_update(textctrl)
def InitUI(self): self.panel = wx.Panel(self, wx.ID_ANY) # Info Text infotext = _(u'Close all open Applications, it is possible that programs will be closed without a warning ' u'and system could reboot without further confirmation.') infobox = wx.StaticBox(self.panel, -1, _(u'Attention')) infoboxbsizer = wx.StaticBoxSizer(infobox, wx.VERTICAL) info = wx.StaticText(self.panel, label=infotext) info.Wrap(380) infoboxbsizer.Add(info, 0) self.gauge = wx.Gauge(self.panel, size=(24, 26)) self.update_label = wx.StaticText(self.panel, label=_(u'Current Progress:')) self.update_box = wx.TextCtrl(self.panel, style=wx.TE_READONLY) self.update_box.SetBackgroundColour(wx.WHITE) self.chk_shutdown = wx.CheckBox(self.panel, size=(160,20), label=_(u"Shutdown after update")) self.logButton = wx.Button(self.panel, size=(54,26), label="LOG") self.logButton.SetToolTip(wx.ToolTip(_(u'Open WPKG Log'))) self.logButton.SetBitmap(img.get('log')) self.startButton = wx.Button(self.panel, label=_(u"Update")) self.abortButton = wx.Button(self.panel, label=_(u"Cancel")) self.logButton.Disable() self.abortButton.Disable() self.line = wx.StaticLine(self.panel, -1, size=(2,2), style=wx.LI_HORIZONTAL) self.startButton.Bind(wx.EVT_BUTTON, self.OnStartButton) self.abortButton.Bind(wx.EVT_BUTTON, self.OnAbortButton) self.logButton.Bind(wx.EVT_BUTTON, self.OnLogButton) self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer2 = wx.BoxSizer(wx.HORIZONTAL) self.sizer.Add(infoboxbsizer, 0, wx.ALL | wx.EXPAND, 5) self.sizer.Add(self.gauge, 0, wx.ALL | wx.EXPAND, 5) self.sizer.Add(self.update_label, 0, wx.ALL | wx.EXPAND, 5) self.sizer.Add(self.update_box, 0, wx.ALL | wx.EXPAND, 5) self.sizer.Add(self.line, 0, wx.ALL | wx.EXPAND, 5) self.sizer.Add(self.chk_shutdown, 0, wx.LEFT | wx.EXPAND, 7) self.sizer2.Add(self.logButton, 0) self.sizer2.AddStretchSpacer() self.sizer2.Add(self.startButton, 0)#, wx.RIGHT, 2) self.sizer2.Add(self.abortButton, 0) self.sizer.Add(self.sizer2, 0, wx.ALL | wx.EXPAND, 5) self.panel.SetSizerAndFit(self.sizer) self.Center()
def CreateMenuBar(self): """Create our menu-bar for triggering operations""" menubar = wx.MenuBar() menu = wx.Menu() menu.Append(ID_OPEN, _('&Open'), _('Open a new profile file')) menu.AppendSeparator() menu.Append(ID_EXIT, _('&Close'), _('Close this RunSnakeRun window')) menubar.Append(menu, _('&File')) menu = wx.Menu() self.packageMenuItem = menu.AppendCheckItem( ID_PACKAGE_VIEW, _('&File View'), _('View time spent by package/module') ) self.percentageMenuItem = menu.AppendCheckItem( ID_PERCENTAGE_VIEW, _('&Percentage View'), _('View time spent as percent of overall time') ) self.rootViewItem = menu.Append( ID_ROOT_VIEW, _('&Root View (Home)'), _('View the root of the tree') ) self.backViewItem = menu.Append( ID_BACK_VIEW, _('&Back'), _('Go back in your viewing history') ) self.upViewItem = menu.Append( ID_UP_VIEW, _('&Up'), _('Go "up" to the parent of this node with the largest cummulative total') ) # This stuff isn't really all that useful for profiling, # it's more about how to generate graphics to describe profiling... # self.deeperViewItem = menu.Append( # ID_DEEPER_VIEW, _('&Deeper'), _('View deeper squaremap views') # ) # self.shallowerViewItem = menu.Append( # ID_SHALLOWER_VIEW, _('&Shallower'), _('View shallower squaremap views') # ) # wx.ToolTip.Enable(True) menubar.Append(menu, _('&View')) self.SetMenuBar(menubar) wx.EVT_MENU(self, ID_EXIT, lambda evt: self.Close(True)) wx.EVT_MENU(self, ID_OPEN, self.OnOpenFile) wx.EVT_MENU(self, ID_PACKAGE_VIEW, self.OnPackageView) wx.EVT_MENU(self, ID_PERCENTAGE_VIEW, self.OnPercentageView) wx.EVT_MENU(self, ID_UP_VIEW, self.OnUpView) wx.EVT_MENU(self, ID_DEEPER_VIEW, self.OnDeeperView) wx.EVT_MENU(self, ID_SHALLOWER_VIEW, self.OnShallowerView) wx.EVT_MENU(self, ID_ROOT_VIEW, self.OnRootView) wx.EVT_MENU(self, ID_BACK_VIEW, self.OnBackView)
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") 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)") ) 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.packageViewTool = wx.CheckBox(tb, -1, _("File View ")) self.packageViewTool.SetToolTip(wx.ToolTip( _("Switch between call-hierarchy and package/module/function hierarchy"))) tb.AddControl(self.packageViewTool) wx.EVT_CHECKBOX(self.packageViewTool, self.packageViewTool.GetId(), self.OnPackageView) tb.Realize()
def end_dragging(self): #print 'Release button of canvas', self._in_canvas print '\nSTART of end_dragging' if self._in_canvas == -1: return if self._drag_mode != SASH_DRAG_DRAGGING: return if self._in_canvas == 1: canvas = self.d1_canvas else: canvas = self.d2_canvas self._drag_mode = SASH_DRAG_NONE self._old_y = None if self.track.HasCapture(): self.track.ReleaseMouse() # print 'mouse solto' y1 = self.d1_canvas.GetPosition()[1] y2 = self.d2_canvas.GetPosition()[1] #print 'y12:', y1, y2 if y1 <= y2: d1 = self.track.get_depth_from_ypixel(y1) d2 = self.track.get_depth_from_ypixel(y2 + self.canvas_width) # print 'considerando y12:', y1, y2 + self.canvas_width else: d1 = self.track.get_depth_from_ypixel(y2) d2 = self.track.get_depth_from_ypixel(y1 + self.canvas_width) # print 'considerando y12:', y2, y1 + self.canvas_width #print 'd12:', d1, d2 # UIM = UIManager() parent_controller_uid = UIM._getparentuid(self._controller_uid) parent_controller = UIM.get(parent_controller_uid) # #parent_controller.model.logplot_y_min = d1 #parent_controller.model.logplot_y_max = d2 # parent_controller.model.set_value_from_event('y_min_shown', d1) parent_controller.model.set_value_from_event('y_max_shown', d2) parent_controller._reload_ylim() # # #self._reload_depths_from_canvas_positions() #if self._callback: # self._callback(self.get_depth()) #print 'Send ' + str(self.get_depth()) + ' to callback...' canvas.SetBackgroundColour(self.canvas_color) canvas.Refresh() # #d1, d2 = self.get_depth() self.track.SetToolTip(wx.ToolTip('{0:.2f} - {1:.2f}'.format(d1, d2))) print 'END of end_dragging'