我们从Python开源项目中,提取了以下18个代码示例,用于说明如何使用wx.EVT_RIGHT_DOWN。
def BindEvents(self): self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_ERASE_BACKGROUND, lambda e: None) self.Bind(wx.EVT_RIGHT_DOWN, self.OnButtonDown) self.Bind(wx.EVT_LEFT_DOWN, self.OnButtonDown) self.Bind(wx.EVT_MIDDLE_DOWN, self.OnButtonDown) self.Bind(wx.EVT_RIGHT_UP, self.OnButtonUp) self.Bind(wx.EVT_LEFT_UP, self.OnButtonUp) self.Bind(wx.EVT_MIDDLE_UP, self.OnButtonUp) self.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel) self.Bind(wx.EVT_MOTION, self.OnMotion) self.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave) self.Bind(wx.EVT_CHAR, self.OnKeyDown) self.Bind(wx.EVT_KEY_UP, self.OnKeyUp) if wx.Platform == "__WXGTK__": # wxGTK requires that the window be created before you can # set its shape, so delay the call to SetWindowShape until # this event. self.Bind(wx.EVT_WINDOW_CREATE, self.OnWindowCreate) else: # On wxMSW and wxMac the window has already been created. self.Bind(wx.EVT_SIZE, self.OnSize) if _useCapture and hasattr(wx, 'EVT_MOUSE_CAPTURE_LOST'): self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, self.OnMouseCaptureLost)
def __init__(self, parent, df, status_bar_callback): wx.ListCtrl.__init__( self, parent, -1, style=wx.LC_REPORT | wx.LC_VIRTUAL | wx.LC_HRULES | wx.LC_VRULES | wx.LB_MULTIPLE ) self.status_bar_callback = status_bar_callback self.df_orig = df self.original_columns = self.df_orig.columns[:] self.current_columns = self.df_orig.columns[:] self.sort_by_column = None self._reset_mask() # prepare attribute for alternating colors of rows self.attr_light_blue = wx.ListItemAttr() self.attr_light_blue.SetBackgroundColour("#D6EBFF") self.Bind(wx.EVT_LIST_COL_CLICK, self._on_col_click) self.Bind(wx.EVT_RIGHT_DOWN, self._on_right_click) self.df = pd.DataFrame({}) # init empty to force initial update self._update_rows() self._update_columns(self.original_columns)
def __init__(self, parent, size, data, *args, **kwargs): wx.ListBox.__init__(self, parent, size, **kwargs) self.data = data self.InsertItems(data, 0) self.Bind(wx.EVT_LISTBOX, self.on_selection_changed) self.Bind(wx.EVT_LEFT_DOWN, self.on_left_down) self.Bind(wx.EVT_RIGHT_DOWN, self.on_right_down) self.Bind(wx.EVT_RIGHT_UP, self.on_right_up) self.Bind(wx.EVT_MOTION, self.on_move) self.index_iter = range(len(self.data)) self.selected_items = [True] * len(self.data) self.index_mapping = list(range(len(self.data))) self.drag_start_index = None self.update_selection() self.SetFocus()
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 __init__(self, parent, obj=None, mouse_callback=None, select_callback=None): wx.Panel.__init__(self, parent) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown) self.Bind(wx.EVT_LEFT_UP, self.OnMouseUp) self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown) self.Bind(wx.EVT_RIGHT_UP, self.OnMouseUp) self.Bind(wx.EVT_MOTION, self.OnMotion) self.Bind(wx.EVT_SIZE, self.OnSize) self.refresh_from_selection = False self.background_bitmap = None self.obj = obj self.selstart = self.selend = self.movepos = None self.moveSelection = False self.createSelection = False self.begin = 0 if self.obj is not None: self.chnls = len(self.obj) self.end = self.obj.getDur(False) else: self.chnls = 1 self.end = 1.0 self.img = [[]] self.mouse_callback = mouse_callback self.select_callback = select_callback if sys.platform == "win32" or sys.platform.startswith("linux"): self.dcref = wx.BufferedPaintDC else: self.dcref = wx.PaintDC self.setImage() #FL 02/10/2017 self.playCursorPos = 0
def __init__(self, parent): attribs = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24) glcanvas.GLCanvas.__init__(self, parent, -1, attribList = attribs) self.context = glcanvas.GLContext(self) self.parent = parent #Camera state variables self.size = self.GetClientSize() #self.camera = MouseSphericalCamera(self.size.x, self.size.y) self.camera = MousePolarCamera(self.size.width, self.size.height) #Main state variables self.MousePos = [0, 0] self.bbox = BBox3D() #Face mesh variables and manipulation variables self.mesh = None self.meshCentroid = None self.displayMeshFaces = True self.displayMeshEdges = False self.displayMeshVertices = True self.displayVertexNormals = False self.displayFaceNormals = False self.useLighting = True self.useTexture = False self.GLinitialized = False #GL-related events wx.EVT_ERASE_BACKGROUND(self, self.processEraseBackgroundEvent) wx.EVT_SIZE(self, self.processSizeEvent) wx.EVT_PAINT(self, self.processPaintEvent) #Mouse Events wx.EVT_LEFT_DOWN(self, self.MouseDown) wx.EVT_LEFT_UP(self, self.MouseUp) wx.EVT_RIGHT_DOWN(self, self.MouseDown) wx.EVT_RIGHT_UP(self, self.MouseUp) wx.EVT_MIDDLE_DOWN(self, self.MouseDown) wx.EVT_MIDDLE_UP(self, self.MouseUp) wx.EVT_MOTION(self, self.MouseMotion)
def __init__(self, title='ImagePy TexLog'): wx.Frame.__init__(self, IPy.curapp,title=title,size=(500,300)) logopath = os.path.join(root_dir, 'data/logo.ico') self.SetIcon(wx.Icon(logopath, wx.BITMAP_TYPE_ICO)) self.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_3DLIGHT ) ) self.title = title TextLogManager.add(title, self) self.file='' ### Create menus (name:event) k-v pairs menus = [ ## File ('File(&F)',[('Open', self.OnOpen), ('Save', self.OnSave), ('Save as', self.OnSaveAs), ('-'), ('Exit', self.OnClose) ]), ## Edit ('Edit(&E)', [ ('Undo', self.OnUndo), ('Redo', self.OnRedo), ('-'), ('Cut', self.OnCut), ('Copy', self.OnCopy), ('Paste', self.OnPaste), ('-'), ('All', self.OnSelectAll) ]), ## Help ('Help(&H)', [('About', self.OnAbout)]) ] ### Bind menus with the corresponding events self.menuBar=wx.MenuBar() for menu in menus: m = wx.Menu() for item in menu[1]: if item[0]=='-': m.AppendSeparator() else: i = m.Append(-1, item[0]) self.Bind(wx.EVT_MENU,item[1], i) self.menuBar.Append(m,menu[0]) self.SetMenuBar(self.menuBar) self.Bind(wx.EVT_CLOSE, self.OnClosing) sizer = wx.BoxSizer( wx.VERTICAL ) self.text= wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_MULTILINE ) sizer.Add( self.text, 1, wx.ALL|wx.EXPAND, 1 ) self.SetSizer( sizer ) self.Bind(wx.EVT_RIGHT_DOWN,self.OnRClick)
def __init__( self, parent, id, server, mech ): wx.StaticText.__init__( self, parent ) self.ScoreServer = server self.Mech = mech self.Bind( wx.EVT_LEFT_DOWN, self.LeftClick ) self.Bind( wx.EVT_RIGHT_DOWN, self.RightClick )
def __init__( self, parent, id, match ): wx.StaticText.__init__( self, parent ) self.Match = match self.Bind( wx.EVT_LEFT_DOWN, self.LeftClick ) self.Bind( wx.EVT_RIGHT_DOWN, self.RightClick )
def __init__(self, wx_parent, view_object): super(PlotLabel, self).__init__(wx_parent) self.track_view_object = view_object self._title = None self._visual_objects = [] self.SetBackgroundColour('white') self.SetSizer(wx.BoxSizer(wx.VERTICAL)) self.Bind(wx.EVT_LEFT_DOWN, self._on_press) self.Bind(wx.EVT_MIDDLE_DOWN, self._on_press) self.Bind(wx.EVT_RIGHT_DOWN, self._on_press) self._selected = False
def __init__(self, app_logic, *args, **kwargs): kwargs.setdefault('title', "Simple test App") wx.Frame.__init__(self, *args, **kwargs) self.app_logic = app_logic # Build up the menu bar: menuBar = wx.MenuBar() fileMenu = wx.Menu() saveasMenuItem = fileMenu.Append(wx.ID_ANY, "&Save As", "Create a new file") self.Bind(wx.EVT_MENU, self.onSaveAs, saveasMenuItem ) openMenuItem = fileMenu.Append(wx.ID_ANY, "&Open", "Open an existing file" ) self.Bind(wx.EVT_MENU, self.onOpen, openMenuItem) closeMenuItem = fileMenu.Append(wx.ID_ANY, "&Close", "Close a file" ) self.Bind(wx.EVT_MENU, self.onClose, closeMenuItem) exitMenuItem = fileMenu.Append(wx.ID_EXIT, "Exit", "Exit the application") self.Bind(wx.EVT_MENU, self.onExit, exitMenuItem) menuBar.Append(fileMenu, "&File") helpMenu = wx.Menu() helpMenuItem = helpMenu.Append(wx.ID_HELP, "Help", "Get help") menuBar.Append(helpMenu, "&Help") self.SetMenuBar(menuBar) ## add just a single button: self.theButton = wx.Button(self, label="Push Me") self.theButton.Bind(wx.EVT_BUTTON, self.onButton) self.theButton.Bind(wx.EVT_RIGHT_DOWN, self.onRight)
def __init__(self, parent, pos=(0,0), size=(100,100), numSpeakers=2): wx.Panel.__init__(self, parent, pos=pos, size=size) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.audio = vars.getVars("Audio") self.pos = None self.size = size self.currentCircle = None self.currentSpeaker = None self.isAList = False self.catch = False self.catchSpeaker = False self.shift = False self.alt = False self.s = False self.numSpeakers = numSpeakers # FL 29/05/17 #OSC Variables self.incs = [0, 0, 0, 0] self.absPos = [0, 0, 0, 0] # FL 04/09/2017 self.mode2 = False # FL 04/09/2017 # Creation des cercles/sources self.blueCircle = Source(self.size[0]*BLUE_START[0], self.size[1]*BLUE_START[1], CIRCLE_RADIUS) self.redCircle = Source(self.size[0]*RED_START[0], self.size[1]*RED_START[1], CIRCLE_RADIUS) speakers = [] for i in range(self.numSpeakers): setup = vars.getVars("Speakers_setup") x, y = self.size[0]*setup[i][0], self.size[1]*setup[i][1] #FL 02/09/2017 speakers.append(Speaker(x, y, SPEAKER_RADIUS)) vars.setVars("Speakers", speakers) # print vars.getVars("Speakers")[0].c self.speakerAdjusted() # FL 29/05/17 # méthode pour les controles self.Bind(wx.EVT_PAINT, self.onPaint) self.Bind(wx.EVT_LEFT_DOWN, self.onLeftDown) self.Bind(wx.EVT_LEFT_UP, self.onLeftUp) self.Bind(wx.EVT_RIGHT_DOWN, self.onRightDown) self.Bind(wx.EVT_MOTION, self.onMotion) self.Bind(wx.EVT_KEY_DOWN, self.onKeyDown) self.Bind(wx.EVT_KEY_UP, self.onKeyUp) self.on_timer()
def __init__(self, parent, dpi=None, **kwargs): wx.Panel.__init__(self, parent, wx.ID_ANY, wx.DefaultPosition, wx.Size(512,512), **kwargs) self.ztv_frame = self.GetTopLevelParent() self.accelerator_table = [] self.center = wx.RealPoint() self.zoom_rect = None self.eventID_to_cmap = {wx.NewId(): x for x in self.ztv_frame.available_cmaps} self.cmap_to_eventID = {self.eventID_to_cmap[x]: x for x in self.eventID_to_cmap} self.eventID_to_scaling = {wx.NewId(): x for x in self.ztv_frame.available_scalings} self.scaling_to_eventID = {self.eventID_to_scaling[x]: x for x in self.eventID_to_scaling} cmap_bitmap_height = 15 cmap_bitmap_width = 100 self.cmap_bitmaps = {} for cmap in self.ztv_frame.available_cmaps: temp = cm.ScalarMappable(cmap=cmap) rgba = temp.to_rgba(np.outer(np.ones(cmap_bitmap_height, dtype=np.uint8), np.arange(cmap_bitmap_width, dtype=np.uint8))) self.cmap_bitmaps[cmap] = wx.BitmapFromBufferRGBA(cmap_bitmap_width, cmap_bitmap_height, np.uint8(np.round(rgba*255))) self.popup_menu_cursor_modes = ['Zoom', 'Pan'] self.available_cursor_modes = {'Zoom':{'set-to-mode':self.set_cursor_to_zoom_mode}, 'Pan':{'set-to-mode':self.set_cursor_to_pan_mode}} self.available_key_presses = {} self.cursor_mode = 'Zoom' self.max_doubleclick_sec = 0.5 # needed to trap 'real' single clicks from the first click of a double click self.popup_menu_needs_rebuild = True self.popup_menu = None self.xlim = [-9e9, 9e9] self.ylim = [-9e9, 9e9] self.figure = Figure(None, dpi) self.axes = self.figure.add_axes([0., 0., 1., 1.]) self.canvas = FigureCanvasWxAgg(self, -1, self.figure) self.Bind(wx.EVT_SIZE, self._onSize) self.axes_widget = AxesWidget(self.figure.gca()) self.axes_widget.connect_event('motion_notify_event', self.on_motion) self.axes_widget.connect_event('figure_leave_event', self.on_cursor_leave) self.axes_widget.connect_event('figure_enter_event', self.on_cursor_enter) self.axes_widget.connect_event('button_press_event', self.on_button_press) self.axes_widget.connect_event('button_release_event', self.on_button_release) self.axes_widget.connect_event('key_press_event', self.on_key_press) wx.EVT_RIGHT_DOWN(self.figure.canvas, self.on_right_down) # supercedes the above button_press_event pub.subscribe(self.redraw_primary_image, 'redraw-image') pub.subscribe(self.reset_zoom_and_center, 'reset-zoom-and-center') pub.subscribe(self.set_zoom_factor, 'set-zoom-factor') pub.subscribe(self.set_xy_center, 'set-xy-center')