Python wx.FileDropTarget() Examples

The following are 10 code examples of wx.FileDropTarget(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module wx , or try the search function .
Example #1
Source File: preview.py    From IkaLog with Apache License 2.0 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        wx.Panel.__init__(self, *args, **kwargs)

        # This is used to determine if a file dialog is open or not.
        self.prev_file_path = ''

        # Textbox for input file
        self.text_ctrl = wx.TextCtrl(self, wx.ID_ANY, '')
        self.text_ctrl.Bind(wx.EVT_TEXT, self.on_text_input)
        self.button = wx.Button(self, wx.ID_ANY, _('Browse'))
        self.button.Bind(wx.EVT_BUTTON, self.on_button_click)

        # Drag and drop
        drop_target = FileDropTarget(self)
        self.text_ctrl.SetDropTarget(drop_target)

        top_sizer = wx.BoxSizer(wx.HORIZONTAL)
        top_sizer.Add(self.text_ctrl, proportion=1)
        top_sizer.Add(self.button)

        self.SetSizer(top_sizer) 
Example #2
Source File: preview.py    From IkaLog with Apache License 2.0 6 votes vote down vote up
def on_button_click(self, event):
        file_path = self.text_ctrl.GetValue()
        if self.should_open_file(file_path):
            evt = InputFileAddedEvent(input_file=file_path)
            wx.PostEvent(self, evt)
            self.prev_file_path = file_path
            self.update_button_label()
            return

        # file_path is invalid. Open a file dialog.
        file_dialog = wx.FileDialog(self, _('Select a video file'))
        if file_dialog.ShowModal() != wx.ID_OK:
            return
        file_path = file_dialog.GetPath()
        self.text_ctrl.SetValue(file_path)


    # Callback from wx.FileDropTarget.OnDropFiles 
Example #3
Source File: filedrop.py    From me-ica with GNU Lesser General Public License v2.1 5 votes vote down vote up
def __init__(self, window):
    wx.FileDropTarget.__init__(self)
    self.window = window 
Example #4
Source File: preview.py    From IkaLog with Apache License 2.0 5 votes vote down vote up
def __init__(self, observer):
        wx.FileDropTarget.__init__(self)
        self.observer = observer 
Example #5
Source File: filedrop.py    From pyFileFixity with MIT License 5 votes vote down vote up
def __init__(self, window):
    wx.FileDropTarget.__init__(self)
    self.window = window 
Example #6
Source File: filedrop.py    From Gooey with MIT License 5 votes vote down vote up
def __init__(self, window):
    wx.FileDropTarget.__init__(self)
    self.window = window 
Example #7
Source File: DropTarget.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, window, callback):
        wx.FileDropTarget.__init__(self)
        self.window = window
        self.callback = callback 
Example #8
Source File: main.py    From wxGlade with MIT License 5 votes vote down vote up
def __init__(self, parent):
        wx.FileDropTarget.__init__(self)
        self.parent = parent 
Example #9
Source File: main.py    From wxGlade with MIT License 5 votes vote down vote up
def OnDragOver(self, x, y, defResult):
            x0,y0 = self.parent.GetClientAreaOrigin()
            screen_xy = self.parent.ClientToScreen( (x-x0,y-y0) )
            ctrl = wx.FindWindowAtPoint( screen_xy )
            print("DragOver", x0,y0, x-x0,y-y0, ctrl)
            return wx.FileDropTarget.OnDragOver(self, x,y, defResult) 
Example #10
Source File: main.py    From wxGlade with MIT License 4 votes vote down vote up
def __init__(self):
        version = config.version
        pos, size, layout = self.init_layout_settings()
        wx.Frame.__init__(self, None, -1, "wxGlade v%s" % version, pos=pos, size=size,
                          style=wx.DEFAULT_FRAME_STYLE, name='MainFrame')

        common.main = self
        self._set_icon()
        self.create_menu()
        self.create_toolbar()

        style = wx.SP_3D | wx.SP_LIVE_UPDATE
        self.splitter1 = wx.SplitterWindow(self, style=style)
        self.splitter2 = wx.SplitterWindow(self.splitter1, style=style)
        self.palette = wxGladePalettePanel(self.splitter2)

        # create the property and the tree frame
        common.property_panel = self.property_panel = wxGladePropertyPanel(self.splitter2)
        common.root = app = application.Application()
        common.app_tree = self.tree = WidgetTree(self.splitter1, app)

        self.splitter1.SplitVertically(self.splitter2, self.tree)
        self.splitter2.SplitHorizontally(self.palette, self.property_panel)

        self.switch_layout(layout, initial=True)

        # last visited directory, used on GTK for wxFileDialog
        self.cur_dir = config.preferences.open_save_path

        # set a drop target for us...
        self._droptarget = FileDropTarget(self)
        self.SetDropTarget(self._droptarget)

        self.create_statusbar()  # create statusbar for display of messages

        self.Show()
        #misc.set_focused_widget(common.root)
        self.Bind(wx.EVT_CLOSE, self.on_close)

        # disable autosave checks during unittests
        if config.testing: return
        self.init_autosave()
        self.check_autosaved()

        self.Bind(wx.EVT_CHAR_HOOK, self.on_char_hook)
        if config.debugging:
            self.splitter1.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.on_sash)
            self.splitter2.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.on_sash)