Unable to run basic WxPython GUI script from tutorial. Inconsistences in Windows 7, bad install?

I would strongly recommend installing the wxPython docs & demos
package from ,
(assuming you are using wxPython 2.8), and using the demos as both a
test of your installation and as a starting point for sample code,
pastes from the web often have problems such as incorrect
indentation, mixed spaces and tabs, hidden chars, etc. - the demos
package is also a good test of just about all of wxPython. Give it
a go!

···

On 22/01/13 22:02, Michael Webb wrote:

General Information:

    I hear a lot of great things about wxpython,

and I want to
get familiar with using the GUI, so I’ve made several stabs at
getting it to
work. I’ve been trying to get wxpython
to work consistently on my machine for many months, having
abandoned it and
walked away several times and then come back to experience more
frustration.

    I have the very strong feeling that there is

something wrong
with my installation, but I don’t understand what it is. I have
installed and re-installed the package
and nothing helps. I install python
scripts by directly copying the entire script from a web page
and running it…
and it doesn’t do the same thing on my machine it does on other
machines. Frequently it creates a window with no
widgets, and can only be closed through the task manager, as in
this case. It’s driving me insane.

    I used to like python but i'm wondering if

I’d should walk
away from the language at this point, maybe try to learn
programming with a
different language because the inconsistences are making it
impossible for me
to progress now. I don’t know how to
learn a language that seems to perform differently for everyone
else.

    I run Windows 7, Python 2.7.3, and use the

Idle GUI. If anybody has experienced similar problems
please let me know.

Specific Script:

    I copied this script from a tutorial.

Evidently it works for most people, but in my
case it opens a window labeled wxHello with the inside greyed
out and no
widgets.

import wx

class wxHelloFrame(wx.Frame):

    """This

is the frame for our application, it is derived from

    the

wx.Frame element.“”"

    def

init(self, *args, **kwargs):

    """Initialize,

and let the user set any Frame settings"“”

    wx.Frame.__init__(self,

*args, **kwargs)

self.create_controls()

    def

create_controls(self):

    """Called

when the controls on Window are to be created"“”

pass

class wxHelloApp(wx.App):

    """The

wx.App for the wxHello application"“”

    def

OnInit(self):

    """Override

OnInit to create our Frame"“”

    frame

= wxHelloFrame(None, title=“wxHello”)

frame.Show()

self.SetTopWindow(frame)

    return

True

def create_controls(self):

    """Called

when the controls on Window are to be created"“”

    #

Horizontal sizer

    self.h_sizer

= wx.BoxSizer(wx.HORIZONTAL)

    # Create

the static text widget and set the text

    self.text =

wx.StaticText(self, label=“Enter some text:”)

    #Create the

Edit Field (or TextCtrl)

    self.edit =

wx.TextCtrl(self, size=wx.Size(250, -1))

    #Add to

horizontal sizer

    #add the

static text to the sizer, tell it not to resize

    self.h_sizer.Add(self.text,

0,)

    #Add 5

pixels between the static text and the edit

self.h_sizer.AddSpacer((5,0))

#Add Edit

    self.h_sizer.Add(self.edit,
    #Set the

sizer

self.SetSizer(self.h_sizer)

if name == “main”:

    app =

wxHelloApp()

app.MainLoop()

  To unsubscribe, send email to

or visit
here


Steve Gadget Barnes

wxPython-users+unsubscribe@googlegroups.com
http://groups.google.com/group/wxPython-users?hl=en