Python 파이썬 거북이경주예제 질문입니다.

지지@Google의 이미지

거북이경주 예제보고 따라했는데 경주 시작전에 누가 1등 예측하는 값을 받고 경기진행 후, 1등을 맞췄는지 틀렸는지 결과창 이렇게 추가하고싶어서 해보는데 잘 안됩니다. 어디를 수정해야하는지 알려주세요.

import turtle as t
import random

#경기장 그리기

t.speed(10)
t.penup()
t.goto(-300,250)

for step in range(10):
t.write(step,align='center')
t.right(90)
t.forward(10)
t.pendown()

for line in range(8):
t.forward(30)
t.penup()
t.forward(30)
t.pendown()

t.penup()
t.backward(490)
t.penup()
t.left(90)
t.forward(20)

tu1=t.Turtle()
tu1.color('red')
tu1.shape('turtle')
tu1.penup()
tu1.goto(-300,190)
tu1.pendown()

tu2=t.Turtle()
tu2.color('blue')
tu2.shape('turtle')
tu2.penup()
tu2.goto(-300,130)
tu2.pendown()

tu3=t.Turtle()
tu3.color('green')
tu3.shape('turtle')
tu3.penup()
tu3.goto(-300,70)
tu3.pendown()

#ratiobox생성

from tkinter import *
from tkinter import messagebox

root = Tk()
root.title("choice")
root.geometry("300x170")
root.resizable(False,False)

def your_choice():
yn = 'not selected'
global Radiovar #전역변수 선언

if Radiovar.get() == 1:
yn = "no.1 is selected"
elif Radiovar.get() == 2:
yn = "no.2 is selected"
elif Radiovar.get() == 3:
yn = "no.3 is selected"

lbl2.configure(text="your choice: "+yn)
messagebox.showinfo("your choice",yn)

lbl = Label(root, text="""Which turtle do you think will win?""")
lbl.pack()

yn = StringVar()

Radiovar = IntVar()
Radiovar = IntVar()
Radiovar = IntVar()

Radio_button1 = Radiobutton(text="no.1", variable = Radiovar, value=1)
Radio_button2 = Radiobutton(text="no.2", variable = Radiovar, value=2)
Radio_button3 = Radiobutton(text="no.3", variable = Radiovar, value=3)

Radio_button1.pack()
Radio_button2.pack()
Radio_button3.pack()

btn = Button(root, text="choice",command=your_choice,width=5,height=1)
btn.pack()

lbl2 = Label(root,text="your choice : ")
lbl2.pack()

root.mainloop()
#root.destroy
#root.protocol("WM_DELETE_WINDOW", lambda: messagebox.showinfo("종료 메시지", "종료합니다."))

#경주시작
for go in range(70):
sp1=tu1.forward(random.randint(1,8))
sp2=tu2.forward(random.randint(1,8))
sp3=tu3.forward(random.randint(1,8))

#결과창

window = Tk()
window.title("result")
window.geometry("300x170")
window.resizable(0,0)

corLab1 = Label(window, text="Correct");
faiLab1 = Label(window, text="fail");

if Radiovar==1:
if sp1>sp2 and sp1>sp3 :
corLab1.pack();
else:
faiLab1.pack();
elif Radiovar==2:
if sp2>sp1 and sp2>sp3 :
corLab1.pack();
else:
faiLab1.pack();
else:
if sp3>sp1 and sp3>sp2 :
corLab1.pack();
else:
faiLab1.pack();

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.