Browse Source

pep8 for wx_utils

subparsing
chriskiehl 9 years ago
parent
commit
62ae1cdfc5
8 changed files with 31 additions and 41 deletions
  1. 46
      gooey/gui/util/wx_util.py
  2. 2
      gooey/gui/widgets/calender_dialog.py
  3. 4
      gooey/gui/widgets/choosers.py
  4. 4
      gooey/gui/widgets/components.py
  5. 8
      gooey/gui/windows/advanced_config.py
  6. 4
      gooey/gui/windows/base_window.py
  7. 2
      gooey/gui/windows/header.py
  8. 2
      gooey/gui/windows/sidebar.py

46
gooey/gui/util/wx_util.py

@ -1,52 +1,42 @@
"""
Collection of Utility methods for creating pre-styled wxWidgets items
Collection of Utility methods for creating often used, pre-styled wx Widgets
"""
__author__ = 'Chris'
import wx
def MakeBold(statictext):
def make_bold(statictext):
pointsize = statictext.GetFont().GetPointSize()
font = wx.Font(pointsize, wx.FONTFAMILY_DEFAULT,
wx.FONTWEIGHT_NORMAL, wx.FONTWEIGHT_BOLD, False)
statictext.SetFont(font)
def dark_grey(statictext):
darkgray = (54, 54, 54)
statictext.SetForegroundColour(darkgray)
def _bold_static_text(parent, text_label):
text = wx.StaticText(parent, label=text_label)
font_size = text.GetFont().GetPointSize()
bold = wx.Font(font_size, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD)
text.SetFont(bold)
return text
def h1(parent, label):
return _header(parent, label, (wx.FONTFAMILY_DEFAULT, wx.FONTWEIGHT_NORMAL, wx.FONTWEIGHT_BOLD, False))
def h2(parent, label):
return _header(parent, label, (wx.FONTFAMILY_DEFAULT, wx.FONTWEIGHT_NORMAL, wx.FONTWEIGHT_NORMAL, False))
def H1(parent, label):
def _header(parent, label, styles):
text = wx.StaticText(parent, label=label)
font_size = text.GetFont().GetPointSize()
font = wx.Font(font_size * 1.2, wx.FONTFAMILY_DEFAULT, wx.FONTWEIGHT_NORMAL, wx.FONTWEIGHT_BOLD, False)
font = wx.Font(font_size * 1.2, *styles)
text.SetFont(font)
return text
def H2(parent, label):
text = wx.StaticText(parent, label=label)
font_size = text.GetFont().GetPointSize()
font = wx.Font(font_size * 1.2, wx.FONTFAMILY_DEFAULT, wx.FONTWEIGHT_NORMAL, wx.FONTWEIGHT_NORMAL, False)
text.SetFont(font)
return text
def HorizontalRule(parent):
line = wx.StaticLine(parent, -1, style=wx.LI_HORIZONTAL)
line.SetSize((10, 10))
return line
def horizontal_rule(parent):
return _rule(parent, wx.LI_HORIZONTAL)
def vertical_rule(parent):
line = wx.StaticLine(parent, -1, style=wx.LI_VERTICAL)
return _rule(parent, wx.LI_VERTICAL)
def _rule(parent, direction):
line = wx.StaticLine(parent, -1, style=direction)
line.SetSize((10, 10))
return line
def MakeDarkGrey(statictext):
darkgray = (54, 54, 54)
statictext.SetForegroundColour(darkgray)

2
gooey/gui/widgets/calender_dialog.py

@ -16,7 +16,7 @@ class CalendarDlg(wx.Dialog):
vertical_container = wx.BoxSizer(wx.VERTICAL)
vertical_container.AddSpacer(10)
vertical_container.Add(wx_util.H1(self, label='Select a Date'), 0, wx.LEFT | wx.RIGHT, 15)
vertical_container.Add(wx_util.h1(self, label='Select a Date'), 0, wx.LEFT | wx.RIGHT, 15)
vertical_container.AddSpacer(10)
vertical_container.Add(self.datepicker, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, 15)

4
gooey/gui/widgets/choosers.py

