mirror of https://github.com/chriskiehl/Gooey.git
25 changed files with 517 additions and 151 deletions
Split View
Diff Options
-
76src/app/dialogs/advanced_config.py
-
BINsrc/app/dialogs/advanced_config.pyc
-
18src/app/dialogs/advanced_config_integration_test.py
-
1src/app/dialogs/argparse_test_data.py
-
75src/app/dialogs/base_window.py
-
60src/app/dialogs/basic_config_panel.py
-
2src/app/dialogs/body.py
-
31src/app/dialogs/component_factory.py
-
BINsrc/app/dialogs/component_factory.pyc
-
2src/app/dialogs/components.py
-
95src/app/dialogs/display_main.py
-
BINsrc/app/dialogs/display_main.pyc
-
36src/app/dialogs/footer.py
-
BINsrc/app/dialogs/footer.pyc
-
92src/app/dialogs/header.py
-
BINsrc/app/dialogs/header.pyc
-
49src/app/dialogs/imageutil.py
-
25src/app/dialogs/option_reader.py
-
28src/app/dialogs/segoe_statictext.py
-
62src/app/dialogs/window.py
-
12src/app/images/image_store.py
-
BINsrc/app/images/image_store.pyc
-
BINsrc/app/images/settings.png
-
BINsrc/app/images/settings2.png
-
4src/model/gui.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 |
@ -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 |
@ -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 |
|||
|
|||
|
|||
|
@ -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() |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
@ -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 |
@ -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 |
|||
|
@ -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 |
|||
|
|||
<wx._gdi.Bitmap; proxy of <Swig Object of type 'wxBitmap *' at 0x2ebf8e0> > |
|||
<wx._gdi.Bitmap; proxy of <Swig Object of type 'wxBitmap *' at 0x2ebc830> > |
|||
''' |
|||
|
|||
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) |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Write
Preview
Loading…
Cancel
Save