FAQ
Hi,
I'm newbie to wxPython and need it to develop my little app.
But from start I have problems with tutorials. Because all of them are
compatible with Windows but not so much with Mac.
For example in this code:


import wx

class MainWindow(wx.Frame) :
def __init__(self, parent, title) :
wx.Frame.__init__(self, parent, title=title, size=(200, 100))
self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE)
self.CreateStatusBar()

filemenu = wx.Menu()

filemenu.Append(wx.ID_ABOUT, '&About', ' Information about this
program.')
filemenu.AppendSeparator()
filemenu.Append(wx.ID_EXIT, 'E&xit', ' Terminate the program')

menuBar = wx.MenuBar()
menuBar.Append(filemenu, '&File')
self.SetMenuBar(menuBar)
self.Show(True)

app = wx.App(False)
frame = MainWindow(None, 'Sample editor')
app.MainLoop()



The menus doesn't appear in the product.
Can anyone help me to find a tutorial that is for using wxPython on a
Mac?
Thanks
Ata

Search Discussions

  • Benjamin Kaplan at Jul 15, 2010 at 11:28 pm

    On Thu, Jul 15, 2010 at 3:04 PM, ata.jaf wrote:

    Hi,
    I'm newbie to wxPython and need it to develop my little app.
    But from start I have problems with tutorials. Because all of them are
    compatible with Windows but not so much with Mac.
    For example in this code:


    import wx

    class MainWindow(wx.Frame) :
    def __init__(self, parent, title) :
    wx.Frame.__init__(self, parent, title=title, size=(200, 100))
    self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE)
    self.CreateStatusBar()

    filemenu = wx.Menu()

    filemenu.Append(wx.ID_ABOUT, '&About', ' Information about this
    program.')
    filemenu.AppendSeparator()
    filemenu.Append(wx.ID_EXIT, 'E&xit', ' Terminate the program')

    menuBar = wx.MenuBar()
    menuBar.Append(filemenu, '&File')
    self.SetMenuBar(menuBar)
    self.Show(True)

    app = wx.App(False)
    frame = MainWindow(None, 'Sample editor')
    app.MainLoop()



    The menus doesn't appear in the product.
    Can anyone help me to find a tutorial that is for using wxPython on a
    Mac?
    Thanks
    Ata
    --

    Did you look on the menubar? wxPython uses native components (Cocoa in the
    case of OS X) so the menu should appear in the menu bar and not in the
    application window. wx will automatically move some of the items in the menu
    to the appropriate location (About, Preferences, and Quit are all in the
    Application menu for instance and not the file menu)

    The wxPython Wiki has a page about Mac-specific issues :
    http://wiki.wxpython.org/Optimizing%20for%20Mac%20OS%20X

    Also, you'll get better answer for questions like this (which are
    wx-specific and not Python-specific) on the wxPython list:
    http://groups.google.com/group/wxpython-users
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://mail.python.org/pipermail/python-list/attachments/20100715/230208c0/attachment.html>
  • David Bolen at Jul 16, 2010 at 10:47 pm

    "ata.jaf" <a.j.romanista at gmail.com> writes:

    import wx

    class MainWindow(wx.Frame) :
    def __init__(self, parent, title) :
    wx.Frame.__init__(self, parent, title=title, size=(200, 100))
    self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE)
    self.CreateStatusBar()

    filemenu = wx.Menu()

    filemenu.Append(wx.ID_ABOUT, '&About', ' Information about this
    program.')
    filemenu.AppendSeparator()
    filemenu.Append(wx.ID_EXIT, 'E&xit', ' Terminate the program')

    menuBar = wx.MenuBar()
    menuBar.Append(filemenu, '&File')
    self.SetMenuBar(menuBar)
    self.Show(True)

    app = wx.App(False)
    frame = MainWindow(None, 'Sample editor')
    app.MainLoop()

    The menus doesn't appear in the product.
    Can anyone help me to find a tutorial that is for using wxPython on a
    Mac?
    I think the menus are actually working as designed, and they are
    present, but just not perhaps what or where you expected. That's
    because some of the standard IDs (e.g., wx.ID_ABOUT) and some names
    (e.g., "E&xit") are adjusted under OSX to conform to that platform's
    menu standard. This is actually to your benefit, as you can use the
    same wxPython code to get menus on each platform to which users on
    that platform will be familiar.

    So for example, ID_ABOUT and ID_EXIT are always under the Application
    menu (and E&xit becomes &Quit) which is where Mac users expect them to
    be. Mac users would be quite confused if your application exited with
    Command-x rather than Command-Q.

    See http://wiki.wxpython.org/Optimizing%20for%20Mac%20OS%20X for a
    little more information. There are also a series of methods on wxApp
    if you want finer control over this (such as SetMacAboutMenuItemId,
    SetMacExitMenuItemId, SetMacPreferencesMenuItemId) but using the
    standard ID_* names does it automatically.

    If you're looking for your own specific menus, I'd just switch away
    from the standard ids and names. For example, if you switched the
    wx.ID_* in the above to -1, you'd see them show up under the File menu
    rather than relocated to the Application menu. Although "E&xit" would
    still get replaced with "&Quit".

    But if you are in fact setting up a menu for an application exit, I'd
    let wxPython do what it's doing, as your application will appear
    "normal" to users on the Mac.

    I'd also suggest moving over to the wxPython mailing list for followup
    questions as there are more folks there familiar with wxPython.

    -- David

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJul 15, '10 at 10:04p
activeJul 16, '10 at 10:47p
posts3
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase