Files
PiperTTS-scripts/Uptated-Prototype/Class-Based-GUI-Test.py

44 lines
1.8 KiB
Python

import tkinter as tk
from tkinter import ttk
class MyApp(tk.Tk):
def __init__(self):
super().__init__()
self.title("PiperTTS - Prototype GUI Class Based") # Sets the GUI Title
Window_Width, Window_Height = 420, 570 # Defining Window Starting Size
Screen_Width, Screen_Height = self.winfo_screenwidth(), self.winfo_screenheight() # Getting Screen Width and Height
Window_PosX, Window_PosY = (Screen_Width/2) - (Window_Width/2), (Screen_Height/2) - (Window_Height/2) # Calculate Center of Screen for the window
self.geometry(f'{Window_Width}x{Window_Height}+{int(Window_PosX)}+{int(Window_PosY)}') # Sets Window Size And Starting Position
self.minsize(Window_Width, Window_Height) # Defining Window Minimum Size
self.MainTextWidget = MainTextWidget(self) # Creates Text input Frame
self.MainPlaybackWidget = MainPlaybackWidget(self) # Creates Playback button Frame
self.mainloop()
class MainTextWidget(ttk.Frame):
def __init__(self, parent):
super().__init__(parent)
self.pack(fill = "both", expand = True)
Input_Box = tk.Text(self, selectbackground="yellow", selectforeground="black", undo=True)
Input_Box.pack(side = "left", padx=5, pady=5, expand = True, fill = "both")
class MainPlaybackWidget(ttk.Frame):
def __init__(self, parent):
super().__init__(parent)
self.pack(fill = "both")
GUI_Button_PlayAndPause = ttk.Button(self, text="")
GUI_Button_Stop = ttk.Button(self, text="")
GUI_Button_previous = ttk.Button(self, text="")
GUI_Button_Next = ttk.Button(self, text="")
GUI_Button_PlayAndPause.grid(row=0, column=0)
GUI_Button_previous.grid(row=0, column=1)
GUI_Button_Stop.grid(row=0, column=2)
GUI_Button_Next.grid(row=0, column=3)
MyApp()