简体   繁体   English

如何从 my.png 图像中删除灰色背景

[英]How remove the gray background from my .png image

I'm using the pysimplegui to create my window, but inside that my image even being.png take the gray background.我正在使用 pysimplegui 创建我的 window,但在其中我的图像甚至 being.png 采用灰色背景。

在此处输入图像描述

thats my.png image:这就是我的.png 图像: 在此处输入图像描述

with "background color = blue"带有“背景颜色=蓝色”

在此处输入图像描述

import PySimpleGUI as sg


icon = sg.Image("./images/plane.png")

start_column = [
    [icon]
]

layout = [
    [start_column]
]

startWindow = sg.Window("hello", layout, background_color="blue")



while True:
    events, values = startWindow.read(timeout=30)
    if events == sg.WINDOW_CLOSED:
        break

without "background-color = "blue" "没有“背景色=”蓝色“”

在此处输入图像描述

There're two background_color, one for sg.Image and another one for sg.Window .有两种 background_color,一种用于sg.Image ,另一种用于sg.Window background_color of sg.Image will be sg.theme_background_color() if you don't specify the option background_color .如果您不指定选项background_colorsg.Image的 background_color 将为sg.theme_background_color()

The background color will be '#64778d' if you also don't specify what theme to use.如果您也没有指定要使用的主题,背景颜色将为'#64778d' So you will see background of your PNG will be different as background of window.所以你会看到你的PNG背景与window的背景不同。

You may specify same value of background_color for both of sg.Image and sg.Window , or all None for them.您可以为sg.Imagesg.Window指定相同的 background_color 值,或者全部为None

import PySimpleGUI as sg

layout = [[sg.Image("d:/plane.png", background_color="blue")]]
window = sg.Window("hello", layout, background_color="blue")
print(sg.theme_background_color())
while True:
    event, value = window.read(timeout=30)
    if event == sg.WINDOW_CLOSED:
        break

window.close()

I used:我用了:

sg.theme('LightBlue')

and remove the (background-color = blue) from my window parametre.并从我的 window 参数中删除 (background-color = blue)。

在此处输入图像描述

Not it's the background color that I wanted but it's working for now.不是我想要的背景颜色,但它现在可以工作。

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

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