You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.4 KiB

  1. """
  2. Collection of Utility methods for creating often used, pre-styled wx Widgets
  3. """
  4. import wx
  5. def make_bold(statictext):
  6. pointsize = statictext.GetFont().GetPointSize()
  7. font = wx.Font(pointsize, wx.FONTFAMILY_DEFAULT,
  8. wx.FONTWEIGHT_NORMAL, wx.FONTWEIGHT_BOLD, False)
  9. statictext.SetFont(font)
  10. def dark_grey(statictext):
  11. darkgray = (54, 54, 54)
  12. statictext.SetForegroundColour(darkgray)
  13. def h0(parent, label):
  14. text = wx.StaticText(parent, label=label)
  15. font_size = text.GetFont().GetPointSize()
  16. font = wx.Font(font_size * 1.4, *(wx.FONTFAMILY_DEFAULT, wx.FONTWEIGHT_NORMAL, wx.FONTWEIGHT_BOLD, False))
  17. text.SetFont(font)
  18. return text
  19. def h1(parent, label):
  20. return _header(parent, label, (wx.FONTFAMILY_DEFAULT, wx.FONTWEIGHT_NORMAL, wx.FONTWEIGHT_BOLD, False))
  21. def h2(parent, label):
  22. return _header(parent, label, (wx.FONTFAMILY_DEFAULT, wx.FONTWEIGHT_NORMAL, wx.FONTWEIGHT_NORMAL, False))
  23. def _header(parent, label, styles):
  24. text = wx.StaticText(parent, label=label)
  25. font_size = text.GetFont().GetPointSize()
  26. font = wx.Font(font_size * 1.2, *styles)
  27. text.SetFont(font)
  28. return text
  29. def horizontal_rule(parent):
  30. return _rule(parent, wx.LI_HORIZONTAL)
  31. def vertical_rule(parent):
  32. return _rule(parent, wx.LI_VERTICAL)
  33. def _rule(parent, direction):
  34. line = wx.StaticLine(parent, -1, style=direction)
  35. line.SetSize((10, 10))
  36. return line