0

Hi I'm trying to add a menubar to my Python Program. I was looking at a tutorial online, but it's for python3.4 and I'm running Python3.5.

The code (shown below) appears as commands in IDE, so I know I'm not typing the commands wrong, but when I run my program it doesn't load (so obviously I am :/ ). The icon appears in the sidebar on the Desktop, but no GUI actually appears, only the little popupmsg saying "Error 404", kinda ironic right?.

Once I comment out these lines, the program works fine.

Does anyone have any idea to what i going on?

Many Thanks in Advance! :)

    menubar = tk.Menu(container)
    filemenu = tk.Menu(menubar, tearoff=0)
    filemenu.add_command(label="Save Settings", command=popupmsg("Error 404"))
    filemenu.add_separator() #adds dividor
    filemenu.add_command(label="Exit", command=quit)
    filemenu.add_cascade(label="File", menu=filemenu)

    tk.Tk.config(self,  menu=menubar)
AlphaBetaGamma96
  • 567
  • 3
  • 6
  • 21
  • *but it's for python3.4* -- So? Has Tkinter really changed that much between one Python release? – OneCricketeer Jul 31 '16 at 22:05
  • I hope you realize that you have not told Tkinter to make a actual window. That is to say, if that is all your code. – Christian Dean Jul 31 '16 at 22:34
  • 1
    _"I was looking at a tutorial online, but it's for python3.4 and I'm running Python3.5."_ - tkinter has no significant changes between python 2.7 and 3.5, other than the way you import it. – Bryan Oakley Jul 31 '16 at 22:45
  • oh yeah that's only the section causing an error, I was just wondering if the commands had changed or something. I can input all the code if you'd like? – AlphaBetaGamma96 Aug 01 '16 at 17:14

1 Answers1

0

I think I came across the same tutorial: https://pythonprogramming.net/creating-main-menu-tkinter/ and like you, I could not see any menubar, although I checked my code several times.

In my case, I expected the menubar right in the window (as shown in the video). But as I am programming on a Mac, the menubar is not shown in the window itself, but in the row next to the Apple logo.

For me, this solved my "problem", thanks to this reply: https://stackoverflow.com/a/31555492/6431917

Community
  • 1
  • 1
SLglider
  • 267
  • 1
  • 4
  • 16