MenuBar not showing

Hi guys.

I have this piece of code that doens’t show the menu bar for some reason. I strip out much of the code shown here, but the MenuBar still don’t appear. The weird thing is that I have other windows with the menu bar showing with no problem. I’m on Windows 10. Any ideia of what could be? Thanks!

import wx

class EnergyConsumption(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent)

        self.menu = wx.MenuBar()
        self.status_bar = self.CreateStatusBar()
        self.Center()

        self.setupMenuBar(self.menu)

    def setupMenuBar(self, menu):
        file_menu = wx.Menu()

        # Criando os itens do menu.
        open_item_menu = file_menu.Append(wx.ID_OPEN, '&Abrir\tCtrl+A', 'Abrir um arquivo')
        file_menu.AppendSeparator()
        home_item_menu = file_menu.Append(wx.ID_HOME, 'Voltar para Home', 'Voltar para a tela de boas vindas')
        exit_item_menu = file_menu.Append(wx.ID_EXIT, 'Sair', 'Sair do programa')

        # Criando os bindings.
        self.Bind(wx.EVT_MENU, self.placeholder, open_item_menu)
        self.Bind(wx.EVT_MENU, self.placeholder, home_item_menu)
        self.Bind(wx.EVT_MENU, self.placeholder, exit_item_menu)

        menu.Append(file_menu, 'Arquivo')

    def placeholder(self, event):
        pass

app = wx.App()
frame = EnergyConsumption(None)
frame.Show()
app.MainLoop()

After the call to self.setupMenuBar(self.menu) you need to call self.SetMenuBar(self.menu).

def __init__(self, parent):
        wx.Frame.__init__(self, parent)

        self.menu = wx.MenuBar()
        self.status_bar = self.CreateStatusBar()
        self.Center()

        self.setupMenuBar(self.menu)
        self.SetMenuBar(self.menu)
1 Like

Thanks so much, @RichardT
Can’t believe that I let this llittle detail slip. :frowning: