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.

64 lines
1.7 KiB

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