Python wx.EVT_ERASE_BACKGROUND Examples
The following are 20
code examples of wx.EVT_ERASE_BACKGROUND().
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: trelby.py From trelby with GNU General Public License v2.0 | 7 votes |
def __init__(self, parent, id): style = wx.WANTS_CHARS | wx.FULL_REPAINT_ON_RESIZE | wx.NO_BORDER wx.Control.__init__(self, parent, id, style = style) self.panel = parent wx.EVT_SIZE(self, self.OnSize) wx.EVT_PAINT(self, self.OnPaint) wx.EVT_ERASE_BACKGROUND(self, self.OnEraseBackground) wx.EVT_LEFT_DOWN(self, self.OnLeftDown) wx.EVT_LEFT_UP(self, self.OnLeftUp) wx.EVT_LEFT_DCLICK(self, self.OnLeftDown) wx.EVT_RIGHT_DOWN(self, self.OnRightDown) wx.EVT_MOTION(self, self.OnMotion) wx.EVT_MOUSEWHEEL(self, self.OnMouseWheel) wx.EVT_CHAR(self, self.OnKeyChar) self.createEmptySp() self.updateScreen(redraw = False)
Example #2
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 #3
Source File: classes_wx.py From calfem-python with MIT License | 6 votes |
def __init__(self, *args, **kwds): kwds["style"] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) self.GLinitialized = False attribList = (glcanvas.WX_GL_RGBA, # RGBA glcanvas.WX_GL_DOUBLEBUFFER, # Double Buffered glcanvas.WX_GL_DEPTH_SIZE, 24) # 24 bit # Create the canvas self.canvas = glcanvas.GLCanvas(self, attribList=attribList) # Set the event handlers. self.canvas.Bind(wx.EVT_ERASE_BACKGROUND, self._doEraseBackground) self.canvas.Bind(wx.EVT_SIZE, self._doSize) self.canvas.Bind(wx.EVT_PAINT, self._doPaint) # Canvas Proxy Methods
Example #4
Source File: pycalfem_classes.py From calfem-python with MIT License | 6 votes |
def __init__(self, *args, **kwds): kwds["style"] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) self.GLinitialized = False attribList = (glcanvas.WX_GL_RGBA, # RGBA glcanvas.WX_GL_DOUBLEBUFFER, # Double Buffered glcanvas.WX_GL_DEPTH_SIZE, 24) # 24 bit # Create the canvas self.canvas = glcanvas.GLCanvas(self, attribList=attribList) # Set the event handlers. self.canvas.Bind(wx.EVT_ERASE_BACKGROUND, self._doEraseBackground) self.canvas.Bind(wx.EVT_SIZE, self._doSize) self.canvas.Bind(wx.EVT_PAINT, self._doPaint) # Canvas Proxy Methods
Example #5
Source File: chapter2.py From OpenCV-Computer-Vision-Projects-with-Python with MIT License | 6 votes |
def __init__(self, parent, id, title, capture, fps=15): # initialize screen capture self.capture = capture # determine window size and init wx.Frame frame,_ = freenect.sync_get_depth() self.imgHeight,self.imgWidth = frame.shape[:2] buffer = np.zeros((self.imgWidth,self.imgHeight,3),np.uint8) self.bmp = wx.BitmapFromBuffer(self.imgWidth, self.imgHeight, buffer) wx.Frame.__init__(self, parent, id, title, size=(self.imgWidth, self.imgHeight)) # set up periodic screen capture self.timer = wx.Timer(self) self.timer.Start(1000./fps) self.Bind(wx.EVT_TIMER, self.NextFrame) # counteract flicker def disable_event(*pargs,**kwargs): pass self.Bind(wx.EVT_ERASE_BACKGROUND, disable_event) # create the layout, which draws all buttons and # connects events to class methods self.CreateLayout()
Example #6
Source File: import_OpenGL_cube_and_cone.py From Python-GUI-Programming-Cookbook-Second-Edition with MIT License | 5 votes |
def __init__(self, parent): glcanvas.GLCanvas.__init__(self, parent, -1) self.init = False self.context = glcanvas.GLContext(self) # <== this was missing when I wrote the book in 2015... # initial mouse position self.lastx = self.x = 30 self.lasty = self.y = 30 self.size = None self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_SIZE, self.OnSize) 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_MOTION, self.OnMouseMotion)
Example #7
Source File: pyslip.py From dials with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__( self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.NO_FULL_REPAINT_ON_RESIZE, ): """Initialize the canvas. parent reference to 'parent' widget id the unique widget ID pos canvas position size canvas size style wxPython style """ wx.Panel.__init__(self, parent, id, pos, size, style) # Bind events self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_SIZE, self.OnSize) # Disable background erasing (flicker-licious) def disable_event(*pargs, **kwargs): pass # the sauce, please self.Bind(wx.EVT_ERASE_BACKGROUND, disable_event) # set callback upon onSize event self.onSizeCallback = None
Example #8
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 #9
Source File: LogViewer.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
def __init__(self, parent, size): wx.Panel.__init__(self, parent, size=size) self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp) self.Bind(wx.EVT_MOTION, self.OnMotion) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_SIZE, self.OnResize) self.ThumbPosition = 0. # -1 <= ThumbPosition <= 1 self.ThumbScrollingStartPos = None
Example #10
Source File: custom_widget.py From wxGlade with MIT License | 5 votes |
def create_widget(self): self.widget = wx.Window(self.parent_window.widget , self.id, style=wx.BORDER_SUNKEN | wx.FULL_REPAINT_ON_RESIZE) self.widget.Bind(wx.EVT_PAINT, self.on_paint) self.widget.Bind(wx.EVT_ERASE_BACKGROUND, lambda event:None)
Example #11
Source File: ListCtrl.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def __init__(self, parent): wx.ListCtrl.__init__(self, parent, wx.ID_ANY, style=wx.LC_REPORT) ContextMenuMixin.__init__(self) self.il = wx.ImageList(self.icon_size, self.icon_size) # TODO: use a real icon self.il.Add(self.draw_blank()) self.il.Add(self.draw_sort_arrow('up')) self.il.Add(self.draw_sort_arrow('down')) self.SetImageList(self.il, wx.IMAGE_LIST_SMALL) self.update_enabled_columns() for i, name in enumerate(self.enabled_columns): column = self.columns[name] column.SetColumn(i) self.InsertColumnItem(i, column) self.itemData_to_row = {} self.index_to_itemData = {} self.selected_column = None self.SelectColumn(self.enabled_columns[0]) cmenu = wx.Menu() for name in self.column_order: column = self.columns[name] id = wx.NewId() cmenu.AppendCheckItem(id, column.GetText()) cmenu.Check(id, column.enabled) self.Bind(wx.EVT_MENU, lambda e, c=column, id=id: self.toggle_column(c, id, e), id=id) self.SetColumnContextMenu(cmenu) ColumnSorterMixin.__init__(self, len(self.enabled_columns)) self._last_scrollpos = 0 if sys.platform != "darwin": self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.default_rect = wx.Rect(0,0)
Example #12
Source File: CustomWidgets.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def bind_events(self): self.Bind(wx.EVT_ERASE_BACKGROUND, lambda e : None) self.Bind(wx.EVT_SIZE, self.OnSize) self.Bind(wx.EVT_PAINT, self.OnPaint)
Example #13
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 #14
Source File: wm_core.py From wafer_map with GNU General Public License v3.0 | 5 votes |
def _bind_events(self): """ Bind panel and canvas events. Note that key-down is bound again - this allws hotkeys to work even if the main Frame, which defines hotkeys in menus, is not present. wx sents the EVT_KEY_DOWN up the chain and, if the Frame and hotkeys are present, executes those instead. At least I think that's how that works... See http://wxpython.org/Phoenix/docs/html/events_overview.html for more info. """ # Canvas Events self.canvas.Bind(FloatCanvas.EVT_MOTION, self.on_mouse_move) self.canvas.Bind(FloatCanvas.EVT_MOUSEWHEEL, self.on_mouse_wheel) self.canvas.Bind(FloatCanvas.EVT_MIDDLE_DOWN, self.on_mouse_middle_down) self.canvas.Bind(FloatCanvas.EVT_MIDDLE_UP, self.on_mouse_middle_up) self.canvas.Bind(wx.EVT_PAINT, self._on_first_paint) # XXX: Binding the EVT_LEFT_DOWN seems to cause Issue #24. # What seems to happen is: If I bind EVT_LEFT_DOWN, then the # parent panel or application can't set focus to this # panel, which prevents the EVT_MOUSEWHEEL event from firing # properly. # self.canvas.Bind(wx.EVT_LEFT_DOWN, self.on_mouse_left_down) # self.canvas.Bind(wx.EVT_RIGHT_DOWN, self.on_mouse_right_down) # self.canvas.Bind(wx.EVT_LEFT_UP, self.on_mouse_left_up) # self.canvas.Bind(wx.EVT_KEY_DOWN, self._on_key_down) # This is supposed to fix flicker on mouse move, but it doesn't work. # self.Bind(wx.EVT_ERASE_BACKGROUND, None) # Panel Events self.Bind(csel.EVT_COLOURSELECT, self.on_color_change)
Example #15
Source File: ui.py From python-wifi-survey-heatmap with GNU Affero General Public License v3.0 | 5 votes |
def __init__(self, parent): super(FloorplanPanel, self).__init__(parent) self.parent = parent self.img_path = parent.img_path self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_LEFT_UP, self.onClick) self.Bind(wx.EVT_PAINT, self.on_paint) self.survey_points = [] self.data_filename = '%s.json' % self.parent.survey_title if os.path.exists(self.data_filename): self._load_file(self.data_filename) self.collector = Collector(self.parent.interface, self.parent.server) self.parent.SetStatusText("Ready.")
Example #16
Source File: MeshCanvas.py From laplacian-meshes with GNU General Public License v3.0 | 5 votes |
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)
Example #17
Source File: titlesdlg.py From trelby with GNU General Public License v2.0 | 5 votes |
def __init__(self, parent, ctrl, cfg): wx.Window.__init__(self, parent, -1) self.cfg = cfg self.ctrl = ctrl wx.EVT_SIZE(self, self.OnSize) wx.EVT_ERASE_BACKGROUND(self, self.OnEraseBackground) wx.EVT_PAINT(self, self.OnPaint)
Example #18
Source File: misc.py From trelby with GNU General Public License v2.0 | 5 votes |
def __init__(self, parent, id, tabCtrl): wx.Window.__init__(self, parent, id) # MyTabCtrl self.tabCtrl = tabCtrl self.tabCtrl.add2(self) wx.EVT_PAINT(self, self.OnPaint) wx.EVT_SIZE(self, self.OnSize) wx.EVT_ERASE_BACKGROUND(self, self.OnEraseBackground)
Example #19
Source File: hypercube.py From spectral with MIT License | 4 votes |
def __init__(self, data, parent, id, *args, **kwargs): global DEFAULT_WIN_SIZE self.kwargs = kwargs self.size = kwargs.get('size', DEFAULT_WIN_SIZE) self.title = kwargs.get('title', 'Hypercube') # # Forcing a specific style on the window. # Should this include styles passed? style = wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE wx.Frame.__init__(self, parent, id, self.title, wx.DefaultPosition, wx.Size(*self.size), style, kwargs.get('name', 'Hypercube')) self.gl_initialized = False attribs = (glcanvas.WX_GL_RGBA, # RGBA glcanvas.WX_GL_DOUBLEBUFFER, # Double Buffered glcanvas.WX_GL_DEPTH_SIZE, settings.WX_GL_DEPTH_SIZE) self.canvas = glcanvas.GLCanvas( self, attribList=attribs, size=self.size) self.canvas.context = wx.glcanvas.GLContext(self.canvas) # These members can be modified before calling the show method. self.clear_color = tuple(kwargs.get('background', (0., 0., 0.))) \ + (1.,) self.win_pos = (100, 100) self.fovy = 60. self.znear = 0.1 self.zfar = 10.0 self.target_pos = [0.0, 0.0, 0.0] self.camera_pos_rtp = [7.0, 45.0, 30.0] self.up = [0.0, 0.0, 1.0] self.hsi = data self.cubeHeight = 1.0 self.rotation = [-60, 0, -30] self.distance = -5 self.light = False self.texturesLoaded = False self.mouse_handler = MouseHandler(self) # Set the event handlers. self.canvas.Bind(wx.EVT_ERASE_BACKGROUND, self.on_erase_background) self.canvas.Bind(wx.EVT_SIZE, self.on_resize) self.canvas.Bind(wx.EVT_PAINT, self.on_paint) self.canvas.Bind(wx.EVT_LEFT_DOWN, self.mouse_handler.left_down) self.canvas.Bind(wx.EVT_LEFT_UP, self.mouse_handler.left_up) self.canvas.Bind(wx.EVT_MOTION, self.mouse_handler.motion) self.canvas.Bind(wx.EVT_CHAR, self.on_char)
Example #20
Source File: misc.py From trelby with GNU General Public License v2.0 | 4 votes |
def __init__(self, parent, id, getCfgGui): style = wx.FULL_REPAINT_ON_RESIZE wx.Window.__init__(self, parent, id, style = style) self.getCfgGui = getCfgGui # pages, i.e., [wx.Window, name] lists. note that 'name' must be an # Unicode string. self.pages = [] # index of selected page self.selected = -1 # index of first visible tab self.firstTab = 0 # how much padding to leave horizontally at the ends of the # control, and within each tab self.paddingX = 10 # starting Y-pos of text in labels self.textY = 5 # width of a single tab self.tabWidth = 150 # width, height, spacing, y-pos of arrows self.arrowWidth = 8 self.arrowHeight = 13 self.arrowSpacing = 3 self.arrowY = 5 # initialized in OnPaint since we don't know our height yet self.font = None self.boldFont = None self.SetMinSize(wx.Size( self.paddingX * 2 + self.arrowWidth * 2 + self.arrowSpacing +\ self.tabWidth + 5, TAB_BAR_HEIGHT)) wx.EVT_LEFT_DOWN(self, self.OnLeftDown) wx.EVT_LEFT_DCLICK(self, self.OnLeftDown) wx.EVT_SIZE(self, self.OnSize) wx.EVT_PAINT(self, self.OnPaint) wx.EVT_ERASE_BACKGROUND(self, self.OnEraseBackground) # get the ctrl that the tabbed windows should use as a parent