Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import wx
- class FileDrop(wx.FileDropTarget):
- def __init__(self, window):
- wx.FileDropTarget.__init__(self)
- self.window = window
- def OnDropFiles(self, x, y, filenames):
- text = '\n'.join(filenames)
- self.window.Clear()
- self.window.WriteText(text)
- return True
- class Example(wx.Frame):
- def __init__(self, parent, id, title):
- wx.Frame.__init__(self, parent, id, title)
- self.InitUI()
- def InitUI(self):
- self.text = wx.TextCtrl(self, style = wx.TE_MULTILINE)
- dt = FileDrop(self.text)
- self.text.SetDropTarget(dt)
- self.SetSize((500, 200))
- self.Centre()
- def main():
- app = wx.App()
- ex = Example(None, wx.ID_ANY, 'File drag and drop')
- ex.Show()
- app.MainLoop()
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement