親愛的,
如何使用 Python/PySimpleGUI 最小化視窗?知道了這一點,我想從我的視窗中隱藏現有的標題欄并添加我的個人圖示:最大化、最小化和關閉,這對于 2 是可以的,而不是最小化的情況。
我遵循了共享的答案:如何使用 pysimplegui 創建最小化按鈕?,不幸的是沒有幫助,它的行為與關閉按鈕相同。
if event == "Button":
window.close()
你能支持嗎?
uj5u.com熱心網友回復:
一直檢查https://www.pysimplegui.org/en/latest/上的檔案。
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()
按鈕minimize和視窗maximize的close按鈕被定義為Text元素。Titlebar如果你想為它們使用數字,你必須自己定義一個元素。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/532207.html
上一篇:消耗性浮動按鈕重定向到另一個活動
下一篇:如何讓不同的按鈕打開不同的內容
