On Wed, Jul 11, 2012 at 3:48 AM, Carl Bednorz <[email protected]> wrote:
> I decided to use floatcanvas for my MSc project where I develop a custom
> handwriting recognition system.
>
> One part of this system is to have an image viewer in the UI. I've already
> played a little bit with the nav and float canvas, but I'm
> stuck now for 2 days in a problem with the nav canvas and I have no idea
> why, so I'd appreciate it a lot if you could help me with my problem.
>
> In general: I have a wx.panel in which I'd like to have the navcanvas.
> Unfortunately, the nav canvas ignores the size parameter so that the canvas
> is just a very small rectangle. However, when I just use a floatcanvas with
> a custom build navigation everything works fine, but the disadvantage here
> is that I'd like to use the UI elements like (zooming, moving, etc.) how
> it's established in the nav canvas.
>
> I've attached my code to this mail.
hmm -- odd -- Both NavCanvas and FloatCanvas are wx.Panels. I'd expect
them to act similarly. I can't run your code -- it require images or
something that I don't have. Ideally, if you can make a small runnable
sample that doesn't require any other data, it's easier for others to
test. But looking quickly at the code:
class DocumentPanel(wx.Panel):
'''
The Document Panel class creates a wx.Panel that provides an image
viewer to access
the historical document databases.
'''
def __init__(self, parent):
'''
Constructor
'''
#Init the wx.Panel
self.panel = wx.Panel.__init__(self, parent, wx.ID_ANY)
this is odd -- this is usually:
wx.Panel.__init__(self, parent, wx.ID_ANY)
I'm not sure assigning to self.panel hurts anything, but as the panel
is self, it's not helping.
#NOTE: The created navcanvas is not fit into the panel but
just a small rectangle window!
NC = NavCanvas.NavCanvas(self, size=(400,400), ProjectionFun =
None , Debug=0, BackgroundColor = "Blue").Canvas
I'm not sure why the size isn't being respoected, but it's probably
better to use a sizer to get it to fill the Panel:
S = wx.BoxSizer(wx.Vertical)
S.Add(NC, 1, wx.EXPAND)
self.SetSizer(S)
I do see:
#Add the image control the the main sizer
self.mainSizer.Add(self.Canvas, 0, wx.ALL | wx.LEFT , 5)
perhaps making that second argument 1 will help -- in general, I"d
thikn yuou'd want the Canvas to re-size with the window anyway.
Though if there is nothing else in the Panel, you could subclass
NavCanvas, rather than putting it on a Panel.
self.Canvas = NC
Careful here -- a Navcanvas is a Panel that holds a toolbar and a
FloatCanvas -- it is not actually a FloatCanvas, so it doens't support
all teh FloatCanvasmethods -- you probably want:
self.Canvas = NC.Canvas
NOTE: NavCanvas is not a sub-classes FloatCanvas because you can't
subclass form wx.Window twice. I started out delegating all method
calls to the NavCanvas to its internal FloatCanvas, but that got
messing and confusing.
Another option is to copy (or subclass) NanCanvas, and make your own
versin of it.
HTH
-Chris
> I'm looking forward to hearing from you soon.
>
> Best Regards,
>
> Carl Bednorz
>
> _______________________________________________
> FloatCanvas mailing list
> [email protected]
> http://paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas
>
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
[email protected]
_______________________________________________
FloatCanvas mailing list
[email protected]
http://paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas