我试图为自己和同学(我知道)创建一个聊天服务器,我想改变文本小部件中背景的颜色。无论如何我能做到这一点吗?我知道偶然window.configure(bg="blue")
但无论如何,文本小部件有颜色吗?另外,我可以更改按钮的颜色甚至文本吗?谢谢!继承人代码:
top = tkinter.Tk()
top.title("Client code chatter!")
messages_frame = tkinter.Frame(top)
my_msg = tkinter.StringVar() # For the messages to be sent.
my_msg.set("")
scrollbar = tkinter.Scrollbar(messages_frame) # To navigate through past
messages.
# Following will contain the messages.
msg_list = tkinter.Listbox(messages_frame, height=17, width=70,
yscrollcommand=scrollbar.set)
scrollbar.pack(side=tkinter.RIGHT, fill=tkinter.Y)
msg_list.pack(side=tkinter.LEFT, fill=tkinter.BOTH)
msg_list.pack()
messages_frame.pack()
entry_field = tkinter.Entry(top, width=65, textvariable=my_msg)
entry_field.bind("<Return>", send)
entry_field.pack()
send_button = tkinter.Button(top, text="Send", command=send)
send_button.pack()