【发布时间】:2014-11-21 06:19:51
【问题描述】:
我有一个代码可以打开一个 word 文档并将照片插入其中。 GUI 部分被证明是非常棘手的。我想要它,这样您就可以拖放文档,然后点击确定,我正在运行的代码将运行并使用从拖放功能获得的文件名...
我已经使用了这个线程的代码:
Wxpython browse for or drag and drop folder
特别是这部分:
class MyFrame(wx.Frame):
def __init__(self, parent,id):
wx.Frame.__init__(self,parent,id,'report maker', size=(300,200))
dt1 = MyFileDropTarget(self)
self.tc_files = wx.TextCtrl(self, wx.ID_ANY)
self.tc_files.SetDropTarget(dt1)
def notify(self, files):
"""Update file in testcontrol after drag and drop"""
self.tc_files.SetValue(files[0])
基本上我已经拖放了一个word doc(使用win32)并想从程序的另一个地方打开它。我不确定如何打开拖放的文件。我已经尝试了很多类似的事情......
doc = word.Documents.Open(notify(tc_files, files[0])
提前感谢您的任何提示!
【问题讨论】:
标签: user-interface drag-and-drop wxpython wxwidgets