[英]How do I change the text colour of an active cell in a TkTable in Python?
我在使用Python的tkinter模块创建的应用程序中使用tktable。
当我选择一个单元格并输入它时,文本的颜色是白色的,这很难读。 例如,如何将此颜色更改为黑色。
我已经改变了'前景'的颜色,但我没有改变。
self.table = tktable.Table(self, rows=5, cols=5, multiline=0, font=("Helvetica", 10), foreground='Red', background='White', cache=True, colstretchmode='all')
self.table.grid(row=0, column=1, padx=10, pady=10, sticky='e,w')
为找到这条线的人们提供全面的解决方案:
import Tkinter as tk
import tktable
class App(tk.Frame):
def __init__(self, parent):
tk.Frame.__init__(self, parent)
self.parent = parent
self.Main()
self.grid()
def Main(self):
self.table = tktable.Table(self, rows=5, cols=5, multiline=0, font=("Helvetica", 10), foreground='Black', background='White', cache=True, colstretchmode='all')
self.table.tag_configure('active', foreground='black') # <<<ADDED LINE/ SOLUTION
self.table.grid(row=0, column=0, padx=10, pady=10, sticky='e,w')
if __name__ == "__main__":
root = tk.Tk()
app = App(root)
app.mainloop()
选择单元格进行编辑时,“active”标签生效。
尝试类似的东西:
self.table.tag_configure('active', foreground='black')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.