Skip to content

Commit

Permalink
Implementation of PasswordField custom widget
Browse files Browse the repository at this point in the history
  • Loading branch information
leo authored and chriskiehl committed Aug 4, 2017
1 parent 106abc7 commit 897189b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gooey/gui/widgets/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,4 @@ def build_subclass(name, widget_class):
Dropdown = build_subclass('Dropdown', widget_pack.DropdownPayload)
Counter = build_subclass('Counter', widget_pack.CounterPayload)
MultiDirChooser = build_subclass('MultiDirChooser', widget_pack.MultiDirChooserPayload)
PasswordField = build_subclass('PasswordField', widget_pack.PasswordInputPayload)
17 changes: 17 additions & 0 deletions gooey/gui/widgets/widget_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,23 @@ class DirDialog(wx.DirDialog):
def __init__(self, parent, *args, **kwargs):
wx.DirDialog.__init__(self, parent, 'Select Directory', style=wx.DD_DEFAULT_STYLE)

class PasswordInputPayload(WidgetPack):
def __init__(self, no_quoting=False):
self.widget = None
self.option_string = None
self.no_quoting = no_quoting

def build(self, parent, data, choices=None):
self.widget = wx.TextCtrl(parent, style=wx.TE_PASSWORD)
dt = FileDrop(self.widget)
self.widget.SetDropTarget(dt)
self.widget.SetMinSize((0, -1))
self.widget.SetDoubleBuffered(True)
self.widget.AppendText('')
return self.widget

def get_value(self):
return self.widget.GetValue()

def safe_default(data, default):
return ''
Expand Down
3 changes: 2 additions & 1 deletion gooey/python_bindings/argparse_to_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
'RadioGroup',
'CheckBox',
'MultiDirChooser',
'Textarea'
'Textarea',
'PasswordField'
)


Expand Down

0 comments on commit 897189b

Please sign in to comment.