help with this code

Hi, Can any pro help me to check the following code? I
took it from wxpython demo and tried to edit and run
by myself. sorry this is the way I learn. everytime it
freeze my computer. The image file(*.png) is the same
directory as the code.

A little more detail: I use pythonwin2.3, wxpython
2.6, windowXP.

import wx # This module uses the new
wx namespace

···

#----------------------------------------------------------------------

msg = "Some text will appear mixed in the image's
shadow..."

class TestPanel(wx.Panel):
    def __init__(self, parent):
        
        wx.Panel.__init__(self, parent, -1)

        self.Bind(wx.EVT_PAINT, self.OnPaint)

    def OnPaint(self, evt):
        dc = wx.PaintDC(self)
        dc.SetBackground(wx.Brush("WHITE"))
        dc.Clear()

        dc.SetFont(wx.Font(16, wx.SWISS, wx.NORMAL,
wx.BOLD, True))
        dc.DrawText("Bitmap alpha blending (on all
ports but gtk+ 1.2)",
                    25,25)
        wx.InitAllImageHandlers()
        bmp = wx.Bitmap('toucan.png')

        dc.DrawBitmap(bmp, 25,100, True)

        dc.SetFont(self.GetFont())
        y = 75
        for line in range(10):
            y += dc.GetCharHeight() + 5
            dc.DrawText(msg, 200, y)
        dc.DrawBitmap(bmp, 250,100, True)

class MyApp(wx.App):
    def OnInit(self):
        frame=wx.Frame(None, -1, 'title')
        TestPanel(frame)
        frame.Show(1)
        self.SetTopWindow(frame)
        return true

app=MyApp(0)
app.MainLoop()

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

The last line of code 'return true'

True needs to be capitalized

You also might want to upgrade to python 2.4 if you are able to.

sm

yi zhang wrote:

···

Hi, Can any pro help me to check the following code? I
took it from wxpython demo and tried to edit and run
by myself. sorry this is the way I learn. everytime it
freeze my computer. The image file(*.png) is the same
directory as the code.

A little more detail: I use pythonwin2.3, wxpython
2.6, windowXP.

import wx # This module uses the new
wx namespace

#----------------------------------------------------------------------

msg = "Some text will appear mixed in the image's
shadow..."

class TestPanel(wx.Panel):
    def __init__(self, parent):
                wx.Panel.__init__(self, parent, -1)

        self.Bind(wx.EVT_PAINT, self.OnPaint)

    def OnPaint(self, evt):
        dc = wx.PaintDC(self)
        dc.SetBackground(wx.Brush("WHITE"))
        dc.Clear()

        dc.SetFont(wx.Font(16, wx.SWISS, wx.NORMAL,
wx.BOLD, True))
        dc.DrawText("Bitmap alpha blending (on all
ports but gtk+ 1.2)",
                    25,25)
        wx.InitAllImageHandlers()
        bmp = wx.Bitmap('toucan.png')

                    dc.DrawBitmap(bmp, 25,100, True)

        dc.SetFont(self.GetFont())
        y = 75
        for line in range(10):
            y += dc.GetCharHeight() + 5
            dc.DrawText(msg, 200, y)
        dc.DrawBitmap(bmp, 250,100, True)

class MyApp(wx.App):
    def OnInit(self):
        frame=wx.Frame(None, -1, 'title')
        TestPanel(frame)
        frame.Show(1)
        self.SetTopWindow(frame)
        return true

app=MyApp(0)
app.MainLoop()

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.8.9/42 - Release Date: 7/6/2005

yi zhang wrote:

Hi, Can any pro help me to check the following code?

        return true

as mention by another poster: this should be True. After fixing that, It works for me on GTK

You need to run your code in a way that you can see errors. One way is to run it from a command prompt:

python myscriptname.py

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov