我使用的是wxpython3.0.2.0、python2.7.13,我使用的是FreeBSD,所以我有一个Unix系统。你知道吗
我的问题是关于wx.DirPickerCtrl文件你知道吗
dir_picker_style = wx.DIRP_DIR_MUST_EXIST | wx.DIRP_USE_TEXTCTRL
dir_picker = wx.DirPickerCtrl(self, wx.ID_ANY, path=path, message="test",
style=dir_picker_style)
如果我的路径超过32个字符(包括反斜杠),那么
value = dir_picker.TextCtrl.Value
值是一个空字符串(u“”),我必须用
dir_picker.GetChildren()[0].SetValue(dir_picker.Path)
一切正常。但是我的同事使用Windows,对于他们来说,一个超过32个字符的路径也可以正常工作。你知道吗
有人知道这个虫子吗?有人知道为什么会这样吗?你知道吗
谢谢你的时间!你知道吗
下面是一个可运行的示例:
#!/usr/bin/env python
import wx
class MyFrame(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, title=title, size=(250,250))
dir_picker_style = wx.DIRP_DIR_MUST_EXIST | wx.DIRP_USE_TEXTCTRL
path1 = "more/than/"
path2 = "more/than/thirtytwo/characters/more"
dir_picker = wx.DirPickerCtrl(self, wx.ID_ANY,
path=path1,
style=dir_picker_style,
pos=(100,50))
statictext1 = wx.StaticText(self, label =
"dir_picker.TextCtrl.Value: ",
pos=(100,90))
control1 = wx.TextCtrl(self, style=wx.TE_READONLY, pos=(100,130))
control1.SetValue(dir_picker.TextCtrl.Value)
control1.Enable(False)
statictext2 = wx.StaticText(self,
label = "dir_picker.GetPath(): ",
pos=(100,170))
control2 = wx.TextCtrl(self, style=wx.TE_READONLY|wx.GROW,
pos=(100,200))
control2.SetValue(dir_picker.GetPath())
control2.Enable(False)
self.Show(True)
app = wx.App(False)
frame = MyFrame(None, 'DirPicker')
app.MainLoop()
当我使用path1时,它将显示在每个textctrl中,但当我使用path2时,它只显示在最后一个textctrl中。(但是当我双击窗口时,path2也会出现在第一个textctrl中。对我来说,这真是一种奇怪的行为。你知道吗
我无法使用wxpython3.0.2.0classic、python2.7和xubuntu16.04复制您的问题。当我尝试访问
TextCtrl.Value
时,会得到一个AttributeError
。你知道吗我尝试改用文档化的API,它调用
GetPath()
,它可以很好地处理长文件夹名:相关问题 更多 >
编程相关推荐