Update Uptated-Prototype/PiperTTS-GUI-Test.py

This commit is contained in:
2025-12-11 17:13:31 -08:00
parent 6e5a7d2670
commit 35bc5b606f

View File

@@ -25,30 +25,35 @@ Root_Window.geometry(f'{Window_Width}x{Window_Height}+{int(Window_PosX)}+{int(Wi
# Attempts to create a Input Frame # Attempts to create a Input Frame
try: try:
Input_Box_Frame = Frame(Root_Window) Input_Box_Frame = Frame(Root_Window)
except: except Exception as e:
print(e, type(e))
print("An exception occurred - when creating input Frame.") print("An exception occurred - when creating input Frame.")
# Attempts to create a Controls Frame # Attempts to create a Controls Frame
try: try:
Controls_Box_Frame = Frame(Root_Window) Controls_Box_Frame = Frame(Root_Window)
except: except Exception as e:
print(e, type(e))
print("An exception occurred - when creating Controls Frame.") print("An exception occurred - when creating Controls Frame.")
# Attempts to create a Prefrences Frame # Attempts to create a Prefrences Frame
try: try:
Prefrences_Frame = Frame(Root_Window) Prefrences_Frame = Frame(Root_Window)
except: except Exception as e:
print(e, type(e))
print("An exception occurred - when creating Controls Frame.") print("An exception occurred - when creating Controls Frame.")
# Attempts to Place Input and Controls frames # Attempts to Place Input and Controls frames
try: try:
Input_Box_Frame.place(x = 0, y = 0, relwidth = 1, relheight = 0.7) Input_Box_Frame.place(x = 0, y = 0, relwidth = 1, relheight = 0.7)
Controls_Box_Frame.place(x = 0, rely = 0.8, relwidth = 1, relheight = 0.7) Controls_Box_Frame.place(x = 0, rely = 0.8, relwidth = 1, relheight = 0.7)
except: except Exception as e:
print(e, type(e))
print("An exception occurred - when placing Frames.") print("An exception occurred - when placing Frames.")
# Attempts to create a Input box # Attempts to create a Input box
try: try:
Input_Box = Text(Input_Box_Frame, selectbackground="yellow", selectforeground="black", undo=True) Input_Box = Text(Input_Box_Frame, selectbackground="yellow", selectforeground="black", undo=True)
Input_Box.pack(padx=5, pady=5, expand = True, fill = "both") Input_Box.pack(padx=5, pady=5, expand = True, fill = "both")
except: except Exception as e:
print(e, type(e))
print("An exception occurred - when creating input box.") print("An exception occurred - when creating input box.")
# Attempts to create a scrollbar for the Input box # Attempts to create a scrollbar for the Input box
@@ -56,7 +61,8 @@ try:
Main_Text_Scrollbar = Scrollbar(Input_Box_Frame, command = Input_Box_Frame.yview) Main_Text_Scrollbar = Scrollbar(Input_Box_Frame, command = Input_Box_Frame.yview)
Input_Box_Frame.configure(yscrollcommand = Main_Text_Scrollbar.set) Input_Box_Frame.configure(yscrollcommand = Main_Text_Scrollbar.set)
Main_Text_Scrollbar.place(relx = 1, rely = 0, relheight = 1, anchor = "ne") Main_Text_Scrollbar.place(relx = 1, rely = 0, relheight = 1, anchor = "ne")
except: except Exception as e:
print(e, type(e))
print("An exception occurred - when creating a scroll bar.") print("An exception occurred - when creating a scroll bar.")
# #
@@ -65,7 +71,8 @@ def PiperTTS_GUI_Play():
My_Test_Label["text"] = "Playing?" My_Test_Label["text"] = "Playing?"
C_Button_Pause["state"] == "normal" C_Button_Pause["state"] == "normal"
C_Button_Play["state"] = "disabled" C_Button_Play["state"] = "disabled"
except: except Exception as e:
print(e, type(e))
print("An exception occurred - when pressing Play Button.") print("An exception occurred - when pressing Play Button.")
# #
@@ -74,7 +81,8 @@ def PiperTTS_GUI_Pause():
My_Test_Label["text"] = "Pause?" My_Test_Label["text"] = "Pause?"
C_Button_Pause["state"] == "disabled" C_Button_Pause["state"] == "disabled"
C_Button_Play["state"] = "normal" C_Button_Play["state"] = "normal"
except: except Exception as e:
print(e, type(e))
print("An exception occurred - when pressing Pause Button.") print("An exception occurred - when pressing Pause Button.")
# #
@@ -83,21 +91,24 @@ def PiperTTS_GUI_Stop():
My_Test_Label["text"] = "Stop?" My_Test_Label["text"] = "Stop?"
C_Button_Pause["state"] == "disabled" C_Button_Pause["state"] == "disabled"
C_Button_Play["state"] = "normal" C_Button_Play["state"] = "normal"
except: except Exception as e:
print(e, type(e))
print("An exception occurred - when pressing Stop Button.") print("An exception occurred - when pressing Stop Button.")
# #
def PiperTTS_GUI_Previous(): def PiperTTS_GUI_Previous():
try: try:
My_Test_Label["text"] = "Previous?" My_Test_Label["text"] = "Previous?"
except: except Exception as e:
print(e, type(e))
print("An exception occurred - when pressing Previous Button.") print("An exception occurred - when pressing Previous Button.")
# #
def PiperTTS_GUI_Next(): def PiperTTS_GUI_Next():
try: try:
My_Test_Label["text"] = "Next?" My_Test_Label["text"] = "Next?"
except: except Exception as e:
print(e, type(e))
print("An exception occurred - when pressing Next Button.") print("An exception occurred - when pressing Next Button.")
# #
@@ -105,7 +116,8 @@ def PiperTTS_GUI_New_File():
try: try:
My_Test_Label["text"] = "New File?" My_Test_Label["text"] = "New File?"
Input_Box.delete("1.0", "end-1c") Input_Box.delete("1.0", "end-1c")
except: except Exception as e:
print(e, type(e))
print("An exception occurred - when pressing New File Button.") print("An exception occurred - when pressing New File Button.")
# #
@@ -117,7 +129,8 @@ def PiperTTS_GUI_Get_Selection():
else: else:
Cursor_Position = Input_Box.index(INSERT) Cursor_Position = Input_Box.index(INSERT)
Input_Box.insert(Cursor_Position, Selected) Input_Box.insert(Cursor_Position, Selected)
except: except Exception as e:
print(e, type(e))
print("An exception occurred - when grabbing Selection.") print("An exception occurred - when grabbing Selection.")
# #
@@ -129,7 +142,8 @@ def PiperTTS_GUI_Get_Clipboard():
else: else:
Cursor_Position = Input_Box.index(INSERT) Cursor_Position = Input_Box.index(INSERT)
Input_Box.insert(Cursor_Position, Selected) Input_Box.insert(Cursor_Position, Selected)
except: except Exception as e:
print(e, type(e))
print("An exception occurred - when grabbing Clipboard.") print("An exception occurred - when grabbing Clipboard.")
# #
def PiperTTS_GUI_TextFile_Open(): def PiperTTS_GUI_TextFile_Open():
@@ -145,7 +159,8 @@ def PiperTTS_GUI_TextFile_Open():
Test_var.set("There are {}, lines".format(len(Input_Box.get("1.0","end-1c").splitlines()))) Test_var.set("There are {}, lines".format(len(Input_Box.get("1.0","end-1c").splitlines())))
else: else:
print("Canceled file dialog.") print("Canceled file dialog.")
except: except Exception as e:
print(e, type(e))
print("An exception occurred - when Opening Text File.") print("An exception occurred - when Opening Text File.")
# #
def PiperTTS_GUI_Reverse_Text(): def PiperTTS_GUI_Reverse_Text():
@@ -153,7 +168,8 @@ def PiperTTS_GUI_Reverse_Text():
TempText = Input_Box.get("1.0","end-1c") TempText = Input_Box.get("1.0","end-1c")
Input_Box.delete("1.0", "end-1c") Input_Box.delete("1.0", "end-1c")
Input_Box.insert("1.0", TempText[::-1]) Input_Box.insert("1.0", TempText[::-1])
except: except Exception as e:
print(e, type(e))
print("An exception occurred - when reversing text.") print("An exception occurred - when reversing text.")
# #
def PiperTTS_GUI_Randomize_Text(): def PiperTTS_GUI_Randomize_Text():
@@ -166,7 +182,8 @@ def PiperTTS_GUI_Randomize_Text():
Input_Box.insert("1.0", ''.join(TempList)) Input_Box.insert("1.0", ''.join(TempList))
end_time = time.time() end_time = time.time()
print(f'Elapsed Time: {end_time - start_time} seconds') print(f'Elapsed Time: {end_time - start_time} seconds')
except: except Exception as e:
print(e, type(e))
print("An exception occurred - when Randomizing text.") print("An exception occurred - when Randomizing text.")
# #
def PiperTTS_GUI_Randomize_Text_2nd(): def PiperTTS_GUI_Randomize_Text_2nd():
@@ -177,7 +194,8 @@ def PiperTTS_GUI_Randomize_Text_2nd():
Input_Box.insert("1.0", "".join(random.sample(TempText, len(TempText)))) Input_Box.insert("1.0", "".join(random.sample(TempText, len(TempText))))
end_time = time.time() end_time = time.time()
print(f'Elapsed Time: {end_time - start_time} seconds') print(f'Elapsed Time: {end_time - start_time} seconds')
except: except Exception as e:
print(e, type(e))
print("An exception occurred - when Randomizing text.") print("An exception occurred - when Randomizing text.")
# #
def PiperTTS_GUI_Set_Prefrences(): def PiperTTS_GUI_Set_Prefrences():
@@ -185,7 +203,8 @@ def PiperTTS_GUI_Set_Prefrences():
Input_Box_Frame.place_forget() Input_Box_Frame.place_forget()
Controls_Box_Frame.place_forget() Controls_Box_Frame.place_forget()
Prefrences_Frame.place(x = 0, y = 0, relwidth = 1, relheight = 1) Prefrences_Frame.place(x = 0, y = 0, relwidth = 1, relheight = 1)
except: except Exception as e:
print(e, type(e))
print("An exception occurred - when Setting prefrences.") print("An exception occurred - when Setting prefrences.")
@@ -197,14 +216,16 @@ def PiperTTS_GUI_Clipboard():
My_Label = Label(Controls_Box_Frame, text="Clipboard?").grid(row=3, column=0, columnspan=5) My_Label = Label(Controls_Box_Frame, text="Clipboard?").grid(row=3, column=0, columnspan=5)
#global labels = [] #global labels = []
labels.append(My_Label) labels.append(My_Label)
except: except Exception as e:
print(e, type(e))
print("An exception occurred - when pressing Clipboard Button.") print("An exception occurred - when pressing Clipboard Button.")
# Deleting info messages # Deleting info messages
def PiperTTS_GUI_Hide_All_Labels(): def PiperTTS_GUI_Hide_All_Labels():
try: try:
for label in labels: for label in labels:
label.destroy() label.destroy()
except: except Exception as e:
print(e, type(e))
print("An exception occurred - when attempting to hide previous messages.") print("An exception occurred - when attempting to hide previous messages.")
''' '''
# Creating Buttons # Creating Buttons
@@ -222,7 +243,8 @@ My_Test_Label.grid(row=0, column=0, columnspan=4)
try: try:
Test_var = StringVar(value = "0") Test_var = StringVar(value = "0")
Test_var.set("There are {}, lines".format(len(Input_Box.get("1.0","end-1c").splitlines()))) Test_var.set("There are {}, lines".format(len(Input_Box.get("1.0","end-1c").splitlines())))
except: except Exception as e:
print(e, type(e))
print("Mkay did not work.") print("Mkay did not work.")
# #
def OnKeyPress(event): def OnKeyPress(event):
@@ -256,9 +278,11 @@ try:
#MyTestText = Input_Box.get("1.0","end-1c") #MyTestText = Input_Box.get("1.0","end-1c")
#MyTestText2 = "There are {}, lines".format(len(Input_Box.get("1.0","end-1c").splitlines())) #MyTestText2 = "There are {}, lines".format(len(Input_Box.get("1.0","end-1c").splitlines()))
My_Test_Label2["text"] = "There are {}, lines".format(len(Input_Box.get("1.0","end-1c").splitlines())) My_Test_Label2["text"] = "There are {}, lines".format(len(Input_Box.get("1.0","end-1c").splitlines()))
except: except Exception as e:
print(e, type(e))
print("Fuckup again.") print("Fuckup again.")
except: except Exception as e:
print(e, type(e))
print("An exception occurred - trying to count like dracula.") print("An exception occurred - trying to count like dracula.")
''' '''
My_Test_Label2.grid(row=2, column=0, columnspan=4) My_Test_Label2.grid(row=2, column=0, columnspan=4)