I just recently created my first custom drawn thing.
Essentially, it is a Gantt Chart. I’ve created a class that inherits from wx.ScrolledWindow. The wx.EVT_PAINT event triggers self.onPaint, which paints the entire chart using a wx.GraphicsContext. I refresh the data the chart stores when user input changes and it is all drawn based on this data. I give it the date range to show and the tasks to show in it, and it uses the tasks’ start and ending date and time to draw the tasks onto the chart.
So, it is all drawn directly onto a scrolled window, and everything works just fine.
However, I’m looking to implement some more functionality, namely a small hovering popup that shows more information about the task when the mouse hovers over the task, as well as being able to move the tasks around directly in the chart.
I can’t figure out how to do either of those, but maybe it’s just the way that I’m drawing everything. I’ve got an event handler for wx.EVT_MOTION that I can get the mouse’s coordinates from, and I was just trying to draw text where the mouse is that says the current position. In my function that gets called for wx.EVT_MOTION, I’m creating the wx.PaintDC and wx.GraphicsContext and trying to draw, however I’m getting an error because I’m not in a native paint event.
Do I have to force a refresh and then pass the data into the drawing function to paint it then? Or how else can I do it?
I’m using wxPython 2.9.3.1 on a Mac.
Thank you.