Update Uptated-Prototype/PiperTTS-GUI-Test.py
This commit is contained in:
@@ -5,7 +5,7 @@ import atexit
|
|||||||
Root_Window = Tk()
|
Root_Window = Tk()
|
||||||
Root_Window.title("PiperTTS - Prototype GUI") # Sets the GUI Title
|
Root_Window.title("PiperTTS - Prototype GUI") # Sets the GUI Title
|
||||||
|
|
||||||
# Setting up Window Starting Size and Position
|
# Setting up Window Starting Size and Position (can only be even numbers)
|
||||||
Window_Width = 426
|
Window_Width = 426
|
||||||
Window_Height = 576
|
Window_Height = 576
|
||||||
# Getting Screen Width and Height
|
# Getting Screen Width and Height
|
||||||
@@ -14,33 +14,37 @@ Screen_Height = Root_Window.winfo_screenheight()
|
|||||||
# Calculate Center of Screen for the window
|
# Calculate Center of Screen for the window
|
||||||
Window_PosX = (Screen_Width/2) - (Window_Width/2)
|
Window_PosX = (Screen_Width/2) - (Window_Width/2)
|
||||||
Window_PosY = (Screen_Height/2) - (Window_Height/2)
|
Window_PosY = (Screen_Height/2) - (Window_Height/2)
|
||||||
# Setting up Window in Center
|
# Sets the GUI geometry and attempts to centers window on screen
|
||||||
Root_Window.geometry(f'{Window_Width}x{Window_Height}+{int(Window_PosX)}+{int(Window_PosY)}') # Sets the GUI geometry
|
Root_Window.geometry(f'{Window_Width}x{Window_Height}+{int(Window_PosX)}+{int(Window_PosY)}')
|
||||||
#Root_Window.minsize(Window_Width, Window_Height)
|
#Root_Window.minsize(Window_Width, Window_Height)
|
||||||
|
|
||||||
# Attempts to make a Input box
|
# Attempts to create a Input Frame
|
||||||
try:
|
try:
|
||||||
Input_Box_Frame = Frame(Root_Window)
|
Input_Box_Frame = Frame(Root_Window)
|
||||||
except:
|
except:
|
||||||
print("An exception occurred - when creating input Frame.")
|
print("An exception occurred - when creating input Frame.")
|
||||||
|
|
||||||
|
# Attempts to create a Controls Frame
|
||||||
try:
|
try:
|
||||||
Controls_Box_Frame = Frame(Root_Window)
|
Controls_Box_Frame = Frame(Root_Window)
|
||||||
except:
|
except:
|
||||||
print("An exception occurred - when creating Controls Frame.")
|
print("An exception occurred - when creating Controls Frame.")
|
||||||
|
|
||||||
|
# Attempts to Place Input and Controls frames
|
||||||
try:
|
try:
|
||||||
Input_Box_Frame.place(x = 0, y = 0, relwidth = 1, relheight = 0.8)
|
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.8)
|
Controls_Box_Frame.place(x = 0, rely = 0.8, relwidth = 1, relheight = 0.7)
|
||||||
except:
|
except:
|
||||||
print("An exception occurred - when placing Frames.")
|
print("An exception occurred - when placing Frames.")
|
||||||
|
|
||||||
|
# Attempts to create a Input box
|
||||||
try:
|
try:
|
||||||
Input_Box = Text(Input_Box_Frame)
|
Input_Box = Text(Input_Box_Frame)
|
||||||
Input_Box.pack(padx=20, pady=20, expand = True, fill = "both")
|
Input_Box.pack(padx=20, pady=20, expand = True, fill = "both")
|
||||||
except:
|
except:
|
||||||
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
|
||||||
try:
|
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)
|
||||||
@@ -51,57 +55,51 @@ except:
|
|||||||
#
|
#
|
||||||
def PiperTTS_GUI_Play():
|
def PiperTTS_GUI_Play():
|
||||||
try:
|
try:
|
||||||
#PiperTTS_GUI_Hide_All_Labels()
|
My_Test_Label["text"] = "Playing?"
|
||||||
My_Label = Label(Controls_Box_Frame, text="Playing?").grid(row=3, column=0, columnspan=5)
|
|
||||||
#global labels = []
|
|
||||||
labels.append(My_Label)
|
|
||||||
C_Button_Pause["state"] == "normal"
|
C_Button_Pause["state"] == "normal"
|
||||||
C_Button_Pause["state"] = "disabled"
|
C_Button_Play["state"] = "disabled"
|
||||||
except:
|
except:
|
||||||
print("An exception occurred - when pressing Play Button.")
|
print("An exception occurred - when pressing Play Button.")
|
||||||
|
|
||||||
#
|
#
|
||||||
def PiperTTS_GUI_Pause():
|
def PiperTTS_GUI_Pause():
|
||||||
try:
|
try:
|
||||||
#PiperTTS_GUI_Hide_All_Labels()
|
My_Test_Label["text"] = "Pause?"
|
||||||
My_Label = Label(Controls_Box_Frame, text="Pause?").grid(row=3, column=0, columnspan=5)
|
|
||||||
#global labels = []
|
|
||||||
labels.append(My_Label)
|
|
||||||
C_Button_Pause["state"] == "disabled"
|
C_Button_Pause["state"] == "disabled"
|
||||||
C_Button_Pause["state"] = "normal"
|
C_Button_Play["state"] = "normal"
|
||||||
except:
|
except:
|
||||||
print("An exception occurred - when pressing Pause Button.")
|
print("An exception occurred - when pressing Pause Button.")
|
||||||
|
|
||||||
#
|
#
|
||||||
def PiperTTS_GUI_Stop():
|
def PiperTTS_GUI_Stop():
|
||||||
try:
|
try:
|
||||||
#PiperTTS_GUI_Hide_All_Labels()
|
My_Test_Label["text"] = "Stop?"
|
||||||
My_Label = Label(Controls_Box_Frame, text="Stop?").grid(row=3, column=0, columnspan=5)
|
C_Button_Pause["state"] == "disabled"
|
||||||
#global labels = []
|
C_Button_Play["state"] = "normal"
|
||||||
labels.append(My_Label)
|
|
||||||
except:
|
except:
|
||||||
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:
|
||||||
#PiperTTS_GUI_Hide_All_Labels()
|
My_Test_Label["text"] = "Previous?"
|
||||||
My_Label = Label(Controls_Box_Frame, text="Previous?").grid(row=3, column=0, columnspan=5)
|
|
||||||
#global labels = []
|
|
||||||
labels.append(My_Label)
|
|
||||||
except:
|
except:
|
||||||
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:
|
||||||
#PiperTTS_GUI_Hide_All_Labels()
|
My_Test_Label["text"] = "Next?"
|
||||||
My_Label = Label(Controls_Box_Frame, text="Next?").grid(row=3, column=0, columnspan=5)
|
|
||||||
#global labels = []
|
|
||||||
labels.append(My_Label)
|
|
||||||
except:
|
except:
|
||||||
print("An exception occurred - when pressing Next Button.")
|
print("An exception occurred - when pressing Next Button.")
|
||||||
|
#
|
||||||
|
def PiperTTS_GUI_New_File():
|
||||||
|
try:
|
||||||
|
My_Test_Label["text"] = "New File?"
|
||||||
|
Input_Box.delete("1.0", END)
|
||||||
|
except:
|
||||||
|
print("An exception occurred - when pressing New File Button.")
|
||||||
|
'''
|
||||||
#
|
#
|
||||||
def PiperTTS_GUI_Clipboard():
|
def PiperTTS_GUI_Clipboard():
|
||||||
try:
|
try:
|
||||||
@@ -119,22 +117,38 @@ def PiperTTS_GUI_Hide_All_Labels():
|
|||||||
label.destroy()
|
label.destroy()
|
||||||
except:
|
except:
|
||||||
print("An exception occurred - when attempting to hide previous messages.")
|
print("An exception occurred - when attempting to hide previous messages.")
|
||||||
|
'''
|
||||||
# Creating Buttons
|
# Creating Buttons
|
||||||
C_Button_Clipboard = Button(Controls_Box_Frame, text="📋", pady=20, padx=30, command=PiperTTS_GUI_Clipboard)
|
#C_Button_Clipboard = Button(Controls_Box_Frame, text="📋", pady=10, padx=10, command=PiperTTS_GUI_Clipboard)
|
||||||
C_Button_Play = Button(Controls_Box_Frame, text="▶", pady=20, padx=30, command=PiperTTS_GUI_Play)
|
C_Button_Play = Button(Controls_Box_Frame, text="▶", pady=10, padx=10, command=PiperTTS_GUI_Play)
|
||||||
C_Button_Pause = Button(Controls_Box_Frame, text="⏸", pady=20, padx=30, command=PiperTTS_GUI_Pause)
|
C_Button_Pause = Button(Controls_Box_Frame, text="⏸", pady=10, padx=10, command=PiperTTS_GUI_Pause)
|
||||||
C_Button_Stop = Button(Controls_Box_Frame, text="⏹", pady=20, padx=30, command=PiperTTS_GUI_Stop)
|
C_Button_Stop = Button(Controls_Box_Frame, text="⏹", pady=10, padx=10, command=PiperTTS_GUI_Stop)
|
||||||
C_Button_previous = Button(Controls_Box_Frame, text="⏮", pady=20, padx=30, command=PiperTTS_GUI_Previous)
|
C_Button_previous = Button(Controls_Box_Frame, text="⏮", pady=10, padx=10, command=PiperTTS_GUI_Previous)
|
||||||
C_Button_Next = Button(Controls_Box_Frame, text="⏭", pady=20, padx=30, command=PiperTTS_GUI_Next)
|
C_Button_Next = Button(Controls_Box_Frame, text="⏭", pady=10, padx=10, command=PiperTTS_GUI_Next)
|
||||||
|
|
||||||
|
# Creating a Test Text Label
|
||||||
|
My_Test_Label = Label(Controls_Box_Frame, text="Test Text?", anchor="center")
|
||||||
|
My_Test_Label.grid(row=0, column=0, columnspan=4)
|
||||||
|
|
||||||
# Aligning Buttons to grid
|
# Aligning Buttons to grid
|
||||||
C_Button_Clipboard.grid(row=1, column=4)
|
#C_Button_Clipboard.grid(row=1, column=4)
|
||||||
C_Button_Play.grid(row=2, column=0)
|
C_Button_Play.grid(row=1, column=0)
|
||||||
C_Button_Pause.grid(row=2, column=1)
|
C_Button_Pause.grid(row=1, column=1)
|
||||||
C_Button_Stop.grid(row=2, column=2)
|
C_Button_Stop.grid(row=1, column=2)
|
||||||
C_Button_previous.grid(row=2, column=3)
|
C_Button_previous.grid(row=1, column=3)
|
||||||
C_Button_Next.grid(row=2, column=4)
|
C_Button_Next.grid(row=1, column=4)
|
||||||
|
|
||||||
|
#Creating Toolbar menu
|
||||||
|
Root_Toolbar = menu(Root_Window)
|
||||||
|
Root_Window.configure(menu=Root_Toolbar)
|
||||||
|
#Creating File menu for Toolbar
|
||||||
|
File_Toolbar = menu(Root_Toolbar, tearoff=False)
|
||||||
|
Root_Toolbar.add_cascade(label="File", menu=File_Toolbar)
|
||||||
|
File_Toolbar.addcommand(label="New", command=PiperTTS_GUI_New_File)
|
||||||
|
File_Toolbar.addcommand(label="Open")
|
||||||
|
File_Toolbar.addcommand(label="Save")
|
||||||
|
File_Toolbar.add_seperator()
|
||||||
|
File_Toolbar.addcommand(label="Exit", command=Root_Window.quit)
|
||||||
|
|
||||||
# End of Code - Emd of Tkinter loop
|
# End of Code - Emd of Tkinter loop
|
||||||
Root_Window.mainloop()
|
Root_Window.mainloop()
|
||||||
|
|||||||
Reference in New Issue
Block a user