简体   繁体   English

在 PySimpleGui 中创建自定义按钮

[英]Create Custom Buttons in PySimpleGui

I'm making a GUI with PySimpleGui and I want one of my buttons to be a circle, one to be bigger and I want to move one of them.我正在用 PySimpleGui 制作一个 GUI,我希望我的一个按钮是一个圆圈,一个更大,我想移动其中一个。 Is there a way to do this?有没有办法做到这一点? If so, how?如果是这样,怎么做? I'm using the TKinter port我正在使用 TKinter 端口

Try option image_filename or image_data of sg.Button , and set correct button color from theme setting, also set border width to 0.尝试sg.Button的选项image_filenameimage_data ,并从主题设置中设置正确的按钮颜色,还将边框宽度设置为 0。

Here's example how it work, remember to use your image file in following code.这是它如何工作的示例,请记住在以下代码中使用您的图像文件。

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()

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM