我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用wx.EVT_LEFT_DCLICK。
def createWidgets(self): self.listCtrl = wxskinListCtrl(self, ID_LISTCTRL, style=wx.LC_REPORT|wx.SUNKEN_BORDER|wx.LC_SINGLE_SEL|wx.LC_VRULES|wx.LC_HRULES) self.listCtrl.InsertColumn(0, "Name") self.listCtrl.InsertColumn(1, "Number") ColumnSorterMixin.__init__(self, 2) self.currentItem = 0 wx.EVT_SIZE(self, self.OnSize) wx.EVT_LIST_ITEM_SELECTED(self, ID_LISTCTRL, self.OnItemSelected) wx.EVT_LIST_ITEM_ACTIVATED(self, ID_LISTCTRL, self.OnItemActivated) wx.EVT_CLOSE(self, self.closeWindow) wx.EVT_LEFT_DCLICK(self.listCtrl, self.OnPopupEdit) wx.EVT_RIGHT_DOWN(self.listCtrl, self.OnRightDown) # for wxMSW and wxGTK respectively wx.EVT_COMMAND_RIGHT_CLICK(self.listCtrl, ID_LISTCTRL, self.OnRightClick) wx.EVT_RIGHT_UP(self.listCtrl, self.OnRightClick)
def createWidgets(self): self.listCtrl = wxskinListCtrl(self, ID_LISTCTRL, style=wx.LC_REPORT|wx.SUNKEN_BORDER|wx.LC_SINGLE_SEL|wx.LC_VRULES|wx.LC_HRULES) self.listCtrl.InsertColumn(COL_STATUS, "Status") self.listCtrl.InsertColumn(COL_DATE, "Date") self.listCtrl.InsertColumn(COL_FROM, "From") self.listCtrl.InsertColumn(COL_MESSAGE, "Message") ColumnSorterMixin.__init__(self, 4) self.currentItem = 0 wx.EVT_SIZE(self, self.OnSize) wx.EVT_LIST_ITEM_SELECTED(self, ID_LISTCTRL, self.OnItemSelected) wx.EVT_LIST_ITEM_ACTIVATED(self, ID_LISTCTRL, self.OnItemActivated) wx.EVT_RIGHT_DOWN(self.listCtrl, self.OnRightDown) wx.EVT_LEFT_DCLICK(self.listCtrl, self.OnPopupEdit) wx.EVT_CLOSE(self, self.closeWindow) # for wxMSW and wxGTK respectively wx.EVT_COMMAND_RIGHT_CLICK(self.listCtrl, ID_LISTCTRL, self.OnRightClick) wx.EVT_RIGHT_UP(self.listCtrl, self.OnRightClick)
def __init__(self): wx.Frame.__init__(self, None, title="Tutorial") self.eventDict = {} evt_names = [x for x in dir(wx) if x.startswith("EVT_")] for name in evt_names: evt = getattr(wx, name) if isinstance(evt, wx.PyEventBinder): self.eventDict[evt.typeId] = name grid_evt_names = [x for x in dir(wx.grid) if x.startswith("EVT_")] for name in grid_evt_names: evt = getattr(wx.grid, name) if isinstance(evt, wx.PyEventBinder): self.eventDict[evt.typeId] = name panel = wx.Panel(self, wx.ID_ANY) btn = wx.Button(panel, wx.ID_ANY, "Get POS") btn.Bind(wx.EVT_BUTTON, self.onEvent) panel.Bind(wx.EVT_LEFT_DCLICK, self.onEvent) panel.Bind(wx.EVT_RIGHT_DOWN, self.onEvent)
def RefreshTabCtrlEvent(self): auitabctrl = [] for child in self.TabsOpened.GetChildren(): if isinstance(child, wx.aui.AuiTabCtrl): auitabctrl.append(child) if child not in self.AuiTabCtrl: child.Bind(wx.EVT_LEFT_DCLICK, self.GetTabsOpenedDClickFunction(child)) self.AuiTabCtrl = auitabctrl if self.TabsOpened.GetPageCount() == 0: pane = self.AUIManager.GetPane(self.TabsOpened) if pane.IsMaximized(): self.AUIManager.RestorePane(pane) self.AUIManager.Update()
def __init__(self, parent, window, items=[]): """ Constructor @param parent: Parent wx.Window of DebugVariableText @param window: Reference to the Debug Variable Panel @param items: List of DebugVariableItem displayed by Viewer """ DebugVariableViewer.__init__(self, window, items) wx.Panel.__init__(self, parent) # Set panel background colour self.SetBackgroundColour(wx.WHITE) # Define panel drop target self.SetDropTarget(DebugVariableTextDropTarget(self, window)) # Bind events self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp) self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick) self.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave) self.Bind(wx.EVT_SIZE, self.OnResize) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_PAINT, self.OnPaint) # Define panel min size for parent sizer layout self.SetMinSize(wx.Size(0, 25)) # Add buttons to Viewer for bitmap, callback in [("force", self.OnForceButton), ("release", self.OnReleaseButton), ("delete_graph", self.OnCloseButton)]: self.Buttons.append(GraphButton(0, 0, bitmap, callback))
def add_tools(bar, datas, curids=[]): ##! TODO: ## datas? dirpath tree to generate menus/toolsbar? ## curids? ?? box = bar.GetSizer() if curids!=None: for curid in curids: bar.RemoveChild(curid) box.Hide(curid) box.Detach(curid) if curids!=None: del curids[:] for data in datas: btn = wx.BitmapButton(bar, wx.ID_ANY, make_bitmap(wx.Bitmap(data[1])), wx.DefaultPosition, (32,32), wx.BU_AUTODRAW|wx.RAISED_BORDER ) if curids!=None: curids.append(btn) if curids==None: box.Add(btn) else: box.Insert(len(box.GetChildren())-2, btn) btn.Bind( wx.EVT_LEFT_DOWN, lambda x, p=data[0]:f(p(), x)) btn.Bind( wx.EVT_ENTER_WINDOW, lambda x, p='"{}" Tool'.format(data[0].title): set_info(p)) if not isinstance(data[0], Macros) and issubclass(data[0], Tool): btn.Bind(wx.EVT_LEFT_DCLICK, lambda x, p=data[0]:p().show()) btn.SetDefault() box.Layout() bar.Refresh() if curids==None: sp = wx.StaticLine( bar, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_VERTICAL ) box.Add( sp, 0, wx.ALL|wx.EXPAND, 2 ) box.AddStretchSpacer(1)
def __init__( self, parent=None, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.TAB_TRAVERSAL|wx.NO_BORDER|wx.FULL_REPAINT_ON_RESIZE, name='SquareMap', model = None, adapter = None, labels = True, # set to True to draw textual labels within the boxes highlight = True, # set to False to turn of highlighting padding = 2, # amount to reduce the children's box from the parent's box ): super( SquareMap, self ).__init__( parent, id, pos, size, style, name ) self.model = model self.padding = padding self.labels = labels self.highlight = highlight self.selectedNode = None self.highlightedNode = None self.Bind( wx.EVT_PAINT, self.OnPaint) self.Bind( wx.EVT_SIZE, self.OnSize ) if highlight: self.Bind( wx.EVT_MOTION, self.OnMouse ) self.Bind( wx.EVT_LEFT_UP, self.OnClickRelease ) self.Bind( wx.EVT_LEFT_DCLICK, self.OnDoubleClick ) self.Bind( wx.EVT_KEY_UP, self.OnKeyUp ) self.hot_map = [] self.adapter = adapter or DefaultAdapter() self.DEFAULT_PEN = wx.Pen( wx.BLACK, 1, wx.SOLID ) self.SELECTED_PEN = wx.Pen( wx.WHITE, 2, wx.SOLID ) self.OnSize(None)
def __init__(self, parent): self.parent = parent fig = Figure(figsize=(1, 0.35)) super(VisDataLabel, self).__init__(self.parent, -1, fig) self.figure.set_facecolor(self._COLOR) self._obj_uid = None #self.Bind(wx.EVT_LEFT_DCLICK, self._on_left_double_click) self._mplot_objects = {} self._properties = {} self._start_variables() self.mpl_connect('button_press_event', self._on_press)
def __init__( self, parent=None, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.TAB_TRAVERSAL|wx.NO_BORDER|wx.FULL_REPAINT_ON_RESIZE, name='SquareMap', model = None, adapter = None, labels = True, highlight = True, padding = 2, margin = 0, square_style = False, ): """Initialise the SquareMap adapter -- a DefaultAdapter or same-interface instance providing SquareMap data api labels -- set to True (default) to draw textual labels within the boxes highlight -- set to True (default) to highlight nodes on mouse-over padding -- spacing within each square and its children (within the square's border) margin -- spacing around each square (on all sides) square_style -- use a more-recursive, less-linear, more "square" layout style which works better on objects with large numbers of children, such as Meliae memory dumps, works fine on profile views as well, but the layout is less obvious wrt what node is "next" "previous" etc. """ super( SquareMap, self ).__init__( parent, id, pos, size, style, name ) self.model = model self.padding = padding self.square_style = square_style self.margin = margin self.labels = labels self.highlight = highlight self.selectedNode = None self.highlightedNode = None self._buffer = wx.Bitmap(20, 20) # Have a default buffer ready self.Bind( wx.EVT_PAINT, self.OnPaint) self.Bind( wx.EVT_SIZE, self.OnSize ) if highlight: self.Bind( wx.EVT_MOTION, self.OnMouse ) self.Bind( wx.EVT_LEFT_UP, self.OnClickRelease ) self.Bind( wx.EVT_LEFT_DCLICK, self.OnDoubleClick ) self.Bind( wx.EVT_KEY_UP, self.OnKeyUp ) self.hot_map = [] self.adapter = adapter or DefaultAdapter() self.DEFAULT_PEN = wx.Pen( wx.BLACK, 1, wx.SOLID ) self.SELECTED_PEN = wx.Pen( wx.WHITE, 2, wx.SOLID ) self.OnSize(None)
def GenerateSearchResultsTreeBranch(self, root, infos): to_delete = [] if infos["name"] == "body": item_name = "%d:" % infos["data"][1][0] else: item_name = infos["name"] self.SearchResultsTree.SetItemText(root, item_name) self.SearchResultsTree.SetPyData(root, infos["data"]) self.SearchResultsTree.SetItemBackgroundColour(root, wx.WHITE) self.SearchResultsTree.SetItemTextColour(root, wx.BLACK) if infos["type"] is not None: if infos["type"] == ITEM_POU: self.SearchResultsTree.SetItemImage(root, self.TreeImageDict[self.ParentWindow.Controler.GetPouType(infos["name"])]) else: self.SearchResultsTree.SetItemImage(root, self.TreeImageDict[infos["type"]]) text = None if infos["text"] is not None: text = infos["text"] start, end = infos["data"][1:3] text_lines = infos["text"].splitlines() start_idx = start[1] end_idx = reduce(lambda x, y: x + y, map(lambda x: len(x) + 1, text_lines[:end[0] - start[0]]), end[1] + 1) style = wx.TextAttr(wx.BLACK, wx.Colour(206, 204, 247)) elif infos["type"] is not None and infos["matches"] > 1: text = _("(%d matches)") % infos["matches"] start_idx, end_idx = 0, len(text) style = wx.TextAttr(wx.Colour(0, 127, 174)) if text is not None: text_ctrl_style = wx.BORDER_NONE | wx.TE_READONLY | wx.TE_RICH2 if wx.Platform != '__WXMSW__' or len(text.splitlines()) > 1: text_ctrl_style |= wx.TE_MULTILINE text_ctrl = wx.TextCtrl(id=-1, parent=self.SearchResultsTree, pos=wx.Point(0, 0), value=text, style=text_ctrl_style) width, height = text_ctrl.GetTextExtent(text) text_ctrl.SetClientSize(wx.Size(width + 1, height)) text_ctrl.SetBackgroundColour(self.SearchResultsTree.GetBackgroundColour()) text_ctrl.Bind(wx.EVT_LEFT_DOWN, self.GetTextCtrlClickFunction(root)) text_ctrl.Bind(wx.EVT_LEFT_DCLICK, self.GetTextCtrlDClickFunction(root)) text_ctrl.SetInsertionPoint(0) text_ctrl.SetStyle(start_idx, end_idx, style) self.SearchResultsTree.SetItemWindow(root, text_ctrl) if wx.VERSION >= (2, 6, 0): item, root_cookie = self.SearchResultsTree.GetFirstChild(root) else: item, root_cookie = self.SearchResultsTree.GetFirstChild(root, 0) for child in infos["children"]: if item is None: item = self.SearchResultsTree.AppendItem(root, "") item, root_cookie = self.SearchResultsTree.GetNextChild(root, root_cookie) self.GenerateSearchResultsTreeBranch(item, child) item, root_cookie = self.SearchResultsTree.GetNextChild(root, root_cookie)