Skip to content

Commit ab52c26

Browse files
committed
[STAGE] Started working on GUI (#75)
1 parent 4298c24 commit ab52c26

File tree

4 files changed

+90
-1
lines changed

4 files changed

+90
-1
lines changed

42PyChecker.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ def main():
203203
with open(root_path + '/.github/LICENSE.lesser', 'r') as file:
204204
print(file.read())
205205
sys.exit()
206+
# @todo: Fix error when log option not provided
206207
# @todo: Check for log file size and delete it if needed.
207208
logging.basicConfig(filename='42PyChecker.log', level=args.log.upper(), format='%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s', datefmt='%d-%m-%Y:%H:%M:%S')
208209
logging.info("************************************************************")
@@ -236,7 +237,10 @@ def main():
236237
if not platform.system() == "Windows":
237238
try:
238239
print_header()
239-
main()
240+
from PyChecker.window import Application
241+
app = Application()
242+
app.create_window()
243+
#main()
240244
except KeyboardInterrupt:
241245
sys.exit(1)
242246
else:

PyChecker/favicon.ico

45.2 KB
Binary file not shown.

PyChecker/logo.gif

178 KB
Loading

PyChecker/window.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
"""
2+
Copyright (C) 2018 Jules Lasne <jules.lasne@gmail.com>
3+
See full notice in `LICENSE'
4+
"""
5+
6+
from tkinter import *
7+
import os
8+
import sys
9+
from tkinter import filedialog
10+
11+
12+
class Checkbar(Frame):
13+
def __init__(self, parent=None, picks=[], side=LEFT, anchor=W):
14+
Frame.__init__(self, parent)
15+
self.vars = []
16+
for pick in picks:
17+
var = IntVar()
18+
chk = Checkbutton(self, text=pick, variable=var)
19+
chk.pack(side=side, anchor=anchor, expand=YES)
20+
self.vars.append(var)
21+
22+
def state(self):
23+
return map((lambda var: var.get()), self.vars)
24+
25+
26+
class Application():
27+
def __init__(self):
28+
self.window = Tk()
29+
30+
def close_window(self):
31+
self.window.destroy()
32+
sys.exit()
33+
34+
def close_window_escape(self, event):
35+
self.window.destroy()
36+
sys.exit()
37+
38+
def get_project_path(self):
39+
self.path = filedialog.askdirectory()
40+
print(self.path)
41+
42+
def callback_project_name_changed(self, *args):
43+
# @todo: Make groups like when you tick `tests` it ticks all the tests
44+
self.project_selected = self.project.get()
45+
if self.project_selected == "other":
46+
# @todo: whitelist/blacklist for options
47+
self.options = Checkbar(self.window, ['author', 'norme', 'Makefile'])
48+
self.options.pack(side=LEFT)
49+
50+
if self.project_selected == "42commandements":
51+
self.options = None
52+
53+
if self.project_selected == "libft":
54+
self.options = Checkbar(self.window, ['author', 'forbidden-functions', 'makefile', 'norme', 'static', 'extra', 'required', 'bonus', 'benchmark', 'tests', 'libftest', 'maintest', 'moulitest', 'fillit-checker', 'libft-unit-test'])
55+
self.options.pack(side=LEFT)
56+
57+
if self.project_selected == "fillit":
58+
self.options = Checkbar(self.window, ['author', 'forbidden-functions', 'makefile', 'norme', 'tests', 'fillit-checker'])
59+
self.options.pack(side=LEFT)
60+
61+
def start(self):
62+
if self.options != None:
63+
print(list(self.options.state()))
64+
65+
def create_window(self):
66+
self.window.title("42PyChecker")
67+
self.window.minsize(width=800, height=800)
68+
# @todo: Set a icon for app image
69+
#self.window.iconbitmap(os.path.dirname(os.path.realpath(__file__)) + "/favicon.ico")
70+
# @todo: Find a way to loop through gif frames to have animated logo
71+
logo = PhotoImage(file=os.path.dirname(os.path.realpath(__file__)) + "/logo.gif")
72+
Label(self.window, image=logo).pack()
73+
Button(self.window, text="Select Project Path", width=20, command=self.get_project_path).pack()
74+
75+
self.project = StringVar(self.window)
76+
dropdown = OptionMenu(self.window, self.project, "other", "42commandements", "libft", 'fillit')
77+
dropdown.pack()
78+
79+
Button(self.window, text="Start", command=self.start).pack(side=BOTTOM)
80+
81+
Button(self.window, text="Exit", command=self.close_window).pack(side=BOTTOM)
82+
self.window.bind('<Escape>', self.close_window_escape)
83+
84+
self.project.trace("w", self.callback_project_name_changed)
85+
self.window.mainloop()

0 commit comments

Comments
 (0)