Whilst the lines aren't in exactly the right position (not sure why). You could bind to a panel and draw directly to it like so,
import wx
class Cartesian(wx.Frame):
def __init__(self, parent=None, id=-1, title=""):
wx.Frame.__init__(self, parent, id, title, size=(640, 480))
self.panel = wx.Panel(self)
self.panel.Bind(wx.EVT_PAINT, self.OnPaint)
def OnPaint(self, event):
dc = wx.PaintDC(event.GetEventObject())
dc.Clear()
dc.SetPen(wx.Pen(wx.BLACK))
dc.DrawLine(320, 0, 320, 480)
dc.DrawLine(0, 240, 640, 240)
app = wx.App(False)
frame = Cartesian()
frame.Show()
app.MainLoop()
So this code creates the panel to draw on based off the frame and then draws in a black pen with the dc.DrawLine()
method, which takes 4 parameters, the first x/y coordinates, and the second x/y coordinates.
Alternatively you can use wx.StaticLine()
in a similar fashion as such:
import wx
class Cartesian(wx.Frame):
def __init__(self, parent=None, id=-1, title=""):
wx.Frame.__init__(self, parent, id, title, size=(640, 480))
self.panel = wx.Panel(self)
wx.StaticLine(self.panel, pos=(320, 0), size=(1, 480), style=wx.LI_VERTICAL)
wx.StaticLine(self.panel, pos=(0, 240), size=(640, 1), style=wx.LI_HORIZONTAL)
app = wx.App(False)
frame = Cartesian()
frame.Show()
app.MainLoop()