Browse Source

Added drag/drop support to plain text fields

pull/61/head
chriskiehl 10 years ago
parent
commit
8284b7224c
5 changed files with 17 additions and 12 deletions
  1. 2
      gooey/_tmp/mockapp.py
  2. 1
      gooey/gui/util/__init__.py
  3. 10
      gooey/gui/util/filedrop.py
  4. 14
      gooey/gui/widgets/widget_pack.py
  5. 2
      gooey/mockapplications/mockapp.py

2
gooey/_tmp/mockapp.py

@ -24,7 +24,7 @@ def main():
file_help_msg = "Name of the file you want to process"
my_cool_parser = GooeyParser(description=desc)
my_cool_parser.add_argument("filename", help=file_help_msg, widget="FileChooser") # positional
my_cool_parser.add_argument("outfile", help="Name of the file where you'll save the output", widget="FileChooser") # 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!', widget='DateChooser')
# my_cool_parser.add_argument('-c', '--cron-schedule', default=10, type=int, help='Set the datetime when the cron should begin', widget='DateChooser')
my_cool_parser.add_argument("-s", "--showtime", action="store_true", help="display the countdown timer")

1
gooey/gui/util/__init__.py

@ -0,0 +1 @@
__author__ = 'Chris'

10
gooey/gui/util/filedrop.py

@ -0,0 +1,10 @@
import wx
class FileDrop(wx.FileDropTarget):
def __init__(self, window):
wx.FileDropTarget.__init__(self)
self.window = window
def OnDropFiles(self, x, y, filenames):
for name in filenames:
self.window.WriteText(name)

14
gooey/gui/widgets/widget_pack.py

@ -1,3 +1,5 @@
from gooey.gui.util.filedrop import FileDrop
__author__ = 'Chris'
from abc import ABCMeta, abstractmethod
@ -26,16 +28,6 @@ class WidgetPack(object):
pass
class FileDrop(wx.FileDropTarget):
def __init__(self, window):
wx.FileDropTarget.__init__(self)
self.window = window
def OnDropFiles(self, x, y, filenames):
for name in filenames:
self.window.WriteText(name)
class BaseChooser(WidgetPack):
@ -121,6 +113,8 @@ class TextInputPayload(WidgetPack):
def build(self, parent, data):
self.option_string = data['commands'][0] if data['commands'] else ''
self.widget = wx.TextCtrl(parent)
dt = FileDrop(self.widget)
self.widget.SetDropTarget(dt)
self.widget.SetMinSize((0, -1))
self.widget.SetDoubleBuffered(True)
return self.widget

2
gooey/mockapplications/mockapp.py

@ -25,7 +25,7 @@ def main():
file_help_msg = "Name of the file you want to process"
my_cool_parser = GooeyParser(description=desc)
my_cool_parser.add_argument("filename", help=file_help_msg, widget="FileChooser") # positional
my_cool_parser.add_argument("outfile", help="Name of the file where you'll save the output", widget="FileChooser") # 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!', widget='DateChooser')
# my_cool_parser.add_argument('-c', '--cron-schedule', default=10, type=int, help='Set the datetime when the cron should begin', widget='DateChooser')
my_cool_parser.add_argument("-s", "--showtime", action="store_true", help="display the countdown timer")

Loading…
Cancel
Save