Matchgame.py - from tkinter import from tkinter import...

This preview shows page 1 - 2 out of 2 pages.

from tkinter import *from tkinter import messageboximport random as r## SETUP ##app = Tk()app.title("Title Goes Here")app['bg'] = "#D3D3D3"## GRID PADDING ##app.rowconfigure(1,pad=10)app.rowconfigure(2,pad=10)app.rowconfigure(3,pad=10)app.rowconfigure(4,pad=10)app.columnconfigure(1,pad=10)app.columnconfigure(2,pad=10)app.columnconfigure(3,pad=10)## DEFS (One for each button) ##def match():tries=0numberList.delete(0,END)number=int(numberEntry.get())numberEntry.delete(0,END)tries2Label['text']="?"if number<1 or number>100:messagebox.showinfo("Error","Value must be from 1 to 100")returnwhile True:compnum=r.randint(1,100)tries+=1numberList.insert(END,"Try %d: %d" %(tries, number))if number==compnum:breaknumberList.see(END)tries2Label['text']="%d"%(tries)def reset():numberList.delete(0,END)numberEntry.delete(0,END)tries2Label['text']="?"

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture