-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathctk_animations.py
52 lines (38 loc) · 1.19 KB
/
ctk_animations.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from tkinter import *
import customtkinter
# Set the theme and color options
customtkinter.set_appearance_mode("dark") # Modes: system (default), light, dark
customtkinter.set_default_color_theme("dark-blue") # Themes: blue (default), dark-blue, green
#root = Tk()
root = customtkinter.CTk()
root.title('Tkinter.com - CustomTkinter Widget Animations')
root.iconbitmap('images/codemy.ico')
root.geometry('700x450')
global my_y
my_y = 450/2+350
def up():
global my_y
my_y -= 20
if my_y >= 195:
my_text.place(x=700/2, y=my_y, anchor='center')
up_button.configure(text=my_y)
root.after(5, up)
def down():
global my_y
my_y += 20
if my_y <= 750:
my_text.place(x=700/2, y=my_y, anchor='center')
up_button.configure(text=my_y)
root.after(5, down)
#Frame
my_frame = customtkinter.CTkFrame(root)
my_frame.pack(pady=20)
# Buttons
up_button = customtkinter.CTkButton(my_frame, text="Up", command=up)
up_button.grid(row=0, column=0, padx=10)
down_button = customtkinter.CTkButton(my_frame, text="Down", command=down)
down_button.grid(row=0, column=1, padx=10)
# Text Box
my_text = customtkinter.CTkTextbox(root, width=400, height=200)
my_text.place(x=700/2, y=my_y, anchor='center')
root.mainloop()