Example #1
0
 def setUp(self):
     pythoncom.OleInitialize()
Example #2
0
    def register(self):
        try:
            pythoncom.RegisterDragDrop(
                self.hwnd,
                pythoncom.WrapObject(self, pythoncom.IID_IDropTarget,
                                     pythoncom.IID_IDropTarget))
        except pywintypes.com_error:
            global text_list
            text_list = ["COM failure!"]


def update_list():
    listbox.delete(0, END)
    for t in text_list:
        listbox.insert(END, t)
    root.after(100, update_list)


root = Tk()
root.geometry('720x360')
listbox = Listbox(root, font=("Courier", 10, "normal"))
listbox.pack(fill=BOTH, expand=1)
text_list = ['Drag files to this window.']

hwnd = root.winfo_id()
pythoncom.OleInitialize()

root.after(100, update_list)
root.after(200, DropTarget, hwnd)
root.mainloop()