13.07.2015 Views

The wxPython tutorial

The wxPython tutorial

The wxPython tutorial

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>The</strong> Graphics Device Interfacehttp://www.zetcode.com/wxpython/gdi/for i in range(20, 220, 20):dc.DrawText(str(i), -30, i+5)dc.DrawLine(2, i, -5, i)for i in range(100, 300, 100):dc.DrawLine(i, 2, i, -5)for i in range(3):dc.DrawText(years[i], i*100-13, -10)def DrawGrid(self, dc):dc.SetPen(wx.Pen('#d5d5d5'))for i in range(20, 220, 20):dc.DrawLine(2, i, 300, i)for i in range(100, 300, 100):dc.DrawLine(i, 2, i, 200)def DrawTitle(self, dc):font = dc.GetFont()font.SetWeight(wx.FONTWEIGHT_BOLD)dc.SetFont(font)dc.DrawText('Historical Prices', 90, 235)def DrawData(self, dc):dc.SetPen(wx.Pen('#0ab1ff'))for i in range(10, 310, 10):dc.DrawSpline(data)class LineChartExample(wx.Frame):def __init__(self, parent, id, title):wx.Frame.__init__(self, parent, id, title, size=(390, 300))panel = wx.Panel(self, -1)panel.SetBackgroundColour('WHITE')hbox = wx.BoxSizer(wx.HORIZONTAL)linechart = LineChart(panel)hbox.Add(linechart, 1, wx.EXPAND | wx.ALL, 15)panel.SetSizer(hbox)self.Centre()self.Show(True)app = wx.App()LineChartExample(None, -1, 'A line chart')app.MainLoop()37 de 44 27/04/2008 1:08

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!