【发布时间】:2022-01-21 17:31:59
【问题描述】:
我正在使用 PySimpleGui 制作一个 GUI,我希望我的一个按钮是一个圆圈,一个是更大的。有没有办法做到这一点?如果是这样,怎么做?我正在使用 TKinter 端口。
【问题讨论】:
标签: python user-interface tkinter button pysimplegui
我正在使用 PySimpleGui 制作一个 GUI,我希望我的一个按钮是一个圆圈,一个是更大的。有没有办法做到这一点?如果是这样,怎么做?我正在使用 TKinter 端口。
【问题讨论】:
标签: python user-interface tkinter button pysimplegui
尝试sg.Button 的image_filename 或image_data 选项,并从主题设置中设置正确的按钮颜色,并将边框宽度设置为0。
这是它的工作原理示例,请记住在以下代码中使用您的图像文件。
import PySimpleGUI as sg
font = ('Helvetica', 12, 'bold italic')
sg.theme('Dark')
sg.set_options(font=font)
colors = (sg.theme_background_color(), sg.theme_background_color())
layout = [
[sg.Button('Blue\nCircle', button_color=colors, image_filename='d:/circle_blue.png', border_width=0)]
]
window = sg.Window('Image Button', layout, finalize=True)
while True:
event, values = window.read()
if event == sg.WINDOW_CLOSED:
break
window.close()
【讨论】:
sg 忘了这里,你可能会误解这里的东西。不要使用sg.image_filename 作为sg.Button 的选项,否则你会得到AttributeError: module 'PySimpleGUI' has no attribute 'image_filename'。