Merge pull request #3277 from PySimpleGUI/Dev-latest
Addition of minimize
This commit is contained in:
commit
c51bef5d47
|
@ -22,23 +22,38 @@ import PySimpleGUI as sg
|
||||||
#
|
#
|
||||||
# sg.theme_add_new('DarkGrey8', DarkGrey8)
|
# sg.theme_add_new('DarkGrey8', DarkGrey8)
|
||||||
|
|
||||||
|
|
||||||
|
def dummy_window():
|
||||||
|
"""
|
||||||
|
Creates an invisible window that is minimized to the taskbar
|
||||||
|
As soon as something happens to the window, it is closed and the function
|
||||||
|
returns.
|
||||||
|
The FocusIn event is set so that if the user restores the window from the taskbar, then the read
|
||||||
|
wille return, the window will be closed, and the function will return
|
||||||
|
"""
|
||||||
|
layout = [[sg.T('You will not see this')]]
|
||||||
|
window = sg.Window('Window Title', layout, finalize=True, alpha_channel=0)
|
||||||
|
window.minimize()
|
||||||
|
window.bind('<FocusIn>', '-FOCUS-')
|
||||||
|
window.read(close=True)
|
||||||
|
|
||||||
|
|
||||||
def title_bar(title):
|
def title_bar(title):
|
||||||
bg = sg.theme_input_background_color()
|
bg = sg.theme_input_background_color()
|
||||||
|
|
||||||
return [sg.Col([[sg.T(title, background_color=bg )]], pad=(0, 0), background_color=bg),
|
return [sg.Col([[sg.T(title, background_color=bg )]], pad=(0, 0), background_color=bg),
|
||||||
sg.Col([[sg.Text('❎', background_color=bg, enable_events=True, key='Exit')]], element_justification='r', k='-C-', pad=(0, 0), background_color=bg)]
|
sg.Col([[sg.T('_', background_color=bg, enable_events=True, key='-MINIMIZE-'),sg.Text('❎', background_color=bg, enable_events=True, key='Exit')]], element_justification='r', k='-C-', pad=(0, 0), background_color=bg)]
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
sg.theme('DarkGrey8') # Requires 4.28.0.4 or the code at the tiop
|
sg.theme('DarkGrey8')
|
||||||
layout = [
|
layout = [ title_bar('Window Title'),
|
||||||
title_bar('Window Title'),
|
|
||||||
[sg.T('This is normal window text. The above is the fake "titlebar"')],
|
[sg.T('This is normal window text. The above is the fake "titlebar"')],
|
||||||
[sg.T('Input something:')],
|
[sg.T('Input something:')],
|
||||||
[sg.Input(key='-IN-'), sg.Text(size=(12,1), key='-OUT-')],
|
[sg.Input(key='-IN-'), sg.Text(size=(12,1), key='-OUT-')],
|
||||||
[sg.Button('Go')] ]
|
[sg.Button('Go')] ]
|
||||||
|
|
||||||
window = sg.Window('Window Title', layout, no_titlebar=True, grab_anywhere=True, keep_on_top=True, margins=(0,0), finalize=True)
|
window = sg.Window('Window Title', layout, resizable=True, no_titlebar=True, grab_anywhere=True, keep_on_top=True, margins=(0,0), finalize=True)
|
||||||
|
|
||||||
window['-C-'].expand(True, False, False)
|
window['-C-'].expand(True, False, False)
|
||||||
|
|
||||||
|
@ -47,6 +62,10 @@ def main():
|
||||||
print(event, values)
|
print(event, values)
|
||||||
if event == sg.WIN_CLOSED or event == 'Exit':
|
if event == sg.WIN_CLOSED or event == 'Exit':
|
||||||
break
|
break
|
||||||
|
if event == '-MINIMIZE-':
|
||||||
|
window.hide()
|
||||||
|
dummy_window()
|
||||||
|
window.un_hide()
|
||||||
if event == 'Go':
|
if event == 'Go':
|
||||||
window['-OUT-'].update(values['-IN-'])
|
window['-OUT-'].update(values['-IN-'])
|
||||||
window.close()
|
window.close()
|
||||||
|
|
Loading…
Reference in New Issue