wxPython tutorial?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jive Dadson

    wxPython tutorial?

    I'm trying (without conspicuous success) to start learning
    wxPython. Sooo... I opened the doc page wxPythonManual. html#wxpython-overview.
    The very first example does not work. Try it. I find much of what follows
    to be incomprehensibl e. Is there a good tutorial for novices?

    Here's the example that does not work. ("No module named frame")


    import wx

    from frame import Frame

    class App(wx.App):
    """Applicat ion class."""

    def OnInit(self):
    self.frame = Frame()
    self.frame.Show ()
    self.SetTopWind ow(self.frame)
    return True

    def main():
    app = App()
    app.MainLoop()

    if __name__ == '__main__':
    main()
  • Greg Krohn

    #2
    Re: wxPython tutorial?

    Jive Dadson wrote:[color=blue]
    > I'm trying (without conspicuous success) to start learning
    > wxPython. Sooo... I opened the doc page wxPythonManual. html#wxpython-overview.
    > The very first example does not work. Try it. I find much of what follows
    > to be incomprehensibl e. Is there a good tutorial for novices?
    >
    > Here's the example that does not work. ("No module named frame")
    >[/color]
    [snip]

    Weird. I've never seen imports like that with wxPython before. Try the
    following code, instead. Notice that I changed three things: I replaced
    the imports, changed "wx.App" and "Frame" to "wxApp" and "wxFrame", and
    changed the constructor args for the frame.

    from wxPython.wx import *

    class App(wxApp):
    def OnInit(self):
    self.frame = wxFrame(NULL, -1, "MyApp Frame")
    self.frame.Show ()
    self.SetTopWind ow(self.frame)
    return True

    def main():
    app = App()
    app.MainLoop()

    if __name__ == '__main__':
    main()



    I'm not too sure about that tutorial you mentioned, but you can try
    these, also:

    <http://wxpython.org/tut-part1.php> Starts off almost identical to what
    you had (except that this one woks). It's a short tutorial, though.

    <http://tinyurl.com/oq0p> Lot's of information.


    greg

    Comment

    • Tjarko de Jong

      #3
      Re: wxPython tutorial?

      On 26 Feb 2004 22:55:52 -0800, jdadson@yahoo.c om (Jive
      Dadson) wrote:
      [color=blue]
      >I'm trying (without conspicuous success) to start learning
      >wxPython. Sooo... I opened the doc page wxPythonManual. html#wxpython-overview.
      >The very first example does not work. Try it. I find much of what follows
      >to be incomprehensibl e. Is there a good tutorial for novices?[/color]

      While using "import wx" is cleaner the turorials uses often
      "from wxpython import * " Thus function and class names are
      changed.

      change:
      self.frame = Frame()
      self.frame = wx.Frame()

      Comment

      • Nicholas Wieland

        #4
        Re: wxPython tutorial?

        - Jive Dadson <jdadson@yahoo. com> :[color=blue]
        > I'm trying (without conspicuous success) to start learning
        > wxPython.[/color]

        Take a look at the wiki on the wxPython site.

        HTH,
        --
        __Nicholas Wieland
        Flat is better than nested.
        __The Zen of Python

        Comment

        • Tjarko de Jong

          #5
          Re: wxPython tutorial?

          On Fri, 27 Feb 2004 09:38:00 GMT, Greg Krohn
          <greg.invalid@c apra.us.invalid > wrote:
          [color=blue]
          >Jive Dadson wrote:[color=green]
          >> I'm trying (without conspicuous success) to start learning
          >> wxPython. Sooo... I opened the doc page wxPythonManual. html#wxpython-overview.
          >> The very first example does not work. Try it. I find much of what follows
          >> to be incomprehensibl e. Is there a good tutorial for novices?
          >>
          >> Here's the example that does not work. ("No module named frame")
          >>[/color]
          >[snip]
          >
          >Weird. I've never seen imports like that with wxPython before.[/color]

          It keeps the namespace clear. see:


          Comment

          • simo

            #6
            Re: wxPython tutorial?

            jdadson@yahoo.c om (Jive Dadson) wrote:[color=blue]
            > I'm trying (without conspicuous success) to start learning
            > wxPython. Sooo... I opened the doc page wxPythonManual. html#wxpython-overview.
            > The very first example does not work. Try it. I find much of what follows
            > to be incomprehensibl e. Is there a good tutorial for novices?
            >
            > Here's the example that does not work. ("No module named frame")[/color]

            Probably a bit out-of-date, not using the wx namespace (wxFrame).

            Here's a good tutorial: http://wxpython.org/tutorial.php

            Which is from http://wiki.wxpython.org/index.cgi/H...arn_20wxPython

            All I needed, and much better than TKinter, although I've since moved onto PyQt.

            Comment

            • Greg Krohn

              #7
              Re: wxPython tutorial?

              Tjarko de Jong wrote:[color=blue]
              > On Fri, 27 Feb 2004 09:38:00 GMT, Greg Krohn
              > <greg.invalid@c apra.us.invalid > wrote:[color=green]
              >>
              >>Weird. I've never seen imports like that with wxPython before.[/color]
              >
              >
              > It keeps the namespace clear. see:
              > http://cvs.osafoundation.org/index.c....html?rev=HEAD
              >[/color]

              Oh, thanks. I'm a little suprised I haven't heard of this before. I must
              be living under a rock. It's nice, though. I like it.

              /me runs off to fix my code.

              greg

              Comment

              Working...