-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfallah.py
More file actions
98 lines (84 loc) · 5.91 KB
/
fallah.py
File metadata and controls
98 lines (84 loc) · 5.91 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
from tkinter import *
from tkinter import ttk, filedialog
from PIL import Image, ImageTk
class MyGame():
'''
Do not change bg and fg2 in the theme of Add Game or Update Game or you'll see
a different color of combobox in one of them.
'''
def __init__(self, root, bg='#333333', fg='orange', fg2='orange', text="Game Info", font=('Times', 20), bd=1, labelanchor='n', relief='raised', abg="orange", afg="#333333", padx=5, pady=5):
self.root = root
self.frame = LabelFrame(self.root, bg=bg, fg=fg2, text=text, font=font, labelanchor=labelanchor)
self.l_name = Label(self.frame, text="Game Name: ", bg=bg, fg=fg, font=font, bd=bd, padx=padx*2, pady=pady*2)
self.l_company = Label(self.frame, text="Company: ", bg=bg, fg=fg, font=font, bd=bd, padx=padx, pady=pady)
self.l_age = Label(self.frame, text="Age Classification: ", bg=bg, fg=fg, font=font, bd=bd, padx=padx, pady=pady)
self.l_price = Label(self.frame, text="Price: ", bg=bg, fg=fg, font=font, bd=bd, padx=padx, pady=pady)
self.l_console_type = Label(self.frame, text="Console: ", bg=bg, fg=fg, font=font, bd=bd, padx=padx, pady=pady)
self.l_stock = Label(self.frame, text="Amount in stock: ", bg=bg, fg=fg, font=font, bd=bd, padx=padx, pady=pady)
self.l_address = Label(self.frame, text="Picture Address: ", bg=bg, fg=fg, font=font, bd=bd, padx=padx, pady=pady)
self.e_name = Entry(self.frame, bg=bg, fg=fg2, font=font, bd=bd, insertbackground=fg2)
self.e_company = Entry(self.frame, bg=bg, fg=fg2, font=font, bd=bd, insertbackground=fg2)
self.e_age = ttk.Combobox(self.frame, values=['', '+3', '+7', '+10', '+12', '+15', '+17', '+25'], foreground=fg2, justify='center', font=font, state='readonly')
self.e_price = Entry(self.frame, bg=bg, fg=fg2, font=font, bd=bd, insertbackground=fg2)
self.e_console_type = Entry(self.frame, bg=bg, fg=fg2, font=font, bd=bd, insertbackground=fg2)
self.e_stock = Entry(self.frame, bg=bg, fg=fg2, font=font, bd=bd, insertbackground=fg2)
self.e_address = Button(self.frame, bg=bg, fg=fg2, font=font, bd=bd, activebackground=abg, activeforeground=afg, text='...', command=self.seak_picture)
self.file_address = None
self.l_name .grid(row=1, column=1, sticky='news', padx=padx, pady=pady)
self.l_company .grid(row=3, column=1, sticky='news', padx=padx, pady=pady)
self.l_age .grid(row=5, column=1, sticky='news', padx=padx, pady=pady)
self.l_price .grid(row=7, column=1, sticky='news', padx=padx, pady=pady)
self.l_console_type .grid(row=9, column=1, sticky='news', padx=padx, pady=pady)
self.l_stock .grid(row=11, column=1, sticky='news', padx=padx, pady=pady)
self.l_address .grid(row=13, column=1, sticky='news', padx=padx, pady=pady)
self.e_name .grid(row=1, column=3, sticky='news', padx=padx, pady=pady)
self.e_company .grid(row=3, column=3, sticky='news', padx=padx, pady=pady)
self.e_age .grid(row=5, column=3, sticky='news', padx=padx, pady=pady)
self.e_price .grid(row=7, column=3, sticky='news', padx=padx, pady=pady)
self.e_console_type .grid(row=9, column=3, sticky='news', padx=padx, pady=pady)
self.e_stock .grid(row=11, column=3, sticky='news', padx=padx, pady=pady)
self.e_address .grid(row=13, column=3, sticky='news', padx=padx, pady=pady)
style = ttk.Style(self.root)
# style.theme_use('clam')
style.theme_create(f'madval_style{self}', parent='alt',settings = {'TCombobox':{'configure':{'selectbackground': bg,'fieldbackground': bg,'background': bg}}})
style.theme_use(f'madval_style{self}')
style.map('TCombobox', fieldbackground=[('readonly', bg)])
style.map('TCombobox', selectbackground=[('readonly', bg)])
style.map('TCombobox', selectforeground=[('readonly', fg2)])
style.configure("Treeview",background=bg,foreground=fg2,rowheight=32,fieldbackground=bg, font=('Consalos', 16))
style.configure("Treeview.Heading", background="#222222", foreground="cyan", font=('Consalos', 18))
style.map("Treeview",background=[('selected', fg)])
style.map("Treeview",foreground=[('selected', bg)])
def reset(self):
self.e_name .delete(0, END)
self.e_company .delete(0, END)
self.e_age .config(state='normal')
self.e_age .delete(0, END)
self.e_age .config(state='readonly')
self.e_price .delete(0, END)
self.e_console_type .delete(0, END)
self.e_stock .delete(0, END)
self.file_address = None
self.e_address .config(text='...', image='')
def seak_picture(self):
self.file_address = filedialog.askopenfilename()
self.set_picture()
def set_picture(self):
try:
if self.file_address in [None, (), '']:
self.file_address = None
self.e_address.config(text='...', image='')
return
self.img = Image.open(self.file_address)
self.img = self.img.resize((200, 200))
self.img = ImageTk.PhotoImage(self.img)
self.e_address.config(image=self.img)
except:
self.file_address = None
self.e_address.config(text='...', image='')
def grid(self, *args, **kwargs):
self.frame.grid(*args, **kwargs)
def place(self, *args, **kwargs):
self.frame.place(*args, **kwargs)
def pack(self, *args, **kwargs):
self.frame.pack(*args, **kwargs)