【问题标题】:How can I get the text in a textbox in customtkinter?如何在 customtkinter 的文本框中获取文本?
【发布时间】:2022-12-04 10:20:11
【问题描述】:

我正在构建一个文本编辑器,但我无法保存文件,因为我无法在文本框中获取文本。甚至想在条目小部件中我可以使用 .get() 来获取文本。

我试过 .get() 但它显示一个错误,它不是一个选项。

【问题讨论】:

  • 请提供足够的代码,以便其他人可以更好地理解或重现问题。

标签: python customtkinter


【解决方案1】:

Customtkinter 库仍在开发中,并且会不断更新。

.get() 函数支持是几天前添加的,您现在可以使用它。确保您的 customtkinter 库是最新的。 (pip install --upgrade customtkinter)

示例代码:

from pytube import *
from tkinter import *
import customtkinter

def getText():
    print(textbox.get('1.0', END))

root = customtkinter.CTk()

textbox = customtkinter.CTkTextbox(root)
button = customtkinter.CTkButton(root, command=getText)
textbox.pack(pady=30, padx=20)
button.pack(pady=30, padx=20)

root.mainloop()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-10
    • 2014-07-17
    • 1970-01-01
    • 1970-01-01
    • 2014-04-25
    • 2016-11-20
    相关资源
    最近更新 更多