1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
# -*- coding: utf-8 -*-
import os
import wx
import wx.xrc as xrc
from DisplayCAL.config import getbitmap
from DisplayCAL.log import safe_print
class BitmapButton(xrc.XmlResourceHandler):
def __init__(self):
xrc.XmlResourceHandler.__init__(self)
# Standard styles
self.AddWindowStyles()
def CanHandle(self, node):
return self.IsOfClass(node, "wxBitmapButton")
# Process XML parameters and create the object
def DoCreateResource(self):
name = os.path.splitext(self.GetText("bitmap"))[0]
if name.startswith("../"):
name = name[3:]
bitmap = getbitmap(name)
w = wx.BitmapButton(
self.GetParentAsWindow(),
self.GetID(),
bitmap,
pos=self.GetPosition(),
size=self.GetSize(),
style=self.GetStyle(),
name=self.GetName(),
)
self.SetupWindow(w)
if self.GetBool("hidden") and w.Shown:
safe_print(f"{self.Name} should have been hidden")
w.Hide()
return w
class StaticBitmap(xrc.XmlResourceHandler):
def __init__(self):
xrc.XmlResourceHandler.__init__(self)
# Standard styles
self.AddWindowStyles()
def CanHandle(self, node):
return self.IsOfClass(node, "wxStaticBitmap")
# Process XML parameters and create the object
def DoCreateResource(self):
name = os.path.splitext(self.GetText("bitmap"))[0]
if name.startswith("../"):
name = name[3:]
bitmap = getbitmap(name)
w = wx.StaticBitmap(
self.GetParentAsWindow(),
self.GetID(),
bitmap,
pos=self.GetPosition(),
size=self.GetSize(),
style=self.GetStyle(),
name=self.GetName(),
)
self.SetupWindow(w)
if self.GetBool("hidden") and w.Shown:
safe_print(f"{self.Name} should have been hidden")
w.Hide()
return w
|