diff --git a/src/app/dialogs/advanced_config.py b/src/app/dialogs/advanced_config.py index 9f5a130..3744dc9 100644 --- a/src/app/dialogs/advanced_config.py +++ b/src/app/dialogs/advanced_config.py @@ -10,11 +10,12 @@ from wx.lib import wordwrap from itertools import chain from component_factory import ComponentFactory from wx.lib.scrolledpanel import ScrolledPanel +from app.dialogs.option_reader import OptionReader PADDING = 10 -class AdvancedConfigPanel(ScrolledPanel): +class AdvancedConfigPanel(ScrolledPanel, OptionReader): ''' Abstract class for the Footer panels. ''' @@ -24,46 +25,46 @@ class AdvancedConfigPanel(ScrolledPanel): self.components = ComponentFactory(parser) - self.container = wx.BoxSizer(wx.VERTICAL) - self.container.AddSpacer(15) + self._msg_req_args = self.BuildHeaderMsg("Required Arguments") + self._msg_opt_args = self.BuildHeaderMsg("Optional Arguments") - self.AddHeaderMsg("Required Arguments") - self.container.AddSpacer(10) + self._do_layout() + self.Bind(wx.EVT_SIZE, self.OnResize) - box = wx.StaticBox(self, label="") - boxsizer = wx.StaticBoxSizer(box, wx.VERTICAL) - self.AddWidgets(self.container, self.components.positionals, add_space=True) + def _do_layout(self): + STD_LAYOUT = (0, wx.LEFT | wx.RIGHT | wx.EXPAND, PADDING) + container = wx.BoxSizer(wx.VERTICAL) + container.AddSpacer(15) - self.container.AddSpacer(10) - self.container.Add(self._draw_horizontal_line(), - 0, wx.LEFT | wx.RIGHT | wx.EXPAND, PADDING) + container.Add(self._msg_req_args, 0, wx.LEFT | wx.RIGHT, PADDING) + container.AddSpacer(5) + container.Add(self._draw_horizontal_line(), *STD_LAYOUT) + container.AddSpacer(20) - self.container.AddSpacer(10) - self.AddHeaderMsg("Optional Arguments") - self.container.AddSpacer(15) + self.AddWidgets(container, self.components.required_args, add_space=True) - flag_grids = self.CreateComponentGrid(self.components.flags, vgap=15) - opt_choice_counter_grid = self.CreateComponentGrid(c for c in self.components - if not isinstance(c, components.Flag) - and not isinstance(c, components.Positional)) - self.container.Add(opt_choice_counter_grid, 0, wx.LEFT | wx.RIGHT | wx.EXPAND, PADDING) - self.container.AddSpacer(30) - self.container.Add(flag_grids, 0, wx.LEFT | wx.RIGHT | wx.EXPAND, PADDING) + container.AddSpacer(10) -# sizer_params = [(grid, 0, wx.LEFT|wx.RIGHT|wx.EXPAND, PADDING) -# for grid in component_grids] -# self.container.AddMany(sizer_params) - self.SetSizer(self.container) - self.Bind(wx.EVT_SIZE, self.OnResize) - + container.AddSpacer(10) + container.Add(self._msg_opt_args, 0, wx.LEFT | wx.RIGHT, PADDING) + container.AddSpacer(5) + container.Add(self._draw_horizontal_line(), *STD_LAYOUT) + container.AddSpacer(20) + + flag_grids = self.CreateComponentGrid(self.components.flags, cols=3, vgap=15) + general_opts_grid = self.CreateComponentGrid(self.components.general_options) + container.Add(general_opts_grid, *STD_LAYOUT) + container.AddSpacer(30) + container.Add(flag_grids, *STD_LAYOUT) + + self.SetSizer(container) - def AddHeaderMsg(self, label): - required_msg = wx.StaticText(self, label=label) - font_size = required_msg.GetFont().GetPointSize() + def BuildHeaderMsg(self, label): + _msg = wx.StaticText(self, label=label) + font_size = _msg.GetFont().GetPointSize() bold = wx.Font(font_size*1.2, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD) - required_msg.SetFont(bold) - self.container.Add(required_msg, 0, wx.LEFT | wx.RIGHT, PADDING) - + _msg.SetFont(bold) + return _msg def AddWidgets(self, sizer, components, add_space=False, padding=PADDING): for component in components: @@ -83,9 +84,16 @@ class AdvancedConfigPanel(ScrolledPanel): return line def OnResize(self, evt): - print evt.m_size + print 'SIZEEEE:', evt.m_size for component in self.components: component.Update(evt.m_size) + evt.Skip() + + def GetOptions(self): + ''' + returns the collective values from all of the + widgets contained in the panel''' + raise NotImplementedError diff --git a/src/app/dialogs/advanced_config.pyc b/src/app/dialogs/advanced_config.pyc index 81da9b8..17ee550 100644 Binary files a/src/app/dialogs/advanced_config.pyc and b/src/app/dialogs/advanced_config.pyc differ diff --git a/src/app/dialogs/advanced_config_integration_test.py b/src/app/dialogs/advanced_config_integration_test.py new file mode 100644 index 0000000..14c5af8 --- /dev/null +++ b/src/app/dialogs/advanced_config_integration_test.py @@ -0,0 +1,18 @@ +''' +Created on Jan 19, 2014 + +@author: Chris +''' + +import argparse_test_data + + +client_parser_obj = argparse_test_data.parser + +frame = MainWindow(client_parser_obj) + + + + +if __name__ == '__main__': + pass \ No newline at end of file diff --git a/src/app/dialogs/argparse_test_data.py b/src/app/dialogs/argparse_test_data.py index 032cc17..2b50c33 100644 --- a/src/app/dialogs/argparse_test_data.py +++ b/src/app/dialogs/argparse_test_data.py @@ -19,4 +19,3 @@ parser.add_argument('-c', '--constoption', action="store_const", const="myconsta parser.add_argument('-t', '--truify', action="store_true", help='Ensure the store_true actions are sorted') # Flag parser.add_argument('-f', '--falsificle', action="store_false", help='Ensure the store_false actions are sorted') # Flag - \ No newline at end of file diff --git a/src/app/dialogs/base_window.py b/src/app/dialogs/base_window.py new file mode 100644 index 0000000..f975cc9 --- /dev/null +++ b/src/app/dialogs/base_window.py @@ -0,0 +1,75 @@ +''' +Created on Jan 19, 2014 + +@author: Chris +''' + +import os +import wx +import header +import footer +from model.controller import Controller +from app.images import image_store + +class BaseWindow(wx.Frame): + + def __init__(self, BodyPanel, parser): + wx.Frame.__init__( + self, + parent=None, + id=-1, + title=os.path.basename(__file__), + size=(610,530) + ) + + self._parser = parser + self._controller = Controller() + + self._init_properties() + self._init_components(BodyPanel) + self._do_layout() + + def _init_properties(self): + self.SetMinSize((400,300)) + self.icon = wx.Icon(image_store.icon, wx.BITMAP_TYPE_ICO) + self.SetIcon(self.icon) + + def _init_components(self, BodyPanel): + # init components + self.head_panel = header.FrameHeader( + heading="Settings", + subheading = self._parser.description, + image_path=image_store.settings2, + parent=self, + size=(30,90)) + self.body_panel = BodyPanel(self, self._parser) + self.cfg_foot_panel = footer.ConfigFooter(self, self._controller) +# self.main_foot_panel = footer.MainFooter(self, self._controller) +# self.main_foot_panel.Hide() + + def _do_layout(self): + sizer = wx.BoxSizer(wx.VERTICAL) + sizer.Add(self.head_panel, 0, wx.EXPAND) + self._draw_horizontal_line(sizer) + sizer.Add(self.body_panel, 1, wx.EXPAND) + self._draw_horizontal_line(sizer) + sizer.Add(self.cfg_foot_panel, 0, wx.EXPAND) + self.SetSizer(sizer) + +# def _init_panels(self): +# self._frame_header = FrameHeader +# self._basic_config_body = None +# self._adv_config_body = None +# self._config_footer = None +# self._output_footer = None + + def _draw_horizontal_line(self, sizer): + line = wx.StaticLine(self, -1, style=wx.LI_HORIZONTAL) + line.SetSize((10, 10)) + sizer.Add(line, 0, wx.EXPAND) + + + + +if __name__ == '__main__': + pass \ No newline at end of file diff --git a/src/app/dialogs/basic_config_panel.py b/src/app/dialogs/basic_config_panel.py new file mode 100644 index 0000000..d2535a1 --- /dev/null +++ b/src/app/dialogs/basic_config_panel.py @@ -0,0 +1,60 @@ +''' +Created on Dec 9, 2013 + +@author: Chris + + +''' + +import wx +import os +from app.dialogs.option_reader import OptionReader + +class BasicDisplayPanel(wx.Panel, OptionReader): + def __init__(self, parent, **kwargs): + wx.Panel.__init__(self, parent, **kwargs) + + self.SetBackgroundColour('#F0F0F0') + + sizer = wx.BoxSizer(wx.VERTICAL) + sizer.AddSpacer(10) + +# about_header = wx.StaticText(self, label="About") +# about_header = self._bold_static_text("About") +# about_body = wx.StaticText(self, label="This program does bla. Enter the command line args of your choice to control bla and bla.") +# +# sizer.Add(about_header, 0, wx.LEFT | wx.RIGHT, 20) +# sizer.AddSpacer(5) +# sizer.Add(about_body, 0, wx.LEFT | wx.RIGHT, 20) + + sizer.AddSpacer(40) + + text = self._bold_static_text("Enter Command Line Arguments") +# + sizer.Add(text, 0, wx.LEFT, 20) + sizer.AddSpacer(10) + + h_sizer = wx.BoxSizer(wx.HORIZONTAL) + self.cmd_textbox = wx.TextCtrl(self, -1, "") + + h_sizer.Add(self.cmd_textbox, 1, wx.ALL | wx.EXPAND) + + sizer.Add(h_sizer, 0, wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, 20) + + self.SetSizer(sizer) + + def get_contents(self): + return self.cmd_textbox.GetValue() + + def _bold_static_text(self, text_label): + text = wx.StaticText(self, 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 GetValues(self): + raise NotImplementedError + + + diff --git a/src/app/dialogs/body.py b/src/app/dialogs/body.py index c4e1a6c..55cc53e 100644 --- a/src/app/dialogs/body.py +++ b/src/app/dialogs/body.py @@ -6,7 +6,7 @@ Created on Dec 23, 2013 import wx -class BodyDisplayPanel(wx.Panel): +class BasicDisplayPanel(wx.Panel): def __init__(self, parent, **kwargs): wx.Panel.__init__(self, parent, **kwargs) diff --git a/src/app/dialogs/component_factory.py b/src/app/dialogs/component_factory.py index 5fbbd16..b00b672 100644 --- a/src/app/dialogs/component_factory.py +++ b/src/app/dialogs/component_factory.py @@ -12,27 +12,18 @@ import argparse_test_data class ComponentFactory(object): ''' - Aggregates all of the Widgets and dispatches - them to the caller. + Aggregates all of the actions and ''' def __init__(self, parser): self._actions = action_sorter.ActionSorter(parser._actions[:]) - self.positionals = self.BuildPositionals(self._actions) - self.choices = self.BuildChoices(self._actions) - self.optionals = self.BuildOptionals(self._actions) - self.flags = self.BuildFlags(self._actions) - self.counters = self.BuildCounters(self._actions) - - self._components = [ - self.positionals, - self.choices, - self.optionals, - self.flags, - self.counters - ] + self.required_args = self.BuildPositionals(self._actions) + self.flags = self.BuildFlags(self._actions) + self.general_options = (self.BuildChoices(self._actions) + + self.BuildOptionals(self._actions) + + self.BuildCounters(self._actions)) def BuildPositionals(self, actions): return self._AssembleWidgetsFromActions(actions, 'Positional', '_positionals') @@ -55,15 +46,13 @@ class ComponentFactory(object): return [cls(action) for action in actions_list] -# def __getitem__(self, slice): -# return self._components[slice] - def __iter__(self): ''' - return an iterator for all of the contained - components + return an iterator for all of the contained components ''' - return itertools.chain(*self._components) + return itertools.chain(self.required_args, + self.flags, + self.general_options) if __name__ == '__main__': a = ComponentFactory(argparse_test_data.parser) diff --git a/src/app/dialogs/component_factory.pyc b/src/app/dialogs/component_factory.pyc index d73e05a..9d0665b 100644 Binary files a/src/app/dialogs/component_factory.pyc and b/src/app/dialogs/component_factory.pyc differ diff --git a/src/app/dialogs/components.py b/src/app/dialogs/components.py index b3fc3eb..6ad1b2f 100644 --- a/src/app/dialogs/components.py +++ b/src/app/dialogs/components.py @@ -232,7 +232,7 @@ class Flag(AbstractComponent): return help_msg = self._msg width, height = size - content_area = int((width/2)*.70) + content_area = int((width/3)*.70) print 'wiget size', help_msg.Size[0] wiggle_room = range(int(content_area - content_area * .05), int(content_area + content_area * .05)) diff --git a/src/app/dialogs/display_main.py b/src/app/dialogs/display_main.py index 131abdf..35830b7 100644 --- a/src/app/dialogs/display_main.py +++ b/src/app/dialogs/display_main.py @@ -11,8 +11,9 @@ import threading from model.controller import Controller from app.images import image_store from app.dialogs.header import FrameHeader -from app.dialogs.body import BodyDisplayPanel +from app.dialogs.basic_config_panel import BasicDisplayPanel from app.dialogs.footer import ConfigFooter +from app.dialogs.advanced_config import AdvancedConfigPanel class MessagePump(object): def __init__(self, queue): @@ -25,22 +26,23 @@ class MessagePump(object): self.queue.put(text) +class Listener(threading.Thread): + def __init__(self, queue, textbox): + threading.Thread.__init__(self) + self.queue = queue + self.update_text = lambda x: textbox.AppendText(x) + + def run(self): + while True: + try: + stdout_msg = self.queue.get(timeout=1) + if stdout_msg != '': + self.update_text(stdout_msg) + except Exception as e: + pass # Timeout. Aint nobody care 'bout dat + + class MainWindow(wx.Frame): - - class Listener(threading.Thread): - def __init__(self, queue, textbox): - threading.Thread.__init__(self) - self.queue = queue - self.update_text = lambda x: textbox.AppendText(x) - - def run(self): - while True: - try: - stdout_msg = self.queue.get(timeout=1) - if stdout_msg != '': - self.update_text(stdout_msg) - except Exception as e: - pass # Timeout. Aint nobody care 'bout dat def __init__(self, queue, payload=None): wx.Frame.__init__( @@ -53,49 +55,52 @@ class MainWindow(wx.Frame): self._controller = Controller() - self._frame_header = FrameHeader - self._simple_config_body = None - self._adv_config_body = None - self._config_footer = None - self._output_footer = None + + self._init_properties() self._init_components() - - self.queue = queue - # the client's main function - self._payload = payload + self._do_layout() + + self.queue = queue + # the client's main function + self._payload = payload _stdout = sys.stdout sys.stdout = MessagePump(queue) - listener = MainWindow.Listener(queue, self.panel2.cmd_textbox) + listener = Listener(queue, self.body_panel.cmd_textbox) listener.start() - def _init_components(self): - # init components + def _init_properties(self): self.SetMinSize((400,300)) self.icon = wx.Icon(image_store.icon, wx.BITMAP_TYPE_ICO) self.SetIcon(self.icon) - panel1 = FrameHeader(image_path=image_store.computer3, parent=self, size=(30,90)) - - self.sizer = wx.BoxSizer(wx.VERTICAL) - self.sizer.Add(panel1, 0, wx.EXPAND) - - self._draw_horizontal_line() - - self.panel2 = BodyDisplayPanel(parent=self) - self.sizer.Add(self.panel2, 1, wx.EXPAND) - self.SetSizer(self.sizer) - - self._draw_horizontal_line() - - self.footer = ConfigFooter(self, self._controller) - self.sizer.Add(self.footer, 0, wx.EXPAND) + def _init_components(self): + # init components + self.head_panel = FrameHeader(image_path=image_store.computer3, parent=self, size=(30,90)) + self.body_panel = BasicDisplayPanel(parent=self) + self.foot_panel = ConfigFooter(self, self._controller) + + def _do_layout(self): + sizer = wx.BoxSizer(wx.VERTICAL) + sizer.Add(self.head_panel, 0, wx.EXPAND) + self._draw_horizontal_line(sizer) + sizer.Add(self.body_panel, 1, wx.EXPAND) + self._draw_horizontal_line(sizer) + sizer.Add(self.foot_panel, 0, wx.EXPAND) + self.SetSizer(sizer) + + def _init_panels(self): + self._frame_header = FrameHeader + self._basic_config_body = None + self._adv_config_body = None + self._config_footer = None + self._output_footer = None - def _draw_horizontal_line(self): + def _draw_horizontal_line(self, sizer): line = wx.StaticLine(self, -1, style=wx.LI_HORIZONTAL) line.SetSize((10, 10)) - self.sizer.Add(line, 0, wx.EXPAND) + sizer.Add(line, 0, wx.EXPAND) diff --git a/src/app/dialogs/display_main.pyc b/src/app/dialogs/display_main.pyc index ed11322..cd670e2 100644 Binary files a/src/app/dialogs/display_main.pyc and b/src/app/dialogs/display_main.pyc differ diff --git a/src/app/dialogs/footer.py b/src/app/dialogs/footer.py index b1b85a8..da45240 100644 --- a/src/app/dialogs/footer.py +++ b/src/app/dialogs/footer.py @@ -12,22 +12,31 @@ class AbstractFooter(wx.Panel): ''' def __init__(self, parent, **kwargs): wx.Panel.__init__(self, parent, **kwargs) - self.SetMinSize((30, 50)) + self.SetMinSize((30, 53)) self.cancel_button = self._button('Cancel', wx.ID_CANCEL) self.next_button = self._button("Next", wx.ID_OK) - - sizer = wx.BoxSizer(wx.HORIZONTAL) - sizer.AddStretchSpacer(1) - sizer.Add(self.cancel_button, 0, wx.ALIGN_RIGHT | wx.RIGHT | wx.TOP, 20) - sizer.Add(self.next_button, 0, wx.ALIGN_RIGHT | wx.RIGHT | wx.TOP, 20) - self.SetSizer(sizer) + + self._do_layout() + + def _do_layout(self): + v_sizer = wx.BoxSizer(wx.VERTICAL) + h_sizer = wx.BoxSizer(wx.HORIZONTAL) + + h_sizer.AddStretchSpacer(1) + h_sizer.Add(self.cancel_button, 0, wx.ALIGN_RIGHT | wx.RIGHT, 20) + h_sizer.Add(self.next_button, 0, wx.ALIGN_RIGHT | wx.RIGHT, 20) + + v_sizer.AddStretchSpacer(1) + v_sizer.Add(h_sizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND) + v_sizer.AddStretchSpacer(1) + self.SetSizer(v_sizer) def _button(self,label=None, style=None): return wx.Button( parent=self, id=-1, - size=(75, 23), + size=(90, 24), label=label, style=style) @@ -45,7 +54,8 @@ class ConfigFooter(AbstractFooter): def __init__(self, parent, controller, **kwargs): AbstractFooter.__init__(self, parent, **kwargs) - self._controller = controller + self._controller = controller + self.Bind(wx.EVT_BUTTON, self.OnConfigCancel, self.cancel_button) self.Bind(wx.EVT_BUTTON, self.OnConfigNext, self.next_button) @@ -77,4 +87,10 @@ class MainFooter(AbstractFooter): self._controller.OnMainCancel(event) def OnMainNext(self, event): - self._controller.OnMainNext(event) \ No newline at end of file + self._controller.OnMainNext(event) + + + + + + \ No newline at end of file diff --git a/src/app/dialogs/footer.pyc b/src/app/dialogs/footer.pyc index 7f5f293..781e14d 100644 Binary files a/src/app/dialogs/footer.pyc and b/src/app/dialogs/footer.pyc differ diff --git a/src/app/dialogs/header.py b/src/app/dialogs/header.py index 4e6387a..adc202e 100644 --- a/src/app/dialogs/header.py +++ b/src/app/dialogs/header.py @@ -5,40 +5,72 @@ Created on Dec 23, 2013 ''' import wx +import imageutil +from app.dialogs.segoe_statictext import SegoeText + +PAD_SIZE = 10 class FrameHeader(wx.Panel): def __init__(self, - heading="Doin Stuff here", + heading="Settings", subheading="Small notification or intructional message", image_path=None, dlg_style=1, **kwargs): wx.Panel.__init__(self, **kwargs) - self.SetBackgroundColour('#ffffff') - self.SetMinSize((120, 90)) + + self._init_properties() + self._init_components(heading, subheading, image_path) + self._do_layout() + - header = self._bold_static_text(label=heading) - subheader = wx.StaticText(self, label=subheading) - img = self._load_image(image_path) + def _init_properties(self): + self.SetBackgroundColour('#ffffff') + self.SetMinSize((120, 80)) + def _init_components(self, heading, subheading, image_path): + self.header = self._bold_static_text(heading) + self.subheader = wx.StaticText(self, label=subheading) + self.img = wx.BitmapFromImage(imageutil.LoadAndResizeImage(image_path)) + print '\n' + print 'Image returned from original method:', type(self._load_image(image_path)) + print 'image returned from imageutil', type(self.img) + + def _do_layout(self): + vsizer = wx.BoxSizer(wx.VERTICAL) sizer = wx.BoxSizer(wx.HORIZONTAL) - headings_sizer = self.build_heading_sizer(header, subheader) - sizer.Add(headings_sizer, 1, wx.ALIGN_LEFT | wx.EXPAND | wx.LEFT, 20) - sizer.Add(img, 0, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, 20) - self.SetSizer(sizer) - - # for i in dir(self): print i + headings_sizer = self.build_heading_sizer() + sizer.Add(headings_sizer, 1, wx.ALIGN_LEFT | wx.EXPAND | wx.LEFT, PAD_SIZE) + sizer.Add(self.img, 0, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, PAD_SIZE) + vsizer.Add(sizer, 1, wx.EXPAND) + self.SetSizer(vsizer) + + def _bold_static_text(self, label): + txt = wx.StaticText(self, label=label) + font_size = txt.GetFont().GetPointSize() + txt.SetFont(wx.Font(font_size * 1.2, wx.FONTFAMILY_DEFAULT, + wx.FONTWEIGHT_NORMAL, wx.FONTWEIGHT_BOLD, False) + ) + return txt + def build_heading_sizer(self): + sizer = wx.BoxSizer(wx.VERTICAL) + sizer.AddStretchSpacer(1) + sizer.Add(self.header, 1) + sizer.Add(self.subheader, 1) + sizer.AddStretchSpacer(1) + return sizer + def _load_image(self, image_path): try: - bitmap = wx.Bitmap(image_path) - - bitmap = self._resize_bitmap(bitmap) - return wx.StaticBitmap(self, -1, bitmap) + bitmap = wx.Bitmap(image_path) + print bitmap + bitmap = self._resize_bitmap(bitmap) + return wx.StaticBitmap(self, -1, bitmap) except: - raise IOError('Invalid Image path') + raise IOError('Invalid Image path') def _resize_bitmap(self, bmap): ''' @@ -55,17 +87,15 @@ class FrameHeader(wx.Panel): ) return wx.BitmapFromImage(image) - def _bold_static_text(self, label): - txt = wx.StaticText(self, label=label) - txt.SetFont(wx.Font(8, wx.FONTFAMILY_DEFAULT, - wx.FONTWEIGHT_NORMAL, wx.FONTWEIGHT_BOLD, False) - ) - return txt - - def build_heading_sizer(self, header, subheader): - sizer = wx.BoxSizer(wx.VERTICAL) - sizer.AddStretchSpacer(1) - sizer.Add(header, 1) - sizer.Add(subheader, 1) - sizer.AddStretchSpacer(1) - return sizer \ No newline at end of file + + def UpdateImage(self, image): + pass + + + + + + + + + \ No newline at end of file diff --git a/src/app/dialogs/header.pyc b/src/app/dialogs/header.pyc index 033d3ed..b6a98bf 100644 Binary files a/src/app/dialogs/header.pyc and b/src/app/dialogs/header.pyc differ diff --git a/src/app/dialogs/imageutil.py b/src/app/dialogs/imageutil.py new file mode 100644 index 0000000..76da8c1 --- /dev/null +++ b/src/app/dialogs/imageutil.py @@ -0,0 +1,49 @@ +''' +Created on Jan 20, 2014 + +@author: Chris +''' +import wx +from PIL import Image # @UnresolvedImport +from app.images import image_store + + + +def LoadAndResizeImage(path): + im = Image.open(path) + return PilImageToWxImage(_Resize(im)) + +def _Resize(pil_image): + ''' + Resizes a bitmap to a height of 79 pixels (the + size of the top panel -1), while keeping aspect ratio + in tact + ''' + target_size = _GetTargetSize(pil_image.size) + return pil_image.resize(target_size) + +def _GetTargetSize(size): + width, height = size + aspect_ratio = float(width)/height + tHeight = 79 + tWidth = int(tHeight * aspect_ratio) + return (tWidth, tHeight) + +def PilImageToWxImage(p_image): + wx_image = wx.EmptyImage(*p_image.size) + wx_image.SetData(p_image.convert( 'RGB' ).tostring()) + return wx_image.ConvertToBitmap() + +if __name__ == '__main__': + app = wx.App() + print 'adsfasdf',LoadAndResizeImage(image_store.computer) + print 'asdfadf' + app.MainLoop() + + + + + + + + \ No newline at end of file diff --git a/src/app/dialogs/option_reader.py b/src/app/dialogs/option_reader.py new file mode 100644 index 0000000..9e38f37 --- /dev/null +++ b/src/app/dialogs/option_reader.py @@ -0,0 +1,25 @@ +''' +Created on Jan 19, 2014 + +@author: Chris +''' + +from abc import ABCMeta, abstractmethod + +class OptionReader(object): + ''' + Mixin for forcing subclasses to + honor GetOptions method + ''' + __metaclass__ = ABCMeta + + def __init__(self): + pass + + @abstractmethod + def GetOptions(self): + ''' + Implemented by subclasses. + Defines how the config panels read their options + ''' + pass \ No newline at end of file diff --git a/src/app/dialogs/segoe_statictext.py b/src/app/dialogs/segoe_statictext.py new file mode 100644 index 0000000..9378635 --- /dev/null +++ b/src/app/dialogs/segoe_statictext.py @@ -0,0 +1,28 @@ +''' +Created on Jan 20, 2014 + +@author: Chris +''' + +import wx + +class SegoeText(wx.StaticText): + ''' + Convenience subclass of wx.StaticText. + + Sets the default font to Segoe UI and + has methods fow easily changing size and weight + ''' + + + def __init__(self, parent, label): + wx.StaticText.__init__(self, parent, label=label) + self._font = wx.Font(20, wx.FONTFAMILY_DEFAULT, + wx.FONTWEIGHT_NORMAL, wx.FONTWEIGHT_BOLD, False, + 'Segoe UI Light') + + self.SetFont(self._font) + + def SetWeight(self, weight): + pass + \ No newline at end of file diff --git a/src/app/dialogs/window.py b/src/app/dialogs/window.py new file mode 100644 index 0000000..1b483bf --- /dev/null +++ b/src/app/dialogs/window.py @@ -0,0 +1,62 @@ +''' +Created on Jan 19, 2014 + +@author: Chris + + +def wrap(): + + Check if there is a parser in the client code + + if parser: + build WindowType based on parser + showWindow() + get user params + pass params to sys.argv. + run client code + + else: + Default WindowType + run client code + + > + > +''' + +import wx +import base_window +import advanced_config +from app.dialogs import argparse_test_data + +def WithNoOptions(): pass + +def WithBasicOptions(): pass + +def WithAdvancedOptions(parser): + app = wx.App(False) + frame = base_window.BaseWindow(advanced_config.AdvancedConfigPanel, parser) + frame.Show(True) # Show the frame. + app.MainLoop() + +if __name__ == '__main__': + parser = argparse_test_data.parser + WithAdvancedOptions(parser) + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/app/images/image_store.py b/src/app/images/image_store.py index 477b4d8..04daf8b 100644 --- a/src/app/images/image_store.py +++ b/src/app/images/image_store.py @@ -7,8 +7,10 @@ Convenience module for keeping the filepaths in one place. """ -computer = r"C:\Users\Chris\Dropbox\pretty_gui\Gui\src\app\images\computer.png" -computer2 = r"C:\Users\Chris\Dropbox\pretty_gui\Gui\src\app\images\computer2.png" -computer3 = r"C:\Users\Chris\Dropbox\pretty_gui\Gui\src\app\images\computer3.png" -icon = r"C:\Users\Chris\Dropbox\pretty_gui\Gui\src\app\images\icon.ico" -terminal = r"C:\Users\Chris\Dropbox\pretty_gui\Gui\src\app\images\terminal.png" +computer = r"C:\Users\Chris\Dropbox\pretty_gui\Gooey\src\app\images\computer.png" +computer2 = r"C:\Users\Chris\Dropbox\pretty_gui\Gooey\src\app\images\computer2.png" +computer3 = r"C:\Users\Chris\Dropbox\pretty_gui\Gooey\src\app\images\computer3.png" +icon = r"C:\Users\Chris\Dropbox\pretty_gui\Gooey\src\app\images\icon.ico" +settings = r"C:\Users\Chris\Dropbox\pretty_gui\Gooey\src\app\images\settings.png" +settings2 = r"C:\Users\Chris\Dropbox\pretty_gui\Gooey\src\app\images\settings2.png" +terminal = r"C:\Users\Chris\Dropbox\pretty_gui\Gooey\src\app\images\terminal.png" diff --git a/src/app/images/image_store.pyc b/src/app/images/image_store.pyc index d24a81a..7874e26 100644 Binary files a/src/app/images/image_store.pyc and b/src/app/images/image_store.pyc differ diff --git a/src/app/images/settings.png b/src/app/images/settings.png new file mode 100644 index 0000000..318269a Binary files /dev/null and b/src/app/images/settings.png differ diff --git a/src/app/images/settings2.png b/src/app/images/settings2.png new file mode 100644 index 0000000..a6b7b2d Binary files /dev/null and b/src/app/images/settings2.png differ diff --git a/src/model/gui.py b/src/model/gui.py index b009fe3..ee069d3 100644 --- a/src/model/gui.py +++ b/src/model/gui.py @@ -49,8 +49,8 @@ if __name__ == '__main__': frame = MainWindow(queue) frame.Show(True) # Show the frame. - mock = MockApplication() - mock.start() +# mock = MockApplication() +# mock.start() app.MainLoop() #