mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
added CTkScrolledTextbox
This commit is contained in:
@ -52,7 +52,7 @@ class App(customtkinter.CTk):
|
||||
self.main_button_1 = customtkinter.CTkButton(self, fg_color=None, border_width=2)
|
||||
self.main_button_1.grid(row=3, column=3, padx=(10, 20), pady=(10, 20), sticky="nsew")
|
||||
|
||||
self.textbox = customtkinter.CTkTextbox(self)
|
||||
self.textbox = customtkinter.CTkScrolledTextbox(self)
|
||||
self.textbox.grid(row=0, column=1, padx=(20, 10), pady=(20, 10), sticky="nsew")
|
||||
|
||||
# create radiobutton frame
|
||||
@ -121,14 +121,14 @@ class App(customtkinter.CTk):
|
||||
self.scaling_optionemenu.set("100%")
|
||||
self.optionmenu_1.set("CTkOptionmenu")
|
||||
self.combobox_1.set("CTkComboBox")
|
||||
self.textbox.insert("1.0", "CTkTextbox\n\nLorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.")
|
||||
self.slider_1.configure(command=self.progressbar_2.set)
|
||||
self.slider_2.configure(command=self.progressbar_3.set)
|
||||
self.progressbar_1.configure(mode="indeterminnate")
|
||||
self.progressbar_1.start()
|
||||
|
||||
r = self.logo_label.bind("<Button-1>", lambda e: print("click"))
|
||||
print(r, type(r))
|
||||
self.textbox.insert("1.0", "CTkTextbox\n\n" + "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.\n\n" * 20)
|
||||
self.textbox.configure(border_width=5, corner_radius=20, wrap="none")
|
||||
self.radiobutton_frame.configure(border_width=3)
|
||||
|
||||
def open_input_dialog(self):
|
||||
dialog = customtkinter.CTkInputDialog(master=self, text="Type in a number:", title="CTkInputDialog")
|
||||
@ -144,7 +144,6 @@ class App(customtkinter.CTk):
|
||||
|
||||
def sidebar_button_callback(self):
|
||||
print("sidebar_button click")
|
||||
self.entry.delete(0, tkinter.END)
|
||||
|
||||
def on_closing(self, event=0):
|
||||
self.destroy()
|
||||
|
@ -1,54 +0,0 @@
|
||||
import tkinter
|
||||
import customtkinter
|
||||
|
||||
# test with scaling
|
||||
# customtkinter.set_widget_scaling(2)
|
||||
# customtkinter.set_window_scaling(2)
|
||||
# customtkinter.set_spacing_scaling(2)
|
||||
|
||||
customtkinter.set_appearance_mode("dark")
|
||||
|
||||
app = customtkinter.CTk()
|
||||
app.title("test_scrollbar.py")
|
||||
app.grid_rowconfigure(0, weight=1)
|
||||
app.grid_columnconfigure((0, 2), weight=1)
|
||||
|
||||
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)
|
||||
ctk_textbox_scrollbar.grid(row=0, column=1, padx=0, sticky="ns")
|
||||
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)
|
||||
ctk_textbox_scrollbar_1.configure(scrollbar_color="red", scrollbar_hover_color="darkred",
|
||||
border_spacing=0, width=12, fg_color="green", corner_radius=4)
|
||||
|
||||
frame_2 = customtkinter.CTkFrame(frame_1)
|
||||
frame_2.grid(row=1, column=0, columnspan=2, padx=20, pady=20, sticky="nsew")
|
||||
frame_2.grid_rowconfigure((0, ), weight=1)
|
||||
frame_2.grid_columnconfigure((0, ), weight=1)
|
||||
tk_textbox_2 = tkinter.Text(frame_2, highlightthickness=0, padx=5, pady=5, wrap="none")
|
||||
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)
|
||||
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)
|
||||
|
||||
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"]))
|
||||
|
||||
tk_textbox.insert("insert", "\n".join([str(i) for i in range(100)]))
|
||||
tk_textbox_1.insert("insert", "\n".join([str(i) for i in range(1000)]))
|
||||
tk_textbox_2.insert("insert", "\n".join([str(i) + " - "*30 for i in range(10000)]))
|
||||
|
||||
app.mainloop()
|
@ -1,54 +1,28 @@
|
||||
import tkinter
|
||||
import customtkinter
|
||||
|
||||
# test with scaling
|
||||
# customtkinter.set_widget_scaling(2)
|
||||
# customtkinter.set_window_scaling(2)
|
||||
# customtkinter.set_spacing_scaling(2)
|
||||
#customtkinter.set_widget_scaling(2)
|
||||
#customtkinter.set_window_scaling(2)
|
||||
#customtkinter.set_spacing_scaling(2)
|
||||
|
||||
customtkinter.set_appearance_mode("dark")
|
||||
|
||||
app = customtkinter.CTk()
|
||||
app.title("test_scrollbar.py")
|
||||
app.grid_rowconfigure(0, weight=1)
|
||||
app.grid_columnconfigure((0, 2), weight=1)
|
||||
app.grid_columnconfigure((0, 1), weight=1)
|
||||
|
||||
tk_textbox = customtkinter.CTkTextbox(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)
|
||||
ctk_textbox_scrollbar.grid(row=0, column=1, padx=0, sticky="ns")
|
||||
tk_textbox.configure(yscrollcommand=ctk_textbox_scrollbar.set)
|
||||
textbox_1 = customtkinter.CTkScrolledTextbox(app, fg_color=None, corner_radius=0)
|
||||
textbox_1.grid(row=0, column=0, sticky="nsew")
|
||||
textbox_1.insert("0.0", "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.\n\n" * 20)
|
||||
|
||||
frame_1 = customtkinter.CTkFrame(app)
|
||||
frame_1.grid(row=0, column=2, padx=10, pady=10, sticky="nsew")
|
||||
frame_1 = customtkinter.CTkFrame(app, corner_radius=0)
|
||||
frame_1.grid(row=0, column=1, sticky="nsew")
|
||||
frame_1.grid_rowconfigure((0, 1), weight=1)
|
||||
frame_1.grid_columnconfigure((0, ), weight=1)
|
||||
tk_textbox_1 = customtkinter.CTkTextbox(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)
|
||||
ctk_textbox_scrollbar_1.configure(scrollbar_color="red", scrollbar_hover_color="darkred",
|
||||
border_spacing=0, width=12, fg_color="green", corner_radius=4)
|
||||
frame_1.grid_columnconfigure(0, weight=1)
|
||||
|
||||
frame_2 = customtkinter.CTkFrame(frame_1)
|
||||
frame_2.grid(row=1, column=0, columnspan=2, padx=20, pady=20, sticky="nsew")
|
||||
frame_2.grid_rowconfigure((0, ), weight=1)
|
||||
frame_2.grid_columnconfigure((0, ), weight=1)
|
||||
tk_textbox_2 = customtkinter.CTkTextbox(frame_2, highlightthickness=0, padx=5, pady=5, wrap="none")
|
||||
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)
|
||||
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)
|
||||
textbox_2 = customtkinter.CTkScrolledTextbox(frame_1, wrap="none")
|
||||
textbox_2.grid(row=0, column=0, sticky="nsew", padx=20, pady=20)
|
||||
textbox_2.insert("0.0", "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.\n\n" * 20)
|
||||
|
||||
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"]))
|
||||
|
||||
tk_textbox.insert("insert", "\n".join([str(i) for i in range(100)]))
|
||||
tk_textbox_1.insert("insert", "\n".join([str(i) for i in range(1000)]))
|
||||
tk_textbox_2.insert("insert", "\n".join([str(i) + " - "*30 for i in range(10000)]))
|
||||
|
||||
app.mainloop()
|
||||
|
Reference in New Issue
Block a user