我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用wx.GetMousePosition()。
def Paste(self, bbx=None): if not self.Debug: element = self.ParentWindow.GetCopyBuffer() if bbx is None: mouse_pos = self.Editor.ScreenToClient(wx.GetMousePosition()) middle = wx.Rect(0, 0, *self.Editor.GetClientSize()).InsideXY(mouse_pos.x, mouse_pos.y) if middle: x, y = self.CalcUnscrolledPosition(mouse_pos.x, mouse_pos.y) else: x, y = self.CalcUnscrolledPosition(0, 0) new_pos = [int(x / self.ViewScale[0]), int(y / self.ViewScale[1])] else: middle = True new_pos = [bbx.x, bbx.y] result = self.Controler.PasteEditedElementInstances(self.TagName, element, new_pos, middle, self.Debug) if not isinstance(result, (StringType, UnicodeType)): self.RefreshBuffer() self.RefreshView(selection=result) self.RefreshVariablePanel() self.ParentWindow.RefreshPouInstanceVariablesPanel() else: message = wx.MessageDialog(self.Editor, result, "Error", wx.OK | wx.ICON_ERROR) message.ShowModal() message.Destroy()
def onCommand( self, event ): if wx.GetMouseState().LeftIsDown(): x = self.sCommand.ScreenToClient(wx.GetMousePosition()).x val = self.sCommand.GetMin() + (self.sCommand.GetMax() - self.sCommand.GetMin()) * x / self.sCommand.GetSize().x self.sCommand.SetValue(val)
def __init__(self, parent, agwStyle=aui.AUI_NB_TOP | aui.AUI_NB_TAB_SPLIT): aui.AuiNotebook.__init__(self, parent=parent, agwStyle=agwStyle | aui.AUI_NB_TAB_FLOAT) #def FloatPage(self, page_index): # pageTitle = self.GetPageText(page_index) # pageContents = self.GetPage(page_index) # frame = wx.Frame(self, title=pageTitle, # size=self.GetClientSize(), # style=wx.DEFAULT_FRAME_STYLE) # self.RemovePage(page_index) # pageContents.Reparent(frame) # frame.Bind(wx.EVT_CLOSE, self.closeFloatPage) # frame.Move(wx.GetMousePosition()) # frame.Show() #def closeFloatPage(self, event): # self.floated = False # event.Skip() # frame = event.GetEventObject() # pageTitle = frame.GetTitle() # pageContents = frame.GetChildren()[0] # pageContents.Reparent(self) # self.AddPage(pageContents, pageTitle, select=True)
def FloatPage(self, page_index): root_manager = aui.GetManager(self) page_title = self.GetPageText(page_index) page_contents = self.GetPage(page_index) page_bitmap = self.GetPageBitmap(page_index) text_colour = self.GetPageTextColour(page_index) info = self.GetPageInfo(page_index) frame = FloatingFrame(self, title=page_title, size=self.GetClientSize(), # request add to standard AuiNotebook? XXX - idfah style=wx.DEFAULT_FRAME_STYLE) #style=wx.DEFAULT_FRAME_STYLE|wx.FRAME_TOOL_WINDOW| # wx.FRAME_FLOAT_ON_PARENT | wx.FRAME_NO_TASKBAR) if info.control: info.control.Reparent(frame) info.control.Hide() frame.bitmap = page_bitmap frame.page_index = page_index frame.text_colour = text_colour frame.control = info.control page_contents.Reparent(frame) frame.Bind(wx.EVT_CLOSE, self.OnCloseFloatingPage) frame.Move(wx.GetMousePosition()) frame.Show() page_contents.SetFocus() self.RemovePage(page_index) self.RemoveEmptyTabFrames() wx.CallAfter(self.RemoveEmptyTabFrames) #def FloatPage(self, page_index): # page_contents = self.GetPage(page_index) # size = page_contents.GetSize() # aui.AuiNotebook.FloatPage(self, page_index) # page_contents.GetParent().SetSize(size)
def on_settings_button(self, evt): pos = self.ScreenToClient(wx.GetMousePosition()) self.PopupMenu(self.settings_popup_menu, pos)
def on_cmap_button(self, evt): for cmap in self.ztv_frame.available_cmaps: self.cmap_popup_menu.Check(self.cmap_to_eventID[cmap], False) self.cmap_popup_menu.Check(self.cmap_to_eventID[self.ztv_frame.cmap], True) pos = self.ScreenToClient(wx.GetMousePosition()) self.PopupMenu(self.cmap_popup_menu, pos)
def on_canvas_mouse(self, event): #print 'on_canvas_mouse' if event.GetEventType() in [wx.wxEVT_MOTION, wx.wxEVT_LEFT_DOWN, wx.wxEVT_LEFT_UP, wx.wxEVT_MOTION|wx.wxEVT_LEFT_DOWN]: evt = wx.MouseEvent(event.GetEventType()) pos = self.track.ScreenToClient(wx.GetMousePosition()) evt.SetPosition(pos) evt.Skip() self.track.GetEventHandler().ProcessEvent(evt)# or evt.IsAllowed()