편집 기록

편집 기록
  • 프로필 김선우님의 편집
    날짜2018.06.21

    가위바위보 프로그램을 만들고 싶어요


    프로그램을 만들려고 예제들을 이리저리 모았는데 영 아닌 것 같아서 질문 올려봐요.. 제일 처음 뜨는 오류는 com이 define 된다고 하네요ㅠㅠ

    from tkinter import *
    import random as r
    
    def GBB() :
        global com
        com = random.randint(1,3)
    
    
    def vs() :
        if com==user :
            print("비겼군요! 다시 가위바위보!")
        else com==1 :
            if user==2 :
            print("이겼어요! 1칸 올라갈게요~")
        else com==1 :
            if user==3 :
            print("졌어요..")
        else com==2 :
            if user==1 :
            print("졌어요..")
        else com==2 :
            if user==3 :
            print("이겼어요! 3칸 올라갈게요~")
        else com==3 :
            if user==1 :
            print("이겼어요! 2칸 올라갈게요~")
        else com==3 :
            if user==2 :
            print("졌어요..")
    
    if com==1:
        path1 = PhotoImage(file = "왼쪽가위.gif")
    elif com==2:
        path1 = PhotoImage(file = "왼쪽바위.gif")
    else:
        path1 = PhotoImage(file = "왼쪽보.gif")
    if var.get()==1:
        path2 = PhotoImage(file = "오른쪽가위.gif")
    elif var.get()==2:
        path2 = PhotoImage(file = "오른쪽바위.gif")
    else :
        path2 = PhotoImage(file = "오른쪽보.gif")
    
    lblcom.config(image = path1)
    lblcom.image = path1
    lbluser.config(image = path2)
    lbluser.image = path2
    
    com = r.randint(1,3)
    
    window = tkinter.Tk()
    window.title("가위바위보 게임")
    
    frm_top = Frame(window)
    frm_mid = Frame(window)
    frm_mid1 = Frame(frm_mid)
    frm_mid2 = Frame(frm_mid)
    frm_mid3 = Frame(frm_mid)
    frm_top.pack(side = "top", fill = "both")
    frm_mid.pack(side = "top", fill = "both")
    frm_mid1.pack(side = "top", fill = "both")
    frm_mid2.pack(side = "top", fill = "both")
    frm_mid3.pack(side = "bottom", fill = "both")
    
    lbl1 = Label(frm_top, text = "가위, 바위, 보 중 하나를 선택하세요.")
    lbl2 = Label(frm_mid1, text = "[컴퓨터]")
    lbl3 = Label(frm_mid1, text = "[사용자]")
    
    photo = PhotoImage(file = "첫화면.gif")
    
    lblcom = Label(frm_mid2, image=photo)
    lbluser = Label(frm_mid2, image=photo)
    lblvs = Label(frm_mid2, text = "vs")
    lblresult = Label(frm_mid3, text = "승부의 결과는?")
    var = IntVar()
    
    radio1 = Radiobutton(frm_mid3, text = "가위", variable = var, value = 1, command = select_img)
    radio2 = Radiobutton(frm_mid3, text = "바위", variable = var, value = 2, command = select_img)
    radio3 = Radiobutton(frm_mid3, text = "보", variable = var, value = 3, command = select_img)
    
    window.mainloop()
    
  • 프로필 알 수 없는 사용자님의 편집
    날짜2017.11.28

    가위바위보 프로그램을 만들고 싶어요


    프로그램을 만들려고 예제들을 이리저리 모았는데 영 아닌 것 같아서 질문 올려봐요.. 제일 처음 뜨는 오류는 com이 define 된다고 하네요ㅠㅠ

    from tkinter import *
    import random as r
    
    def GBB() :
        global com
        com = random.randint(1,3)
    
    
    def vs() :
        if com==user :
            print("비겼군요! 다시 가위바위보!")
        else com==1 :
            if user==2 :
            print("이겼어요! 1칸 올라갈게요~")
        else com==1 :
            if user==3 :
            print("졌어요..")
        else com==2 :
            if user==1 :
            print("졌어요..")
        else com==2 :
            if user==3 :
            print("이겼어요! 3칸 올라갈게요~")
        else com==3 :
            if user==1 :
            print("이겼어요! 2칸 올라갈게요~")
        else com==3 :
            if user==2 :
            print("졌어요..")
    
    if com==1:
        path1 = PhotoImage(file = "왼쪽가위.gif")
    elif com==2:
        path1 = PhotoImage(file = "왼쪽바위.gif")
    else:
        path1 = PhotoImage(file = "왼쪽보.gif")
    if var.get()==1:
        path2 = PhotoImage(file = "오른쪽가위.gif")
    elif var.get()==2:
        path2 = PhotoImage(file = "오른쪽바위.gif")
    else :
        path2 = PhotoImage(file = "오른쪽보.gif")
    
    lblcom.config(image = path1)
    lblcom.image = path1
    lbluser.config(image = path2)
    lbluser.image = path2
    
    com = r.randint(1,3)
    
    window = tkinter.Tk()
    window.title("가위바위보 게임")
    
    frm_top = Frame(window)
    frm_mid = Frame(window)
    frm_mid1 = Frame(frm_mid)
    frm_mid2 = Frame(frm_mid)
    frm_mid3 = Frame(frm_mid)
    frm_top.pack(side = "top", fill = "both")
    frm_mid.pack(side = "top", fill = "both")
    frm_mid1.pack(side = "top", fill = "both")
    frm_mid2.pack(side = "top", fill = "both")
    frm_mid3.pack(side = "bottom", fill = "both")
    
    lbl1 = Label(frm_top, text = "가위, 바위, 보 중 하나를 선택하세요.")
    lbl2 = Label(frm_mid1, text = "[컴퓨터]")
    lbl3 = Label(frm_mid1, text = "[사용자]")
    
    photo = PhotoImage(file = "첫화면.gif")
    
    lblcom = Label(frm_mid2, image=photo)
    lbluser = Label(frm_mid2, image=photo)
    lblvs = Label(frm_mid2, text = "vs")
    lblresult = Label(frm_mid3, text = "승부의 결과는?")
    var = IntVar()
    
    radio1 = Radiobutton(frm_mid3, text = "가위", variable = var, value = 1, command = select_img)
    radio2 = Radiobutton(frm_mid3, text = "바위", variable = var, value = 2, command = select_img)
    radio3 = Radiobutton(frm_mid3, text = "보", variable = var, value = 3, command = select_img)
    
    window.mainloop()