22# ## Execute Elements GUI Main
33
44## Library Dependencies##
5- # ## Python
6- # ## Tkinter
7- # ## Pillow
8- # ## Pygame
9- # ## NLTK
10- # ## IPython
11- # ## Speech Recognition
5+ # ## Python
6+ # ## Tkinter
7+ # ## Pillow
8+ # ## Pygame
9+ # ## NLTK
10+ # ## IPython
11+ # ## Speech Recognition
1212
1313######## !!!! Internet Access Required For Voice Activated Editing ###########
1414
3636from pocketsphinx import LiveSpeech ## pocketsphinx lib for offline voice detection
3737from pynput .keyboard import Key , Listener ## detect keyboard press for shortcuts with listener
3838from pynput import keyboard ## keyboard press for shortcut
39+ import random ## import random generator
3940
4041############################################################### Class ####################################################################
4142#Hover button Class
@@ -102,21 +103,21 @@ def connection():
102103
103104#logo Button FunctionS
104105def logobtn_clicked ():
105-
106+ random_number = str ( random . randint ( 0 , 21 ))
106107 logo_win = Toplevel (mainwin )
107- img1_logo = Image .open (r"elements2.0Images\assets\ splashscreen.png" )
108- img1_logo = img1_logo .resize ((900 ,400 ), Image .ANTIALIAS )
108+ img1_logo = Image .open (r"elements2.0Images/ splashscreen/" + random_number + " .png" )
109+ img1_logo = img1_logo .resize ((900 ,563 ), Image .ANTIALIAS )
109110 photo_logo = ImageTk .PhotoImage (img1_logo )
110111 l1 = Label (logo_win , bg = "grey" , image = photo_logo )
111112 l1 .pack ()
112113 l1 .photo = photo_logo
113114
114115 logo_win .title ("Credits" )
115116 logo_win .iconbitmap (r"elements2.0Images\logofull2_1TB_icon.ico" )
116- logo_win .geometry ("900x400 +400+200" )
117- logo_win .maxsize (900 ,400 )
117+ logo_win .geometry ("900x563 +400+200" )
118+ logo_win .maxsize (900 ,563 )
118119 logo_win .attributes ('-topmost' , 'true' ) ## bring savve window top and visible
119- logo_win .after (3000 , logo_win .destroy )
120+ logo_win .after (3456 , logo_win .destroy )
120121
121122#logo button
122123img_logo = Image .open (r"elements2.0Images\elementslogo.png" )
@@ -332,7 +333,7 @@ def new_board():
332333 ## Apply
333334 def apply_board ():
334335 global current_img
335-
336+ global original_img
336337 # get board size
337338 w = int (w_board )
338339 h = int (h_board )
@@ -350,7 +351,8 @@ def apply_board():
350351 board_show = ImageTk .PhotoImage (image = image_resized )
351352 labelshow .image = board_show
352353 labelshow .config (image = board_show )
353- current_img = board
354+ current_img = board
355+ original_img = board
354356
355357 # destroy unrequired
356358 import_label .destroy ()
@@ -388,7 +390,9 @@ def import_clicked():
388390 name = fd .askopenfilename (filetypes = [('Image Files' , ['.jpeg' ,'.jpg' ,'.png' ,'.gif' ,'.tiff' ,'.tif' ,'.bmp' ])],title = 'Please select a picture to Elementize' ,initialfile = "Select a file to elemetize." ) ## shows only these extentions
389391 image = Image .open (name )
390392 global current_img
391- current_img = image
393+ global original_img
394+ current_img = image ## editing variable
395+ original_img = image ## keeping original copy of image for comparison
392396 #img_frm = image.resize((1018,598), Image.ANTIALIAS)
393397 #current_img=img_frm
394398 width , height = image .size
@@ -1126,52 +1130,41 @@ def mic_activate():
11261130button_mic .place (x = "550" , y = "700" , relwidth = ".075" , relheight = ".09" )
11271131
11281132############################################################ Play Button ##################################################################
1129- #play button function
1130- def playbtn_clicked ():
1131- play_win = Toplevel (mainwin )
1132- play_win .title ("elements_Music" )
1133- play_win .iconbitmap (r"elements2.0Images\logofull2_1TB_icon.ico" )
1134- play_win .geometry ("600x400+400+200" )
1135-
1136- play_logo = Image .open (r"elements2.0Images\logofull2.png" )
1137- play_logo = play_logo .resize ((600 ,400 ), Image .ANTIALIAS )
1138- photo_logo = ImageTk .PhotoImage (play_logo )
1139- l1 = Label (play_win , image = photo_logo )
1140- l1 .pack ()
1141- l1 .photo = photo_logo
1142-
1143- play_button = Image .open (r"elements2.0Images\play-button.png" )
1144- play_button = play_button .resize ((40 ,30 ), Image .ANTIALIAS )
1145- play_button1 = ImageTk .PhotoImage (play_button )
1146- button_play_button = HoverButton (play_win , bd = "0" , image = play_button1 )
1147- button_play_button .place (x = "350" , y = "50" , relwidth = ".07" , relheight = ".074" )
1148- button_play_button .play_button1 = play_button1
1149-
1150- play_back = Image .open (r"elements2.0Images\play-button.png" )
1151- play_back = play_back .resize ((40 ,30 ), Image .ANTIALIAS )
1152- play_back1 = ImageTk .PhotoImage (play_back )
1153- button_play_back = HoverButton (play_win , bg = "white" , bd = "0" , image = play_back1 )
1154- button_play_back .place (x = "300" , y = "50" , relwidth = ".07" , relheight = ".065" )
1155- button_play_back .play_back1 = play_back1
1156-
1157- #add music to collection button
1158- add_music = Image .open (r"elements2.0Images\play-button.png" )
1159- add_music = add_music .resize ((40 ,30 ), Image .ANTIALIAS )
1160- add_music1 = ImageTk .PhotoImage (add_music )
1161- button_add_music = HoverButton (play_win , bd = "0" , image = add_music1 )
1162- button_add_music .place (x = "400" , y = "50" , relwidth = ".07" , relheight = ".074" )
1163- button_add_music .add_music = add_music1
1164-
1165- # play button
1166- img_play = Image .open (r"elements2.0Images\play-button.png" )
1167- img_play = img_play .resize ((30 ,30 ), Image .ANTIALIAS )
1168- img_play1 = ImageTk .PhotoImage (img_play )
1169- button_play = HoverButton (canvas , bg = "#0d0d0d" , bd = "0" , image = img_play1 , activebackground = '#0d0d0d' , compound = "left" ,fg = "gray" ,command = playbtn_clicked )
1170- button_play .place (x = "1062" , y = "700" , relwidth = ".065" , relheight = ".05" )
11711133
1134+ # to shows import error
11721135import_label = Label (canvas1 ,fg = "white" ,bg = "black" ,text = None )
11731136import_label .place (x = "460" ,y = "270" )
11741137
1138+ ## show original image on hover // for comparison click to reset
1139+ def show_on_enter (event ):
1140+ global original_img
1141+ width , height = original_img .size
1142+ image_resized = resize_image (width , height ,label_width ,label_height ,original_img )
1143+ showimage = ImageTk .PhotoImage (image = image_resized )
1144+ labelshow .image = showimage
1145+ labelshow .configure (image = showimage )
1146+
1147+ def show_on_leave (event ):
1148+ global current_img
1149+ image = current_img
1150+ width , height = image .size
1151+ image_resized = resize_image (width , height ,label_width ,label_height ,image )
1152+ current_img = image
1153+ showimage = ImageTk .PhotoImage (image = image_resized )
1154+ labelshow .image = showimage
1155+ labelshow .configure (image = showimage )
1156+
1157+ # reset image on click
1158+ def reset_image ():
1159+ global current_img
1160+ global original_img
1161+ current_img = original_img
1162+
1163+ show_on_hover = HoverButton (canvas , bg = "#1f1f1f" , bd = "0" ,text = "compare/reset here" ,fg = "white" ,activebackground = "#FF6B26" , command = lambda : reset_image ())
1164+ show_on_hover .place (x = "1100" , y = "750" , relwidth = ".088" , relheight = ".05" )
1165+ show_on_hover .bind ("<Enter>" , show_on_enter )
1166+ show_on_hover .bind ("<Leave>" , show_on_leave )
1167+
11751168############################################################# Save Portion ##############################################################
11761169#save using top level for voice on progerss
11771170def saved (): ## image Saved confirmation stay or leave??
@@ -1526,7 +1519,7 @@ def on_release(key):
15261519 Auto gama correction
15271520 merge images/add
15281521 histogram
1529- okey elements recognition
1522+ okey elements "do" recognition
15301523 ruler
15311524
15321525### try ###
0 commit comments