[wxPython-users] Drawing connectors between two buttons
Robin Dunn
robin at alldunn.com
Tue Sep 4 15:33:36 PDT 2007
Jarno Väyrynen wrote:
> Hi all,
>
> I have been working on a tool that has three columns of buttons. These buttons
> visualize interdependencies, which are based on xml data. I have now managed to
> draw the buttons and process the interdependency data appropriately, but I have
> no idea how then to connect two buttons to each other i.e. draw a line between
> them. Is there a way to directly connect two buttons, or do you always have to
> parse their coordinates?
>
> I have studied material about wxDc, wxBufferedPaintDC and so on, but I still
> haven't managed to use them, even though I have a working example in
> wxPython2.8 Docs and Demos.
>
> Are there some limitations on what surface one can draw lines? Can I draw on a
> normal wx.Frame?
Some platforms allow it, but you would be better off to put all the
content in another panel which is the only child of the frame, and then
draw in it.
> Currently those 3 columns of buttons are each in a separate
> wx.Panel that have been added to horizontal box sizer.
Are the panels adjacent or is there space between them? Are the buttons
next to the edge of their panels or is there space between the edge of
the parent and the button? The reason I ask these questions is that it
will determine where you need to draw. Think of the contents of your
Frame as a stack of differently sized and shaped pancakes, and on top of
the largest pancake at the bottom of the stack you have three smaller
pancakes each with a collection of tiny pancakes on top of that. Now
visualize looking at the pancakes from above and make a line of syrup
from one of the tiny pancakes in one substack to a tiny pancake in
another substack. Which pancake(s) does the syrup touch on its way from
one to the other? Those are the window(s) where you need to draw the
line, or a fragment of the line.
Do you need the 3 panels for something other than helping with the
layout? If not you might consider not using those panels and just put
the buttons directly on the main panel and put their vertical sizers
directly in the main horizontal sizer. Then you'll only need to worry
about putting the lines on the main panel.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list