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

This commit is contained in:
2025-12-09 02:27:56 -08:00
parent 4a4544f51a
commit 3cb3f51b03

View File

@@ -2,6 +2,7 @@ from tkinter import *
#from tkinter import ttk
from tkinter import filedialog
import atexit
import random
# Start of Code - Start of Tkinter loop
Root_Window = Tk()
@@ -99,7 +100,7 @@ def PiperTTS_GUI_Next():
def PiperTTS_GUI_New_File():
try:
My_Test_Label["text"] = "New File?"
Input_Box.delete("1.0", END)
Input_Box.delete("1.0", "end-1c")
except:
print("An exception occurred - when pressing New File Button.")
@@ -131,9 +132,33 @@ def PiperTTS_GUI_TextFile_Open():
try:
Root_Window.filename = filedialog.askopenfilename(initialdir = "./",title = "Select file",filetypes = (("Text files","*.txt"),("all files","*.*")))
print(Root_Window.filename)
if not Root_Window.filename:
with open(Root_Window.filename) as f:
Cursor_Position = Input_Box.index(INSERT)
Input_Box.insert("Cursor_Position", f.read())
else:
print("Canceled file dialog.")
except:
print("An exception occurred - when Opening Text File.")
#
def PiperTTS_GUI_Reverse_Text():
try:
TempText = Input_Box.get("1.0","end-1c")
Input_Box.delete("1.0", "end-1c")
Input_Box.insert("1.0", TempText[::-1])
except:
print("An exception occurred - when reversing text.")
#
def PiperTTS_GUI_Randomize_Text():
try:
TempText = Input_Box.get("1.0","end-1c")
Input_Box.delete("1.0", "end-1c")
TempList = list(TempText)
random.shuffle(TempList)
Input_Box.insert("1.0", ''.join(TempList))
except:
print("An exception occurred - when Randomizing text.")
#
def PiperTTS_GUI_Set_Prefrences():
try:
Input_Box_Frame.place_forget()
@@ -205,6 +230,10 @@ 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 Clipboard", command=PiperTTS_GUI_Get_Clipboard)
Tools_Toolbar.add_separator()
Tools_Toolbar.add_command(label="Randomise Text", command=PiperTTS_GUI_Randomize_Text)
Tools_Toolbar.add_command(label="Reverse Text", command=PiperTTS_GUI_Reverse_Text)
Tools_Toolbar.add_separator()
Tools_Toolbar.add_command(label="Prefrences", command=PiperTTS_GUI_Set_Prefrences)
# End of Code - Emd of Tkinter loop