python - Close TopLevel window after command -


i'm doing simple compressor in python school assignment, problem here when enter name of file, little window has appear button execute tar command, want window close after command dont know why, here's code

def crea_arxiu():     global aux     if v.get() 1 or v.get() 2 or v.get() 3 or v.get() 4:         f = open('fitxers.txt','w')         in range(llista2.size()):             f.write(llista2.get(i)+'\n')         f.close()         print 'arxius comprimir:',llista2.size()           obre_finestra()          if aux 1:             print 'aux true'             subprocess.call(['rm','fitxers.txt'])     else:          print 'escolleix una opcio' #aquest mètode crea mostra la pantalla per guardar el nom #i la finestra amb la comanda que executara def obre_finestra():     global aux     ruta_text = stringvar()      finestra2=toplevel(finestra)     finestra2.minsize(0,0)     finestra2.title('comanda executar:')     ruta = label(finestra2, width=60, relief=sunken, textvariable=ruta_text)     ruta.pack(side=left)     boto = button(finestra2, text = 'executar', command = lambda: executar_commanda(nom_arxiu, tipus_comp))     boto.pack(side = right)     nom_arxiu = tkfiledialog.asksaveasfilename(title='guardar com')      if v.get() 1:         tipus_comp = 'cf'         nom_arxiu = nom_arxiu+'.tar'     elif v.get() 2:         tipus_comp = 'czf'         nom_arxiu = nom_arxiu+'.tgz'     elif v.get() 3:         tipus_comp = 'cjf'         nom_arxiu = nom_arxiu+'.tbz'     elif v.get() 4:         tipus_comp = 'cjf'         nom_arxiu = nom_arxiu+'.txz'     ruta_text.set('tar '+tipus_comp+' '+nom_arxiu+' '+'fitxers de la llista')     if aux 1:         finestra2.destroy()  def executar_commanda(nom,tipus_comp):     global aux      aux = 1     subprocess.call(['tar',tipus_comp,nom,'-t','fitxers.txt']) 

the order of functions is: crea_arxiu -> obre_finestra (summons asksaveasfilename , little window) , , when press 'execute' executar_commanda , want window killed

before entering name of file: http://imgur.com/kogxie3

after name given: http://imgur.com/zdb5bbs

so @ end want path window closed after de 'executar' button, thank guys , sry english not being ^^'


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -