테스트 사이트 - 개발 중인 베타 버전입니다

파이썬 질문!

강강진호 3년 전 조회 2,386

from tkinter import *
window = Tk()
window.title("My Calculator")
display = Entry(window,bg="yellow", font='30')
display.grid(row=0,column=0, columnspan='5')


button_list =  [
'7', '8', '9', '/', 'C',
'4', '5', '6', '*', '웹사이트',
'1', '2', '3', '-', '도형',
'0', '.', '=', '+', '연락처' ]


def click(key):
    if key == "=":
        result = eval(display.get())
        s = str(round(result,2))
        display.insert(END, "=" + s)
    elif key == "C":
        display.delete(0,END)
    elif key == "연락처":
        infile=open("phones.txt","r")
        lines=infile.read()
        print(lines)
        infile.close()
    elif key == "웹사이트":
        from tkinter import *

        root=Tk()
        root.title("My calculator")
        def process1():
            child=Toplevel(root)
            child.title("웹사이트")
            button=Button(child,text="닫기",command=child.destroy)
            button.pack(padx=100,pady=50)
        button=Button(root.text="웹사이트",command=process1)
        button.pack(padx=100,pady=50)
        window.mainloop()
    else:
        display.insert(END, key)
   


r=1 #grid의 행위치 변수  1,2,3,4
c=0 #grid의 열위치 변수  0,1,2,3,4
  
for button_text in button_list:
    def process(t=button_text):
        click(t)
    Button(window,text=button_text,font='50',command=process).grid(row=r,column=c,sticky='ew')
    c+=1
    if c>4:
        c=0
        r+=1

 

실행하면 expression cannot contain assignment,perhaps you meant "==" ? 라고 나오는데 어디가 문제일까요?  오류는 elif 웹사이트 부분에서 나와요

댓글을 작성하려면 로그인이 필요합니다.

답변 1개

3년 전
로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인