Hello,
I am trying to use wxPython to draw some simple lines but am not
getting the results that I want. In my user interface, when the user
makes certain actions I want a window to pop up which will have certain
multi-coloured bars displaying some information to them.
This is the code I have for that window, with some sample coordinates
put in there. I get the window with a white background but no line. Do
I need to refresh it somehow after the line is drawn?
Thanks,
Gabriel
···
##############
class PopupFrame(wx.Frame):
def init(self):
wx.Frame.init(self, None, -1, ‘Status Windowt’, size=(300,250))
self.sketch = SketchWindow(self,-1)
class SketchWindow(wx.Window):
def init(self, parent, ID):
wx.Window.init(self, parent, ID)
self.SetBackgroundColour(“White”)
self.color = “Black”
self.thickness = 1
self.pen = wx.Pen(self.color, self.thickness, wx.SOLID)
self.InitBuffer()
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.DrawLines(dc)
self.reInitBuffer = False
def DrawLines(self, dc):
coords = [(12,13,12,14), (12,14,12,15), (12,15,12,16), (13,16,13,17), (14,17,14,18)]
for eachcoord in coords:
dc.DrawLine(*eachcoord)