how can evaluate if user pressed
close windowbutton inwx.filedialogwhile opening file?
i have 2 textboxes... 1 showing input filepath , other show output filepath
the output depends on input filepath, since output filepath gonna same directory of input, different name.
sometimes user opens filepath , press close button... , action generates outfile equals _edited.txt shouldn't happen.
i wanna
if user_action == press_the_close_button: outfile = "" else: outfile = infile_edited.txt how can fix that?
i'm using: py 2.7.9 , wx 3.0.2.0
the openfile function
def abrirarquivo(self, event): try: #open filedialog box openfiledialog = wx.filedialog(self, "open", "", "", "text files (*.txt)|*.txt", wx.fd_open | wx.fd_file_must_exist) openfiledialog.showmodal() #get filepath infile = openfiledialog.getpath() #change inputtxtctrl filepath self.inputtxtctrl.setvalue(infile) #if user dont select file in filedialog, how can evaluate , correctly doesnt change outfiletextbox if infile == "": #change textlabel "file not selected.." self.textoprogresso.setlabel("file wasn't loaded properly...") else: #create output filepath outfile = infile[0:len(str(infile))-4] + "_edited.txt" #change outputtxtctrl outfile filepath self.outputtxtctrl.setvalue(outfile) #change progress bar 10% self.barraprogresso.setvalue(10) #change textlabel "file found.." self.textoprogresso.setlabel("file loaded in system...") except exception: print "error_abrir_arquivo"
you need check return wxfiledialog::showmodal. wxid_ok if user pressed ok, , wxid_cancel otherwise.
http://docs.wxwidgets.org/trunk/classwx_file_dialog.html#a04943e4abb27a197a110898d40ddb4f0
Comments
Post a Comment