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

This commit is contained in:
2025-12-06 10:32:24 -08:00
parent 0fe63a27e7
commit 5894fd4926

View File

@@ -1,4 +1,6 @@
from tkinter import * from tkinter import *
from tkinter import ttk
from tkinter import filedialog
import atexit import atexit
# Start of Code - Start of Tkinter loop # Start of Code - Start of Tkinter loop
@@ -104,8 +106,11 @@ def PiperTTS_GUI_New_File():
# #
def PiperTTS_GUI_Get_Selection(): def PiperTTS_GUI_Get_Selection():
try: try:
Cursor_Position = Input_Box.index(INSERT)
Selected = Root_Window.selection_get() Selected = Root_Window.selection_get()
if not Selected:
My_Test_Label["text"] = "No text Selected"
else:
Cursor_Position = Input_Box.index(INSERT)
Input_Box.insert(Cursor_Position, Selected) Input_Box.insert(Cursor_Position, Selected)
except: except:
print("An exception occurred - when grabbing Selection.") print("An exception occurred - when grabbing Selection.")
@@ -113,11 +118,28 @@ def PiperTTS_GUI_Get_Selection():
# #
def PiperTTS_GUI_Get_Clipboard(): def PiperTTS_GUI_Get_Clipboard():
try: try:
Cursor_Position = Input_Box.index(INSERT)
Selected = Root_Window.clipboard_get() Selected = Root_Window.clipboard_get()
if not Selected:
My_Test_Label["text"] = "No text in clipboard"
else:
Cursor_Position = Input_Box.index(INSERT)
Input_Box.insert(Cursor_Position, Selected) Input_Box.insert(Cursor_Position, Selected)
except: except:
print("An exception occurred - when grabbing Clipboard.") print("An exception occurred - when grabbing Clipboard.")
#
def PiperTTS_GUI_TextFile_Open():
try:
root.filename = filedialog.askopenfilename(initialdir = "/",title = "Select file",filetypes = (("Text files","*.txt"),("all files","*.*")))
print(root.filename)
except:
print("An exception occurred - when Opening Text File.")
#
def PiperTTS_GUI_Set_Prefrences():
try:
pass
except:
print("An exception occurred - when Setting prefrences.")
''' '''
# #
@@ -164,8 +186,8 @@ Root_Window.configure(menu=Root_Toolbar)
File_Toolbar = Menu(Root_Toolbar, tearoff=False) File_Toolbar = Menu(Root_Toolbar, tearoff=False)
Root_Toolbar.add_cascade(label="File", menu=File_Toolbar) Root_Toolbar.add_cascade(label="File", menu=File_Toolbar)
File_Toolbar.add_command(label="New", command=PiperTTS_GUI_New_File) File_Toolbar.add_command(label="New", command=PiperTTS_GUI_New_File)
File_Toolbar.add_command(label="Open") File_Toolbar.add_command(label="Open", command=PiperTTS_GUI_TextFile_Open)
File_Toolbar.add_command(label="Save") File_Toolbar.add_command(label="Save as Wave")
File_Toolbar.add_separator() File_Toolbar.add_separator()
File_Toolbar.add_command(label="Exit", command=Root_Window.quit) File_Toolbar.add_command(label="Exit", command=Root_Window.quit)
#Creating Playback menu for Toolbar #Creating Playback menu for Toolbar
@@ -182,7 +204,7 @@ Root_Toolbar.add_cascade(label="Tools", menu=Tools_Toolbar)
Tools_Toolbar.add_command(label="Insert Selection", command=PiperTTS_GUI_Get_Selection) Tools_Toolbar.add_command(label="Insert Selection", command=PiperTTS_GUI_Get_Selection)
Tools_Toolbar.add_command(label="Insert Clipboard", command=PiperTTS_GUI_Get_Clipboard) Tools_Toolbar.add_command(label="Insert Clipboard", command=PiperTTS_GUI_Get_Clipboard)
Tools_Toolbar.add_separator() Tools_Toolbar.add_separator()
Tools_Toolbar.add_command(label="Prefrences") Tools_Toolbar.add_command(label="Prefrences", command=PiperTTS_GUI_Set_Prefrences)
# End of Code - Emd of Tkinter loop # End of Code - Emd of Tkinter loop
Root_Window.mainloop() Root_Window.mainloop()