Python wx.EVT_ENTER_WINDOW Examples
The following are 17
code examples of wx.EVT_ENTER_WINDOW().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
wx
, or try the search function
.
Example #1
Source File: panel.py From wxGlade with MIT License | 6 votes |
def create_widget(self): if self.widget: # re-creating -> use old frame win = self.widget.GetTopLevelParent() else: style = wx.DEFAULT_FRAME_STYLE if common.pin_design_window: style |= wx.STAY_ON_TOP win = wx.Frame( common.main, -1, misc.design_title(self.name), size=(400, 300), style=style ) import os, compat icon = compat.wx_EmptyIcon() xpm = os.path.join(config.icons_path, 'panel.xpm') icon.CopyFromBitmap(misc.get_xpm_bitmap(xpm)) win.SetIcon(icon) win.Bind(wx.EVT_CLOSE, self.hide_widget) # CLOSE event of the frame, not the panel if wx.Platform == '__WXMSW__': win.CentreOnScreen() if self.scrollable: self.widget = wx.ScrolledWindow(win, self.id, style=0) else: self.widget = wx.Panel(win, self.id, style=0) self.widget.Bind(wx.EVT_ENTER_WINDOW, self.on_enter) self.widget.GetBestSize = self.get_widget_best_size #self.widget.SetSize = win.SetSize
Example #2
Source File: edit_base.py From wxGlade with MIT License | 6 votes |
def destroy_widget(self, level): if self.widget is None: return if misc.currently_under_mouse is self.widget: misc.currently_under_mouse = None self.widget.Hide() if wx.VERSION_STRING!="2.8.12.0": # unbind events to prevent new created (and queued) events self.widget.Bind(wx.EVT_PAINT, None) self.widget.Bind(wx.EVT_RIGHT_DOWN, None) self.widget.Bind(wx.EVT_LEFT_DOWN, None) self.widget.Bind(wx.EVT_MIDDLE_DOWN, None) self.widget.Bind(wx.EVT_ENTER_WINDOW, None) self.widget.Bind(wx.EVT_LEAVE_WINDOW, None) self.widget.Bind(wx.EVT_KEY_DOWN, None) compat.DestroyLater(self.widget) self.widget = None if misc.focused_widget is self: misc.set_focused_widget(None)
Example #3
Source File: edit_base.py From wxGlade with MIT License | 6 votes |
def create_widget(self): if self.overlapped and self.parent._IS_GRIDBAG: return style = wx.FULL_REPAINT_ON_RESIZE if self.parent.CHILDREN in (-1, 1): # e.g. Panel in a Frame size = self.parent.widget.GetClientSize() else: size = (20, 20) self.widget = wx.Window(self.parent_window.widget, -1, size=size, style=style) self.widget.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) #self.widget.SetAutoLayout(True) self.widget.Bind(wx.EVT_PAINT, self.on_paint) self.widget.Bind(wx.EVT_ERASE_BACKGROUND, self.on_erase_background) self.widget.Bind(wx.EVT_RIGHT_DOWN, self.popup_menu) self.widget.Bind(wx.EVT_LEFT_DOWN, self.on_drop_widget) self.widget.Bind(wx.EVT_MIDDLE_DOWN, misc.exec_after(self.on_select_and_paste)) self.widget.Bind(wx.EVT_ENTER_WINDOW, self.on_enter) self.widget.Bind(wx.EVT_LEAVE_WINDOW, self.on_leave) #self.widget.Bind(wx.EVT_CHAR_HOOK, misc.on_key_down_event) # catch cursor keys XXX still required?
Example #4
Source File: edit_windows.py From wxGlade with MIT License | 6 votes |
def finish_widget_creation(self, level): WindowBase.finish_widget_creation(self, level) if self.CHILDREN: # not for MenuBar, ToolBar self.drop_target = clipboard.DropTarget(self) self.widget.SetDropTarget(self.drop_target) self.widget.SetMinSize = self.widget.SetSize if self.has_title: self.widget.SetTitle( misc.design_title(self.title) ) elif hasattr(self.widget, 'SetTitle'): self.widget.SetTitle(misc.design_title(self.name)) self.widget.Bind(wx.EVT_LEFT_DOWN, self.drop_sizer) self.widget.Bind(wx.EVT_ENTER_WINDOW, self.on_enter) self.widget.Bind(wx.EVT_CLOSE, self.hide_widget) if wx.Platform == '__WXMSW__': # MSW isn't smart enough to avoid overlapping windows, so at least move it away from the 3 wxGlade frames self.widget.Center()
Example #5
Source File: DebugVariableTextViewer.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
def __init__(self, parent, window, items=None): """ 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))
Example #6
Source File: ConfTreeNodeEditor.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
def GenerateMethodButtonSizer(self): normal_bt_font = wx.Font(faces["size"] // 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName=faces["helv"]) mouseover_bt_font = wx.Font(faces["size"] // 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName=faces["helv"], underline=True) msizer = wx.BoxSizer(wx.HORIZONTAL) for confnode_method in self.Controler.ConfNodeMethods: if "method" in confnode_method and confnode_method.get("shown", True): button = GenBitmapTextButton(self.Editor, bitmap=GetBitmap(confnode_method.get("bitmap", "Unknown")), label=confnode_method["name"], style=wx.NO_BORDER) button.SetFont(normal_bt_font) button.SetToolTipString(confnode_method["tooltip"]) if confnode_method.get("push", False): button.Bind(wx.EVT_LEFT_DOWN, self.GetButtonCallBackFunction(confnode_method["method"], True)) else: button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(confnode_method["method"]), button) # a fancy underline on mouseover def setFontStyle(b, s): def fn(event): b.SetFont(s) b.Refresh() event.Skip() return fn button.Bind(wx.EVT_ENTER_WINDOW, setFontStyle(button, mouseover_bt_font)) button.Bind(wx.EVT_LEAVE_WINDOW, setFontStyle(button, normal_bt_font)) # hack to force size to mini if not confnode_method.get("enabled", True): button.Disable() msizer.AddWindow(button, flag=wx.ALIGN_CENTER) return msizer
Example #7
Source File: main.py From python-examples with MIT License | 5 votes |
def InitUI(self): img_color = wx.Image('Obrazy/furas.png') img_grey = img_color.ConvertToGreyscale(0.3, 0.3, 0.3) self.hbox = wx.BoxSizer(wx.HORIZONTAL) self.panel = wx.Panel(self) self.panel.SetSizer(self.hbox) self.bitmap_color = wx.Bitmap(img_color) self.bitmap_grey = wx.Bitmap(img_grey) #self.image = wx.StaticBitmap(self.panel, 1, self.bitmap_color) self.image = wx.BitmapButton(self.panel, 1, self.bitmap_color, style=wx.BORDER_NONE) # use 0 to not resize image to full window self.hbox.Add(self.image, 0) # binds don't work on Linux for StaticBitmap # but they works for BitmapButton (but Button has border) self.image.Bind(wx.EVT_ENTER_WINDOW, self.OnOver) self.image.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave) # set color to see how many space use it self.panel.SetBackgroundColour((0,255,0)) # set color to see how many space use it self.image.SetBackgroundColour((255,0,0))
Example #8
Source File: panel.py From wxGlade with MIT License | 5 votes |
def create_widget(self): # to be done: use ScrolledWindow only if scrolling is required if self.scrollable: self.widget = wx.ScrolledWindow(self.parent_window.widget, self.id, style=0) else: self.widget = wx.Panel(self.parent_window.widget, self.id, style=0) self.widget.Bind(wx.EVT_ENTER_WINDOW, self.on_enter) self.widget.GetBestSize = self.get_widget_best_size if not self.parent.IS_SIZER: def GetBestSize(): if self.widget and self.widget.GetSizer(): return self.widget.GetSizer().GetMinSize() return self.widget.__class__.GetBestSize(self.widget) self.widget.GetBestSize = GetBestSize
Example #9
Source File: recipe-577951.py From code with MIT License | 5 votes |
def OnMouseEnter(self, event): """ Handles the ``wx.EVT_ENTER_WINDOW`` event for L{RoundButton}. :param `event`: a `wx.MouseEvent` event to be processed. """ if not self.IsEnabled(): return self._mouseAction = HOVER self.Refresh() event.Skip()
Example #10
Source File: recipe-577951.py From code with MIT License | 5 votes |
def __init__(self, parent, id=wx.ID_ANY, label="", pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.NO_BORDER, validator=wx.DefaultValidator, name="roundbutton"): """ Default class constructor. :param `parent`: the L{RoundButton} parent; :param `id`: window identifier. A value of -1 indicates a default value; :param `label`: the button text label; :param `pos`: the control position. A value of (-1, -1) indicates a default position, chosen by either the windowing system or wxPython, depending on platform; :param `size`: the control size. A value of (-1, -1) indicates a default size, chosen by either the windowing system or wxPython, depending on platform; :param `style`: the button style (unused); :param `validator`: the validator associated to the button; :param `name`: the button name. """ wx.PyControl.__init__(self, parent, id, pos, size, style, validator, name) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_ERASE_BACKGROUND, lambda event: None) self.Bind(wx.EVT_SIZE, self.OnSize) self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave) self.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter) self.Bind(wx.EVT_SET_FOCUS, self.OnGainFocus) self.Bind(wx.EVT_KILL_FOCUS, self.OnLoseFocus) self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) self.Bind(wx.EVT_KEY_UP, self.OnKeyUp) self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDown) self._mouseAction = None self._hasFocus = False self._buttonRadius = 0 self.SetLabel(label) self.InheritAttributes() self.SetInitialSize(size)
Example #11
Source File: wxcursor_demo_sgskip.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, ): wx.Frame.__init__(self, None, -1, 'CanvasFrame', size=(550, 350)) self.figure = Figure() self.axes = self.figure.add_subplot(111) t = np.arange(0.0, 3.0, 0.01) s = np.sin(2*np.pi*t) self.axes.plot(t, s) self.axes.set_xlabel('t') self.axes.set_ylabel('sin(t)') self.figure_canvas = FigureCanvas(self, -1, self.figure) # Note that event is a MplEvent self.figure_canvas.mpl_connect( 'motion_notify_event', self.UpdateStatusBar) self.figure_canvas.Bind(wx.EVT_ENTER_WINDOW, self.ChangeCursor) self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.Add(self.figure_canvas, 1, wx.LEFT | wx.TOP | wx.GROW) self.SetSizer(self.sizer) self.Fit() self.statusBar = wx.StatusBar(self, -1) self.SetStatusBar(self.statusBar) self.toolbar = NavigationToolbar2Wx(self.figure_canvas) self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND) self.toolbar.Show()
Example #12
Source File: backend_wx.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 4 votes |
def __init__(self, parent, id, figure): """ Initialise a FigureWx instance. - Initialise the FigureCanvasBase and wxPanel parents. - Set event handlers for: EVT_SIZE (Resize event) EVT_PAINT (Paint event) """ FigureCanvasBase.__init__(self, figure) # Set preferred window size hint - helps the sizer (if one is # connected) l, b, w, h = figure.bbox.bounds w = math.ceil(w) h = math.ceil(h) wx.Panel.__init__(self, parent, id, size=wx.Size(w, h)) # Create the drawing bitmap self.bitmap = wx.Bitmap(w, h) DEBUG_MSG("__init__() - bitmap w:%d h:%d" % (w, h), 2, self) # TODO: Add support for 'point' inspection and plot navigation. self._isDrawn = False self.Bind(wx.EVT_SIZE, self._onSize) self.Bind(wx.EVT_PAINT, self._onPaint) self.Bind(wx.EVT_KEY_DOWN, self._onKeyDown) self.Bind(wx.EVT_KEY_UP, self._onKeyUp) self.Bind(wx.EVT_RIGHT_DOWN, self._onRightButtonDown) self.Bind(wx.EVT_RIGHT_DCLICK, self._onRightButtonDClick) self.Bind(wx.EVT_RIGHT_UP, self._onRightButtonUp) self.Bind(wx.EVT_MOUSEWHEEL, self._onMouseWheel) self.Bind(wx.EVT_LEFT_DOWN, self._onLeftButtonDown) self.Bind(wx.EVT_LEFT_DCLICK, self._onLeftButtonDClick) self.Bind(wx.EVT_LEFT_UP, self._onLeftButtonUp) self.Bind(wx.EVT_MOTION, self._onMotion) self.Bind(wx.EVT_LEAVE_WINDOW, self._onLeave) self.Bind(wx.EVT_ENTER_WINDOW, self._onEnter) # Add middle button events self.Bind(wx.EVT_MIDDLE_DOWN, self._onMiddleButtonDown) self.Bind(wx.EVT_MIDDLE_DCLICK, self._onMiddleButtonDClick) self.Bind(wx.EVT_MIDDLE_UP, self._onMiddleButtonUp) self.Bind(wx.EVT_MOUSE_CAPTURE_CHANGED, self._onCaptureLost) self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, self._onCaptureLost) self.SetBackgroundStyle(wx.BG_STYLE_PAINT) # Reduce flicker. self.SetBackgroundColour(wx.WHITE)
Example #13
Source File: backend_wx.py From coffeegrindsize with MIT License | 4 votes |
def __init__(self, parent, id, figure): """ Initialise a FigureWx instance. - Initialise the FigureCanvasBase and wxPanel parents. - Set event handlers for: EVT_SIZE (Resize event) EVT_PAINT (Paint event) """ FigureCanvasBase.__init__(self, figure) # Set preferred window size hint - helps the sizer (if one is # connected) l, b, w, h = figure.bbox.bounds w = math.ceil(w) h = math.ceil(h) wx.Panel.__init__(self, parent, id, size=wx.Size(w, h)) # Create the drawing bitmap self.bitmap = wx.Bitmap(w, h) DEBUG_MSG("__init__() - bitmap w:%d h:%d" % (w, h), 2, self) # TODO: Add support for 'point' inspection and plot navigation. self._isDrawn = False self.Bind(wx.EVT_SIZE, self._onSize) self.Bind(wx.EVT_PAINT, self._onPaint) self.Bind(wx.EVT_KEY_DOWN, self._onKeyDown) self.Bind(wx.EVT_KEY_UP, self._onKeyUp) self.Bind(wx.EVT_RIGHT_DOWN, self._onRightButtonDown) self.Bind(wx.EVT_RIGHT_DCLICK, self._onRightButtonDClick) self.Bind(wx.EVT_RIGHT_UP, self._onRightButtonUp) self.Bind(wx.EVT_MOUSEWHEEL, self._onMouseWheel) self.Bind(wx.EVT_LEFT_DOWN, self._onLeftButtonDown) self.Bind(wx.EVT_LEFT_DCLICK, self._onLeftButtonDClick) self.Bind(wx.EVT_LEFT_UP, self._onLeftButtonUp) self.Bind(wx.EVT_MOTION, self._onMotion) self.Bind(wx.EVT_LEAVE_WINDOW, self._onLeave) self.Bind(wx.EVT_ENTER_WINDOW, self._onEnter) # Add middle button events self.Bind(wx.EVT_MIDDLE_DOWN, self._onMiddleButtonDown) self.Bind(wx.EVT_MIDDLE_DCLICK, self._onMiddleButtonDClick) self.Bind(wx.EVT_MIDDLE_UP, self._onMiddleButtonUp) self.Bind(wx.EVT_MOUSE_CAPTURE_CHANGED, self._onCaptureLost) self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, self._onCaptureLost) self.SetBackgroundStyle(wx.BG_STYLE_PAINT) # Reduce flicker. self.SetBackgroundColour(wx.WHITE)
Example #14
Source File: backend_wx.py From CogAlg with MIT License | 4 votes |
def __init__(self, parent, id, figure): """ Initialise a FigureWx instance. - Initialise the FigureCanvasBase and wxPanel parents. - Set event handlers for: EVT_SIZE (Resize event) EVT_PAINT (Paint event) """ FigureCanvasBase.__init__(self, figure) # Set preferred window size hint - helps the sizer (if one is # connected) l, b, w, h = figure.bbox.bounds w = math.ceil(w) h = math.ceil(h) wx.Panel.__init__(self, parent, id, size=wx.Size(w, h)) # Create the drawing bitmap self.bitmap = wx.Bitmap(w, h) DEBUG_MSG("__init__() - bitmap w:%d h:%d" % (w, h), 2, self) # TODO: Add support for 'point' inspection and plot navigation. self._isDrawn = False self.Bind(wx.EVT_SIZE, self._onSize) self.Bind(wx.EVT_PAINT, self._onPaint) self.Bind(wx.EVT_KEY_DOWN, self._onKeyDown) self.Bind(wx.EVT_KEY_UP, self._onKeyUp) self.Bind(wx.EVT_RIGHT_DOWN, self._onRightButtonDown) self.Bind(wx.EVT_RIGHT_DCLICK, self._onRightButtonDClick) self.Bind(wx.EVT_RIGHT_UP, self._onRightButtonUp) self.Bind(wx.EVT_MOUSEWHEEL, self._onMouseWheel) self.Bind(wx.EVT_LEFT_DOWN, self._onLeftButtonDown) self.Bind(wx.EVT_LEFT_DCLICK, self._onLeftButtonDClick) self.Bind(wx.EVT_LEFT_UP, self._onLeftButtonUp) self.Bind(wx.EVT_MOTION, self._onMotion) self.Bind(wx.EVT_LEAVE_WINDOW, self._onLeave) self.Bind(wx.EVT_ENTER_WINDOW, self._onEnter) # Add middle button events self.Bind(wx.EVT_MIDDLE_DOWN, self._onMiddleButtonDown) self.Bind(wx.EVT_MIDDLE_DCLICK, self._onMiddleButtonDClick) self.Bind(wx.EVT_MIDDLE_UP, self._onMiddleButtonUp) self.Bind(wx.EVT_MOUSE_CAPTURE_CHANGED, self._onCaptureLost) self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, self._onCaptureLost) self.SetBackgroundStyle(wx.BG_STYLE_PAINT) # Reduce flicker. self.SetBackgroundColour(wx.WHITE)
Example #15
Source File: preview.py From IkaLog with Apache License 2.0 | 4 votes |
def __init__(self, *args, **kwargs): self._prev_bmp = None self._enter = False self._pause = False self.refresh_at_next = False self.latest_frame = None self.lock = threading.Lock() wx.Panel.__init__(self, *args, **kwargs) self.timer = wx.Timer(self) self.timer.Start(100) self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer) self.GetTopLevelParent().Bind(EVT_INPUT_INITIALIZED, self.on_input_initialized) self.GetTopLevelParent().Bind(EVT_IKALOG_PAUSE, self.on_ikalog_pause) # Preview self.preview_size = (640, 360) # Preview image. self.preview_panel = wx.Panel(self, wx.ID_ANY, size=self.preview_size) self.preview_panel.Bind(wx.EVT_LEFT_UP, self.on_preview_click) self.preview_panel.Bind(wx.EVT_ENTER_WINDOW, self.on_enter_preview) self.preview_panel.Bind(wx.EVT_LEAVE_WINDOW, self.on_leave_preview) # Video Input self.video_input_title_text = wx.StaticText( self, wx.ID_ANY, _('Video Input')) self.video_input_source_text = wx.StaticText(self, wx.ID_ANY, '') self.input_file_panel = InputFilePanel(self, wx.ID_ANY) self.input_file_panel.Bind(EVT_INPUT_FILE_ADDED, self.on_input_file_added) self.show_input_file(False) self.video_input_source_sizer = wx.BoxSizer(wx.HORIZONTAL) self.video_input_source_sizer.Add( self.video_input_source_text, flag=wx.LEFT, border=10) self.video_input_source_sizer.Add(self.input_file_panel, proportion=1) # Sizer to set the width of the text box to 640. self.video_input_sizer = wx.BoxSizer(wx.VERTICAL) self.video_input_sizer.Add(self.video_input_title_text) self.video_input_sizer.Add(self.video_input_source_sizer, flag=wx.EXPAND | wx.ALL, border=5) self.video_input_sizer.Add((640, 5)) # Top sizer self.top_sizer = wx.BoxSizer(wx.VERTICAL) self.top_sizer.Add(self.video_input_sizer, flag=wx.ALL, border=5) self.top_sizer.Add(self.preview_panel) self.SetSizer(self.top_sizer)
Example #16
Source File: backend_wx.py From GraphicDesignPatternByPython with MIT License | 4 votes |
def __init__(self, parent, id, figure): """ Initialise a FigureWx instance. - Initialise the FigureCanvasBase and wxPanel parents. - Set event handlers for: EVT_SIZE (Resize event) EVT_PAINT (Paint event) """ FigureCanvasBase.__init__(self, figure) # Set preferred window size hint - helps the sizer (if one is # connected) l, b, w, h = figure.bbox.bounds w = math.ceil(w) h = math.ceil(h) wx.Panel.__init__(self, parent, id, size=wx.Size(w, h)) # Create the drawing bitmap self.bitmap = wx.Bitmap(w, h) DEBUG_MSG("__init__() - bitmap w:%d h:%d" % (w, h), 2, self) # TODO: Add support for 'point' inspection and plot navigation. self._isDrawn = False self.Bind(wx.EVT_SIZE, self._onSize) self.Bind(wx.EVT_PAINT, self._onPaint) self.Bind(wx.EVT_KEY_DOWN, self._onKeyDown) self.Bind(wx.EVT_KEY_UP, self._onKeyUp) self.Bind(wx.EVT_RIGHT_DOWN, self._onRightButtonDown) self.Bind(wx.EVT_RIGHT_DCLICK, self._onRightButtonDClick) self.Bind(wx.EVT_RIGHT_UP, self._onRightButtonUp) self.Bind(wx.EVT_MOUSEWHEEL, self._onMouseWheel) self.Bind(wx.EVT_LEFT_DOWN, self._onLeftButtonDown) self.Bind(wx.EVT_LEFT_DCLICK, self._onLeftButtonDClick) self.Bind(wx.EVT_LEFT_UP, self._onLeftButtonUp) self.Bind(wx.EVT_MOTION, self._onMotion) self.Bind(wx.EVT_LEAVE_WINDOW, self._onLeave) self.Bind(wx.EVT_ENTER_WINDOW, self._onEnter) # Add middle button events self.Bind(wx.EVT_MIDDLE_DOWN, self._onMiddleButtonDown) self.Bind(wx.EVT_MIDDLE_DCLICK, self._onMiddleButtonDClick) self.Bind(wx.EVT_MIDDLE_UP, self._onMiddleButtonUp) self.Bind(wx.EVT_MOUSE_CAPTURE_CHANGED, self._onCaptureLost) self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, self._onCaptureLost) self.SetBackgroundStyle(wx.BG_STYLE_PAINT) # Reduce flicker. self.SetBackgroundColour(wx.WHITE)
Example #17
Source File: backend_wx.py From Mastering-Elasticsearch-7.0 with MIT License | 4 votes |
def __init__(self, parent, id, figure): """ Initialise a FigureWx instance. - Initialise the FigureCanvasBase and wxPanel parents. - Set event handlers for: EVT_SIZE (Resize event) EVT_PAINT (Paint event) """ FigureCanvasBase.__init__(self, figure) # Set preferred window size hint - helps the sizer (if one is # connected) l, b, w, h = figure.bbox.bounds w = math.ceil(w) h = math.ceil(h) wx.Panel.__init__(self, parent, id, size=wx.Size(w, h)) # Create the drawing bitmap self.bitmap = wx.Bitmap(w, h) DEBUG_MSG("__init__() - bitmap w:%d h:%d" % (w, h), 2, self) # TODO: Add support for 'point' inspection and plot navigation. self._isDrawn = False self.Bind(wx.EVT_SIZE, self._onSize) self.Bind(wx.EVT_PAINT, self._onPaint) self.Bind(wx.EVT_KEY_DOWN, self._onKeyDown) self.Bind(wx.EVT_KEY_UP, self._onKeyUp) self.Bind(wx.EVT_RIGHT_DOWN, self._onRightButtonDown) self.Bind(wx.EVT_RIGHT_DCLICK, self._onRightButtonDClick) self.Bind(wx.EVT_RIGHT_UP, self._onRightButtonUp) self.Bind(wx.EVT_MOUSEWHEEL, self._onMouseWheel) self.Bind(wx.EVT_LEFT_DOWN, self._onLeftButtonDown) self.Bind(wx.EVT_LEFT_DCLICK, self._onLeftButtonDClick) self.Bind(wx.EVT_LEFT_UP, self._onLeftButtonUp) self.Bind(wx.EVT_MOTION, self._onMotion) self.Bind(wx.EVT_LEAVE_WINDOW, self._onLeave) self.Bind(wx.EVT_ENTER_WINDOW, self._onEnter) # Add middle button events self.Bind(wx.EVT_MIDDLE_DOWN, self._onMiddleButtonDown) self.Bind(wx.EVT_MIDDLE_DCLICK, self._onMiddleButtonDClick) self.Bind(wx.EVT_MIDDLE_UP, self._onMiddleButtonUp) self.Bind(wx.EVT_MOUSE_CAPTURE_CHANGED, self._onCaptureLost) self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, self._onCaptureLost) self.SetBackgroundStyle(wx.BG_STYLE_PAINT) # Reduce flicker. self.SetBackgroundColour(wx.WHITE)