]> git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/wxPIA_book/Chapter-18/drop_target.py
don't use invalid wxIconBundles, it results in asserts after recent changes
[wxWidgets.git] / wxPython / samples / wxPIA_book / Chapter-18 / drop_target.py
1 import wx
2
3 class MyFileDropTarget(wx.FileDropTarget):
4 def __init__(self, window):
5 wx.FileDropTarget.__init__(self)
6 self.window = window
7
8 def OnDropFiles(self, x, y, filenames):
9 self.window.AppendText("\n%d file(s) dropped at (%d,%d):\n" %
10 (len(filenames), x, y))
11 for file in filenames:
12 self.window.AppendText("\t%s\n" % file)
13
14
15 class MyFrame(wx.Frame):
16 def __init__(self):
17 wx.Frame.__init__(self, None, title="Drop Target",
18 size=(500,300))
19 p = wx.Panel(self)
20
21 # create the controls
22 label = wx.StaticText(p, -1, "Drop some files here:")
23 text = wx.TextCtrl(p, -1, "",
24 style=wx.TE_MULTILINE|wx.HSCROLL)
25
26 # setup the layout with sizers
27 sizer = wx.BoxSizer(wx.VERTICAL)
28 sizer.Add(label, 0, wx.ALL, 5)
29 sizer.Add(text, 1, wx.EXPAND|wx.ALL, 5)
30 p.SetSizer(sizer)
31
32 # make the text control be a drop target
33 dt = MyFileDropTarget(text)
34 text.SetDropTarget(dt)
35
36
37 app = wx.PySimpleApp()
38 frm = MyFrame()
39 frm.Show()
40 app.MainLoop()