python - 具有透明背景 Python 的 Tkinter 图像按钮
问题描述
我对 python 真的很陌生,并试图让一个触摸 gui 与 python 一起运行。
我在 figma 中设计了它,现在我要让按钮运行了。
问题是,我不会得到按钮的透明背景。有没有其他方法可以代替 tkinter?
我最后一次尝试是使用鼠标点击的坐标,只使用图标作为背景。但是如果没有为背景制作许多新图像,我就不会得到这个“点击”动画。
此代码独立运行并显示我的问题:
from tkinter import *
from tkinter.ttk import *
from PIL import Image, ImageTk
import tkinter as tk
window = Tk()
window.title('title')
window.geometry('1024x768')
Background = PhotoImage(file="Background.gif")
Background_Label = Label(window, image = Background)
Background_Label.place(x = 0, y = 0, relwidth = 1, relheight = 1)
ButtonMapLoad = Image.open('ButtonMap.png')
ButtonMap = ImageTk.PhotoImage(ButtonMapLoad)
tk.Button(window, image=ButtonMap, borderwidth = 0 , highlightthickness = 0, relief = "flat", overrelief = "flat").pack(padx = 100, pady = 20)
mainloop()
图片显示了我的按钮的外观。
背景按钮:
我只想要一个看起来不像 1998 年的漂亮 GUI :-(
在此先感谢,祝您有美好的一天。
威廉
解决方案
推荐阅读
- javascript - Node.js - Firebase 函数数据库 onCreate 未触发
- python - Python 3 - 将函数的 Return 存储为变量以供以后重复使用
- android - 使用 Retrofit 将 cookie 下载为文件,然后再次将 cookie 转发为文件
- firebase - Firebase 邀请:400 未找到
- c# - HttpClient client.GetAsync 可以在完整的 .Net 框架中工作,但不能在 .Net core 2.1 中工作?
- bash - 根据主机名更改鱼壳提示
- vba - 如何填充列循环?VBA Excel
- html - 我的样式表不适用于我的代码的某些部分
- swift - 为什么我不能在 self 是一个类的协议扩展中更改变量?
- c# - 将 JSON 数组反序列化为列表