Tkinter ttk.Button背景色溢出边框问题求助
自定义Tkinter按钮背景色溢出边框问题
![边框外的颜色]
以下是自定义按钮的代码:
style.configure('Dark.TButton', background=button_base, foreground=colors['text'], borderwidth=1, bordercolor=edge, lightcolor=edge, darkcolor=edge, padding=(10, 4)) style.map('Dark.TButton', background=[('pressed', pressed_bg or hover_bg or button_base), ('active', hover_bg or button_base), ('!disabled', 'red')], foreground=[('active', colors['text']), ('pressed', colors['text'])], bordercolor=[('pressed', edge), ('active', edge)], lightcolor=[('pressed', edge), ('active', edge)], darkcolor=[('pressed', edge), ('active', edge)]) style.layout('Dark.TButton', [ ('Button.border', {'sticky': 'nswe', 'children': [ ('Button.padding', {'sticky': 'nswe', 'children': [ ('Button.label', {'sticky': 'nswe'}) ]}) ] }) ])
为了让问题更直观,我把按钮背景色设成了红色。试过增大borderwidth参数,结果只是让边框整体外扩,厚度并没有变化,背景色溢出边框的问题依然存在。
用原生Tk.Button不会出现背景溢出的情况,但会丢失按钮的斜面边框效果:
![完整UI展示]
内容的提问来源于stack exchange,提问作者Maj mac
相关产品推荐
相关产品推荐

