mirror of https://github.com/chriskiehl/Gooey.git
5 changed files with 264 additions and 14 deletions
Unified View
Diff Options
-
140gooey/gui/Chooser.py
-
25gooey/gui/ChooserRunner.py
-
44gooey/gui/calender_dialog.py
-
17gooey/gui/components.py
-
52gooey/mockapplications/qwindelzorf _example.py
@ -0,0 +1,140 @@ |
|||||
|
__author__ = 'Chris' |
||||
|
|
||||
|
import wx |
||||
|
import styling |
||||
|
from calender_dialog import CalendarDlg |
||||
|
|
||||
|
|
||||
|
class AbstractChooser(object): |
||||
|
def __init__(self, data): |
||||
|
self.data = data |
||||
|
|
||||
|
# parent |
||||
|
self.panel = None |
||||
|
|
||||
|
self.button_text = 'Browse' |
||||
|
|
||||
|
# Widgets |
||||
|
self.title = None |
||||
|
self.help_msg = None |
||||
|
self.text_box = None |
||||
|
self.button = None |
||||
|
self.panel = None |
||||
|
|
||||
|
def build(self, parent): |
||||
|
return self.do_layout(parent) |
||||
|
|
||||
|
def do_layout(self, parent): |
||||
|
self.panel = wx.Panel(parent) |
||||
|
|
||||
|
self.title = self.CreateNameLabelWidget(self.panel) |
||||
|
self.help_msg = self.CreateHelpMsgWidget(self.panel) |
||||
|
self.text_box = wx.TextCtrl(self.panel) |
||||
|
self.button = wx.Button(self.panel, label=self.button_text, size=(73, 23)) |
||||
|
|
||||
|
vertical_container = wx.BoxSizer(wx.VERTICAL) |
||||
|
widget_sizer = wx.BoxSizer(wx.HORIZONTAL) |
||||
|
|
||||
|
vertical_container.Add(self.title) |
||||
|
vertical_container.AddSpacer(2) |
||||
|
|
||||
|
if self.help_msg.GetLabelText(): |
||||
|
vertical_container.Add(self.help_msg, 1, wx.EXPAND) |
||||
|
vertical_container.AddSpacer(2) |
||||
|
else: |
||||
|
vertical_container.AddStretchSpacer(1) |
||||
|
|
||||
|
widget_sizer.Add(self.text_box, 1, wx.EXPAND) |
||||
|
widget_sizer.AddSpacer(10) |
||||
|
widget_sizer.Add(self.button, 0) |
||||
|
|
||||
|
vertical_container.Add(widget_sizer, 0, wx.EXPAND) |
||||
|
self.panel.SetSizer(vertical_container) |
||||
|
|
||||
|
self.panel.Bind(wx.EVT_SIZE, self.OnResize) |
||||
|
self.panel.Bind(wx.EVT_BUTTON, self.on_button, self.button) |
||||
|
return self.panel |
||||
|
|
||||
|
def CreateHelpMsgWidget(self, parent): |
||||
|
base_text = wx.StaticText(parent, label=self.data['help_msg']) |
||||
|
# if self.data['nargs']: |
||||
|
# base_text.SetLabelText(base_text.GetLabelText() + self.CreateNargsMsg(action)) |
||||
|
styling.MakeDarkGrey(base_text) |
||||
|
return base_text |
||||
|
|
||||
|
def CreateNameLabelWidget(self, parent): |
||||
|
label = self.data['title'].title() |
||||
|
text = wx.StaticText(parent, label=label) |
||||
|
styling.MakeBold(text) |
||||
|
return text |
||||
|
|
||||
|
def OnResize(self, evt): |
||||
|
if self.help_msg is None: |
||||
|
return |
||||
|
|
||||
|
container_width, _ = self.panel.Size |
||||
|
text_width, _ = self.help_msg.Size |
||||
|
|
||||
|
if text_width != container_width: |
||||
|
self.help_msg.SetLabel(self.help_msg.GetLabelText().replace('\n', ' ')) |
||||
|
self.help_msg.Wrap(container_width) |
||||
|
evt.Skip() |
||||
|
|
||||
|
def on_button(self, evt): |
||||
|
raise NotImplementedError |
||||
|
|
||||
|
|
||||
|
|
||||
|
class FileChooser(AbstractChooser): |
||||
|
def __init__(self, data): |
||||
|
AbstractChooser.__init__(self, data) |
||||
|
|
||||
|
def on_button(self, evt): |
||||
|
dlg = wx.FileDialog(self.panel, style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) |
||||
|
result = (dlg.GetPath() |
||||
|
if dlg.ShowModal() == wx.ID_OK |
||||
|
else None) |
||||
|
if result: |
||||
|
self.text_box.SetLabelText(result) |
||||
|
|
||||
|
|
||||
|
class DirectoryChooser(AbstractChooser): |
||||
|
def __init__(self, data): |
||||
|
AbstractChooser.__init__(self, data) |
||||
|
|
||||
|
def on_button(self, evt): |
||||
|
dlg = wx.DirDialog(self.panel, 'Select directory', style=wx.DD_DEFAULT_STYLE) |
||||
|
result = (dlg.GetPath() |
||||
|
if dlg.ShowModal() == wx.ID_OK |
||||
|
else None) |
||||
|
if result: |
||||
|
self.text_box.SetLabelText(result) |
||||
|
|
||||
|
|
||||
|
class CalendarChooser(AbstractChooser): |
||||
|
def __init__(self, data): |
||||
|
AbstractChooser.__init__(self, data) |
||||
|
self.button_text = 'Choose Date' |
||||
|
|
||||
|
def on_button(self, evt): |
||||
|
dlg = CalendarDlg(self.panel) |
||||
|
dlg.ShowModal() |
||||
|
if dlg.GetPath(): |
||||
|
self.text_box.SetLabelText(dlg.GetPath()) |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
@ -0,0 +1,25 @@ |
|||||
|
__author__ = 'Chris' |
||||
|
|
||||
|
|
||||
|
import wx |
||||
|
from wx.lib import wordwrap |
||||
|
from Chooser import FileChooser, DirectoryChooser, CalendarChooser |
||||
|
|
||||
|
class MyFrame(wx.Frame): |
||||
|
def __init__(self, parent): |
||||
|
wx.Frame.__init__(self, parent, title="test", size=(320, 240)) |
||||
|
self.SetBackgroundColour('#ffffff') |
||||
|
|
||||
|
sizer = wx.BoxSizer(wx.VERTICAL) |
||||
|
f = CalendarChooser({'title':'cool title', 'help_msg':'cool help msg that is super long and intense and has lots of words!', 'nargs': '+'}) |
||||
|
sizer.Add(f.build(self), 0, wx.EXPAND) |
||||
|
self.SetSizer(sizer) |
||||
|
|
||||
|
if __name__ == '__main__': |
||||
|
app = wx.App(False) |
||||
|
frame = MyFrame(None) |
||||
|
frame.Show(True) |
||||
|
app.MainLoop() |
||||
|
|
||||
|
|
||||
|
|
@ -0,0 +1,44 @@ |
|||||
|
__author__ = 'Chris' |
||||
|
|
||||
|
import wx |
||||
|
import styling |
||||
|
|
||||
|
|
||||
|
class CalendarDlg(wx.Dialog): |
||||
|
def __init__(self, parent): |
||||
|
wx.Dialog.__init__(self, parent) |
||||
|
|
||||
|
self.SetBackgroundColour('#ffffff') |
||||
|
|
||||
|
self.ok_button = wx.Button(self, label='Ok') |
||||
|
self.datepicker = wx.DatePickerCtrl(self, style=wx.DP_DROPDOWN) |
||||
|
|
||||
|
vertical_container = wx.BoxSizer(wx.VERTICAL) |
||||
|
vertical_container.AddSpacer(10) |
||||
|
vertical_container.Add(styling.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) |
||||
|
|
||||
|
vertical_container.AddSpacer(10) |
||||
|
button_sizer = wx.BoxSizer(wx.HORIZONTAL) |
||||
|
button_sizer.AddStretchSpacer(1) |
||||
|
button_sizer.Add(self.ok_button, 0) |
||||
|
|
||||
|
vertical_container.Add(button_sizer, 0, wx.LEFT | wx.RIGHT, 15) |
||||
|
vertical_container.AddSpacer(20) |
||||
|
self.SetSizerAndFit(vertical_container) |
||||
|
|
||||
|
self.Bind(wx.EVT_BUTTON, self.OnOkButton, self.ok_button) |
||||
|
|
||||
|
def OnOkButton(self, event): |
||||
|
self.Close() |
||||
|
return wx.ID_OK |
||||
|
|
||||
|
def OnCancellButton(self, event): |
||||
|
try: |
||||
|
return None |
||||
|
except: |
||||
|
self.Close() |
||||
|
|
||||
|
def GetPath(self): |
||||
|
return str(self.datepicker.GetValue()).split(' ')[0] |
@ -1,25 +1,49 @@ |
|||||
import argparse |
|
||||
|
"""inline""" |
||||
|
|
||||
|
import argparse |
||||
from gooey import Gooey |
from gooey import Gooey |
||||
|
|
||||
|
x = '''random line''' |
||||
|
|
||||
|
y = """ |
||||
|
Buncha text here |
||||
|
and here |
||||
|
and here |
||||
|
and here |
||||
|
""" |
||||
|
|
||||
@Gooey |
@Gooey |
||||
def main(): |
def main(): |
||||
|
"""This is my main module""" |
||||
parser = argparse.ArgumentParser('Get my users') |
parser = argparse.ArgumentParser('Get my users') |
||||
parser.add_argument('-type', "--type", type=str, action='store', dest='type', help= "type Query") |
|
||||
parser.add_argument('-dst', "--datestart", type=str, action='store', dest='date_start', help= "from Date") |
|
||||
parser.add_argument('-dsp', "--datestop", type=str, action='store', dest='date_stop', help= "to Date") |
|
||||
parser.add_argument('-n',"--IDuser", type=str, action='store', dest='idu', help="IDuser") |
|
||||
parser.add_argument('-t',"--text", type=str, action='store', dest='text', help="find Text") |
|
||||
parser.add_argument('-f',"--file", type=str, action='store', dest='filepath', help="File Save") |
|
||||
|
verbosity = parser.add_mutually_exclusive_group() |
||||
|
verbosity.add_argument('-v', '--verbose', dest='verbose', action="store_true", help="Show more details") |
||||
|
verbosity.add_argument('-q', '--quiet', dest='quiet', action="store_true", help="Only output on error") |
||||
|
|
||||
args = parser.parse_args() |
args = parser.parse_args() |
||||
query_type = args.type |
|
||||
date_start=args.date_start |
|
||||
date_stop=args.date_stop |
|
||||
userid=args.idu |
|
||||
input_data = args.text |
|
||||
path_to_file = args.filepath |
|
||||
print path_to_file |
|
||||
|
|
||||
|
def moo(asdf): |
||||
|
'''single quoted inline comment''' |
||||
|
a = 1 |
||||
|
|
||||
|
def foo(): |
||||
|
"""Double quoted inline comment """ |
||||
|
a = 1 |
||||
|
|
||||
|
def bar(): |
||||
|
""" |
||||
|
Double quoted |
||||
|
multiline comment |
||||
|
""" |
||||
|
a = 1 |
||||
|
|
||||
|
def baz(): |
||||
|
''' |
||||
|
Double quoted |
||||
|
multiline comment |
||||
|
''' |
||||
|
a = 1 |
||||
|
|
||||
|
|
||||
if __name__ == '__main__': |
if __name__ == '__main__': |
||||
main() |
main() |
Write
Preview
Loading…
Cancel
Save