Python Forum

Full Version: No menu bar in window
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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 ?
Does it appear on the mac menubarĀ  (!= windows menu bar) ?
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 ?
Ok thanks.
Now I'm going to look for a way to manage with both mac and windows OS.
OK, keep us up to date