Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Help in wxpython

Reply
Thread Tools

Help in wxpython

 
 
madhura vadvalkar
Guest
Posts: n/a
 
      12-02-2009
Hi

I am trying to write an PAINT like application where on the mouse
click a circle is drawn on canvas. I am new to python and using
wxpython to create this.

here is the code:

import wx

class SketchWindow(wx.Window):

def __init__ (self, parent,ID):

wx.Window.__init__(self, parent, ID)

self.panel =wx.Panel(self, size= (350,350))
self.pen=wx.Pen( 'blue',4)
self.pos=(0,0)
self.InitBuffer()
self.Bind(wx.EVT_LEFT_DOWN,self.OnLeftDown)

def InitBuffer(self):

size=self.GetClientSize()
self.Buffer=wx.EmptyBitmap(size.width,size.height)
dc=wx.BufferedDC(None,self.buffer)
dc.SetBackground(wx.Brush(self.GetBackgroundColour ()))
dc.Clear()
self.Drawcircle(dc)
self.reInitBuffer=False

def OnLeftDown(self,event):
self.pos=event.GetPositionTuple()
self.CaptureMouse()

def Drawcircle(self,dc):
pen=wx.Pen(colour,thickness,wx.SOLID)
dc.SetPen(pen)
dc.DrawCircle(self.pos.x,self.pos.y,r)

class SketchFrame(wx.Frame):
def __init__(self, parent):

wx.Frame.__init__(self, parent, -1, "Sketch Frame",size=(800,600))
self.sketch = SketchWindow(self, -1)

if __name__=='__main__':
app=wx.PySimpleApp()
frame=SketchFrame(None)
frame.Show(True)
app.MainLoop()

I am getting the following error:

Traceback (most recent call last):
File "C:/Python26/circle.py", line 42, in <module>
frame=SketchFrame(None)
File "C:/Python26/circle.py", line 38, in __init__
self.sketch = SketchWindow(self, -1)
File "C:/Python26/circle.py", line 12, in __init__
self.InitBuffer()
File "C:/Python26/circle.py", line 19, in InitBuffer
dc=wx.BufferedDC(None,self.buffer)
AttributeError: 'SketchWindow' object has no attribute 'buffer'

Please tell me what I am doing wrong.

Thanks









--
Madhura
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[wxPython-users] ANNOUNCE: wxPython 2.6.3.0 Robin Dunn Python 0 03-28-2006 06:03 PM
[wxPython-users] Web based applications are possible with wxPython? Ruben Charles Python 6 10-25-2005 09:41 PM
wxPython - wx package (new style wxPython?) Logan Python 5 12-11-2003 04:12 PM
[PY GUI] interest function in python GUI(wxpython,pyqt) program.wxpython,pyqt ulysses Python 4 10-22-2003 03:28 PM
wxPython looses function "wxPython.wx.miscc" Anand Python 1 07-23-2003 01:59 AM



Advertisments