2

Does anyone know why it will not show the taskbar in my code. I am trying to get the top to say Exit and information in the file drop down menu. I am kind of new to tkinter and i just need a bit of help please. Also if you have any suggestions on how to improve it, i would really appreciate it!

My code is below:

from time import sleep
from tkinter import * 
from tkinter import messagebox, ttk, Tk

root = Tk()

class GUI():

    def taskbar(self):

        menu = Menu(root)
        file = Menu(menu)
        file.add_command(label="Exit", command=self.exit_GUI)
        file.add_command(label = "Information", command=self.info_popup)        

   def Main_Menu(self):

        topFrame = Frame(root)
        topFrame.pack()
        bottomFrame = Frame(root)
        bottomFrame.pack(side=BOTTOM)

        Income_button = Button(topFrame, text="Enter your incomes", command=self.Income)
        Expense_button = Button(topFrame, text="Enter your expenses", command=self.Expense)
        Total_button = Button(bottomFrame, text="View Results", command=self.Total)
        Income_button.pack()
        Expense_button.pack()
        Total_button.pack()

    def Income(self):
        pass

    def Expense(self):
        pass

    def Total(self):
        pass

    def exit_GUI(self):
        exit()

    def info_popup(self):
        pass

g = GUI()
g.taskbar()
g.Main_Menu()
g.Income()
g.Expense()
g.Total()
g.info_popup()

root.mainloop()
3
  • You forgot the root.config(menu=menu) to tell the window to actually use your menubar. Commented Oct 19, 2018 at 22:28
  • @jasonharper didn't work, it said menu is not defined Commented Oct 19, 2018 at 22:40
  • You need to do it at a point where menu actually is defined, then. Commented Oct 19, 2018 at 23:19

1 Answer 1

2

You need to change the taskbar function to:

def taskbar(self):

    menu = Menu(root)
    file = Menu(menu)
    file.add_command(label="Exit", command=self.exit_GUI)
    file.add_command(label = "Information", command=self.info_popup) 
    root.config(menu=file)

This will tell the window to use the menubar.

Sign up to request clarification or add additional context in comments.

1 Comment

it stopped giving me the error but it still didn't show up when the script is run

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.