This repository has been archived by the owner on Feb 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Home
XiaoBaiYun edited this page Jun 2, 2023
·
1 revision
Welcome to the TkTerminal wiki!
Here is an example to use the widget:
from tkinter import Tk
from tktermwidget import Terminal
# Create root window
root = Tk()
# Hide root window during initialization
root.withdraw()
# Set title
root.title("Terminal")
# Create terminal
term = Terminal(root)
term.pack(expand=True, fill="both")
# Set minimum size and center app
# Update widgets so minimum size is accurate
root.update_idletasks()
# Get minimum size
minimum_width: int = root.winfo_reqwidth()
minimum_height: int = root.winfo_reqheight()
# Get center of screen based on minimum size
x_coords = int(root.winfo_screenwidth() / 2 - minimum_width / 2)
y_coords = int(root.wm_maxsize()[1] / 2 - minimum_height / 2)
# Place app and make the minimum size the actual minimum size (non-infringable)
root.geometry(f"{minimum_width}x{minimum_height}+{x_coords}+{y_coords}")
root.wm_minsize(minimum_width, minimum_height)
# Show root window
root.deiconify()
# Start mainloop
root.mainloop()
If there is something wrong with the package, please create a issuse!