I have created a program using wx.lib.ogl that allows the user to right-click in order to add a new CircleShape and then edges are drawn from that shape to all the others currently drawn. Adding the shapes and creating the edges was not hard. However, I have these problems that just won’t go away:
1)When I create the OGL directly as the child of a frame, it fits in perfectly i.e fills up all available space. But I need to put it in one half of a SplitterWindow. Splitting is not a problem. But when I try to put my OGL in the panel that is window1 of my SplitterWindow, it creates a small box (around (20,20) in size) at the top left corner. I have tried to use sizers with different combinations of wx.ALL and wx.EXPAND and all those other options but it doesn’t change. I’ve tried to follow the OGL demo in the wx Demos, but I don’t see what I am doing wrong.
2)Secondly, the OGL I have created has
scrollbars. The user should be able to scroll down or right and add a shape by right-clicking. However, when I tried that, it somehow translates the position so that the shape is created much further to the left (if you scroll right) or further up (if you scroll down), such that it seems as if you hadn’t scrolled at all.
3)Is there a way superimposing text on the edges I create so that is shows the distance between two shapes. I calculate the distance using pythogras theorem (or is there an OGL method for doing this?) and I need the distance to be shown somewhere in the middle of the line.
Can anyone guide me on how to solve these problems please.
I am using wxPython 2.6.3.3 and Python 2.4 on Win XP.
Hi everyone,
I have created a program using wx.lib.ogl that allows the user to right-click in order to add a new CircleShape and then edges are drawn from that shape to all the others currently drawn. Adding the shapes and creating the edges was not hard. However, I have these problems that just won't go away:
1)When I create the OGL directly as the child of a frame, it fits in perfectly i.e fills up all available space. But I need to put it in one half of a SplitterWindow. Splitting is not a problem. But when I try to put my OGL in the panel that is window1 of my SplitterWindow, it creates a small box (around (20,20) in size) at the top left corner. I have tried to use sizers with different combinations of wx.ALL and wx.EXPAND and all those other options but it doesn't change. I've tried to follow the OGL demo in the wx Demos, but I don't see what I am doing wrong.
You can try putting the OGL canvas window directly in the splitter, instead of putting an extra panel there. Otherwise, you probably want to use the sizer like this:
2)Secondly, the OGL I have created has scrollbars. The user should be able to scroll down or right and add a shape by right-clicking. However, when I tried that, it somehow translates the position so that the shape is created much further to the left (if you scroll right) or further up (if you scroll down), such that it seems as if you hadn't scrolled at all.
You need to convert your mouse coordinates to the scrolled position. Something like this:
3)Is there a way superimposing text on the edges I create so that is shows the distance between two shapes. I calculate the distance using pythogras theorem (or is there an OGL method for doing this?) and I need the distance to be shown somewhere in the middle of the line.
You can check the code to be sure, but I think that line objects can have label objects attached to them.
Can anyone guide me on how to solve these problems please.
I am using wxPython 2.6.3.3 and Python 2.4 on Win XP.
You may want to upgrade to 2.8.x as there have been some fixes and improvements to OGL since 2.6.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!