我在应用程序中使用curses python库,并且还实现了
Textbox
https://docs.python.org/3/library/curses.html#textbox-objects.
有没有办法在显示文本框时添加默认文本,然后用户可以编辑或替换该默认文本?
有没有办法在显示文本框时添加默认文本 然后可以由用户编辑或替换吗?
尝试这样的事情:
片段:
import tkinter as tk
root = tk.Tk()
root.title('default text to curses Textbox object')
root.geometry('400x300')
root.config(bg='#84BF04')
message ='''
I'm using the curses python library in an application and have implemented a Textbox
Is there a way to add a default text when displaying the text box that can then be either edited or replaced by the user?
'''
text_box = tk.Text(
root,
height=12,
width=40
)
text_box.pack(expand=True)
text_box.insert('end', message)
text_box.config(state='disabled')
root.mainloop()
截图: