【问题标题】:wx.TextCtrl use drag and drop folder to get file pathwx.TextCtrl 使用拖放文件夹获取文件路径
【发布时间】:2013-07-13 20:22:15
【问题描述】:

我目前有一个使用 wx.TextCtrl 的工作应用程序,我在其中打开一个选择文件夹对话框。我想添加拖放功能,这样我就可以拖放一个文件夹来获取文件夹路径,这样我就可以为用户提供这两个选项。 这是我当前代码的一部分:

self.pathindir = wx.TextCtrl(panel, -1, pos=(35, 380), size=(300, 25))
self.buttonin = wx.Button(panel, -1, "Open", pos=(350, 378))
self.buttonin.Bind(wx.EVT_BUTTON, self.openindir)
def openindir(self, event):
    dlg = wx.DirDialog(self, "Choose your input lookup directory:", style=wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON)
    if dlg.ShowModal() == wx.ID_OK:
        global pathindir
        pathindir = dlg.GetPath()
        self.SetStatusText("Your selected input lookup directory is: %s" % pathindir)
    self.pathindir.Clear()
    self.pathindir.WriteText(pathindir)
    dlg.Destroy()

【问题讨论】:

    标签: python drag-and-drop wxpython wx.textctrl


    【解决方案1】:

    你不能按照你的方式去做。您正在使用模态对话框,它会在对话框运行时暂停主应用程序。因此,您无法与主应用程序进行交互。这意味着您不能将路径从对话框拖放到框架。您可以只 Show() 对话框,或者您可以查看 wxPython 演示,其中也有一个示例。

    【讨论】:

      猜你喜欢
      • 2016-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-26
      • 2021-02-07
      • 1970-01-01
      • 2010-10-14
      • 2010-10-23
      相关资源
      最近更新 更多