use_custom_titlebar=True
sets no_titlebar=True
for your window. Under Windows, this sets window.TKroot.wm_overrideredirect(True)
, causing the (system) window manager to ignore the window. As one of the consequences, there is no taskbar icon.
Tcl/Tk documentation: wm overrideredirect
There are some tricks to deal with it when working directly with Tkinter (see, e.g., Making Tkinter windows show up in the taskbar) but we cannot do this directly via PySimpleGUI so far. Currently, I'm exploring how to make a dummy window to appear in the taskbar and to couple it with my window, but I don't have a working solution yet.
To keep my main window accessible even if it's behind another window, I'm using a system tray that always stays on top. (You may want to consider setting keep_on_top=True
for your window, but sometimes it's simply not convenient.)
To prevent maximisation, you can either tweak the function Titlebar()
in PySimpleGUI and comment out its part where the maximise-symbol is added like this:
return Column([[Column([icon_and_text_portion], pad=(0, 0), background_color=bc),
Column([[T(SYMBOL_TITLEBAR_MINIMIZE, text_color=tc, background_color=bc, enable_events=True, font=font, key=TITLEBAR_MINIMIZE_KEY),
# Text(SYMBOL_TITLEBAR_MAXIMIZE, text_color=tc, background_color=bc, enable_events=True, font=font,key=TITLEBAR_MAXIMIZE_KEY),
Text(SYMBOL_TITLEBAR_CLOSE, text_color=tc, background_color=bc, font=font, enable_events=True, key=TITLEBAR_CLOSE_KEY),
]],
element_justification='r', expand_x=True, grab=True, pad=(0, 0), background_color=bc)
]],
expand_x=True, grab=True, background_color=bc, pad=(0,0),metadata=TITLEBAR_METADATA_MARKER, key=key)
or you can remove the titlebar completely using no_titlebar=True
in your window and add your own titlebar at the beginning of your layout, for example with this function (tweaked from https://github.com/PySimpleGUI/PySimpleGUI/blob/master/DemoPrograms/Demo_Window_Background_Image.py):
titlebar = [sg.Col([[sg.Text(your_titlebar_text, text_color=tc, background_color=bc, font=font, grab=True)]],
pad=(0, 0), background_color=bc),
sg.Col([[sg.Text(sg.SYMBOL_X, background_color=bc, enable_events=enable_events)]], # '❎'
element_justification='r', key='-X-', grab=True, pad=(0, 0), background_color=bc)]
(you may want to add sg.HorizontalSeparator()
as an extra row in the titlebar).
As an example:
import PySimpleGUI as sg
titlebar = [[sg.Col([[sg.Text('My window', grab=True)]], pad=(0, 0)),
sg.Col([[sg.Text(sg.SYMBOL_X, enable_events=True, key='-X-')]], # '❎'
element_justification='r', grab=True, pad=(0, 0), expand_x=True)],
[sg.HorizontalSeparator()]]
layout = titlebar + [[sg.B('Exit', size=(12, 3))]]
window = sg.Window('My window', layout, no_titlebar=True, finalize=True)
while True:
event, values = window.read()
print(event)
if event in (None, 'Exit', '-X-'):
break
window.close()
