2 @package libtextworker.interface.wx
3 Contains classes for wxPython.
4 wxPython must be installed first:
6 $ pip install attrdict3
9 Else libtextworker will refuse to use this package.
17 from libtextworker
import Importable
18 from .
import constants
19 from ..
import manager
21 if Importable[
"wx"] ==
True:
24 raise Exception(
"wxPython is needed to use libtextworker.interface.wx")
28 recursive_configure: bool =
True
31 size, style, weight, family = manager.ColorManager.GetFont(this)
33 _dict = {
"system":
"normal"}
34 weight = _dict.get(weight, weight)
35 style = _dict.get(style, style)
37 return wx.Font(size, wx.FONTFAMILY_MODERN, constants.FONTST[style],
38 constants.FONTWT[weight], 0, family)
40 def configure(this, widget: wx.Control, childs_too: bool = recursive_configure):
41 manager.ColorManager.configure(this, widget)
44 bg, fg = this.GetColor()
45 bg = wx.Colour(*manager.hextorgb(bg))
46 fg = wx.Colour(*manager.hextorgb(fg))
51 if childs_too
and hasattr(widget,
"GetChildren"):
52 widget.SetBackgroundColour(bg)
53 widget.SetForegroundColour(fg)
54 for children
in widget.GetChildren():
55 this.configure(children,
True)
57 widget.SetOwnBackgroundColour(bg)
58 widget.SetOwnForegroundColour(fg)