简体   繁体   English

如何设置tkinter消息边框

[英]How to set tkinter Message border

I have tried all ways to set tkinter message widget border, but still receive any effect. 我尝试了所有方法来设置tkinter消息窗口小部件边框,但是仍然会收到任何效果。 I wonder if it does not have a border attribute? 我想知道它是否没有边框属性? But I can set label and Text border using the same code. 但是我可以使用相同的代码设置标签和文本边框。 Here is my code snippet: 这是我的代码段:

from tkinter import *

root = Tk()
frame = Frame(root)
message = Message(frame, text="hello world", width=200)
message.config(fg="red", borderwidth=100, highlightcolor="green")
frame.pack()
message.pack()

root.minsize(300, 200)
root.mainloop()

this's result: 结果:

没有绿色边框的结果

OS Version:OS X 10.11.4 作业系统版本:OS X 10.11.4

Python version: 3.52 Python版本:3.52

You are setting the borderwidth correctly. 您正在正确设置borderwidth。 The issue is that you can't see the changes you are implementing, until your add background colour and change the relief of the Frame and Message widget. 问题是,直到添加background颜色并更改“ FrameMessage小部件的relief ,您才能看到正在执行的更改。 Now try changing the borderwidths with this revised code, and I trust you get the "gotcha" moment. 现在,尝试使用此修改后的代码更改borderwidths,我相信您会遇到“麻烦”的时刻。

from tkinter import *

root = Tk()
frame = Frame(root, background='yellow', borderwidth=20, relief=RAISED)
message = Message(frame, text="hello world", width=200)
message.config(fg="red", borderwidth=50, highlightcolor="green",
               background='light blue', relief=SUNKEN)
frame.pack()
message.pack()

root.minsize(300, 200)
root.mainloop()

结果

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM