【发布时间】:2019-01-28 07:45:57
【问题描述】:
This is how the output of my GUI looks if I run the program right now 我使用 xrc 为我的程序制作了一个 gui,但我不知道文件路径字符串存储在 wxFilePickerCtrl 类按钮上的什么位置
示例和教程在线显示命令,例如使用 GetPath() 当然更改变量以适合但在框架中的 filepicker1 中似乎没有该属性,我可以使用按钮选择文件正常执行按钮也可以,一直在使用简单的打印命令对其进行测试。感谢您的帮助
!/usr/bin/python
第一行是这样它可以在不使用 python 命令的情况下运行
默认导入
import os
import sys
wxdiag 和 src 需要这个导入行
import wx
from wx import xrc
这个应用是加载xrc文件
class MyApp(wx.App):
def init_frame(self):
self.res = xrc.XmlResource("test.xrc")
self.frame = self.res.LoadFrame(None, "framemain")
self.panel = xrc.XRCCTRL(self.frame, "panel1")
self.text1 = xrc.XRCCTRL(self.panel, "text1")
self.filepicker1 = xrc.XRCCTRL(self.panel, "filepicker1")
self.button1= xrc.XRCCTRL(self.panel, "button1")
def OnInit(self):
self.init_frame()
self.Bind(wx.EVT_BUTTON, self.OnButton_gobutton, id=xrc.XRCID('button1'))
#--------ListCtrl colums
#--------call populate functions
#--------this gets the main frame to show
self.frame.Show()
return True
def OnButton_gobutton(self, evt):
print "hello"
这会加载主框架和每个后续元素,第一行没有是因为第一框架有父框架
if __name__=="__main__":
app= MyApp(False)
app.MainLoop()
现在就在这条线上
defOnButton_gobutton(self,evt):
line 我设置了一个打印命令来确认按钮是否正常工作,但是在这个操作中,我想从我在 xrc 上设置的 wxFilePickerCtrl 类按钮获取文件路径字符串。目标是选择一个文件,当我单击 GUI 按钮时,我应该对所选文件执行其他操作,但我找不到所选文件的#the 字符串的存储位置。
【问题讨论】: