python - 我如何在 tkinter 中创建带有背景的圆形按钮
问题描述
我有一个带有背景的 GUI,当我放置一个按钮时,borderwidth=0
它会显示一个圆形按钮,但它周围有正方形。我该如何解决?
所以这是我的按钮:
exit_image = tk.PhotoImage(file="cancel.png")
button_exit = tk.Button(root,image=exit_image, borderwidth=0 ,command=quit_window)
button_exit.place(relx=0.89, rely=0.009, relwidth=0.1, relheight=0.07)
我的问题:
我认为问题出在我的背景图片上,但我不确定。因此,如果您对此感兴趣,这里是我如何设置背景图像的代码:
#Backround Image:
backround_image = tk.PhotoImage(file="schloss3.png")
backround_label = tk.Label(root,image = backround_image)
backround_label.place(relwidth=1, relheight=1)
解决方案
您需要将背景颜色设置为窗口的主颜色,看起来像黑色。
还将highlightthickness 和borderwidth 设置为0,因此图像上没有边框。
backround_label = tk.Label(root,image = backround_image,bg='black',highlightthickness=0,borderwidth=0)
推荐阅读
- php - 上传 excel 时,我的 php 自动加载器文件中有错误
- python - 如何在groupby对象中对没有时间列的基于时间的列进行排序
- html -
- 打破列表指标
- database - 一个帖子可以多次查询吗?
- python-3.x - 从 self._uid 获取错误的用户 ID
- python - 如何在神经网络的隐藏层中对权重矩阵的列实施正交约束?
- kubernetes - 为什么即使我没有访问权限,我的 PodSecurityPolicy 也会被应用?
- sorting - 对未排序的数组进行排序和二进制搜索 n 次或线性搜索未排序的数组 n 次更好?
- forms - 在 Flutter TextFormField 中输入数据时键盘一直消失
- javascript - Vue.js Snotify - 异步触发多个调用