import tkinter as tk
window=tk.Tk()
window.geometry("800x600+50+100")
import random as rd
window.title('Correct Score')
write=tk.Label(window,text='Welcome',fg='blue',bg='green',font='Times 22 ') .place(x=45, y=10)
write2=tk.Label(window,text='Correct Score Outcome Predictor') .place(x=10, y=50)
button2=tk.Button(window,text='click and guess',command=guess) .place(x=360, y=350)
button1=tk.Button(window,text='Close Window',command=window.quit) .place(x=10, y=570)
teamname1=tk.Entry(window) .place(x=230, y=300)
teamname2=tk.Entry(window) .place(x=470, y=300)
def guess():
a=rd.randint(0,5)
b=rd.randint(o,5)
result.config()
result=tk.Label(window, text="",fg='blue',font='Times 22 ') .place(x=245, y=250)
window.mainloop()
result diye bir değişken yok ki def guess() tanımlandığı sırada? a'yı b'yi de hiç bir yere atamıyorsun. b = rd.randint(o, 5) yazmışsın 0 yerine.import tkinter as tk
import random as rd
def guess():
a=rd.randint(0,5)
b=rd.randint(0,5)
result.config()
window = tk.Tk()
window.geometry("800x600+50+100")
window.title('Correct Score')
write = tk.Label(window,text='Welcome',fg='blue',bg='green',font='Times 22 ') .place(x=45, y=10)
write2 = tk.Label(window,text='Correct Score Outcome Predictor') .place(x=10, y=50)
result=tk.Label(window, text="",fg='blue',font='Times 22 ') .place(x=245, y=250)
button2 = tk.Button(window,text='click and guess',command=guess) .place(x=360, y=350)
button1 = tk.Button(window,text='Close Window',command=window.quit) .place(x=10, y=570)
teamname1 = tk.Entry(window) .place(x=230, y=300)
teamname2 = tk.Entry(window) .place(x=470, y=300)
window.mainloop()
resultdiye bir değişken yok kidef guess()tanımlandığı sırada? a'yı b'yi de hiç bir yere atamıyorsun. b = rd.randint(o, 5) yazmışsın 0 yerine.
import tkinter as tk
window=tk.Tk()
window.geometry("800x600+50+100")
import random as rd
window.title('Correct Score')
write=tk.Label(window,text='Welcome',fg='blue',bg='green',font='Times 22 ') .place(x=45, y=10)
write2=tk.Label(window,text='Correct Score Outcome Predictor') .place(x=10, y=50)
button2=tk.Button(window,text='click and guess',command=guess) .place(x=360, y=350)
button1=tk.Button(window,text='Close Window',command=window.quit) .place(x=10, y=570)
teamname1=tk.Entry(window) .place(x=230, y=300)
teamname2=tk.Entry(window) .place(x=470, y=300)
result=tk.Label(window, text="",fg='blue',font='Times 22 ') .place(x=245, y=250)
def guess():
a=rd.randint(0,5)
b=rd.randint(o,5)
result.()
window.mainloop()
olmadi hocamPython:import tkinter as tk import random as rd def guess(): a=rd.randint(0,5) b=rd.randint(0,5) result.config() window = tk.Tk() window.geometry("800x600+50+100") window.title('Correct Score') write = tk.Label(window,text='Welcome',fg='blue',bg='green',font='Times 22 ') .place(x=45, y=10) write2 = tk.Label(window,text='Correct Score Outcome Predictor') .place(x=10, y=50) result=tk.Label(window, text="",fg='blue',font='Times 22 ') .place(x=245, y=250) button2 = tk.Button(window,text='click and guess',command=guess) .place(x=360, y=350) button1 = tk.Button(window,text='Close Window',command=window.quit) .place(x=10, y=570) teamname1 = tk.Entry(window) .place(x=230, y=300) teamname2 = tk.Entry(window) .place(x=470, y=300) window.mainloop()
Kodu yazarken bir fonksiyon tanımlamışsınız, içerisinde bir değişken kullanıyor ama bu değişkeni de tanımladığınız fonksiyondan sonra tanımlamışsınız. Kod çalıştırılırken yukarıdan aşağı doğru çalıştırılır. Buna dikkat ederek yazın kodunuzu.
Bende bu hâli çalıştı. Bir deneyin bakalım.
Ne yapmaya çalıştığınızı bilmediğim için programın işlevselliğinin çalışıp çalışmadığına bakmadım. Bende en azından uygulama penceresi açılır hâle geldi bu şekilde yapınca.
import tkinter as tk
import random as rd
def guess():
a=rd.randint(0,5)
b=rd.randint(0,5)
result.config(text=a+''+against+''+b)
window = tk.Tk()
window.geometry("800x600+50+100")
window.title('Correct Score')
write = tk.Label(window,text='Welcome',fg='blue',bg='green',font='Times 22 ') .place(x=45, y=10)
write2 = tk.Label(window,text='Correct Score Outcome Predictor') .place(x=10, y=50)
result=tk.Label(window, text="",fg='blue',font='Times 22 ') .place(x=245, y=250)
button2 = tk.Button(window,text='click and guess',command=guess) .place(x=360, y=350)
button1 = tk.Button(window,text='Close Window',command=window.quit) .place(x=10, y=570)
teamname1 = tk.Entry(window) .place(x=230, y=300)
teamname2 = tk.Entry(window) .place(x=470, y=300)
window.mainloop()
Kod:import tkinter as tk import random as rd def guess(): a=rd.randint(0,5) b=rd.randint(0,5) result.config(text=a+''+against+''+b) window = tk.Tk() window.geometry("800x600+50+100") window.title('Correct Score') write = tk.Label(window,text='Welcome',fg='blue',bg='green',font='Times 22 ') .place(x=45, y=10) write2 = tk.Label(window,text='Correct Score Outcome Predictor') .place(x=10, y=50) result=tk.Label(window, text="",fg='blue',font='Times 22 ') .place(x=245, y=250) button2 = tk.Button(window,text='click and guess',command=guess) .place(x=360, y=350) button1 = tk.Button(window,text='Close Window',command=window.quit) .place(x=10, y=570) teamname1 = tk.Entry(window) .place(x=230, y=300) teamname2 = tk.Entry(window) .place(x=470, y=300) window.mainloop()
Bu kodda pencereyi açtığımız zaman click and guess e basınca butonun biraz ustunde sayilar çıkmalı ama olmuyor
Kaba dilde dersek config isildamiyor hocam komut gibi gorunmuyor
import tkinter as tkimport random as rd
def guess():
a = rd.randint(0, 5)
b = rd.randint(0, 5)
result.config(text=str(a) + ' ' + 'against' + ' ' + str(b))
window = tk.Tk()
window.geometry("800x600+50+100")
window.title('Correct Score')
write = tk.Label(window, text='Welcome', fg='blue', bg='green', font='Times 22 ').place(x=45, y=10)
write2 = tk.Label(window, text='Correct Score Outcome Predictor').place(x=10, y=50)
result = tk.Label(window, text="", fg='blue', font='Times 22 ')
result.place(x=245, y=250)
button2 = tk.Button(window, text='click and guess', command=guess).place(x=360, y=350)
button1 = tk.Button(window, text='Close Window', command=window.quit).place(x=10, y=570)
teamname1 = tk.Entry(window).place(x=230, y=300)
teamname2 = tk.Entry(window).place(x=470, y=300)
window.mainloop()
Bu sitenin çalışmasını sağlamak için gerekli çerezleri ve deneyiminizi iyileştirmek için isteğe bağlı çerezleri kullanıyoruz.