147 lines
5.0 KiB
Python
147 lines
5.0 KiB
Python
from tkinter import *
|
|
import atexit
|
|
|
|
# Start of Code - Start of Tkinter loop
|
|
Root_Window = Tk()
|
|
Root_Window.title("PiperTTS - Prototype GUI") # Sets the GUI Title
|
|
|
|
# Setting up Window Starting Size and Position
|
|
Window_Width = 426
|
|
Window_Height = 576
|
|
# Getting Screen Width and Height
|
|
Screen_Width = Root_Window.winfo_screenwidth()
|
|
Screen_Height = Root_Window.winfo_screenheight()
|
|
# Calculate Center of Screen for the window
|
|
Window_PosX = (Screen_Width/2) - (Window_Width/2)
|
|
Window_PosY = (Screen_Height/2) - (Window_Height/2)
|
|
# Setting up Window in Center
|
|
Root_Window.geometry(f'{Window_Width}x{Window_Height}+{int(Window_PosX)}+{int(Window_PosY)}') # Sets the GUI geometry
|
|
#Root_Window.minsize(Window_Width, Window_Height)
|
|
|
|
# Attempts to make a Input box
|
|
try:
|
|
Input_Box_Frame = Frame(Root_Window)
|
|
except:
|
|
print("An exception occurred - when creating input Frame.")
|
|
|
|
try:
|
|
Controls_Box_Frame = Frame(Root_Window)
|
|
except:
|
|
print("An exception occurred - when creating Controls Frame.")
|
|
|
|
try:
|
|
Input_Box_Frame.place(x = 0, y = 0, relwidth = 1, relheight = 0.8)
|
|
Controls_Box_Frame.place(x = 0, rely = 0.8, relwidth = 1, relheight = 0.8)
|
|
except:
|
|
print("An exception occurred - when placing Frames.")
|
|
|
|
try:
|
|
Input_Box = Text(Input_Box_Frame)
|
|
Input_Box.pack(padx=20, pady=20, expand = True, fill = "both")
|
|
except:
|
|
print("An exception occurred - when creating input box.")
|
|
|
|
try:
|
|
Main_Text_Scrollbar = Scrollbar(Input_Box_Frame, command = Input_Box_Frame.yview)
|
|
Input_Box_Frame.configure(yscrollcommand = Main_Text_Scrollbar.set)
|
|
Main_Text_Scrollbar.place(relx = 1, rely = 0, relheight = 1, anchor = "ne")
|
|
except:
|
|
print("An exception occurred - when creating a scroll bar.")
|
|
|
|
#
|
|
def PiperTTS_GUI_Play():
|
|
try:
|
|
#PiperTTS_GUI_Hide_All_Labels()
|
|
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"] = "disabled"
|
|
except:
|
|
print("An exception occurred - when pressing Play Button.")
|
|
|
|
#
|
|
def PiperTTS_GUI_Pause():
|
|
try:
|
|
#PiperTTS_GUI_Hide_All_Labels()
|
|
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"] = "normal"
|
|
except:
|
|
print("An exception occurred - when pressing Pause Button.")
|
|
|
|
#
|
|
def PiperTTS_GUI_Stop():
|
|
try:
|
|
#PiperTTS_GUI_Hide_All_Labels()
|
|
My_Label = Label(Controls_Box_Frame, text="Stop?").grid(row=3, column=0, columnspan=5)
|
|
#global labels = []
|
|
labels.append(My_Label)
|
|
except:
|
|
print("An exception occurred - when pressing Stop Button.")
|
|
|
|
#
|
|
def PiperTTS_GUI_Previous():
|
|
try:
|
|
#PiperTTS_GUI_Hide_All_Labels()
|
|
My_Label = Label(Controls_Box_Frame, text="Previous?").grid(row=3, column=0, columnspan=5)
|
|
#global labels = []
|
|
labels.append(My_Label)
|
|
except:
|
|
print("An exception occurred - when pressing Previous Button.")
|
|
|
|
#
|
|
def PiperTTS_GUI_Next():
|
|
try:
|
|
#PiperTTS_GUI_Hide_All_Labels()
|
|
My_Label = Label(Controls_Box_Frame, text="Next?").grid(row=3, column=0, columnspan=5)
|
|
#global labels = []
|
|
labels.append(My_Label)
|
|
except:
|
|
print("An exception occurred - when pressing Next Button.")
|
|
|
|
#
|
|
def PiperTTS_GUI_Clipboard():
|
|
try:
|
|
#PiperTTS_GUI_Hide_All_Labels()
|
|
My_Label = Label(Controls_Box_Frame, text="Clipboard?").grid(row=3, column=0, columnspan=5)
|
|
#global labels = []
|
|
labels.append(My_Label)
|
|
except:
|
|
print("An exception occurred - when pressing Clipboard Button.")
|
|
|
|
# Deleting info messages
|
|
def PiperTTS_GUI_Hide_All_Labels():
|
|
try:
|
|
for label in labels:
|
|
label.destroy()
|
|
except:
|
|
print("An exception occurred - when attempting to hide previous messages.")
|
|
|
|
# Creating Buttons
|
|
C_Button_Clipboard = Button(Controls_Box_Frame, text="📋", pady=20, padx=30, command=PiperTTS_GUI_Clipboard)
|
|
C_Button_Play = Button(Controls_Box_Frame, text="▶", pady=20, padx=30, command=PiperTTS_GUI_Play)
|
|
C_Button_Pause = Button(Controls_Box_Frame, text="⏸", pady=20, padx=30, command=PiperTTS_GUI_Pause)
|
|
C_Button_Stop = Button(Controls_Box_Frame, text="⏹", pady=20, padx=30, command=PiperTTS_GUI_Stop)
|
|
C_Button_previous = Button(Controls_Box_Frame, text="⏮", pady=20, padx=30, command=PiperTTS_GUI_Previous)
|
|
C_Button_Next = Button(Controls_Box_Frame, text="⏭", pady=20, padx=30, command=PiperTTS_GUI_Next)
|
|
|
|
# Aligning Buttons to grid
|
|
C_Button_Clipboard.grid(row=1, column=4)
|
|
C_Button_Play.grid(row=2, column=0)
|
|
C_Button_Pause.grid(row=2, column=1)
|
|
C_Button_Stop.grid(row=2, column=2)
|
|
C_Button_previous.grid(row=2, column=3)
|
|
C_Button_Next.grid(row=2, column=4)
|
|
|
|
# End of Code - Emd of Tkinter loop
|
|
Root_Window.mainloop()
|
|
|
|
# Function called on Exit
|
|
def Registered_Exit():
|
|
print("Goodbye!?")
|
|
|
|
# Regestering Exit
|
|
atexit.register(Registered_Exit) |