이것은 내 GUI 프로그램에서 내가 문제가있어 누군가가 나를 도울 수 있기를 바란다. 내가 당신이 체크 버튼을 클릭하면, 그것은 텍스트 위젯에 가격을 표시해야한다 할 노력하고있어하지만 난 체크 버튼을 클릭 할 때 나에게 오류 제공 :Python - Tkinter CheckButton 문제
File "E:\Phython\Theater.py", line 147, in update_text if self.matinee_price.get(): AttributeError: 'Checkbutton' object has no attribute 'get'
def matinee_pricing(self):
#Purchase Label
self.theater_label = tkinter.Label(text='Purchase Theater Seats Here', font=('Verdana', 15, 'bold'))
self.theater_label.grid(row=2, column=10)
#Checkbutton
self.matinee_price = BooleanVar()
self.matinee_price = tkinter.Checkbutton(text = '101 \nthru \n105', font=('Verdana', 10), bg='light pink', height=5, width=10,\
variable = self.matinee_price, command = self.update_text)
self.matinee_price.grid(row=5, column=9)
self.result = tkinter.Text(width=10, height=1, wrap = WORD)
self.result.grid(row=20, column=10)
def update_text(self):
price = ''
if self.matinee_price.get():
price += '$50'
self.result.delete(0.0, END)
self.result.insert(0.0, price)
tkinter를 두 번 가져 오지 마세요. 나쁜 습관입니다. 자세한 내용은 [this] (https://stackoverflow.com/questions/47479965/is-there-a-point-to-import-two-different-ways-in-a-program)를 참조하십시오. – Nae