-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstartup.py
More file actions
164 lines (129 loc) · 3.55 KB
/
Copy pathstartup.py
File metadata and controls
164 lines (129 loc) · 3.55 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
from tkinter import *
from tkinter import filedialog
import Editor
import Utilities
#from win32gui import FindWindow, GetWindowRect
import File_management
def edit_clicked():
folder_selected = filedialog.askopenfile(
mode = 'r+',
title='Choose the OpenQuiz File you want to edit',
filetypes= (("OpenQuiz Files","*.oq"),("JSON Files","*.json"),("all files","*.*"))
)
if folder_selected is not None and File_management.validate_file_schema(folder_selected.name): # if user closes the file dialog or chooses invalid file, does not execute
window.destroy()
folder_selected.close()
Editor.load_ui(folder_selected.name, False)
def name_new_file_menu():
name_win = Toplevel(window)
#dimensions
x = 380
y = 150
name_win.geometry("%dx%d" %(x,y))
name_win.title("Create a quiz - Name your quiz")
name_win.configure(bg="#2f3136")
name_win.grab_set() # keeps the window in focus
name_win.geometry("+%d+%d" % (100, 200))
name_win.attributes("-topmost", True)
# method after button click
def create_project():
proj_name = name.get()
if not File_management.valid_filename(proj_name):
return
filename = proj_name+ ".oq"
if filename == ".oq":
filename = "Untitled quiz.oq"
name_win.destroy()
name_win.master.destroy()
Editor.load_ui(filename,new =True)
canvas2 = Canvas(
name_win,
bg="#2f3136",
height=150,
width=380,
bd=0,
highlightthickness=0,
relief="ridge")
canvas2.place(x=0, y=0)
canvas2.create_text(
189.5, 30.0,
text="Name your New Project",
fill="#ffffff",
font=("Inter-Bold", int(20.0)))
img = PhotoImage(file=f"create_button.png")
b = Button(name_win,
image=img,
borderwidth=0,
highlightthickness=0,
command=create_project,
relief="flat")
b.place(
x=153, y=106,
width=73,
height=29)
entry0_img = PhotoImage(file=f"create_textbox.png")
entry0_bg = canvas2.create_image(
189.5, 79.0,
image=entry0_img)
name = StringVar()
entry0 = Entry(name_win,
bd=0,
bg="#969eae",
highlightthickness=0,
textvariable = name)
entry0.place(
x=79.0, y=61,
width=221.0,
height=34)
name_win.resizable(False, False)
name_win.mainloop()
#
def new_button():
print("new quiz")
project_name = name_new_file_menu()
window = Tk()
window.geometry("1600x900")
window.configure(bg = "#2f3136")
canvas = Canvas(
window,
bg = "#2f3136",
height = 900,
width = 1600,
bd = 0,
highlightthickness = 0,
relief = "ridge")
canvas.place(x = 0, y = 0)
canvas.create_text(
799.5, 117.0,
text = "Open Quiz [DEMO]",
fill = "#ffffff",
font = ("InriaSans-Regular", int(72.0)))
canvas.create_text(
197.5, 867.0,
text = "Powered by special.nobodies",
fill = "#ffffff",
font = ("None", int(20.0)))
img0 = PhotoImage(file = f"img0.png")
b0 = Button(
image = img0,
borderwidth = 0,
highlightthickness = 0,
command = edit_clicked,
relief = "flat")
b0.place(
x = 250, y = 350,
width = 220,
height = 200)
img1 = PhotoImage(file = f"img1.png")
b1 = Button(
image = img1,
borderwidth = 0,
highlightthickness = 0,
command = new_button,
relief = "flat")
b1.place(
x = 1100, y = 350,
width = 220,
height = 200)
window.resizable(False, False)
window.mainloop()