wxPython question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • diffuser78@gmail.com

    #1

    wxPython question

    I tried to follow wxPython Demo examples to understand it better. I
    used wxGlade to generate my code from the GUI builder.

    When I try to see the code for Menu and Menubar I see a little mismatch
    in the way functions are being used.

    For example, wxGlade produces code like this

    self.Action = wx.Menu()
    self.AddCompute r = wx.MenuItem(sel f.Action, wx.NewId(), _("Add
    Computer"), "",wx.ITEM_NORM AL)
    self.Action.App endItem(self.Ad dComputer)
    ## Code end

    and in the demo it is gives as

    self.Action = wx.Menu()
    Action.append(2 01, "Add Computer")
    # Code end

    Can somebody please explain this discrepancy ?

    Thanks, every help is appreciated.

  • Tim Roberts

    #2
    Re: wxPython question

    diffuser78@gmai l.com wrote:[color=blue]
    >
    >I tried to follow wxPython Demo examples to understand it better. I
    >used wxGlade to generate my code from the GUI builder.
    >
    >When I try to see the code for Menu and Menubar I see a little mismatch
    >in the way functions are being used.
    >
    >For example, wxGlade produces code like this
    >
    >self.Action = wx.Menu()
    >self.AddComput er = wx.MenuItem(sel f.Action, wx.NewId(), _("Add
    >Computer"), "",wx.ITEM_NORM AL)
    >self.Action.Ap pendItem(self.A ddComputer)
    >## Code end
    >
    >and in the demo it is gives as
    >
    >self.Action = wx.Menu()
    >Action.append( 201, "Add Computer")
    ># Code end
    >
    >Can somebody please explain this discrepancy ?[/color]

    It's not really a "discrepanc y". It's just that the latter example is a
    shortcut for the first. (Well, it would be a shortcut if you used "201"
    instead of "wx.NewId() in the first.)

    wxPython has, over the years, developed sensible shortcuts for many common
    operations. The GUI generators tend to use the "long" way, since that
    tends to be the original method that will work with any version.

    Also note that, in the first example, you are given a wx.MenuItem object to
    work with, should you need it. The second example hides it. It is rarely
    necessary to access a wx.MenuItem directly, so this is not usually an
    issue.
    --
    - Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.

    Comment

    Working...