1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
| from Tkinter import *
class GAME(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("DEMINEUR")
self.pack(fill=BOTH, expand=True)
FrMenu = Frame(self)
FrMenu.pack(side = TOP)
FrM1 = Frame(FrMenu)
FrM1.pack(side = LEFT)
FrM10 = Frame(FrM1)
FrM10.pack(fill=X, pady = 5)
FrM11 = Frame(FrM1)
FrM11.pack(fill=X)
FrM12 = Frame(FrM1)
FrM12.pack(fill=X)
FrM2 = Frame(FrMenu)
FrM2.pack(side = LEFT, padx=20, pady=5)
FrM3 = Frame(FrMenu)#, relief=SUNKEN)
FrM3.pack(side = LEFT, padx=10, pady=10)
separator = Frame(self, relief=SUNKEN, height = 2)
separator.pack(fill=X, padx = 10, pady = 5)
global FrGame
FrGame = Frame(self, relief=SUNKEN, height = 250)
FrGame.pack(side = BOTTOM)
lbl1 = Label(FrM11, text="Taille du plateau : ")
lbl1.pack(side=LEFT, padx=5, pady=0)
global entry1
entry1 = Entry(FrM11, width = 3)
entry1.pack(side =RIGHT, padx=5)#, expand=True)
entry1.insert(5, 10)
lbl2 = Label(FrM12, text="Nombre de mines : ")
lbl2.pack(side=LEFT, padx=5, pady=5)
lblScore = Label(FrM3, text="Score : ")
lblScore.pack(fill = X, padx = 50)
global entry2
entry2 = Entry(FrM12, width = 3)
entry2.pack(side =RIGHT, padx=5)#, expand=True)
entry2.insert(5, "20")
okButton = Button(FrM2, text="OK", command=BoutonOK())
okButton.pack(fill=X)
QuitButton = Button(FrM2, text="Quitter", command=self.quit)
QuitButton.pack(fill=X)
def BoutonOK():
global taille
taille = int(entry1.get())
print taille
for ligne in range(taille):
for colonne in range(taille):
Button(FrGame, text='%s%s' % (ligne, colonne), borderwidth=1, height = 2, width = 2).grid(row=ligne, column=colonne)
root = Tk()
app = GAME(root)
root.mainloop() |
Partager