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 = 400 Window_Height = 500 # 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 # Attempts to make a Input box try: Input_Box_Frame = Frame(Root_Window, width=400, height=400) Input_Box_Frame.grid(row=0, column=0, columnspan=5, padx=10, pady=20, sticky="NSEW") Main_Text_Scrollbar = Scrollbar(Input_Box_Frame) Main_Text_Scrollbar.pack(side=RIGHT, fill=y) Input_Box = Text(Input_Box_Frame, Yscrollcommand=Main_Text_Scrollbar.set) Input_Box.pack(padx=20, pady=20) except: print("An exception occurred - when creating input box.") # def PiperTTS_GUI_Play(): try: PiperTTS_GUI_Hide_All_Labels() My_Label = Label(Root_Window, text="Playing?").grid(row=3, column=0, columnspan=5) global 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(Root_Window, text="Pause?").grid(row=3, column=0, columnspan=5) global 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(Root_Window, text="Stop?").grid(row=3, column=0, columnspan=5) global 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(Root_Window, text="Previous?").grid(row=3, column=0, columnspan=5) global 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(Root_Window, text="Next?").grid(row=3, column=0, columnspan=5) global 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(Root_Window, text="Clipboard?").grid(row=3, column=0, columnspan=5) global 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: global label.destroy() except: print("An exception occurred - when attempting to hide previous messages.") # Creating Buttons C_Button_Clipboard = Button(Root_Window, text="📋", pady=20, padx=30, command=PiperTTS_GUI_Clipboard) C_Button_Play = Button(Root_Window, text="▶", pady=20, padx=30, command=PiperTTS_GUI_Play) C_Button_Pause = Button(Root_Window, text="⏸", pady=20, padx=30, command=PiperTTS_GUI_Pause) C_Button_Stop = Button(Root_Window, text="⏹", pady=20, padx=30, command=PiperTTS_GUI_Stop) C_Button_previous = Button(Root_Window, text="⏮", pady=20, padx=30, command=PiperTTS_GUI_Previous) C_Button_Next = Button(Root_Window, 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)