@ -60,13 +60,13 @@ class AbstractChooser(object):
base_text = wx.StaticText(parent, label=self.data['help_msg'])
# if self.data['nargs']:
# base_text.SetLabelText(base_text.GetLabelText() + self.CreateNargsMsg(action))
wx_util.MakeDarkGrey(base_text)
wx_util.dark_grey(base_text)
return base_text
def CreateNameLabelWidget(self, parent):
label = self.data['title'].title()
text = wx.StaticText(parent, label=label)
wx_util.MakeBold(text)
wx_util.make_bold(text)
return text
def OnResize(self, evt):

4
gooey/gui/widgets/components.py

@ -56,12 +56,12 @@ class BaseGuiComponent(object):
if self.data['nargs']
else self.data['help'])
base_text = wx.StaticText(parent, label=label_text or '')
wx_util.MakeDarkGrey(base_text)
wx_util.dark_grey(base_text)
return base_text
def createTitle(self, parent):
text = wx.StaticText(parent, label=self.data['display_name'].title())
wx_util.MakeBold(text)
wx_util.make_bold(text)
return text
def formatExtendedHelpMsg(self, data):

8
gooey/gui/windows/advanced_config.py

@ -46,9 +46,9 @@ class AdvancedConfigPanel(ScrolledPanel, OptionReader):
container.AddSpacer(15)
if self.widgets.required_args:
container.Add(wx_util.H1(self, i18n.translate("required_args_msg")), 0, wx.LEFT | wx.RIGHT, PADDING)
container.Add(wx_util.h1(self, i18n.translate("required_args_msg")), 0, wx.LEFT | wx.RIGHT, PADDING)
container.AddSpacer(5)
container.Add(wx_util.HorizontalRule(self), *STD_LAYOUT)
container.Add(wx_util.horizontal_rule(self), *STD_LAYOUT)
container.AddSpacer(20)
self.CreateComponentGrid(container, self.widgets.required_args, cols=self._build_spec['requireds_cols'])
@ -58,9 +58,9 @@ class AdvancedConfigPanel(ScrolledPanel, OptionReader):
if self.widgets.optional_args:
container.AddSpacer(10)
container.Add(wx_util.H1(self, i18n.translate("optional_args_msg")), 0, wx.LEFT | wx.RIGHT, PADDING)
container.Add(wx_util.h1(self, i18n.translate("optional_args_msg")), 0, wx.LEFT | wx.RIGHT, PADDING)
container.AddSpacer(5)
container.Add(wx_util.HorizontalRule(self), *STD_LAYOUT)
container.Add(wx_util.horizontal_rule(self), *STD_LAYOUT)
container.AddSpacer(20)
self.CreateComponentGrid(container, self.widgets.optional_args, cols=self._build_spec['optionals_cols'])

4
gooey/gui/windows/base_window.py

@ -62,7 +62,7 @@ class BaseWindow(wx.Frame):
def _do_layout(self):
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.head_panel, 0, wx.EXPAND)
sizer.Add(wx_util.HorizontalRule(self), 0, wx.EXPAND)
sizer.Add(wx_util.horizontal_rule(self), 0, wx.EXPAND)
if self.build_spec['layout_type'] == 'column':
print 'hello!'
@ -75,7 +75,7 @@ class BaseWindow(wx.Frame):
sizer.Add(self.runtime_display, 1, wx.EXPAND)
self.runtime_display.Hide()
sizer.Add(wx_util.HorizontalRule(self), 0, wx.EXPAND)
sizer.Add(wx_util.horizontal_rule(self), 0, wx.EXPAND)
sizer.Add(self.foot_panel, 0, wx.EXPAND)
self.SetSizer(sizer)

2
gooey/gui/windows/header.py

@ -39,7 +39,7 @@ class FrameHeader(wx.Panel):
self.SetMinSize((120, 80))
def _init_components(self, heading, subheading):
self._header = wx_util.H1(self, heading)
self._header = wx_util.h1(self, heading)
self._subheader = wx.StaticText(self, label=subheading)

2
gooey/gui/windows/sidebar.py

@ -31,7 +31,7 @@ class Sidebar(wx.Panel):
container = wx.BoxSizer(wx.VERTICAL)
container.AddSpacer(15)
container.Add(wx_util.H1(self, 'Actions'), *STD_LAYOUT)
container.Add(wx_util.h1(self, 'Actions'), *STD_LAYOUT)
container.AddSpacer(5)
thing = wx.ListBox(self, -1, choices=['Connect', 'process', 'commit', 'fetch'])
container.Add(thing, 1, wx.LEFT | wx.RIGHT | wx.EXPAND, 10)

Loading…
Cancel
Save