-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCreate.py
436 lines (343 loc) · 14 KB
/
Create.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
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
# CREATE - A tool that is used to create Modern Gui Using Tkinter
import os
from tkinter import Frame
from tkinter.constants import RADIOBUTTON
import pyfiglet
title=pyfiglet.figlet_format("C R E A T E")
app_name=input("Enter your app name : ")
if app_name == "":
print("Please enter a valid name !")
f =open(app_name+".py","a+")
f.write('''import tkinter as tk
from tkinter import ttk
root = tk.Tk()
root.title("'''+app_name+'''")
root.iconbitmap('icon.ico')
root.option_add("*tearOff", False) # This is always a good idea''')
f.flush()
########################################### Functions ###########################################
def text():
print("\nADD TEXT :-")
widget_name=input("\n Enter widget name : ")
layout= input(" Add widget to(root / custom_widget) :")
Label= input(" Add text here :")
fg_color= input(" Add foreground colour : ")
font=input(" Enter font name : ")
align=input(" Align text to ( left / right / center ): ")
row=input(" Add row number : ")
column=input(" Add column number : ")
pady=input(" Add y spacing : ")
f.write('''
# Label
'''+widget_name+''' = ttk.Label('''+layout+''', text="'''+Label+'''",font="'''+font+'''" ,justify="'''+align+'''",foreground="'''+fg_color+'''")
'''+widget_name+'''.grid(row='''+row+''', column='''+column+''', pady='''+pady+''', columnspan=2)''')
print("\nText added successfully !\n")
f.flush()
def button():
print("\nSelect Button Style :-")
print("\n 1. Normal Button")
print(" 2. Accent Button")
print(" 3. Toggle button")
button_type = input("\n Enter Button Style [1-3] :")
widget_name=input(" Enter widget name : ")
layout= input(" Add widget to(root / custom_widget) :")
text=input("\n Add text : ")
row=input(" Add row number :")
column=input(" Add column number :")
padx=input(" Add x spacing :")
pady=input(" Add y spacing :")
if button_type=="1":
f.write('''
'''+widget_name+''' = ttk.Button('''+layout+''', text="'''+text+'''")
'''+widget_name+'''.grid(row='''+row+''', column='''+column+''', padx='''+padx+''', pady='''+pady+''', sticky="nsew")''')
f.flush()
print("\nButton added successfully !\n")
if button_type=="2":
f.write('''
'''+widget_name+''' = ttk.Button('''+layout+''', text="'''+text+'''",style="AccentButton")
'''+widget_name+'''.grid(row='''+row+''', column='''+column+''', padx='''+padx+''', pady='''+pady+''', sticky="nsew")''')
f.flush()
print("\nButton added successfully !\n")
if button_type=="3":
f.write('''
'''+widget_name+''' = ttk.Button('''+layout+''', text="'''+text+'''",style="ToggleButton")
'''+widget_name+'''.grid(row='''+row+''', column='''+column+''', padx='''+padx+''', pady='''+pady+''', sticky="nsew")''')
f.flush()
print("\nButton added successfully !\n")
def wedget_frame():
print("\nADD Widget Frame :-")
widget_name=input("\n Enter widget name : ")
layout= input(" Add widget to(root / custom_widget) :")
padding=input(" Add spacing (x,y,z,value) : ")
row=input(" Add row number : ")
column=input(" Add column number : ")
padx=input(" Add x spacing (value1,value2) : ")
pady=input(" Add y spacing (value1,value2) : ")
index=input(" Add index number : ")
weight=input(" Add border weight :")
f.write('''
'''+widget_name+''' = ttk.Frame('''+layout+''', padding='''+ padding+''')
'''+widget_name+'''.grid(row='''+row+''', column='''+column+''', padx='''+padx+''', pady='''+pady+''', sticky="nsew", rowspan=3)
'''+widget_name+'''.columnconfigure(index='''+index+''', weight='''+weight+''')''')
print("\nWidget Frame added successfully !\n")
f.flush()
def entry_box():
print("\nADD Entry Frame :-")
widget_name=input("\n Enter widget name : ")
layout= input(" Add widget to(root / custom_widget) :")
l_text=input(" Add text : ")
row=input(" Add row number : ")
column=input(" Add column number : ")
padx=input(" Add x spacing (value1,value2) : ")
pady=input(" Add y spacing (value1,value2) : ")
f.write( '''
# Entry
'''+widget_name+''' = ttk.Entry('''+layout+''')
'''+widget_name+'''.insert(0, "'''+ l_text +'''")
'''+widget_name+'''.grid(row='''+row+''', column='''+column+''', padx='''+padx+''', pady='''+pady+''', sticky="ew")''')
f.flush()
print("\nEntry added successfully !\n")
def radio_button():
print("\nADD Radio Button :-")
widget_name=input("\n Enter widget name : ")
layout= input(" Add widget to(root / custom_widget) :")
text_radio=input(" Add text here : ")
row=input(" Add row number : ")
column=input(" Add column number : ")
padx=input(" Add x spacing (value1,value2) : ")
pady=input(" Add y spacing (value1,value2) : ")
f.write(
'''
'''+widget_name+''' = ttk.Radiobutton('''+layout+''', text="'''+text_radio+'''")
'''+widget_name+'''.grid(row='''+row+''', column='''+column+''', padx='''+padx+''', pady='''+pady+''', sticky="nsew")''')
f.flush()
print("\nRadio Button added successfully !\n")
def Spinbox():
print("\nADD Spinbox :-")
widget_name=input("\n Enter widget name : ")
layout= input(" Add widget to(root / custom_widget) :")
row=input(" Add row number : ")
column=input(" Add column number : ")
padx=input(" Add x spacing (value1,value2) : ")
pady=input(" Add y spacing (value1,value2) : ")
f.write(
'''
'''+widget_name+''' = ttk.Spinbox('''+layout+''', from_=0, to=100, increment=0.1)
'''+widget_name+'''.insert(0, "'''+ text+'''")
'''+widget_name+'''.grid(row='''+row+''', column='''+column+''', padx='''+padx+''', pady='''+pady+''', sticky="ew")''')
f.flush()
print("\nSpinbox added successfully !\n")
def Combobox():
print("\nADD Combobox :-")
widget_name=input("\n Enter widget name : ")
layout= input(" Add widget to(root / custom_widget) :")
row=input(" Add row number : ")
column=input(" Add column number : ")
padx=input(" Add x spacing (value1,value2) : ")
pady=input(" Add y spacing (value1,value2) : ")
f.write(
'''
combo_list = ["Combobox", "Editable item 1", "Editable item 2"]
'''+widget_name+''' = ttk.Combobox('''+layout+''',values=combo_list)
'''+widget_name+'''.combobox.current(0)
'''+widget_name+'''.grid(row='''+row+''', column='''+column+''', padx='''+padx+''', pady='''+pady+''', sticky="ew")''')
f.flush()
print("\nCombobox added successfully !\n")
def Switch():
print("\nADD Switch :-")
widget_name=input("\n Enter widget name : ")
layout= input(" Add widget to(root / custom_widget) :")
add_text=input(" Add text here : ")
row=input(" Add row number : ")
column=input(" Add column number : ")
padx=input(" Add x spacing (value1,value2) : ")
pady=input(" Add y spacing (value1,value2) : ")
f.write(
'''
# Switch
'''+widget_name+''' = ttk.Checkbutton('''+layout+''', text="'''+add_text+'''", style="Switch")
'''+widget_name+'''.grid(row='''+row+''', column='''+column+''', padx='''+padx+''', pady='''+pady+''', sticky="nsew") ''')
f.flush()
print("\nCombobox added successfully !\n")
def frame():
print("\nADD Frame :-")
widget_name=input("\n Enter widget name : ")
layout= input(" Add widget to(root / custom_widget) :")
add_text=input(" Add text here : ")
padding=input(" Add Spacing : ")
row=input(" Add row number : ")
column=input(" Add column number : ")
padx=input(" Add x spacing (value1,value2) : ")
pady=input(" Add y spacing (value1,value2) : ")
f.write('''
# Create a Frame
'''+widget_name+''' = ttk.LabelFrame('''+layout+''', text="'''+add_text+'''", padding='''+padding+''')
'''+widget_name+'''.grid(row='''+row+''', column='''+column+''', padx='''+padx+''', pady='''+pady+''', sticky="nsew") ''')
f.flush()
print("\nFrame added successfully !\n")
def Slider():
print("\nADD Slider :-")
widget_name=input("\n Enter widget name : ")
layout= input(" Add widget to(root / custom_widget) :")
row=input(" Add row number : ")
column=input(" Add column number : ")
padx=input(" Add x spacing (value1,value2) : ")
pady=input(" Add y spacing (value1,value2) : ")
f.write(
'''
g = tk.DoubleVar(value=75.0)
'''+widget_name+''' = ttk.Scale('''+layout+''', from_=100, to=0, variable=g, command=lambda event: g.set('''+widget_name+'''.get()))
'''+widget_name+'''.grid(row='''+row+''', column='''+column+''', padx='''+padx+''', pady='''+pady+''', sticky="ew")
''')
f.flush()
print("\nSlider added successfully !\n")
def Progressbar():
print("\nProgressbar :-")
widget_name=input("\n Enter widget name : ")
layout= input(" Add widget to(root / custom_widget) :")
value=input("\n Enter value here : ")
row=input(" Add row number : ")
column=input(" Add column number : ")
padx=input(" Add x spacing (value1,value2) : ")
pady=input(" Add y spacing (value1,value2) : ")
f.write(
'''
g = tk.DoubleVar(value=75.0)
'''+widget_name+''' = ttk.Progressbar('''+layout+''', value='''+value+''', variable=g, mode="determinate")
'''+widget_name+'''.grid(row='''+row+''', column='''+column+''', padx='''+padx+''', pady='''+pady+''', sticky="ew")
''')
f.flush()
print("\nProgressbar added successfully !\n")
def run():
f=open(app_name+".py")
output = []
for line in f:
if not "root.mainloop()" in line:
output.append(line)
f.close()
f = open("Run_Demo.py", 'w')
f.writelines(output)
f.write('''\nroot.mainloop()''')
f.flush()
os.popen("python Run_Demo.py")
print("Running "+app_name+".py")
def export():
commands=input("Enter Commands here (--onedir / --console) : ")
os.popen('''pyinstaller --noconfirm '''+commands+''' --icon "icon.ico" "'''+app_name+'''.py"''')
def image():
print("\nADD Image (Not supported yet!) ")
################################# MAIN APP ####################################################################
app_size = input("Enter size of "+ app_name +" (w x h) : ")
f.write('''
root.geometry("'''+ app_size + '''")''')
f.flush()
app_R= input("Do you want to make "+ app_name +" responsive (y/n) : ")
if app_R=="y":
f.write('''
root.columnconfigure(index=0, weight=1)
root.columnconfigure(index=1, weight=1)
root.columnconfigure(index=2, weight=1)
root.rowconfigure(index=0, weight=1)
root.rowconfigure(index=1, weight=1)
root.rowconfigure(index=2, weight=1)
sizegrip = ttk.Sizegrip(root)
sizegrip.grid(row=100, column=100, padx=(0, 5), pady=(0, 5))''')
f.flush()
if app_R=="n":
f.write('''
root.columnconfigure(index=0, weight=1)
root.columnconfigure(index=1, weight=1)
root.columnconfigure(index=2, weight=1)
root.rowconfigure(index=0, weight=1)
root.rowconfigure(index=1, weight=1)
root.rowconfigure(index=2, weight=1)
root.resizable(False,False)''' )
f.flush()
app_theme=input("Select theme for "+ app_name +" (dark/light) :")
if app_theme== "dark" :
f.write('''# Create a style
style = ttk.Style(root)
# Import the tcl file
root.tk.call("source", "proxttk-dark.tcl")
# Set the theme with the theme_use method
style.theme_use("proxttk-dark")
d = tk.IntVar(value=2)''')
else:
f.write('''# Create a style
style = ttk.Style(root)
# Import the tcl file
root.tk.call("source", "proxttk.tcl")
# Set the theme with the theme_use method
style.theme_use("proxttk")
d = tk.IntVar(value=2)''')
f.flush()
print(
115*"-"
)
print(title)
def print_menu(): ## Your menu design here
print ("\n",50 * "-" , "Add Widgets" , 50 * "-","\n")
print ("\n1. Text\n")
print ("2. Widget Frame\n")
print ("3. Button\n")
print ("4. Image\n")
print ("5. Entry Box\n")
print ("6. Spinbox\n")
print ("7. Combobox\n")
print ("8. Switch\n")
print ("9. Frame\n")
print ("10. Slider\n")
print ("11. Progressbar\n")
print ("12. Radio Button\n")
print ("13. Run Final "+app_name+"\n")
print ("14. Export\n")
print ("15. Exit\n")
print ("\n",115 * "-")
loop=True
while loop: ## While loop which will keep going until loop = False
print_menu() ## Displays menu
choice = input("Enter your choice [1-15]: ")
if choice=="1":
text()
elif choice=="2":
wedget_frame()
elif choice=="3":
button()
elif choice=="4":
image()
elif choice=="5":
entry_box()
## You can add your code or functions here
elif choice=="6":
Spinbox()
## You can add your code or functions here
elif choice=="7":
Combobox()
## You can add your code or functions here
elif choice=="8":
Switch()
## You can add your code or functions here
elif choice=="9":
frame()
## You can add your code or functions here
elif choice=="10":
Slider()
## You can add your code or functions here
elif choice=="11":
Progressbar()
## You can add your code or functions here
elif choice=="12":
radio_button()
## You can add your code or functions here
elif choice=="13":
run()
## You can add your code or functions here
elif choice=="14":
export()
## You can add your code or functions here
elif choice=="15":
## You can add your code or functions here
loop=False # This will make the while loop to end as not value of loop is set to False
else:
# Any integer inputs other than values 1-5 we print an error message
input("Wrong option selection. Enter any key to try again..")