DEV Community

Kaveh Sabouri
Kaveh Sabouri

Posted on

CustomTkinter training

Hello everyone today we want to learn about CustomTkinter.

1.Making main window

import customtkinter

app = customtkinter.CTk()
app.geometry("600x500")
app.title("CTk example")


app.mainloop()
Enter fullscreen mode Exit fullscreen mode

output:

Image description

2.Making Frame

master: root
width: width (px)
height: height (px)
border_width : setting width of border (px)
fg_color : (foreground color) setting background color.
corner_radius : setting border radius

How to make a frame?

import customtkinter

app = customtkinter.CTk()
app.geometry("600x500")
app.title("CTk example")

frame = customtkinter.CTkFrame(master=app,
                               width=200,
                               height=200,
                               corner_radius=10,
                               fg_color="red")
frame.place(x=20, y=20)


app.mainloop()

Enter fullscreen mode Exit fullscreen mode

output:

Image description

3.Making Label

import customtkinter
import tkinter

app = customtkinter.CTk()
app.geometry("600x500")
app.title("CTk example")

simple_label = customtkinter.CTkLabel(master=app, text="CTkLabel")
simple_label.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)


app.mainloop()

Enter fullscreen mode Exit fullscreen mode

output:

Image description

4.Making Button

import customtkinter
import tkinter
app = customtkinter.CTk()
app.geometry("600x500")
app.title("CTk example")

button = customtkinter.CTkButton(master=app,
                                 width=120,
                                 height=32,
                                 border_width=0,
                                 corner_radius=8,
                                 text="CTkButton")
button.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)

app.mainloop()
Enter fullscreen mode Exit fullscreen mode

output:

Image description

5.Making Entry

import customtkinter

app = customtkinter.CTk()
app.geometry("600x500")
app.title("CTk example")


entry = customtkinter.CTkEntry(master=app, placeholder_text="CTkEntry")
entry.pack(padx=20, pady=10)

app.mainloop()
Enter fullscreen mode Exit fullscreen mode

output:

Image description

If you want learn more about CustomTkinter: Source

Thank you for reading this post.

Don't forget : Like Comment Subscribe

Top comments (1)

Collapse
 
artydev profile image
artydev

Thank you :-)