You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is a DynamicBitmap component which someone may enjoy.
classDynamicBitmap(GenStaticBitmap):
""" A `StaticBitmap` which redraws with every render if the `bitmap` props is present. If the `bitmap` props is not present, it leaves the last `bitmap`. props = { bitmap: wx.Bitmap } To update the `DynamicBitmap` rapidly without calling `set_state()`, consider using the [Refs](https://github.com/chriskiehl/re-wx/blob/main/docs/main-concepts.md#refs) technique and calling `my_dynamicbitmap_ref.SetBitmap(bitmap)` directly. https://discuss.wxpython.org/t/staticbitmap-fast-refresh-state-of-the-art/36197 """defOnPaint(self, event):
""" Handles the ``wx.EVT_PAINT`` for :class:`GenStaticBitmap`. :param `event`: a :class:`wx.PaintEvent` event to be processed. We override this so we can Clear() for alpha-transparent images. """dc=wx.PaintDC(self)
ifself._bitmap:
dc.Clear()
dc.DrawBitmap(self._bitmap, 0, 0, True)
@mount.register(DynamicBitmap)defdynamicbitmap(element, parent) ->DynamicBitmap:
instance=DynamicBitmap(parent, -1, wx.Bitmap.FromRGBA(1,1,0,0,0,0))
returnupdate(element, instance)
@update.register(DynamicBitmap)defdynamicbitmap(element, instance: DynamicBitmap) ->DynamicBitmap:
props=element['props']
bitmap=props.get('bitmap')
ifbitmap:
instance.SetBitmap(bitmap)
instance.Unbind(wx.EVT_LEFT_DOWN)
if'on_left_down'inprops:
instance.Bind(wx.EVT_LEFT_DOWN, props['on_left_down'])
instance.Unbind(wx.EVT_LEFT_UP)
if'on_left_up'inprops:
instance.Bind(wx.EVT_LEFT_UP, props['on_left_up'])
instance.Unbind(wx.EVT_RIGHT_DOWN)
if'on_right_down'inprops:
instance.Bind(wx.EVT_RIGHT_DOWN, props['on_right_down'])
instance.Unbind(wx.EVT_RIGHT_UP)
if'on_right_up'inprops:
instance.Bind(wx.EVT_RIGHT_UP, props['on_right_up'])
instance.Unbind(wx.EVT_MOTION)
if'on_mouse_motion'inprops:
instance.Bind(wx.EVT_MOTION, props['on_mouse_motion'])
instance.Unbind(wx.EVT_MOUSE_CAPTURE_LOST)
if'on_mouse_capture_lost'inprops:
instance.Bind(wx.EVT_MOUSE_CAPTURE_LOST, props['on_mouse_capture_lost'])
returninstance
The text was updated successfully, but these errors were encountered:
Here is a
DynamicBitmap
component which someone may enjoy.The text was updated successfully, but these errors were encountered: