How to put an image in the background using the "Pysimplegui" library?

Asked

Viewed 394 times

0

The Code I tried to use to put the image , but I could not :

 [sg.Image(r"C:\Users\Josiene\Desktop\Criptografia1.png")],

And that’s all the code :

import PySimpleGUI as sg

sg.theme('Dark')  

layout = [
          [sg.Text('Your typed chars appear here:'), sg.Text(size=(12,1), key='-OUTPUT-')],
          [sg.Image(r"C:\Users\Josiene\Desktop\Criptografia1.png")], #Esse é o código que eu coloquei achando que a imagem ia ficar como plano de fundo.
          [sg.Input(key='-IN-')],
          [sg.Button('Show'), sg.Button('Exit')]
]

window = sg.Window('Window Title', layout)

while True: 
    event, values = window.read()
    print(event, values)
    if event == sg.WIN_CLOSED or event == 'Exit':
        break
    if event == 'Show':
        window['-OUTPUT-'].update(values['-IN-'])

window.close()
  • Exit:

inserir a descrição da imagem aqui

  • I want to put an image as background , but the image when I put is on top of the "Input" and buttons.

  • shows the output of how it is getting.

  • I put out the code

  • You have to put that "blue lock" image in the background.You know how to do this ?

  • I don’t know, it’s just that by putting out the door, people can better interpret what needs to be done. I saw that using Tk() is simpler but about this library you are using I found nothing.

  • beauty bro , thanks for having tried, I think someday whoever created the library come here and answer kkkkkk

  • for nothing! if I find any solution I put here

  • Found the solution?

  • You need to put the image in the background,i don’t Read the documentation in that part,but this is the doc: https://pysimplegui.readthedocs.io/en/latest/#image-element

Show 3 more comments

1 answer

-2

good afternoon!!

Pysimplegui does not yet have the Background to Window function, we have to wait for the update, for interface beyond those that see by default I can recommend you to create your own theme with the following command:

Sg.Setoptions(background_color='#363636', text_element_background_color='#363636', element_background_color='#363636', scrollbar_color=None, input_elements_background_color='#F7F3EC', button_color=('white', '#4F4F4F'))

Browser other questions tagged

You are not signed in. Login or sign up in order to post.