Пример #1
0
def main():
    #create app window
    win = GraphWin("Dice Roller")
    win.setCoords(0, 0, 10, 10)
    win.setBackground('green2')

    #draw interface widgets
    die1 = DieView(win, Point(3, 7), 2)
    die2 = DieView(win, Point(7, 7), 2)
    rollButton = Button(win, Point(5, 4.5), 6, 1, 'Roll Dice')
    rollButton.activate()
    quitButton = Button(win, Point(5, 1), 2, 1, 'Quit')

    #event loop
    pt = win.getMouse()
    while not quitButton.clicked(pt):
        if rollButton.clicked(pt):
            value1 = randrange(1, 7)
            die1.setValue(value1)
            value2 = randrange(1, 7)
            die2.setValue(value2)
            quitButton.activate()
        pt = win.getMouse()

    #close shope
    win.close()
Пример #2
0
def main():
    # create the application window
    win = GraphWin("Dice Roller")
    win.setCoords(0, 0, 10, 10)
    win.setBackground("CadetBlue1")

    # draw the interface widgets
    die1 = DieView(win, Point(3, 7), 2)
    die2 = DieView(win, Point(7, 7), 2)
    rollButton = Button(win, Point(5, 4.5), 6, 1, "Roll Dice")
    rollButton.activate()
    quitButton = Button(win, Point(5, 1), 2, 1, "Quit")

    # event loop
    pt = win.getMouse()
    while not quitButton.clicked(pt):
        if rollButton.clicked(pt):
            value1 = randrange(1, 7)
            die1.setValue(value1)
            value2 = randrange(1, 7)
            die2.setValue(value2)
            quitButton.activate()
        pt = win.getMouse()

    # close up shop
    win.close()
Пример #3
0
 def createDice(self, center, size):
     center.move(-3 * size, 0)
     self.dice = []
     for i in range(2):
         view = DieView(self.win, center, size)
         self.dice.append(view)
         center.move(1.5 * size, 0)
Пример #4
0
 def drawDice(self):
     self.dieOne = DieView(self.win, Point(2.9, 3), 0.5)
     self.dieTwo = DieView(self.win, Point(3.5, 3.6), 0.5)
     self.dieThree = DieView(self.win, Point(4.1, 3), 0.5)