[Tkinter] No menu bar in window - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: [Tkinter] No menu bar in window (/thread-6483.html) |
No menu bar in window - bde69 - Nov-25-2017 Hello, Please could you help me to understand why I cannot properly run this code under mac OS : #!/usr/bin/python # coding: utf-8 from tkinter import Tk, PanedWindow, Label from tkinter.filedialog import * from tkinter.messagebox import * def ouverture_fichier() : filename = askopenfilename(title="Ouvrir votre document",filetypes=[('txt files','.txt'),('all files','.*')]) fichier = open(filename, 'r') content = fichier.read() fichier.close() Label(fenetre, text=content).pack(padx=10, pady=10) def alert() : showinfo("alerte", "Bravo!") fenetre = Tk() fenetre.title("Analyse de transcriptions") fenetre.resizable(True, False) fenetre.geometry('600x500-100+100') menubar = Menu(fenetre) menufichier = Menu(menubar, tearoff=0) menubar.add_cascade(label="Fichier", menu=menufichier) menufichier.add_command(label="Ouvrir", command=ouverture_fichier) menufichier.add_command(label="Editer", command=alert) menufichier.add_separator() menufichier.add_command(label="Quitter", command=fenetre.quit) menuediter = Menu(menubar, tearoff=0) menubar.add_cascade(label="Editer", menu=menuediter) menuediter.add_command(label="Couper", command=alert) menuediter.add_command(label="Copier", command=alert) menuediter.add_command(label="Coller", command=alert) menuaide = Menu(menubar, tearoff=0) menubar.add_cascade(label="Aide", menu=menuaide) menuaide.add_command(label="A propos", command=alert) fenetre.config(menu=menubar) fenetre.mainloop() print ("Fenetre fermee")1 / I run this code under : mac OS 10.13 / python 3.6.3 / tkinter.Tcl 8.5.18.0 As a result, the window appears without menu. Here is the problem. 2/ I run this code under 2 other different windows os, (one test is under windows XP / python 3.4.4 / tkinter.Tcl 8.6.1) As a result, the window appears with menu. Any idea please ? RE: No menu bar in window - heiner55 - Nov-25-2017 Does it appear on the mac menubarĀ (!= windows menu bar) ? RE: No menu bar in window - bde69 - Nov-25-2017 Yes you are right, the menu is on the mac menubar. I didn't saw it before. Thank you. So do you know an issue ? RE: No menu bar in window - heiner55 - Nov-25-2017 Maybe this helps: https://stackoverflow.com/questions/42744454/is-there-a-way-to-show-the-menu-bar-inside-an-application-window-on-a-mac RE: No menu bar in window - bde69 - Nov-25-2017 Ok thanks. Now I'm going to look for a way to manage with both mac and windows OS. RE: No menu bar in window - heiner55 - Nov-25-2017 OK, keep us up to date |