2016-04-11 16 views
0

yok edildi tkinter.Some hatası her zaman bu kodu çalıştırdığımda her zaman gösteriyorum. Sadece basit bir python projesi için bir gui istedim. hataları widgetName, self._w) + ekstra + self._options (cnf)) şunlardır _tkinter.TclError: çağırmak olamaz "düğmesi" komutu: Uygulama tahrip edilmiş"button" komutunu çağırdı: uygulama

import tkinter 
import os 


MASTER = tkinter.Tk() 
REVIEW_CONTENT_RAW = [] 
REVIEWS_SEL_FILM = [] 







def getReviewFileName(filmNum): 
    basepath = os.path.abspath("..").split("/src") 
    filepath = basepath[0] + "/resources/reviews" 
    filename = filepath + "/review_film" + str(filmNum) +".txt"; 
    return filename 


def loadReviewContents(): 
    global REVIEW_CONTENT 
    for i in range(1,6): 
     f = open(getReviewFileName(i), mode='r') 
     fileContent = f.read().split("\n") 
     REVIEW_CONTENT_RAW.append(fileContent) 

def getFilmName(filmIndex): 
    content = REVIEW_CONTENT_RAW[filmIndex] 
    fTitle = content[0] 
    return fTitle 

def getReviewListByMovie(filmIndex): 
    reviewList = REVIEW_CONTENT_RAW[filmIndex] 
    return reviewList 

def setReviewsForSelectedFilm(filmIndex): 
    global REVIEWS_SEL_FILM 
    REVIEWS_SEL_FILM = getReviewListByMovie(filmIndex) 


def getReviewsForSelectedFilm(): 
    return REVIEWS_SEL_FILM 

def populateUI(): 
    loadReviewContents() 
    tkinter.Button(MASTER, text=getFilmName(0), 
        command=buttonClickActionforFilm1).grid(row=1, column=0, sticky=tkinter.W, pady=4) 
    tkinter.Button(MASTER, text=getFilmName(1), 
        command=buttonClickActionforFilm2).grid(row=2, column=0, sticky=tkinter.W, pady=4) 
    tkinter.Button(MASTER, text=getFilmName(2), 
        command=buttonClickActionforFilm3).grid(row=3, column=0, sticky=tkinter.W, pady=4) 
    tkinter.Button(MASTER, text=getFilmName(3), 
        command=buttonClickActionforFilm4).grid(row=4, column=0, sticky=tkinter.W, pady=4) 
    tkinter.Button(MASTER, text=getFilmName(4), 
        command=buttonClickActionforFilm5).grid(row=5, column=0, sticky=tkinter.W, pady=4) 
    tkinter.mainloop() 

    return getReviewsForSelectedFilm() 


def buttonClickActionforFilm1(): 
    global MASTER 
    setReviewsForSelectedFilm(0) 
    MASTER.destroy() 

def buttonClickActionforFilm2(): 
    setReviewsForSelectedFilm(1) 
    MASTER.destroy() 

def buttonClickActionforFilm3(): 
    setReviewsForSelectedFilm(2) 
    MASTER.destroy() 

def buttonClickActionforFilm4(): 
    setReviewsForSelectedFilm(3) 
    MASTER.destroy() 

def buttonClickActionforFilm5(): 
    setReviewsForSelectedFilm(4) 
    MASTER.destroy() 



x = populateUI() 
print(x) 

cevap

1

İşte kusurlu hattı (var ler) MASTER.destroy()

sen dolayısıyla burada yöntem adı destroy()MASTER kök Tk() pencere yok ediyorlar, vb widget kolları GUI olay iplik, komutları sırayla, içinde Yani, düğmeler komutları çağırmak olamaz .

+0

Çok teşekkür ederim. Ama bu satırı yorumlamayı denedim ama program çalışmadı –