2017-04-10 75 views
1

繼承人的相關代碼:GUI凍結當我使用「獲得」

def opencommand(): 

    number=entry1.get() 

    mydata = csv.reader(open('result.csv','rU')) 

    card_name = [] 

    for row in mydata: 
     card_name.append(row[9]) 


    r=0 
    while r<number: 
     randomnumbers=[] 
     counter=0 
     while counter<5: 

      randomnumbers.append(randint(1,90)) 
      counter=counter+1 

     pack1=[] 
     p=0 
     while p<5: 
      pack1.append(card_name[randomnumbers[p]]) 
      p=p+1 
     print pack1 
     r=r+1 

和....

numpac = Label(options_frame,text='Number of Packs') 
entry1 = Entry(options_frame) 
numpac.grid(row=0,column=0,sticky=E) 
entry1.grid(row=0,column=1) 


openbutton = Button(options_frame, text='Open',command=opencommand) 
openbutton.grid(row=1,column=0,columnspan=2) 

誰能告訴我,爲什麼當我包括獲取部分凍結,但如果我把它設置爲一個固定的數字我不?

繼承人,因爲它說孤單得多代碼一些文字:vkjberbverihjbvjerhbvjhebvjhervhjberjvhberjhbverhjbvjlerbvjlerbvljerbverjlhbvrejlvhberljvhberljvhberljvbherjlvhberjvlhbevljerbvljerbvlerjhbvelrjbvlerjhbvlejrhbv

回答

2

因爲get()返回一個字符串,而不是數量。你需要轉換它:

number = int(entry1.get()) 
+0

非常感謝你 –