Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[Bug] Menu Element visibility parameter does not work

Đang mở
#6,524 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
desktop

Hướng nghiên cứu

Bắt đầu với bản tái hiện Windows 10, tkinter được cung cấp bằng cách sử dụng sg.Menu(menu_def, visible=False, key='-MENUBAR-'), sau đó so sánh hành vi ban đầu của nó với window['-MENUBAR-'].update(visible=False). Được xem là hoàn tất khi thanh menu bắt đầu ở trạng thái ẩn với visible=False và vẫn phản hồi chính xác với các sự kiện enable-visibility và disable-visibility của ví dụ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Bug Port - TK
Type of Issue (Enhancement, Error, Bug, Question)

Bug


Operating System

Windows 10

PySimpleGUI Port (tkinter, Qt, Wx, Web)

tkinter


Versions

Python version: 3.11.5 (tags/v3.11.5:cce6ba9, Aug 24 2023, 14:38:34) [MSC v.1936 64 bit (AMD64)]
port: tkinter
tkinter version: 8.6.12
PySimpleGUI version: 4.60.5
PySimpleGUI filename: C:\Users\stephen.cholvat\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\PySimpleGUI\PySimpleGUI.py

Troubleshooting

These items may solve your problem. Please check those you've done by changing - [ ] to - [X]

  • Searched main docs for your problem www.PySimpleGUI.org
  • Looked for Demo Programs that are similar to your goal. It is recommend you use the Demo Browser! Demos.PySimpleGUI.org
  • None of your GUI code was generated by an AI algorithm like GPT
  • If not tkinter - looked for Demo Programs for specific port
  • For non tkinter - Looked at readme for your specific port if not PySimpleGUI (Qt, WX, Remi)
  • Run your program outside of your debugger (from a command line)
  • Searched through Issues (open and closed) to see if already reported Issues.PySimpleGUI.org
  • Have upgraded to the latest release of PySimpleGUI on PyPI (lastest official version)
  • Tried using the PySimpleGUI.py file on GitHub. Your problem may have already been fixed but not released
Detailed Description

I tried to initialize a menu bar using the following line:
sg.Menu(menu_def, visible=False, key='-MENUBAR-')

However, the menu bar was still visible. Using the .update(visible=False) function did properly hide the menu bar.

Code To Duplicate

# Paste your code here
import PySimpleGUI as sg

menu_def = [['&File', ['&Open     Ctrl-O', '&Save       Ctrl-S', '&Properties', 'E&xit']]]

layout = [
    #This visible=False parameter has no effect
    [sg.Menu(menu_def, visible=False, key='-MENUBAR-')],
    [sg.Button('Enable Visibility', key="enable-visibility")],
    [sg.Button('Disable Visibility', key="disable-visibility")]
]
window = sg.Window("Menu Visibility Test", layout)

while True:
    event, values = window.read()
    if event in (sg.WIN_CLOSED, 'Exit'):
        break
    elif event == "enable-visibility":
        window['-MENUBAR-'].update(visible = True)
    elif event == "disable-visibility":
        window['-MENUBAR-'].update(visible = False)
window.close()

Screenshot, Sketch, or Drawing

image


Watcha Makin?

If you care to share something about your project, it would be awesome to hear what you're building.

Ngôn ngữ chính
Python
Star
13.8k
Fork
1.8k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của PySimpleGUI/PySimpleGUI

Tất cả issue của PySimpleGUI/PySimpleGUI

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.