-
Notifications
You must be signed in to change notification settings - Fork 0
/
view.py
43 lines (32 loc) · 1.36 KB
/
view.py
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
from tkinter import *
import boardgameidea
import data
def generate():
resMechanics.configure(state='normal')
resMechanics.delete('1.0', END)
mechanics = boardgameidea.draw_mechanics(int(mechanicsNb.get()))
for i in range(len(mechanics)):
title = "### " + mechanics[i] + " ###\n"
decoration = "#"*(len(title)-1) + "\n"
resMechanics.insert(END, decoration + title + decoration + data.mechanics[mechanics[i]] + "\n\n")
resMechanics.configure(state='disabled')
resCategory.set("Category : " + boardgameidea.draw_category())
if __name__ == "__main__":
window = Tk()
window.title("BoardGameIdea")
frameMechEntry = Frame()
frameResCategory = Frame()
Label(frameMechEntry, text='Mechanics number ').pack(side=LEFT, padx=5, pady=5)
mechanicsNb = StringVar()
mechanicsNb.set(3)
box = Spinbox(frameMechEntry, from_=1, to=10, increment=1, textvariable=mechanicsNb, width=5)
box.pack(side=LEFT, padx=30, pady=10)
Button(frameMechEntry, text='Generate', command=generate).pack(side=LEFT, padx=5, pady=5)
resCategory = StringVar()
resCategory.set("Category : ")
Label(frameResCategory, textvariable=resCategory).pack(padx=30, pady=10)
resMechanics = Text(frameResCategory, state='disabled')
resMechanics.pack()
frameMechEntry.pack()
frameResCategory.pack()
window.mainloop()