1

Dears,

How To Minimize Window Using Python/PySimpleGUI ? Knowing that , I want to hide existing title bar from my Window and add my personal icons :Maximize, Minimize and Close, it's OK for 2 and not the case for Minimize.

I followed answer shared in : How to create a minimize button with pysimplegui?, unfortunately didn't help , it's behavying same as Close button.

if event == "Button":

  window.close()

Could you please support on that ?

1 Answers1

3

Check the document on https://www.pysimplegui.org/en/latest/ all the time.

import PySimpleGUI as sg

sg.PySimpleGUI.SYMBOL_TITLEBAR_MINIMIZE = '.'
sg.PySimpleGUI.SYMBOL_TITLEBAR_MAXIMIZE = 'O'
sg.PySimpleGUI.SYMBOL_TITLEBAR_CLOSE    = 'x'

layout = [
    [sg.Titlebar(
        title='TITLE',
        icon=sg.EMOJI_BASE64_HAPPY_IDEA,
        text_color='white',
        background_color='blue',
        font=('Courier New', 40, 'bold'),
    )],
    [sg.Button('Minimize'), sg.Button('Exit')],
]

window = sg.Window('Title', layout, finalize=True,
    # use_custom_titlebar=True,
    # titlebar_background_color='blue',
    # titlebar_text_color='white',
    # titlebar_font=('Courier New', 40, 'bold'),
    # titlebar_icon=sg.EMOJI_BASE64_HAPPY_IDEA,
)

while True:

    event, values = window.read()

    if event in (sg.WIN_CLOSED, 'Exit'):
        break
    elif event == 'Minimize':
        window.minimize()

window.close()

The buttons for minimize, maximize and close button of a window are defined as Text elements. You have to define one Titlebar element by yourself if you want to use figures for them.

Jason Yang
  • 11,284
  • 2
  • 9
  • 23
  • Thanks @Jason Yang, it's Working as expected – PyiPath2022 Nov 09 '22 at 12:40
  • `sg.PySimpleGUI.SYMBOL_TITLEBAR_MINIMIZE` won't work with a local copy of PySimpleGUI.py.... GitHub issues would be so much easier/better, but can't seem to convince Hacene2022 to use github. – Mike from PSG Nov 09 '22 at 18:15