-
Notifications
You must be signed in to change notification settings - Fork 6
/
GitLearn.py
1395 lines (970 loc) · 56.5 KB
/
GitLearn.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
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# import required pacakges
import os
import win32com.client as wincl
from tkinter import *
import tkinter as tk
from PIL import Image,ImageTk
from tkinter import ttk
import subprocess, sys
import webbrowser
import tkinter.messagebox
from datetime import datetime
import json,requests
# Image Scrollbar
import tkinter
class ScrollableImage(tkinter.Canvas):
def __init__(self, master=None, **kw):
self.image = kw.pop('image', None)
super(ScrollableImage, self).__init__(master=master, **kw)
self['highlightthickness'] = 0
self.propagate(0) # wont let the scrollbars rule the size of Canvas
self.create_image(0,0, anchor='nw', image=self.image)
# Vertical and Horizontal scrollbars
self.v_scroll = tkinter.Scrollbar(self, orient='vertical', width=6)
self.h_scroll = tkinter.Scrollbar(self, orient='horizontal', width=6)
self.v_scroll.pack(side='right', fill='y')
self.h_scroll.pack(side='bottom', fill='x')
# Set the scrollbars to the canvas
self.config(xscrollcommand=self.h_scroll.set,
yscrollcommand=self.v_scroll.set)
# Set canvas view to the scrollbars
self.v_scroll.config(command=self.yview)
self.h_scroll.config(command=self.xview)
# Assign the region to be scrolled
self.config(scrollregion=self.bbox('all'))
self.focus_set()
self.bind_class(self, "<MouseWheel>", self.mouse_scroll)
def mouse_scroll(self, evt):
if evt.state == 0 :
# self.yview_scroll(-1*(evt.delta), 'units') # For MacOS
self.yview_scroll( int(-1*(evt.delta/120)) , 'units') # For windows
if evt.state == 1:
# self.xview_scroll(-1*(evt.delta), 'units') # For MacOS
self.xview_scroll( int(-1*(evt.delta/120)) , 'units') # For windows
#============================Appending info to logs =======================================
def append(fname,info):
# current date and time
now = datetime.now()
now = str(now)
now = now[:-7]
file1 = open("logs/"+fname, "a") # append mode
file1.write(now+" : "+info+"\n")
file1.close()
#=================================Home Screen===================================
def home():
append("status.txt","Opened HOME tab")
# create a home window
global home_screen
home_screen = Toplevel(root)
home_screen.title("HOME")
home_screen.geometry(window_size)
home_screen.configure(background='#2d302d')
# logo 1
logo = tk.PhotoImage(master=home_screen,file="Images/head.png")
l=Label(home_screen,image=logo,bg='#2d302d')
l.image=logo
l.place(x=80,y=30,width=810,height=175)
Label(home_screen,text="",bg='#2d302d').pack()
# Button with Image for Git Play
imagetest = PhotoImage(master=home_screen,file="Images/gitplay.png")
button_qwer = tk.Button(home_screen, text="Use GitLearn now",height= 170, image=imagetest,compound="top",font="bold 12",command=gitplay)
button_qwer.image=imagetest
button_qwer.place(x=80,y=400)
# Button with Image for Help
imagehelp = PhotoImage(master=home_screen,file="Images/help.png")
#Label(home_screen,text="",height="8").pack()
button_qwer = tk.Button(home_screen, text="Need Any Help?",height=170, image=imagehelp,compound="top",font="bold 12",command=githelp)
button_qwer.image=imagehelp
button_qwer.place(x=580,y=400)
#Label(home_screen,text="Git Learn",fg="black" ,width=50, height="4", font=("Calibri", 18)).pack()
#Label(home_screen,text="").pack(padx=250)
Button(home_screen, text="Introduction to\nGit", borderwidth=8,width=18, fg="black",height=4, bg="#dce2e6",font="bold 14" ,command = introduction).place(x=80,y=250)
Button(home_screen, text="Set Up\nGit Installation", width=18, fg="black",height=4,borderwidth=8, bg="#dce2e6",font="bold 14" ,command = setup).place(x=380,y=250)
Button(home_screen, text="Git\nCommands", width=18,borderwidth=6, fg="black",height=4, bg="#dce2e6",font="bold 14" ,command = basics ).place(x=680,y=250)
#Button(home_screen,image=im, width=60, borderwidth=8,fg="black",height=8, bg="#dce2e6",font="bold 12" ,command = about).place(x=100,y=400)
#Button(home_screen, text="About", width=20,borderwidth=8, fg="black",height=8, bg="#dce2e6",font="bold 12" ,command = about).place(x=400,y=400)
#Button(home_screen, text="About", width=20,borderwidth=8, fg="black",height=8, bg="#dce2e6",font="bold 12" ,command = about).place(x=700,y=400)
Button(home_screen, text="X", width=3,borderwidth=6, fg="white",height=1, bg="red", font="bold 12" ,command = delete_home_screen).place(x=915,y=20)
def delete_home_screen():
append("status.txt","Closed HOME tab")
home_screen.destroy()
#============================================= Home Screen END ==================================================
#============================================= Introduction Screen ==============================================
def introduction():
append("status.txt","Visited Introduction section")
# create a introduction window
global intro_screen
intro_screen = Toplevel(home_screen)
intro_screen.title("Introduction")
intro_screen.geometry(window_size)
intro_screen.configure(background='#2d302d')
# background image
logo = tk.PhotoImage(master=intro_screen,file="Images/Introduction.png")
l=Label(intro_screen,image=logo)
l.image=logo
l.place(x=50,y=30)
#Label(intro_screen,text="").pack()
#Label(intro_screen,text="",height="8").pack()
Button(intro_screen, text="Back", width=10,borderwidth=6, fg="white",height=1, bg="red", font="bold 12" ,command = delete_intro_screen).place(x=100,y=600)
Button(intro_screen, text="Next", width=10,borderwidth=6, fg="white",height=1, bg="#4287f5", font="bold 12" ,command = firstslide).place(x=800,y=600)
def delete_intro_screen():
append("status.txt","Closed Introduction Section")
intro_screen.destroy()
#=================================Introduction - Slide 1 ================================================
def firstslide():
append("status.txt","Visited Section 1.1")
# create a introduction window
global firstslide_screen
firstslide_screen = Toplevel(intro_screen)
firstslide_screen.title("What is Version Control?")
firstslide_screen.geometry(window_size)
firstslide_screen.configure(background='#2d302d')
# background image
logo = tk.PhotoImage(master=firstslide_screen,file="Images/firstslide.png")
l=Label(firstslide_screen,image=logo)
l.image=logo
l.place(x=50,y=70)
# hyperlink for more information
link = Label(firstslide_screen, text="more info...",width=10,height=1,bg="#dce2e6", fg="blue", font="bold 12",cursor="hand2")
link.place(x=800,y=30)
link.bind("<Button-1>", lambda e: callback("https://www.atlassian.com/git/tutorials/what-is-version-control"))
#Label(firstslide_screen,text="",height="8").pack()
Button(firstslide_screen, text="Previous",borderwidth=6, width=10, fg="white",height=1, bg="#4287f5", font="bold 12" ,command = delete_firstslide_screen).place(x=100,y=600)
Button(firstslide_screen, text="Home",borderwidth=6, width=10, fg="black",height=1, bg="#dce2e6", font="bold 12" ,command = delete_intro_screen).place(x=100,y=30)
Button(firstslide_screen, text="Next", borderwidth=6,width=10, fg="white",height=1, bg="#4287f5", font="bold 12" ,command = secondslide).place(x=800,y=600)
def callback(url):
append("status.txt","Opened the url : "+url)
webbrowser.open_new(url)
def delete_firstslide_screen():
append("status.txt","Closed Section 1.1")
firstslide_screen.destroy()
#=================================Introduction - Slide 2 ================================================
def secondslide():
append("status.txt","Visited Section 1.2")
# create a introduction window
global secondslide_screen
secondslide_screen = Toplevel(firstslide_screen)
secondslide_screen.title("Centralized Version Control")
secondslide_screen.geometry(window_size)
secondslide_screen.configure(background='#2d302d')
# background image
logo = tk.PhotoImage(master=secondslide_screen,file="Images/secondslide.png")
l=Label(secondslide_screen,image=logo)
l.image=logo
l.place(x=50,y=70)
# hyperlink for more information
link = Label(secondslide_screen, text="more info...",width=10,height=1,bg="#dce2e6", fg="blue", font="bold 12",cursor="hand2")
link.place(x=800,y=30)
link.bind("<Button-1>", lambda e: callback("https://www.atlassian.com/blog/software-teams/version-control-centralized-dvcs"))
#Label(secondslide_screen,text="").pack()
#Label(secondslide_screen,text="",height="8").pack()
Button(secondslide_screen, text="Previous",borderwidth=6, width=10, fg="white",height=1, bg="#4287f5", font="bold 12" ,command = delete_secondslide_screen).place(x=100,y=600)
Button(secondslide_screen, text="Home", width=10,borderwidth=6, fg="black",height=1, bg="#dce2e6", font="bold 12" ,command = delete_intro_screen).place(x=100,y=30)
Button(secondslide_screen, text="Next", width=10, borderwidth=6,fg="white",height=1, bg="#4287f5", font="bold 12" ,command = thirdslide).place(x=800,y=600)
def delete_secondslide_screen():
append("status.txt","Closed Section 1.2")
secondslide_screen.destroy()
#=================================== Introduction - Slide 3 ========================================
def thirdslide():
append("status.txt","Visited Section 1.3")
# create a introduction window
global thirdslide_screen
thirdslide_screen = Toplevel(secondslide_screen)
thirdslide_screen.title("Distributed Version Control")
thirdslide_screen.geometry(window_size)
thirdslide_screen.configure(background='#2d302d')
# background image
logo = tk.PhotoImage(master=thirdslide_screen,file="Images/thirdslide.png")
l=Label(thirdslide_screen,image=logo)
l.image=logo
l.place(x=50,y=70)
# hyperlink for more information
link = Label(thirdslide_screen, text="more info...",width=10,height=1,bg="#dce2e6", fg="blue", font="bold 12",cursor="hand2")
link.place(x=800,y=30)
link.bind("<Button-1>", lambda e: callback("https://en.wikipedia.org/wiki/Distributed_version_control"))
#Label(thirdslide_screen,text="").pack()
#Label(thirdslide_screen,text="",height="8").pack()
Button(thirdslide_screen, text="Previous", width=10,borderwidth=6, fg="white",height=1, bg="#4287f5", font="bold 12" ,command = delete_thirdslide_screen).place(x=100,y=600)
Button(thirdslide_screen, text="Home", width=10, borderwidth=6,fg="black",height=1, bg="#dce2e6", font="bold 12" ,command = delete_intro_screen).place(x=100,y=30)
Button(thirdslide_screen, text="Next", width=10, borderwidth=6,fg="white",height=1, bg="#4287f5", font="bold 12" ,command = fourthslide).place(x=800,y=600)
def delete_thirdslide_screen():
append("status.txt","Closed Section 1.3")
thirdslide_screen.destroy()
#=================================== Introduction - Slide 4 ========================================
def fourthslide():
append("status.txt","Visited Section 1.4")
# create a introduction window
global fourthslide_screen
fourthslide_screen = Toplevel(thirdslide_screen)
fourthslide_screen.title("Centralized vs Distributed Version Control")
fourthslide_screen.geometry(window_size)
fourthslide_screen.configure(background='#2d302d')
# background image
logo = tk.PhotoImage(master=fourthslide_screen,file="Images/fourthslide.png")
l=Label(fourthslide_screen,image=logo)
l.image=logo
l.place(x=50,y=70)
# hyperlink for more information
link = Label(fourthslide_screen, text="more info...",width=10,height=1,bg="#dce2e6", fg="blue", font="bold 12",cursor="hand2")
link.place(x=800,y=30)
link.bind("<Button-1>", lambda e: callback("https://www.teamstudio.com/blog/distributed-vs-centralized-version-control-systems-for-lotus-notes"))
#Label(fourthslide_screen,text="").pack()
#Label(fourthslide_screen,text="",height="8").pack()
Button(fourthslide_screen, text="Previous", width=10,borderwidth=6, fg="white",height=1, bg="#4287f5", font="bold 12" ,command = delete_fourthslide_screen).place(x=100,y=600)
Button(fourthslide_screen, text="Home", width=10,borderwidth=6, fg="black",height=1, bg="#dce2e6", font="bold 12" ,command = delete_intro_screen).place(x=100,y=30)
Button(fourthslide_screen, text="Next", width=10,borderwidth=6, fg="white",height=1, bg="#4287f5", font="bold 12" ,command = fifthslide).place(x=800,y=600)
def delete_fourthslide_screen():
append("status.txt","Closed Section 1.4")
fourthslide_screen.destroy()
#=================================== Introduction - Slide 5 ========================================
def fifthslide():
append("status.txt","Visited Section 1.5")
# create a introduction window
global fifthslide_screen
fifthslide_screen = Toplevel(fourthslide_screen)
fifthslide_screen.title("What is Git?")
fifthslide_screen.geometry(window_size)
fifthslide_screen.configure(background='#2d302d')
# background image
logo = tk.PhotoImage(master=fifthslide_screen,file="Images/fifthslide.png")
l=Label(fifthslide_screen,image=logo)
l.image=logo
l.place(x=50,y=70)
# hyperlink for more information
link = Label(fifthslide_screen, text="more info...",width=10,height=1,bg="#dce2e6", fg="blue", font="bold 12",cursor="hand2")
link.place(x=800,y=30)
link.bind("<Button-1>", lambda e: callback("https://git-scm.com/book/en/v2/Getting-Started-A-Short-History-of-Git"))
#Label(fifthslide_screen,text="").pack()
#Label(fifthslide_screen,text="",height="8").pack()
Button(fifthslide_screen, text="Previous", width=10, borderwidth=6,fg="white",height=1, bg="#4287f5", font="bold 12" ,command = delete_fifthslide_screen).place(x=100,y=600)
Button(fifthslide_screen, text="Home", width=10,borderwidth=6, fg="black",height=1, bg="#dce2e6", font="bold 12" ,command = delete_intro_screen).place(x=100,y=30)
Button(fifthslide_screen, text="Next", width=10,borderwidth=6, fg="white",height=1, bg="#4287f5", font="bold 12" ,command = sixthslide).place(x=800,y=600)
def delete_fifthslide_screen():
append("status.txt","Closed Section 1.5")
fifthslide_screen.destroy()
#=================================== Introduction - Slide 6 ========================================
def sixthslide():
append("status.txt","Visited Section 1.6")
# create a introduction window
global sixthslide_screen
sixthslide_screen = Toplevel(fifthslide_screen)
sixthslide_screen.title("Git - Life Cycle")
sixthslide_screen.geometry(window_size)
sixthslide_screen.configure(background='#2d302d')
# background image
logo = tk.PhotoImage(master=sixthslide_screen,file="Images/sixthslide.png")
l=Label(sixthslide_screen,image=logo)
l.image=logo
l.place(x=50,y=70)
# hyperlink for more information
link = Label(sixthslide_screen, text="more info...",width=10,height=1,bg="#dce2e6", fg="blue", font="bold 12",cursor="hand2")
link.place(x=800,y=30)
link.bind("<Button-1>", lambda e: callback("https://www.toolsqa.com/git/git-life-cycle/"))
#Label(sixthslide_screen,text="").pack()
#Label(sixthslide_screen,text="",height="8").pack()
Button(sixthslide_screen, text="Previous", borderwidth=6,width=10, fg="white",height=1, bg="#4287f5", font="bold 12" ,command = delete_sixthslide_screen).place(x=100,y=600)
Button(sixthslide_screen, text="Home", width=10,borderwidth=6, fg="black",height=1, bg="#dce2e6", font="bold 12" ,command = delete_intro_screen).place(x=100,y=30)
Button(sixthslide_screen, text="Cheat Sheet", borderwidth=6,width=10, fg="white",height=1, bg="green", font="bold 12" ,command = open_cheatsheet).place(x=800,y=600)
def open_cheatsheet():
append("status.txt","Opened CheatSheet")
webbrowser.open('Cheatsheet.pdf')
def delete_sixthslide_screen():
append("status.txt","Closed Section 1.6")
sixthslide_screen.destroy()
#==================================== Introduction Screen END ==========================================================
def about():
pass
#root.destroy()
def delete_root():
append("status.txt","********************Closed the application*************************")
root.destroy()
#===================================== SetUp Screen =======================================================
def setup():
append("status.txt","Opened SetUp Section")
# create a introduction window
global setup_screen
setup_screen = Toplevel(home_screen)
setup_screen.title("SetUp Git")
setup_screen.geometry(window_size)
setup_screen.configure(background='#2d302d')
# background image
logo = tk.PhotoImage(master=setup_screen,file="Images/setup.png")
l=Label(setup_screen,image=logo)
l.image=logo
l.place(x=50,y=70)
#Label(setup_screen,text="").pack()
#Label(setup_screen,text="",height="8").pack()
Button(setup_screen, text="Back", width=10, fg="white",height=1,borderwidth=6, bg="red", font="bold 12" ,command = delete_setup_screen).place(x=100,y=600)
Button(setup_screen, text="Next", width=10, fg="white",height=1,borderwidth=6, bg="#4287f5", font="bold 12" ,command = git).place(x=800,y=600)
Button(setup_screen, text="Home", width=10, fg="black",height=1,borderwidth=6, bg="#dce2e6", font="bold 12" ,command = delete_setup_screen).place(x=100,y=30)
def delete_setup_screen():
append("status.txt","Closed SetUp Section")
setup_screen.destroy()
#================================== Installation of Git Screen ===================================================
def git():
append("status.txt","Visited Installation of Git tab")
# create a introduction window
global git_screen
git_screen = Toplevel(setup_screen)
git_screen.title("Installation of Git on Windows")
git_screen.geometry(window_size)
git_screen.configure(background='#2d302d')
# background image
logo = tk.PhotoImage(master=git_screen,file="Images/install.png")
l=Label(git_screen,image=logo)
l.image=logo
l.place(x=50,y=70)
# hyperlink for more information
link = Label(git_screen, text="On Linux & Mac",width=15,height=1,bg="#dce2e6", fg="blue", font="bold 12",cursor="hand2")
link.place(x=830,y=30)
link.bind("<Button-1>", lambda e: callback("https://git-scm.com/book/en/v2/Getting-Started-Installing-Git"))
#Label(git_screen,text="").pack()
#Label(git_screen,text="",height="8").pack()
Button(git_screen, text="Previous", width=10, fg="white",borderwidth=6,height=1, bg="#4287f5", font="bold 12" ,command = delete_git_screen).place(x=100,y=600)
Button(git_screen, text="Home", width=10, fg="black",height=1, borderwidth=6,bg="#dce2e6", font="bold 12" ,command = delete_setup_screen).place(x=100,y=30)
Button(git_screen, text="Next", width=10, fg="white",height=1,borderwidth=6, bg="#4287f5", font="bold 12" ,command = account).place(x=800,y=600)
Button(git_screen, text="Install", width=10, fg="white",height=1,borderwidth=6, bg="green", font="bold 12" ,command = install).place(x=250,y=600)
Button(git_screen, text="Git Bash", width=10, fg="white",height=1,borderwidth=6, bg="green", font="bold 12" ,command = gitbash).place(x=650,y=600)
def gitbash():
append("status.txt","Trying to open GitBash")
cwd=os.getcwd()
f=open("scripts/path.txt",'w')
f.write(cwd)
f.close()
try:
p = subprocess.Popen(["powershell.exe","-ExecutionPolicy","Unrestricted","./scripts/gitbash.ps1",cwd],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
p.communicate()
append("status.txt","GitBash Opened!")
except Exception as e:
append("gitbash.txt",str(e))
append("status.txt",str(e))
tkinter.messagebox.showerror("Error","Something went wrong.Check logs/gitbash.txt",parent=git_screen)
def install():
append("status.txt","Installing Git")
cwd=os.getcwd()
f=open("scripts/path.txt",'w')
f.write(cwd)
f.close()
try:
p = subprocess.Popen(["powershell.exe","-ExecutionPolicy","Unrestricted","./scripts/setup.ps1",cwd],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
p.communicate()
tkinter.messagebox.showinfo("Info","You can use Git Bash now!",parent=git_screen)
append("status.txt","Git Installed")
except Exception as e:
append("setup.txt",str(e))
append("status.txt",str(e))
tkinter.messagebox.showerror("Error","Something went wrong.Check logs/setup.txt",parent=git_screen)
def delete_git_screen():
append("status.txt","Closed Installation of Git tab")
git_screen.destroy()
#=============================================== Github Account Creating ==========================================
def account():
append("status.txt","Visited the Why Github? screen")
# create a introduction window
global account_screen
account_screen = Toplevel(git_screen)
account_screen.title("Why GitHub Account?")
account_screen.geometry(window_size)
account_screen.configure(background='#2d302d')
# background image
logo = tk.PhotoImage(master=account_screen,file="Images/gitaccount.png")
l=Label(account_screen,image=logo)
l.image=logo
l.place(x=50,y=70)
# hyperlink for more information
link = Label(account_screen, text="GitHub About",width=10,height=1,bg="#dce2e6", fg="blue", font="bold 12",cursor="hand2")
link.place(x=830,y=30)
link.bind("<Button-1>", lambda e: callback("https://github.com/about"))
#Label(account_screen,text="").pack()
#Label(account_screen,text="",height="8").pack()
Button(account_screen, text="Previous", width=10, fg="white",height=1,borderwidth=6, bg="#4287f5", font="bold 12" ,command = delete_account_screen).place(x=100,y=600)
Button(account_screen, text="Home", width=10, fg="black",height=1,borderwidth=6, bg="#dce2e6", font="bold 12" ,command = delete_setup_screen).place(x=100,y=30)
Button(account_screen, text="Video", width=10, fg="white",height=1,borderwidth=6, bg="#8c3526", font="bold 12" ,command = setupvideo).place(x=800,y=600)
Button(account_screen, text="Create Account", width=15, fg="white",borderwidth=6,height=1, bg="green", font="bold 12" ,command = githubaccount).place(x=250,y=600)
Button(account_screen, text="Git Bash", width=10, fg="white",height=1,borderwidth=6, bg="green", font="bold 12" ,command = gitbash).place(x=650,y=600)
# video for creating account
def setupvideo():
append("status.txt","Playing Video for SetUp GitHub Account")
callback("https://www.youtube.com/watch?v=6U7_Om4zffM")
# creating Github account
def githubaccount():
append("status.txt","Visited Github Sign Up page")
callback("https://github.com/join?source=login")
def delete_account_screen():
append("status.txt","Closed why GitHub? screen")
account_screen.destroy()
#============================================ SetUp Screen END ================================================
#============================================== Basic Concepts ============================================
def basics():
append("status.txt","Opened Basics Git Commands section")
# create a introduction window
global content_screen
content_screen = Toplevel(home_screen)
content_screen.title("Basic Concepts of Git")
content_screen.geometry(window_size)
content_screen.configure(background='#2d302d')
# background image
logo = tk.PhotoImage(master=content_screen,file="Images/basics.png")
l=Label(content_screen,image=logo)
l.image=logo
l.place(x=50,y=70)
Label(content_screen,text="").pack()
Label(content_screen,text="",height="8").pack()
Button(content_screen, text="Back", width=10, fg="white",height=1,borderwidth=6, bg="red", font="bold 12" ,command = delete_content_screen).place(x=100,y=600)
Button(content_screen, text="Next", width=10, fg="white",height=1,borderwidth=6, bg="#4287f5", font="bold 12" ,command = firstconcept).place(x=800,y=600)
Button(content_screen, text="Home", width=10, fg="black",height=1,borderwidth=6, bg="#dce2e6", font="bold 12" ,command = delete_content_screen).place(x=100,y=30)
def delete_content_screen():
append("status.txt","Closed Git Commands section")
content_screen.destroy()
#============================================ First Page =====================================================================
def firstconcept():
append("status.txt","Visited Section 3.1")
# create a introduction window
global firstconcept_screen
firstconcept_screen = Toplevel(content_screen)
firstconcept_screen.title("Basic Git Commands")
firstconcept_screen.geometry(window_size)
firstconcept_screen.configure(background='#2d302d')
# background image
img = Image.open('Images/basics1.png')
img = ImageTk.PhotoImage(img)
ScrollableImage(firstconcept_screen, image=img, width=980, height=650).pack()
Label(firstconcept_screen,text="").pack()
Label(firstconcept_screen,text="",height="8").pack()
Button(firstconcept_screen, text="Previous", width=12, fg="white",height=1,borderwidth=6, bg="#4287f5", font="bold 12" ,command = delete_firstconcept_screen).place(x=800,y=500)
Button(firstconcept_screen, text="Next", width=12, fg="white",height=1,borderwidth=6, bg="#4287f5", font="bold 12" ,command = secondconcept).place(x=800,y=600)
Button(firstconcept_screen, text="Home", width=12, fg="black",height=1,borderwidth=6, bg="#dce2e6", font="bold 12" ,command = delete_content_screen).place(x=800,y=30)
Button(firstconcept_screen, text="Tutorial", width=12, fg="white",height=8,borderwidth=6, bg="black", font="bold 12" ,command=basicsvideo).place(x=800,y=300)
def basicsvideo():
append("status.txt","Playing video for Git Commands")
callback("https://www.youtube.com/watch?v=HVsySz-h9r4")
def delete_firstconcept_screen():
append("status.txt","Closed Section 3.1")
firstconcept_screen.destroy()
#========================================== Second Page ============================================================
def secondconcept():
append("status.txt","Visited Section 3.2")
# create a introduction window
global secondconcept_screen
secondconcept_screen = Toplevel(firstconcept_screen)
secondconcept_screen.title("Basic Git Commands")
secondconcept_screen.geometry(window_size)
secondconcept_screen.configure(background='#2d302d')
# background image
img = Image.open('Images/basics2.png')
img = ImageTk.PhotoImage(img)
ScrollableImage(secondconcept_screen, image=img, width=980, height=650).pack()
Label(secondconcept_screen,text="").pack()
Label(secondconcept_screen,text="",height="8").pack()
Button(secondconcept_screen, text="Previous", width=12, fg="white",height=1,borderwidth=6, bg="#4287f5", font="bold 12" ,command = delete_secondconcept_screen).place(x=800,y=500)
Button(secondconcept_screen, text="Next", width=12, fg="white",height=1,borderwidth=6, bg="#4287f5", font="bold 12" ,command = thirdconcept).place(x=800,y=600)
Button(secondconcept_screen, text="Home", width=12, fg="black",height=1,borderwidth=6, bg="#dce2e6", font="bold 12" ,command = delete_content_screen).place(x=800,y=30)
Button(secondconcept_screen, text="Tutorial", width=12, fg="white",height=8,borderwidth=6, bg="black", font="bold 12" ,command = basicsvideo).place(x=800,y=300)
def delete_secondconcept_screen():
append("status.txt","Closed Section 3.2")
secondconcept_screen.destroy()
#============================================ Third Page =====================================================================
def thirdconcept():
append("status.txt","Visited Section 3.3")
# create a introduction window
global thirdconcept_screen
thirdconcept_screen = Toplevel(secondconcept_screen)
thirdconcept_screen.title("Basic Git Commands")
thirdconcept_screen.geometry(window_size)
thirdconcept_screen.configure(background='#2d302d')
# background image
img = Image.open('Images/basics3.png')
img = ImageTk.PhotoImage(img)
ScrollableImage(thirdconcept_screen, image=img, width=980, height=650).pack()
Label(thirdconcept_screen,text="").pack()
Label(thirdconcept_screen,text="",height="8").pack()
Button(thirdconcept_screen, text="Previous", width=12, fg="white",height=1,borderwidth=6, bg="#4287f5", font="bold 12" ,command = delete_thirdconcept_screen).place(x=800,y=500)
Button(thirdconcept_screen, text="Next", width=12, fg="white",height=1,borderwidth=6, bg="#4287f5", font="bold 12" ,command = fourthconcept).place(x=800,y=600)
Button(thirdconcept_screen, text="Home", width=12, fg="black",height=1,borderwidth=6, bg="#dce2e6", font="bold 12" ,command = delete_content_screen).place(x=800,y=30)
Button(thirdconcept_screen, text="Tutorial", width=12, fg="white",height=8,borderwidth=6, bg="black", font="bold 12" ,command = basicsvideo).place(x=800,y=300)
def delete_thirdconcept_screen():
append("status.txt","Closed Section 3.3")
thirdconcept_screen.destroy()
#============================================ Fourth Page =====================================================================
def fourthconcept():
append("status.txt","Visited Section 3.4")
# create a introduction window
global fourthconcept_screen
fourthconcept_screen = Toplevel(thirdconcept_screen)
fourthconcept_screen.title("Basic Git Commands")
fourthconcept_screen.geometry(window_size)
fourthconcept_screen.configure(background='#2d302d')
# background image
img = Image.open('Images/basics4.png')
img = ImageTk.PhotoImage(img)
ScrollableImage(fourthconcept_screen, image=img, width=980, height=650).pack()
Label(fourthconcept_screen,text="").pack()
Label(fourthconcept_screen,text="",height="8").pack()
Button(fourthconcept_screen, text="Previous", width=12, fg="white",height=1,borderwidth=6, bg="#4287f5", font="bold 12" ,command = delete_fourthconcept_screen).place(x=800,y=500)
Button(fourthconcept_screen, text="Next", width=12, fg="white",height=1,borderwidth=6, bg="#4287f5", font="bold 12" ,command = fifthconcept).place(x=800,y=600)
Button(fourthconcept_screen, text="Home", width=12, fg="black",height=1,borderwidth=6, bg="#dce2e6", font="bold 12" ,command = delete_content_screen).place(x=800,y=30)
Button(fourthconcept_screen, text="Tutorial", width=12, fg="white",height=8,borderwidth=6, bg="black", font="bold 12" ,command = basicsvideo).place(x=800,y=300)
def delete_fourthconcept_screen():
append("status.txt","Closed Section 3.4")
fourthconcept_screen.destroy()
#============================================ Fifth Page =====================================================================
def fifthconcept():
append("status.txt","Visited Section 3.5")
# create a introduction window
global fifthconcept_screen
fifthconcept_screen = Toplevel(thirdconcept_screen)
fifthconcept_screen.title("Basic Git Commands")
fifthconcept_screen.geometry(window_size)
fifthconcept_screen.configure(background='#2d302d')
# background image
img = Image.open('Images/basics5.png')
img = ImageTk.PhotoImage(img)
ScrollableImage(fifthconcept_screen, image=img, width=980, height=650).pack()
Label(fifthconcept_screen,text="").pack()
Label(fifthconcept_screen,text="",height="8").pack()
Button(fifthconcept_screen, text="Previous", width=12, fg="white",height=1,borderwidth=6, bg="#4287f5", font="bold 12" ,command = delete_fifthconcept_screen).place(x=800,y=500)
Button(fifthconcept_screen, text="Cheat Sheet", width=12, fg="black",height=1,borderwidth=6, bg="#49eb34", font="bold 12" ,command = open_cheatsheet).place(x=800,y=600)
Button(fifthconcept_screen, text="Home", width=12, fg="black",height=1,borderwidth=6, bg="#dce2e6", font="bold 12" ,command = delete_content_screen).place(x=800,y=30)
Button(fifthconcept_screen, text="Tutorial", width=12, fg="white",height=8,borderwidth=6, bg="black", font="bold 12" ,command = basicsvideo).place(x=800,y=300)
def delete_fifthconcept_screen():
append("status.txt","Closed Section 3.5")
fifthconcept_screen.destroy()
#================================================ Basics Concepts for Git - END ====================================================
#============================================== Git Play ===============================================
def gitplay():
append("status.txt","Opened the GitPlay section")
# create a introduction window
global gitplay_screen
gitplay_screen = Toplevel(home_screen)
gitplay_screen.title("Git Play")
gitplay_screen.geometry(window_size)
gitplay_screen.configure(background='#2d302d')
Label(gitplay_screen,text="",bg="#2d302d").pack()
Label(gitplay_screen,text="Use this automated tool to create your own repositories",font=("Calibri", 26),bg="#2d302d",fg="white").place(x=100,y=100)
Label(gitplay_screen,text="Let's have fun!",font=("Calibri", 26),bg="#2d302d",fg="white").place(x=400,y=200)
Label(gitplay_screen,text="",bg="#2d302d",height="8").pack()
Label(gitplay_screen,text="Note : Make sure you have installed Git. If not go to SetUp section - Slide 2 and\n click on install button.Also you need to have a GitHub account.\nBy using this tool you can push your files into remote repository",bg="#2d302d",fg="white",height=3,width=100,font="bold 11").place(x=80,y=450)
Button(gitplay_screen, text="Create New \nRepository & Push files", width=20, fg="white",height=5,borderwidth=6, bg="#32a852", font="bold 12" ,command = createrepo).place(x=100,y=300)
Button(gitplay_screen, text="Push files to\nExisiting Repositroy", width=20, fg="white",height=5,borderwidth=6, bg="#f5424b", font="bold 12" ,command = existingrepo).place(x=400,y=300)
Button(gitplay_screen, text="Clone a\n Repository", width=20, fg="white",height=5,borderwidth=6, bg="#428af5", font="bold 12" ,command = clonerepo).place(x=700,y=300)
Button(gitplay_screen, text="X", width=3,borderwidth=6, fg="white",height=1, bg="red", font="bold 12" ,command = delete_gitplay_screen).place(x=915,y=20)
def delete_gitplay_screen():
append("status.txt","Closed GitPlay scetion")
gitplay_screen.destroy()
#===================================================Creating new repository================================
def createrepo():
append("status.txt","Getting ready to create a repository")
# create a introduction window
global create_screen
create_screen = Toplevel(gitplay_screen)
create_screen.title("Create New Repository")
create_screen.geometry(window_size)
create_screen.configure(background='#2d302d')
Label(create_screen,text="Mandatory sections are marked with ** ",bg="white",fg="red",height=1,width=30,font="bold 12").place(x=100,y=20)
# UserName
global entry1
Label(create_screen,text="Enter GitHub Username** : ",bg="#2d302d",fg="white",height=1,width=25,font="bold 15").place(x=100,y=60)
entry1 = Entry(create_screen,fg="black",bg="#dce2e6",width=30,font="bold 12")
entry1.place(x=400,y=60,height=30)
# RepoName
global entry2
Label(create_screen,text="Enter new Repository name** : ",bg="#2d302d",fg="white",height=1,width=25,font="bold 15").place(x=100,y=160)
entry2 = Entry(create_screen,fg="black",bg="#dce2e6",width=30,font="bold 12")
entry2.place(x=400,y=160,height=30)
# Description
global entry3
Label(create_screen,text="Enter Description : ",bg="#2d302d",fg="white",height=1,width=25,font="bold 15").place(x=100,y=260)
entry3 = Entry(create_screen,fg="black",bg="#dce2e6",width=50,font="bold 12")
entry3.place(x=400,y=260,height=30)
# RepoPath
global entry4
Label(create_screen,text="Enter the path : \n( deafult: current directory) ",bg="#2d302d",fg="white",height=2,width=25,font="bold 15").place(x=100,y=360)
entry4 = Entry(create_screen,fg="black",bg="#dce2e6",width=50,font="bold 12")
entry4.place(x=400,y=360,height=30)
Label(create_screen,text="Note : On clciking Submit button your files in the specified path will\n be pushed to your GitHub with Repositor name given ",bg="#2d302d",fg="white",height=3,width=100,font="bold 11").place(x=80,y=450)
Button(create_screen,text='Submit',font="bold 12",borderwidth=6,height=1,width=20,bg="#32a852",fg="white" ,command=actionCreateRepo).place(x=400,y=550)
Button(create_screen, text="X", width=3,borderwidth=6, fg="white",height=1, bg="red", font="bold 12" ,command = delete_create_screen).place(x=915,y=20)
# Github UserName Validation
def UserExist(UserName):
if UserName == "":
return False
api_url = "https://api.github.com/users/" + UserName
r=requests.get(api_url)
if r.status_code == 200:
d =json.loads(r.content.decode('utf-8'))
try:
if d['login']==UserName:
return True
else:
return False
except:
return False
else:
return False
# Check if the RepoName exists
def RepoExist(UserName,RepoName):
if RepoName == "" or len(RepoName.split())>1:
return "bad"
api_url = "https://api.github.com/users/" + UserName +"/repos"
r=requests.get(api_url)
if r.status_code == 200:
d =json.loads(r.content.decode('utf-8'))
try:
for i in d:
if RepoName == i['name']:
return "good"
except:
return "no"
return "no"
def actionCreateRepo():
append("gitplay.txt","=========Creating new repository============")
append("status.txt","Submitted the details")
# UserName
UserName = entry1.get()
append("status.txt","Checking if the UserName :"+UserName+" exists")
if not UserExist(UserName):
msg = "User is not Found!"
append("gitplay.txt",msg)
append("status.txt",msg)
tkinter.messagebox.showwarning("Warning",msg+"Check logs/gitplay.txt",parent=create_screen)
return
append("gitplay.txt","GitHub User Found")
append("status.txt","GitHub User Found")
# RepoName
RepoName = entry2.get()
append("status.txt","Checking if a repository with name "+RepoName+" exists")
result = RepoExist(UserName,RepoName)
if result=="bad":
msg = "Repository name is invalid"
append("gitplay.txt",msg)
append("status.txt",msg)
tkinter.messagebox.showwarning("Warning",msg+"\nCheck logs/gitplay.txt",parent=create_screen)
return
elif result=="good":
msg = "Repo already exists!"
append("gitplay.txt",msg)
append("status.txt",msg)
tkinter.messagebox.showwarning("Warning",msg+"\nCheck logs/gitplay.txt",parent=create_screen)
return
# Description
Description = entry3.get()
if Description == "":
Description = "This repository was made with GitLearn"
msg = "A default description was added to your repo"
append("gitplay.txt",msg)
append("status.txt",msg)
f = open("logs/description.txt", "w")
f.write(Description)
f.close()
# RepoPath
RepoPath = entry4.get()
append("status.txt","Checking if the path is valid")
if RepoPath == "":
RepoPath = os.getcwd()
if not os.path.exists(RepoPath):
msg = "Given Path not found!!"
append("gitplay.txt",msg)
append("status.txt",msg)
tkinter.messagebox.showwarning("Error",msg+"\nCheck logs/gitplay.txt",parent=create_screen)
return
msg = "Path Found -- "+RepoPath
append("gitplay.txt",msg)
append("status.txt",msg)
f=open("scripts/path.txt",'w')
f.write(RepoPath)
f.close()