create a GUI app with TKinter and Python

Publié le: 15 août 2023
sur la chaîne: Paul Cayley
59
1

Build a GUI application using Tkinter / customTKinter.

Using TCL/Tk to build apps with python

https://docs.python.org/3/library/tkinter....

See also
• TkDocs
Extensive tutorial on creating user interfaces with Tkinter. Explains key concepts, and illustrates recommended approaches using the modern API.
• Tkinter 8.5 reference: a GUI for Python
Reference documentation for Tkinter 8.5 detailing available classes, methods, and options.
Tcl/Tk Resources:
• Tk commands
Comprehensive reference to each of the underlying Tcl/Tk commands used by Tkinter.
• Tcl/Tk Home Page
Additional documentation, and links to Tcl/Tk core development.
Books:
• Modern Tkinter for Busy Python Developers
By Mark Roseman. (ISBN 978-1999149567)
• Python and Tkinter Programming
By Alan Moore. (ISBN 978-1788835886)
• Programming Python
By Mark Lutz; has excellent coverage of Tkinter. (ISBN 978-0596158101)
• Tcl and the Tk Toolkit (2nd edition)
By John Ousterhout, inventor of Tcl/Tk, and Ken Jones; does not cover Tkinter. (ISBN 978-0321336330)

---------------------

Here is the code that was shown in this video:

#! /usr/bin/env python3
'''Demonstration of customTKinter see TKInter documentation at https://docs.python.org/3/library/tkinter.... '''

import sys
import os
from platform import system as system_name # Returns the system/OS name
from subprocess import call as system_call # Execute a shell command

'''-----------------'''
import customtkinter

'''================='''

import my_module

'''-----------------'''

def my_calculate():
output_box.delete(0)
print("my_calculate invoked")
output_box.delete(0,)
output_box.insert(0, my_module.my_strlen(input_box.get()))

'''================='''


try:


customtkinter.set_appearance_mode("dark") # Modes: system (default), light, dark

customtkinter.set_default_color_theme("blue") # Themes: blue (default), dark-blue, green

app =customtkinter.CTk() # create CTk window like you do with the Tk window


app.geometry("230x280")

input_box = customtkinter.CTkEntry(master = app, placeholder_text = "enter text here")
input_box.pack( padx = 12, pady=20)

output_box = customtkinter.CTkEntry(master = app, placeholder_text = "Char Count")
output_box.pack( padx = 12, pady=10)




Use CTkButton instead of tkinter Button


button = customtkinter.CTkButton(master=app, text="Calculate", command=my_calculate)
button.place(relx=0.5, rely=0.6, anchor=customtkinter.CENTER)


button1 = customtkinter.CTkButton(master=app, text="Exit", command=app.destroy)
button1.place(relx=0.5, rely=0.8, anchor=customtkinter.CENTER)


app.mainloop()


except Exception as e:
print(type(e), e)
sys.exit(-1)


Sur cette page du site, vous pouvez voir la vidéo en ligne create a GUI app with TKinter and Python durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Paul Cayley 15 août 2023, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 59 fois et il a aimé 1 téléspectateurs. Bon visionnage!