小编김창회*_*김창회的帖子

如何设置tkinter框架的透明度?

Python 2.7 版

代码:

from Tkinter import *

root = Tk();
root.geometry ('{}x{}'.format(w,h));
left_frame = Frame(root, width = w*0.8, height=400, bg='#988C89');
right_frame = Frame(root, bg='#988C89',  width = w*0.8, height=400 );


left_frame.grid_propagate(0);
right_frame.grid_propagate(0);

root.grid_rowconfigure(1, weight=1);
root.grid_columnconfigure(0, weight=1); 

visible = Frame (root,  width = w*0.8, height=400);
visible.grid(row=0, column=0, sticky="new");
Run Code Online (Sandbox Code Playgroud)

如何调整可见框架的透明度?

如果我添加代码

 visible.attributes("transparentcolor","red")
Run Code Online (Sandbox Code Playgroud)

我得到 error : AttributeError: Frame instance has no attribute 'attributes'

和代码

visible.configure(bg='#988C8900');
Run Code Online (Sandbox Code Playgroud)

我得到 error : tkinter.TclError: invalid color name "#988C8900"

我该怎么办?

python tkinter frame

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

frame ×1

python ×1

tkinter ×1