Feature request: Enable detection of window minimised state
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 39/100
Direzione di ricerca
Start by tracing the window.read and window.minimize entry points, then inspect how window.TKroot.state() and winfo_viewable() are exposed across supported platforms. The issue names no source files or tests; done should provide a reliable way to distinguish minimized, restored, and systray states so applications can respond accordingly.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
It would help to have a feature that allows detecting whether the window is minimised or un-minimised or in systray. The reason it helps to have this feature is that the programmer can then write code to avoid having to process any GUI event loop when the program is minimised. In certain programs this can help save a huge amount of processing.
I tried asking an LLM if such a feature is already available, and it generated the below code but it does not detect the minimised and un-minimised state.
import platform
# Identify the OS
OS_TYPE = platform.system() # Returns 'Linux', 'Windows', or 'Darwin' (macOS)
layout = [
[sg.Text("Window State Monitor", font=("Helvetica", 16))],
[sg.Text("Current State:", size=(15, 1)), sg.Text("", key="-STATE-", text_color="yellow")],
[sg.Button("Minimize Me"), sg.Button("Exit")]
]
window = sg.Window("OS State Demo", layout, finalize=True)
while True:
# Use a short timeout to refresh the check periodically
event, values = window.read(timeout=200)
if event in (sg.WIN_CLOSED, 'Exit'):
break
if event == "Minimize Me":
window.minimize()
# --- CROSS-PLATFORM STATE DETECTION ---
# 1. Get the standard tkinter state
raw_state = window.TKroot.state()
# 2. Check if the window is physically 'viewable' (especially useful on Linux)
# returns 1 if visible on screen, 0 if minimized/hidden
is_viewable = window.TKroot.winfo_viewable()
display_status = "Unknown"
if OS_TYPE == "Windows":
# Windows handles 'zoomed' and 'iconic' reliably
if raw_state == "iconic":
display_status = "MINIMIZED"
elif raw_state == "zoomed":
display_status = "MAXIMIZED"
else:
display_status = "VISIBLE (Normal)"
elif OS_TYPE == "Linux":
# On Linux, raw_state often stays 'normal'. Use winfo_viewable for accuracy.
if is_viewable == 0 or raw_state == "iconic":
display_status = "MINIMIZED (Iconified)"
else:
display_status = "VISIBLE (Normal)"
elif OS_TYPE == "Darwin": # macOS
if raw_state == "iconic":
display_status = "MINIMIZED"
else:
display_status = "VISIBLE"
# Update GUI and Console
window["-STATE-"].update(display_status)
print(f"[{OS_TYPE}] Raw State: {raw_state} | Viewable: {is_viewable} | Status: {display_status}")
window.close()
- Lingua principale
- Python
- Stelle
- 867
- Fork
- 106
- Merge medio
- 1m
- PR unite (30g)
- 2
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di spyoungtech/FreeSimpleGUI
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
spyoungtech/FreeSimpleGUI#109 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
spyoungtech/FreeSimpleGUI#86 · 1 commento · 2 reazioni ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 58/100
spyoungtech/FreeSimpleGUI#101 · 8 reazioni ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
spyoungtech/FreeSimpleGUI#99 · 1 reazione ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
spyoungtech/FreeSimpleGUI#95 ·
Tutte le issue di spyoungtech/FreeSimpleGUI
Issue simili
-
货币战争手改优先级配置缺少列表元素类型校验(P3) Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
syfoud/Simulated_Scepter#172 ·
-
A cancelled tests run makes the coverage comment workflow fail and reports it as a red check on main Apertaarea: ci bug perceived difficulty: 3
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Nitjsefnie-Harness-Commons/daedalus#921 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
EleutherAI/lm-evaluation-harness#4207 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
ClickHouse/clickhouse-connect#1057 ·