Hi I am beginning to learn wxPython a little with the "wxPython in Action" book but I haven't managed to figure out this one thing I really want to do and am hoping someone can help me.

I want to do something like create an Ellipse to which I can add some text then right click the Ellipse so I can add a line+rectangle to it such that I can edit text in the rectangle...

in other words it would visually look something like the mind map attached to the post which I created in FreeMind

What concepts do I need to get the hang of to be able do something like this? I know about adding event handlers and such but not concepts relating to drawing the objects. I don't think that the wx.PaintDC will be useful for me since that is literally drawing with a pen/brush thing while what I want is to be able to create editable objects.

Do I need to create custom objects such as "an editable ellipse" "a node" etc somehow and create methods for them such as OnClick which would edit the text and onRightClick which would add a node etc etc? If so how can I go about this - creating such objects I mean and giving such objects the ability to be editable etc.

Or maybe I should create images and add labels to them and set the property of these labels to editable? But my problem is that for the nodes I want to be able to stretch them or whenever a new node is added it will be positioned relative to the other stuff attached to the ellipse...how can this happen if I just have a predefined image.

Are there widgets in wxPython that have such abilities that I can just use?

Thanks for any advice you can give me - I am not familiar enough with GUIs and wxPython to know how to go about doing something like this.

I have been Googling some more and am wondering if OpenGL would be a solution to my issues?

For example I can create objects using the wx.lib.ogl like so

import wx
import wx.lib.ogl as ogl

class MyFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__( self, None, wx.ID_ANY,
            "objects", size=(400,300))

        canvas = ogl.ShapeCanvas(self)
        canvas.SetBackgroundColour("white")

        diagram = ogl.Diagram()
        canvas.SetDiagram(diagram)
        diagram.SetCanvas(canvas)

        ellipse = ogl.EllipseShape(100, 80) 
        ellipse.SetX(180.0)  
        ellipse.SetY(100.0)  
        ellipse.SetPen(wx.Pen("red", 2))        
        canvas.AddShape(ellipse)

        text = ogl.TextShape(250, 30)  
        text.SetX(180)  
        text.SetY(240)
        text.SetPen(wx.Pen("red", 2))
        text.AddText("draggable text but can I give it a border?")
        canvas.AddShape(text)


        diagram.ShowAll(True)
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(canvas, 1, wx.GROW)
        self.SetSizer(sizer)



app = wx.App(0)
ogl.OGLInitialize()
MyFrame().Show()
app.MainLoop()

Except I have not been able to find helpful examples online that would explain if I can bind text to objects, how I can associate LineShapes to an object, what is the point of a LabelShape etc.

Would anyone over here know of any helpful tutorials for wxPython's ogl library?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.