mirror of https://github.com/chriskiehl/Gooey.git
Browse Source
More project restructuring. Fixed bugs in widget_pack's getvalue methods, changed how parsing is done. Started updating the fantastically out of date unittests. Getting close!
pull/61/head
More project restructuring. Fixed bugs in widget_pack's getvalue methods, changed how parsing is done. Started updating the fantastically out of date unittests. Getting close!
pull/61/head
24 changed files with 411 additions and 165 deletions
Split View
Diff Options
-
1gooey/_tmp/__init__.py
-
69gooey/_tmp/mockapp.py
-
77gooey/gui/componenets2_runner.py
-
12gooey/gui/controller.py
-
3gooey/gui/image_repository.py
-
6gooey/gui/lang/i18n.py
-
0gooey/gui/lang/i18n_config.py
-
19gooey/gui/widgets/components2.py
-
29gooey/gui/widgets/widget_pack.py
-
2gooey/gui/windows/advanced_config.py
-
12gooey/gui/windows/base_window.py
-
6gooey/gui/windows/basic_config_panel.py
-
6gooey/gui/windows/footer.py
-
9gooey/gui/windows/header.py
-
3gooey/gui/windows/runtime_display_panel.py
-
24gooey/mockapplications/mockapp.py
-
1gooey/python_bindings/argparse_to_json.py
-
46gooey/python_bindings/gooey_decorator.py
-
49gooey/python_bindings/source_parser.py
-
1gooey/tests/gui/__init__.py
-
1gooey/tests/gui/widgets/__init__.py
-
194gooey/tests/gui/widgets/componenets2_runner.py
-
3gooey/tests/i18n_unittest.py
-
3gooey/tests/source_parser_unittest.py
@ -0,0 +1 @@ |
|||
__author__ = 'Chris' |
@ -0,0 +1,69 @@ |
|||
''' |
|||
Created on Dec 21, 2013 |
|||
|
|||
@author: Chris |
|||
''' |
|||
import sys |
|||
import hashlib |
|||
from time import time as _time |
|||
from time import sleep as _sleep |
|||
# from argparse import ArgumentParser |
|||
# import argparse |
|||
import argparse as ap |
|||
from argparse import ArgumentParser as AP |
|||
|
|||
|
|||
a = globals() |
|||
|
|||
|
|||
def main(): |
|||
''' |
|||
does stuff with parser.parse_args() |
|||
''' |
|||
desc = "Mock application to test Gooey's functionality" |
|||
file_help_msg = "Name of the file you want to process" |
|||
my_cool_parser = ap.ArgumentParser(description=desc) |
|||
my_cool_parser.add_argument("filename", help=file_help_msg, metavar='asdf') # positional |
|||
my_cool_parser.add_argument("outfile", help="Name of the file where you'll save the output") # positional |
|||
my_cool_parser.add_argument('-c', '--countdown', default=10, type=int, help='sets the time to count down from you see its quite simple!') |
|||
my_cool_parser.add_argument("-s", "--showtime", action="store_true", help="display the countdown timer") |
|||
my_cool_parser.add_argument("-d", "--delay", action="store_true", help="Delay execution for a bit") |
|||
my_cool_parser.add_argument('-v', '--verbose', action='count') |
|||
my_cool_parser.add_argument("-o", "--obfuscate", action="store_true", help="obfuscate the countdown timer!") |
|||
my_cool_parser.add_argument('-r', '--recursive', choices=['yes', 'no'], help='Recurse into subfolders') |
|||
my_cool_parser.add_argument("-w", "--writelog", default="No, NOT whatevs", help="write log to some file or something") |
|||
my_cool_parser.add_argument("-e", "--expandAll", action="store_true", help="expand all processes") |
|||
verbosity = my_cool_parser.add_mutually_exclusive_group() |
|||
verbosity.add_argument('-t', '--verbozze', dest='verbose', action="store_true", help="Show more details") |
|||
verbosity.add_argument('-q', '--quiet', dest='quiet', action="store_true", help="Only output on error") |
|||
|
|||
print 'inside of main(), my_cool_parser =', my_cool_parser |
|||
args = my_cool_parser.parse_args() |
|||
|
|||
print sys.argv |
|||
print args.countdown |
|||
print args.showtime |
|||
|
|||
start_time = _time() |
|||
print 'Counting down from %s' % args.countdown |
|||
while _time() - start_time < args.countdown: |
|||
if args.showtime: |
|||
print 'printing message at: %s' % _time() |
|||
else: |
|||
print 'printing message at: %s' % hashlib.md5(str(_time())).hexdigest() |
|||
_sleep(.5) |
|||
print 'Finished running the program. Byeeeeesss!' |
|||
|
|||
# raise ValueError("Something has gone wrong! AHHHHHHHHHHH") |
|||
|
|||
if __name__ == '__main__': |
|||
print sys.argv |
|||
main() |
|||
# import inspect |
|||
# import dis |
|||
# # print dir(main.__code__) |
|||
# # for i in dir(main.__code__): |
|||
# # print i, getattr(main.__code__, i) |
|||
# print dis.dis(main.__code__) |
|||
# # for i in inspect.getmembers(main): |
|||
# # print i |
@ -1,77 +0,0 @@ |
|||
__author__ = 'Chris' |
|||
|
|||
import wx |
|||
from wx.lib.scrolledpanel import ScrolledPanel |
|||
|
|||
|
|||
class TestPanel(ScrolledPanel): |
|||
def __init__(self, parent): |
|||
ScrolledPanel.__init__(self, parent) |
|||
self.SetupScrolling(scroll_x=False) |
|||
|
|||
self.textctrls = [wx.TextCtrl(self) for _ in range(1)] |
|||
|
|||
sizer = wx.BoxSizer(wx.VERTICAL) |
|||
hsizer = wx.BoxSizer(wx.HORIZONTAL) |
|||
for textctrl in self.textctrls: |
|||
hsizer.Add(textctrl, 1, wx.EXPAND) |
|||
textctrl.SetMinSize((10,23)) |
|||
|
|||
sizer.Add(hsizer, 0, wx.EXPAND) |
|||
self.SetSizer(sizer) |
|||
|
|||
class MyFrame(wx.Frame): |
|||
def __init__(self, parent): |
|||
wx.Frame.__init__(self, parent, title="test", size=(320, 240)) |
|||
self.SetBackgroundColour('#ffffff') |
|||
self.panel = TestPanel(self) |
|||
self.Show() |
|||
|
|||
if __name__ == '__main__': |
|||
app = wx.App(False) |
|||
MyFrame(None) |
|||
app.MainLoop() |
|||
|
|||
|
|||
|
|||
|
|||
# a = { |
|||
# 'required' : [ |
|||
# { |
|||
# 'component': 'TextField', |
|||
# 'data': { |
|||
# 'display_name': 'filename', |
|||
# 'help_text': 'path to file you want to process', |
|||
# 'command_args': ['-f', '--infile'] |
|||
# } |
|||
# }, |
|||
# { |
|||
# 'component': 'FileChooser', |
|||
# 'data': { |
|||
# 'display_name': 'Output Location', |
|||
# 'help_text': 'Where to save the file', |
|||
# 'command_args': ['-o', '--outfile'] |
|||
# } |
|||
# } |
|||
# ], |
|||
# 'optional' : [ |
|||
# { |
|||
# 'component': 'RadioGroup', |
|||
# 'data': [ |
|||
# { |
|||
# 'display_name': 'Output Location', |
|||
# 'help_text': 'Where to save the file', |
|||
# 'command_args': ['-o', '--outfile'] |
|||
# }, { |
|||
# 'display_name': 'Output Location', |
|||
# 'help_text': 'Where to save the file', |
|||
# 'command_args': ['-o', '--outfile'] |
|||
# } |
|||
# ] |
|||
# } |
|||
# ] |
|||
# } |
|||
# |
|||
# ] |
|||
# } |
|||
|
@ -1,9 +1,10 @@ |
|||
import os |
|||
|
|||
|
|||
__author__ = 'Chris' |
|||
|
|||
base_path = os.path.dirname(__file__) |
|||
image_dir = os.path.join(base_path, 'images') |
|||
image_dir = os.path.join(base_path, '../images') |
|||
|
|||
alessandro_rei_checkmark = os.path.join(image_dir, "alessandro_rei_checkmark.png") |
|||
computer = os.path.join(image_dir, "computer.png") |
@ -0,0 +1 @@ |
|||
__author__ = 'Chris' |
@ -0,0 +1 @@ |
|||
__author__ = 'Chris' |
@ -0,0 +1,194 @@ |
|||
from gooey.gui.widgets import components2 |
|||
|
|||
__author__ = 'Chris' |
|||
|
|||
import unittest |
|||
import wx |
|||
from wx.lib.scrolledpanel import ScrolledPanel |
|||
|
|||
TEXT_FIELD = components2.TextField({ |
|||
'display_name': 'cool title', |
|||
'help_msg': 'a help message', |
|||
'nargs': '+', |
|||
'commands': ['-f', '--fudge'], |
|||
'choices': [] |
|||
}) |
|||
|
|||
DROPDOWN = components2.Dropdown({ |
|||
'display_name': 'cool title', |
|||
'help_msg': 'a help message', |
|||
'nargs': '+', |
|||
'commands': ['-f', '--fudge'], |
|||
'choices': ['one', 'two', 'three'] |
|||
}) |
|||
|
|||
COUNTER = components2.Counter({ |
|||
'display_name': 'cool title', |
|||
'help_msg': 'a help message', |
|||
'nargs': '+', |
|||
'commands': ['-f', '--fudge'], |
|||
'choices': [] |
|||
}) |
|||
|
|||
CHECKBOX = components2.CheckBox({ |
|||
'display_name': 'cool title', |
|||
'help_msg': 'a help message', |
|||
'nargs': '+', |
|||
'commands': ['-f', '--fudge'], |
|||
'choices': [] |
|||
}) |
|||
|
|||
RADIOGROUP = components2.RadioGroup({ |
|||
'display_name': 'mutux options', |
|||
'data': [{ |
|||
'help_msg': 'a help message', |
|||
'nargs': '+', |
|||
'commands': ['-f', '--fudge'], |
|||
'choices': [] |
|||
}, { |
|||
'help_msg': 'a help message', |
|||
'nargs': '+', |
|||
'commands': ['-g', '--gudge'], |
|||
'choices': [] |
|||
}] |
|||
}) |
|||
|
|||
|
|||
class TestPanel(ScrolledPanel): |
|||
def __init__(self, parent, widget): |
|||
ScrolledPanel.__init__(self, parent) |
|||
self.SetupScrolling(scroll_x=False) |
|||
|
|||
sizer = wx.BoxSizer(wx.VERTICAL) |
|||
self.widget = widget |
|||
|
|||
sizer.Add(self.widget.build(self), 0, wx.EXPAND) |
|||
self.SetSizer(sizer) |
|||
|
|||
|
|||
class MyFrame(wx.Frame): |
|||
def __init__(self, parent, widget): |
|||
wx.Frame.__init__(self, parent, title="test", size=(320, 240)) |
|||
self.SetBackgroundColour('#ffffff') |
|||
self.panel = TestPanel(self, widget) |
|||
self.Show() |
|||
|
|||
def get_widget(self): |
|||
return self.panel.widget |
|||
|
|||
def close(self): |
|||
self.Destroy() |
|||
|
|||
|
|||
|
|||
class TestComponents(unittest.TestCase): |
|||
|
|||
def setUp(self): |
|||
self.app = wx.App(False) |
|||
self.frame = None |
|||
|
|||
def tearDown(self): |
|||
# self.app = wx.App(False) |
|||
self.frame.Destroy() |
|||
self.frame = None |
|||
|
|||
def test_textfield_returns_option_and_value_else_none(self): |
|||
self.build_test_frame(TEXT_FIELD) |
|||
self.assertTrue(self.get_value() == '') |
|||
self.get_widget().SetLabelText('value') |
|||
self.assertEqual('-f value', self.get_value()) |
|||
|
|||
|
|||
def test_dropdown_returns_option_and_value_else_none(self): |
|||
self.build_test_frame(DROPDOWN) |
|||
self.assertTrue(self.get_value() == '') |
|||
# grab first item from the combo box |
|||
self.frame.get_widget()._GetWidget().SetSelection(0) |
|||
self.assertEqual('-f one', self.get_value()) |
|||
|
|||
|
|||
def test_counter_returns_option_and_value_else_none(self): |
|||
self.build_test_frame(COUNTER) |
|||
self.assertTrue(self.get_value() == '') |
|||
# counter objects stack, |
|||
# so |
|||
# 1 = -f, |
|||
# 4 = -ffff |
|||
self.frame.get_widget()._GetWidget().SetSelection(0) |
|||
self.assertEqual('-f', self.get_value()) |
|||
self.frame.get_widget()._GetWidget().SetSelection(4) |
|||
self.assertEqual('-fffff', self.get_value()) |
|||
|
|||
|
|||
def test_checkbox_returns_option_if_checked_else_none(self): |
|||
self.build_test_frame(CHECKBOX) |
|||
self.assertTrue(self.get_value() == '') |
|||
self.frame.get_widget()._GetWidget().SetValue(1) |
|||
self.assertEqual('-f', self.get_value()) |
|||
|
|||
|
|||
def test_radiogroup_returns_option_if_checked_else_none(self): |
|||
self.build_test_frame(RADIOGROUP) |
|||
self.assertTrue(self.get_value() == '') |
|||
# self.frame.get_widget()._GetWidget()[0].SetValue(1) |
|||
# self.assertEqual('-f', self.get_value()) |
|||
|
|||
|
|||
def build_test_frame(self, widget): |
|||
# self.app = wx.App(False) |
|||
self.frame = MyFrame(None, widget) |
|||
|
|||
def get_widget(self): |
|||
return self.frame.get_widget()._GetWidget() |
|||
|
|||
def get_value(self): |
|||
return self.frame.get_widget().GetValue() |
|||
|
|||
|
|||
|
|||
if __name__ == '__main__': |
|||
unittest.main() |
|||
|
|||
|
|||
|
|||
|
|||
# a = { |
|||
# 'required' : [ |
|||
# { |
|||
# 'component': 'TextField', |
|||
# 'data': { |
|||
# 'display_name': 'filename', |
|||
# 'help_text': 'path to file you want to process', |
|||
# 'command_args': ['-f', '--infile'] |
|||
# } |
|||
# }, |
|||
# { |
|||
# 'component': 'FileChooser', |
|||
# 'data': { |
|||
# 'display_name': 'Output Location', |
|||
# 'help_text': 'Where to save the file', |
|||
# 'command_args': ['-o', '--outfile'] |
|||
# } |
|||
# } |
|||
# ], |
|||
# 'optional' : [ |
|||
# { |
|||
# 'component': 'RadioGroup', |
|||
# 'data': [ |
|||
# { |
|||
# 'display_name': 'Output Location', |
|||
# 'help_text': 'Where to save the file', |
|||
# 'command_args': ['-o', '--outfile'] |
|||
# }, { |
|||
# 'display_name': 'Output Location', |
|||
# 'help_text': 'Where to save the file', |
|||
# 'command_args': ['-o', '--outfile'] |
|||
# } |
|||
# ] |
|||
# } |
|||
# ] |
|||
# } |
|||
# |
|||
# ] |
|||
# } |
|||
|
Write
Preview
Loading…
Cancel
Save