在onClick_button事件我有一個if條件來顯示messagedialog如果條件失敗或執行其餘的語句。 基本上,如果條件是檢查textctrl是否有價值或不。如果有值執行else語句。蟒蛇如果條件不能正常工作如預期
這是第一次在tc(textctrls)中帶有msgdlg的任何值,但是當在dlg上單擊確定並在tc中添加一些值時,msgdlg仍然會在執行else時彈出。
非常感謝您的幫助。 我檢查了所有的縮進。
def onClick_button_new(self, event):
self.list_box.Clear()
varstr = "csv"
if [(self.tc1.GetValue() == "") or (self.tc2.GetValue() == "")]:
dial = wx.MessageDialog(None, 'No file specified. Please specify relevant file', 'Error', wx.OK)
dial.ShowModal()
else:
file1 = subprocess.check_output("cut -d '.' -f2 <<< %s" %self.var1, shell = True, executable="bash")
file1type = file1.strip()
print file1type
file2 = subprocess.check_output("cut -d '.' -f2 <<< %s" %self.var2, shell = True, executable="bash")
file2type = file2.strip()
if varstr in (file1type, file2type):
print "yes"
else:
dial = wx.MessageDialog(None, ' Invalid file format. Please specify relevant file', 'Error', wx.OK)
dial.ShowModal()
非常感謝。這工作。 –