Python wx.EVT_PAINT Examples
The following are 30
code examples of wx.EVT_PAINT().
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: live_demo.py From mr_saliency with GNU General Public License v2.0 | 6 votes |
def __init__(self, parent, capture, fps=24): wx.Panel.__init__(self, parent) self.capture = capture2 ret, frame = self.capture.read() sal = mr_sal.saliency(frame) sal = cv2.resize(sal,(320,240)).astype(sp.uint8) sal = cv2.normalize(sal, None, 0, 255, cv2.NORM_MINMAX) outsal = cv2.applyColorMap(sal,cv2.COLORMAP_HSV) self.bmp = wx.BitmapFromBuffer(320,240, outsal.astype(sp.uint8)) self.timer = wx.Timer(self) self.timer.Start(1000./fps) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_TIMER, self.NextFrame)
Example #3
Source File: CustomToolTip.py From OpenPLC_Editor with GNU General Public License v3.0 | 6 votes |
def __init__(self, parent, tip, restricted=True): """ Constructor @param parent: Parent window @param tip: Tip text (may be multiline) @param restricted: Tool tip must follow size restriction in line and characters number defined (default True) """ wx.PopupWindow.__init__(self, parent) self.Restricted = restricted self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.SetTip(tip) # Initialize text font style self.Font = wx.Font( faces["size"], wx.SWISS, wx.NORMAL, wx.NORMAL, faceName=faces["mono"]) self.Bind(wx.EVT_PAINT, self.OnPaint)
Example #4
Source File: misc.py From trelby with GNU General Public License v2.0 | 6 votes |
def __init__(self, parent, id, getCfgGui): wx.Window.__init__(self, parent, id, size = (MyStatus.WIDTH, TAB_BAR_HEIGHT), style = wx.FULL_REPAINT_ON_RESIZE) self.getCfgGui = getCfgGui self.page = 0 self.pageCnt = 0 self.elemType = "" self.tabNext = "" self.enterNext = "" self.elementFont = util.createPixelFont( TAB_BAR_HEIGHT // 2 + 6, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.NORMAL) self.font = util.createPixelFont( TAB_BAR_HEIGHT // 2 + 2, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.NORMAL) wx.EVT_PAINT(self, self.OnPaint)
Example #5
Source File: widget_meter.py From RF-Monitor with GNU General Public License v2.0 | 6 votes |
def __init__(self, parent): wx.Panel.__init__(self, parent, size=(-1, 25), style=wx.SUNKEN_BORDER) self._value = LEVEL_MIN self._threshold = LEVEL_MIN self._noise = None font = self.GetFont() font.SetFamily(wx.FONTFAMILY_MODERN) self.SetFont(font) self.SetMinSize((250, 25)) self.Bind(wx.EVT_PAINT, self.__on_paint) self.Bind(wx.EVT_SIZE, self.__on_size) try: self.SetBackgroundStyle(wx.BG_STYLE_PAINT) except AttributeError: pass
Example #6
Source File: gui.py From OpenCV-Computer-Vision-Projects-with-Python with MIT License | 6 votes |
def _init_base_layout(self): """Initialize parameters This method performs initializations that are common to all GUIs, such as the setting up of a timer. It then calls an abstract method self.init_custom_layout() that allows for additional, application-specific initializations. """ # set up periodic screen capture self.timer = wx.Timer(self) self.timer.Start(1000./self.fps) self.Bind(wx.EVT_TIMER, self._on_next_frame) self.Bind(wx.EVT_PAINT, self._on_paint) # allow for custom modifications self._init_custom_layout()
Example #7
Source File: ShowOSD.py From EventGhost with GNU General Public License v2.0 | 6 votes |
def __init__(self, parent): wx.Frame.__init__( self, parent, -1, "OSD Window", size=(0, 0), style=( wx.FRAME_SHAPED | wx.NO_BORDER | wx.FRAME_NO_TASKBAR | wx.STAY_ON_TOP ) ) self.hwnd = self.GetHandle() self.bitmap = wx.EmptyBitmap(0, 0) # we need a timer to possibly cancel it self.timer = threading.Timer(0.0, eg.DummyFunc) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_CLOSE, self.OnClose)
Example #8
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 #9
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 #10
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 #11
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 #12
Source File: rasterwindow.py From spectral with MIT License | 6 votes |
def __init__(self, parent, index, rgb, **kwargs): if 'title' in kwargs: title = kwargs['title'] else: title = 'SPy Image' # wxFrame.__init__(self, parent, index, "SPy Frame") # wxScrolledWindow.__init__(self, parent, index, style = wxSUNKEN_BORDER) img = wx.EmptyImage(rgb.shape[0], rgb.shape[1]) img = wx.EmptyImage(rgb.shape[1], rgb.shape[0]) img.SetData(rgb.tostring()) self.bmp = img.ConvertToBitmap() self.kwargs = kwargs wx.Frame.__init__(self, parent, index, title, wx.DefaultPosition) self.SetClientSizeWH(self.bmp.GetWidth(), self.bmp.GetHeight()) wx.EVT_PAINT(self, self.on_paint) wx.EVT_LEFT_DCLICK(self, self.left_double_click)
Example #13
Source File: live_demo.py From mr_saliency with GNU General Public License v2.0 | 6 votes |
def __init__(self, parent, capture, fps=24): wx.Panel.__init__(self, parent) self.SetDoubleBuffered(True) self.capture = capture ret, frame = self.capture.read() height, width = frame.shape[:2] parent.SetSize((width, height)) frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) self.bmp = wx.BitmapFromBuffer(width, height, frame) self.timer = wx.Timer(self) self.timer.Start(1000./fps) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_TIMER, self.NextFrame)
Example #14
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def __init__(self, parent=None): wx.Frame.__init__( self, parent, style=wx.NO_BORDER|wx.FRAME_NO_TASKBAR|wx.CLIP_CHILDREN ) self.drawing = None self.displayNum = 0 self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_LEFT_DCLICK, self.LeftDblClick) self.Bind(wx.EVT_KEY_DOWN, self.OnChar) self.Bind(wx.EVT_MOTION, self.ShowCursor) self.timer = None self.SetBackgroundColour((0, 0, 0))
Example #15
Source File: wx_app.py From pyopenvr with BSD 3-Clause "New" or "Revised" License | 5 votes |
def init_gl(self): print('creating Frame') self.window = wx.Frame ( parent=None, id=wx.ID_ANY, title=self.title, style=wx.DEFAULT_FRAME_STYLE|wx.WS_EX_PROCESS_IDLE ) print('creating GLCanvas') self.canvas = glcanvas.GLCanvas ( self.window, glcanvas.WX_GL_RGBA ) print('creating GLContext') self.context = glcanvas.GLContext(self.canvas) self.canvas.SetFocus() self.window.SetSize ( (self.renderer.window_size[0], self.renderer.window_size[1]) ) print('showing Frame') self.window.Show(True) print('calling SetTopWindow') self.SetTopWindow(self.window) self.Bind ( wx.EVT_CHAR, self.OnChar ) self.canvas.Bind ( wx.EVT_SIZE, self.OnCanvasSize ) self.canvas.Bind ( wx.EVT_PAINT, self.OnCanvasPaint ) wx.IdleEvent.SetMode ( wx.IDLE_PROCESS_SPECIFIED ) self.Bind ( wx.EVT_IDLE, self.OnIdle ) print('making context current') self.canvas.SetCurrent ( self.context ) self.renderer.init_gl()
Example #16
Source File: DebugVariableTextViewer.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
def RefreshViewer(self): """Triggers EVT_PAINT event to refresh UI""" self.Refresh()
Example #17
Source File: main.py From python-examples with MIT License | 5 votes |
def __init__(self, parent, camera, fps=15, flip=False): wx.Window.__init__(self, parent) # remember arguments self.camera = camera self.fps = fps self.flip = flip # get frame size ret_value, frame = self.camera.read() height, width = frame.shape[:2] # resize panel with camera image self.SetSize( (width, height) ) #self.SetMinSize( (width, height) ) # resize main window self.GetParent().GetParent().SetSize( (width, height+37) ) # wymaga poprawki aby nie trzeba bylo dawac +37 #self.GetGrandParent().SetSize( (width, height+25) ) #self.GetTopLevelParent().SetSize( (width, height+25) ) # wrong parent frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) if self.flip: frame = cv2.flip(frame, 1) # create bitmap with frame self.bmp = wx.BitmapFromBuffer(width, height, frame) # timer to refresh frames self.timer = wx.Timer(self) self.timer.Start(1000./fps) # add functions to events self.Bind(wx.EVT_PAINT, self.OnPaint) # run when it is needed self.Bind(wx.EVT_TIMER, self.NextFrame) # run by timer
Example #18
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 #19
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 #20
Source File: params.py From admin4 with Apache License 2.0 | 5 votes |
def __init__(self, parent, name): PPanel.__init__(self, parent, name) self.ID_TEXT_CTRL = wx.NewId() self.ID_BUTTON = wx.NewId() sizer = wx.BoxSizer() self.text = wx.TextCtrl(self, self.ID_TEXT_CTRL, size=(80,-1)) sizer.Add(self.text, 0, wx.ALIGN_CENTER_VERTICAL | wx.TOP | wx.BOTTOM, 2) self.button = wx.Panel(self, self.ID_BUTTON, wx.DefaultPosition, wx.Size(20, 20)) sizer.Add(self.button, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) self.SetAutoLayout(True) self.SetSizerAndFit(sizer) self.textModified = False wx.EVT_PAINT(self.button, self.OnPaintButton) wx.EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange) wx.EVT_LEFT_DOWN(self.button, self.OnLeftDown)
Example #21
Source File: WordWrapRenderer.py From bookhub with MIT License | 5 votes |
def __init__(self, parent): wx.Panel.__init__(self, parent, -1, style=wx.FULL_REPAINT_ON_RESIZE) self.Bind(wx.EVT_PAINT, self.OnPaint) self.text = """This is Thisisareallylongwordtoseewhathappens the text to be drawn. It needs to be long to see if wrapping works. to long words. This is on new line by itself. This should have a blank line in front of it but still wrap when we reach the edge. The bottom of the red rectangle should be immediately below this.""" self.font = wx.Font(12, wx.SWISS, wx.NORMAL, wx.NORMAL, faceName="Gill Sans")
Example #22
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 #23
Source File: __init__.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def __init__(self, parent, bitmap=None, *a, **k): wx.Window.__init__(self, parent, *a, **k) self.Bind(wx.EVT_PAINT, self.OnPaint) self.bitmap = None if bitmap: self.SetBitmap(bitmap) else: self.SetSize((0, 0))
Example #24
Source File: __init__.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def __init__(self, parent, id=wx.ID_ANY, label='', dotify=False): wx.StaticText.__init__(self, parent, id, label) self.label = label self._string = self.label if dotify: self.Bind(wx.EVT_PAINT, self.DotifyOnPaint)
Example #25
Source File: gui.py From opencv-python-blueprints with GNU General Public License v3.0 | 5 votes |
def _on_paint(self, event): """ This method draws the camera frame stored in the bitmap self.bmp onto the panel self.pnl. Make sure self.pnl exists and is at least the size of the camera frame. This method is called whenever an event wx.EVT_PAINT is triggered. """ # read and draw buffered bitmap deviceContext = wx.BufferedPaintDC(self.pnl) deviceContext.DrawBitmap(self.bmp, 0, 0)
Example #26
Source File: gui.py From opencv-python-blueprints with GNU General Public License v3.0 | 5 votes |
def _on_next_frame(self, event): """ This method captures a new frame from the camera (or capture device) and sends an RGB version to the method self.process_frame. The latter will then apply task-specific post-processing and return an image to be displayed. """ success, frame = self._acquire_frame() if success: # process current frame frame = self._process_frame(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)) # update buffer and paint (EVT_PAINT triggered by Refresh) self.bmp.CopyFromBuffer(frame) self.Refresh(eraseBackground=False)
Example #27
Source File: gui.py From opencv-python-blueprints with GNU General Public License v3.0 | 5 votes |
def _create_base_layout(self): """Create generic layout This method sets up a basic layout that is common to all GUIs, such as a live stream of the camera (capture device). This stream is assigned to the variable self.pnl, and arranged in a vertical layout self.panels_vertical. Additional layout elements can be added below the livestream by means of the method self.panels_vertical.Add. """ # set up video stream self.pnl = wx.Panel(self, size=(self.imgWidth, self.imgHeight)) self.pnl.SetBackgroundColour(wx.BLACK) self.pnl.Bind(wx.EVT_PAINT, self._on_paint) # display the button layout beneath the video stream self.panels_vertical = wx.BoxSizer(wx.VERTICAL) self.panels_vertical.Add(self.pnl, 1, flag=wx.EXPAND | wx.TOP, border=1) # allow for custom layout modifications self._create_custom_layout() # round off the layout by expanding and centering self.SetMinSize((self.imgWidth, self.imgHeight)) self.SetSizer(self.panels_vertical) self.Centre()
Example #28
Source File: viewer.py From GraphLayout with MIT License | 5 votes |
def __init__(self, parent): super(View, self).__init__(parent) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.EVT_PAINT, self.on_paint) self.Bind(wx.EVT_CHAR_HOOK, self.on_char) self.index = -1 self.weights = {} self.model = None self.bitmap = None wx.CallAfter(self.next)
Example #29
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 #30
Source File: DebugVariablePanel.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
def OnGraphicsWindowPaint(self, event): """EVT_PAINT handler""" self.DrawView() event.Skip()