2022-06-19 22:16:19 +03:00
|
|
|
import tkinter
|
|
|
|
import customtkinter
|
|
|
|
|
2022-06-23 18:41:12 +03:00
|
|
|
# test with scaling
|
|
|
|
# customtkinter.set_widget_scaling(2)
|
|
|
|
# customtkinter.set_window_scaling(2)
|
|
|
|
# customtkinter.set_spacing_scaling(2)
|
2022-06-19 23:12:19 +03:00
|
|
|
|
2022-06-23 18:41:12 +03:00
|
|
|
customtkinter.set_appearance_mode("dark")
|
2022-06-19 22:16:19 +03:00
|
|
|
|
|
|
|
app = customtkinter.CTk()
|
2022-06-23 18:41:12 +03:00
|
|
|
app.title("test_scrollbar.py")
|
2022-06-19 22:16:19 +03:00
|
|
|
app.grid_rowconfigure(0, weight=1)
|
2022-06-21 00:44:35 +03:00
|
|
|
app.grid_columnconfigure((0, 2), weight=1)
|
2022-06-19 22:16:19 +03:00
|
|
|
|
2022-06-21 00:44:35 +03:00
|
|
|
tk_textbox = tkinter.Text(app, highlightthickness=0, padx=5, pady=5)
|
|
|
|
tk_textbox.grid(row=0, column=0, sticky="nsew")
|
|
|
|
ctk_textbox_scrollbar = customtkinter.CTkScrollbar(app, command=tk_textbox.yview)
|
2022-06-19 22:16:19 +03:00
|
|
|
ctk_textbox_scrollbar.grid(row=0, column=1, padx=0, sticky="ns")
|
2022-06-21 00:44:35 +03:00
|
|
|
tk_textbox.configure(yscrollcommand=ctk_textbox_scrollbar.set)
|
|
|
|
|
|
|
|
frame_1 = customtkinter.CTkFrame(app)
|
|
|
|
frame_1.grid(row=0, column=2, padx=10, pady=10, sticky="nsew")
|
|
|
|
frame_1.grid_rowconfigure((0, 1), weight=1)
|
|
|
|
frame_1.grid_columnconfigure((0, ), weight=1)
|
|
|
|
tk_textbox_1 = tkinter.Text(frame_1, highlightthickness=0, padx=5, pady=5)
|
|
|
|
tk_textbox_1.grid(row=0, column=0, sticky="nsew", padx=(5, 0), pady=5)
|
|
|
|
ctk_textbox_scrollbar_1 = customtkinter.CTkScrollbar(frame_1, command=tk_textbox_1.yview)
|
|
|
|
ctk_textbox_scrollbar_1.grid(row=0, column=1, sticky="ns", padx=(0, 5), pady=5)
|
|
|
|
tk_textbox_1.configure(yscrollcommand=ctk_textbox_scrollbar_1.set)
|
2022-06-23 18:41:12 +03:00
|
|
|
ctk_textbox_scrollbar_1.configure(scrollbar_color="red", scrollbar_hover_color="darkred",
|
|
|
|
border_spacing=0, width=12, fg_color="green", corner_radius=4)
|
2022-06-21 00:44:35 +03:00
|
|
|
|
|
|
|
frame_2 = customtkinter.CTkFrame(frame_1)
|
|
|
|
frame_2.grid(row=1, column=0, columnspan=2, padx=20, pady=20, sticky="nsew")
|
2022-06-23 23:14:19 +03:00
|
|
|
frame_2.grid_rowconfigure((0, ), weight=1)
|
2022-06-21 00:44:35 +03:00
|
|
|
frame_2.grid_columnconfigure((0, ), weight=1)
|
2022-06-23 18:41:12 +03:00
|
|
|
tk_textbox_2 = tkinter.Text(frame_2, highlightthickness=0, padx=5, pady=5, wrap="none")
|
2022-06-21 00:44:35 +03:00
|
|
|
tk_textbox_2.grid(row=0, column=0, sticky="nsew", padx=(5, 0), pady=5)
|
|
|
|
ctk_textbox_scrollbar_2 = customtkinter.CTkScrollbar(frame_2, command=tk_textbox_2.yview)
|
|
|
|
ctk_textbox_scrollbar_2.grid(row=0, column=1, sticky="ns", padx=(0, 5), pady=5)
|
2022-06-23 18:41:12 +03:00
|
|
|
ctk_textbox_scrollbar_2_horizontal = customtkinter.CTkScrollbar(frame_2, command=tk_textbox_2.xview, orientation="horizontal")
|
|
|
|
ctk_textbox_scrollbar_2_horizontal.grid(row=1, column=0, sticky="ew", padx=(5, 0), pady=(0, 5))
|
|
|
|
tk_textbox_2.configure(yscrollcommand=ctk_textbox_scrollbar_2.set, xscrollcommand=ctk_textbox_scrollbar_2_horizontal.set)
|
2022-06-21 00:44:35 +03:00
|
|
|
|
|
|
|
tk_textbox.configure(font=(customtkinter.ThemeManager.theme["text"]["font"], customtkinter.ThemeManager.theme["text"]["size"]))
|
|
|
|
tk_textbox_1.configure(font=(customtkinter.ThemeManager.theme["text"]["font"], customtkinter.ThemeManager.theme["text"]["size"]))
|
|
|
|
tk_textbox_2.configure(font=(customtkinter.ThemeManager.theme["text"]["font"], customtkinter.ThemeManager.theme["text"]["size"]))
|
2022-06-19 22:16:19 +03:00
|
|
|
|
|
|
|
tk_textbox.insert("insert", "\n".join([str(i) for i in range(100)]))
|
2022-06-21 00:44:35 +03:00
|
|
|
tk_textbox_1.insert("insert", "\n".join([str(i) for i in range(1000)]))
|
2022-06-23 18:41:12 +03:00
|
|
|
tk_textbox_2.insert("insert", "\n".join([str(i) + " - "*30 for i in range(10000)]))
|
2022-06-19 22:16:19 +03:00
|
|
|
|
|
|
|
app.mainloop()
|