【发布时间】:2012-05-13 21:26:51
【问题描述】:
我在使用 if 和 else 语句时遇到了一些问题,我使用多个 wx.FileDialog 语句来更改文件类型,我允许用户根据选择的单选按钮进行选择。所以问题是我不断收到一个 UnboundLocalError ,我的局部变量分配给在分配之前引用的 FileDialog 语句。这是我的代码:
def OnOpen(self, e):
if self.radioButton1.GetValue():
opendialog = wx.FileDialog(self, "Choose a file", "", "", "*.txt", wx.MULTIPLE)
if self.radioButton2.GetValue():
opendialog = wx.FileDialog(self, "Choose a file", "", "", "*.csv", wx.MULTIPLE)
else:
selectdialog = wx.MessageDialog(self,"Select process", "Warn", wx.OK)
selectdialog.ShowModal()
selectdialog.Destroy()
if opendialog.ShowModal() == wx.ID_OK:
#More code to file path information
【问题讨论】:
-
你的意思是“elif self.radioButton2...”吗?
-
@acattle,我不是这个意思,但我应该有。我认为这也可以解决我的问题。谢谢你这么说。