예제 #1
0
    def __init__(self, parent=None):
        Frame.__init__(self, parent)

        # create game directions
        lab = Label(self, text="Throw the dice!", width=20, height=3)
        lab.pack(side=TOP, fill=BOTH)

        # create a frame for dice throw
        res = Label(self, width=20, height=10)
        res.config(text='hi')
        res.pack(side=TOP)

        # create an entry form for number of dice
        form = Frame(self)
        form.pack(side=TOP, fill=X)

        ent_lab = Label(form, text="How many dice?", width=15)
        ent_lab.pack(side=LEFT)

        ent = Entry(form)
        var = IntVar()
        ent.config(textvariable=var)
        ent.pack(side=LEFT)

        # create a button that executes a roll
        but = Button(form, text="Roll", width=5, height=3)
        but.config(command=(lambda: self.toss(var.get(), res)))
        but.pack(side=RIGHT, fill=X, expand=YES)

        # create a button that quits program
        quit = Quitter(self)
        quit.pack(side=TOP, fill=X, expand=YES)
예제 #2
0
파일: tk_dice.py 프로젝트: ginnypx1/PyDice
	def __init__(self, parent=None):
		Frame.__init__(self, parent)

		# create game directions
		lab = Label(self, text="Throw the dice!", width=20, height=3)
		lab.pack(side=TOP, fill=BOTH)

		# create a frame for dice throw
		res = Label(self, width=20, height=10)
		res.config(text='hi')
		res.pack(side=TOP)

		# create an entry form for number of dice
		form = Frame(self)
		form.pack(side=TOP, fill=X)

		ent_lab = Label(form, text="How many dice?", width=15)
		ent_lab.pack(side=LEFT)

		ent = Entry(form)
		var = IntVar()
		ent.config(textvariable=var)
		ent.pack(side=LEFT)

		# create a button that executes a roll
		but = Button(form, text="Roll", width=5, height=3)
		but.config(command=(lambda: self.toss(var.get(), res)))
		but.pack(side=RIGHT, fill=X, expand=YES)

		# create a button that quits program
		quit = Quitter(self)
		quit.pack(side=TOP, fill=X, expand=YES)
예제 #3
0
    def __init__(self, parent=None):
        Frame.__init__(self, parent)

        # game variables
        self.my_number = random.randint(1, 10)
        self.count = 0

        # create game directions
        lab = Label(self, text="I am thinking of a number 1 to 10...")
        lab.config(width=40, bg='blue', fg='white')
        labl = Label(self, text="Try to guess it in 3 tries!")
        labl.config(width=40, bg='blue', fg='white')
        lab.pack(side=TOP, fill=BOTH, pady=10)
        labl.pack(side=TOP, fill=BOTH, pady=5)

        # create results/hint window
        hint = Label(self, width=40, bg='orange', fg='white')
        hint.pack(side=TOP, fill=BOTH, pady=10)

        # create an entry for for your guess
        form = Frame(self)
        form.pack(side=TOP, fill=BOTH)
        ent_lab = Label(form, text="Your guess: ", width=10)
        ent_lab.pack(side=LEFT, padx=10)
        var = IntVar()
        ent = Entry(form, textvariable=var)
        ent.config(width=10, bg='lemon chiffon', fg='red')
        ent.pack(side=LEFT)

        # creates button to check the guess/ enter game loop
        but = Button(form, text="Check", width=10)
        but.config(command=(lambda: self.turn(var.get(), hint)))
        but.pack(side=RIGHT, fill=X, padx=10)

        # creates play again button
        new_game = Button(self, text='Play Again')
        new_game.config(command=(lambda: self.new_game(hint)))
        new_game.pack(side=TOP, fill=BOTH, expand=YES, padx=10, pady=5)

        # creates quit button
        quit = Quitter(self)
        quit.pack(side=TOP, fill=BOTH)
예제 #4
0
	def __init__(self, parent=None):
		Frame.__init__(self, parent)

		# game variables
		self.my_number = random.randint(1, 10)
		self.count = 0

		# create game directions
		lab = Label(self, text="I am thinking of a number 1 to 10...")
		lab.config(width=40, bg='blue', fg='white')
		labl = Label(self, text="Try to guess it in 3 tries!")
		labl.config(width=40, bg='blue', fg='white')
		lab.pack(side=TOP, fill=BOTH, pady=10)
		labl.pack(side=TOP, fill=BOTH, pady=5)

		# create results/hint window
		hint = Label(self, width=40, bg='orange', fg='white')
		hint.pack(side=TOP, fill=BOTH, pady=10)

		# create an entry for for your guess
		form = Frame(self)
		form.pack(side=TOP, fill=BOTH)
		ent_lab = Label(form, text="Your guess: ", width=10)
		ent_lab.pack(side=LEFT, padx=10)
		var = IntVar()
		ent = Entry(form, textvariable=var)
		ent.config(width=10, bg='lemon chiffon', fg='red')
		ent.pack(side=LEFT)

		# creates button to check the guess/ enter game loop
		but = Button(form, text="Check", width=10)
		but.config(command=(lambda: self.turn(var.get(), hint)))
		but.pack(side=RIGHT, fill=X, padx=10)

		# creates play again button
		new_game = Button(self, text='Play Again')
		new_game.config(command=(lambda: self.new_game(hint)))
		new_game.pack(side=TOP, fill=BOTH, expand=YES, padx=10, pady=5)

		# creates quit button
		quit = Quitter(self)
		quit.pack(side=TOP, fill=BOTH)