attaching floatcanvas on a wxpanel

Hi,
I have problems attaching a floatcanvas/navcanvas on a wxpanel. I've attached my code and what I'm trying to do is to is to position the navcanvas inside a wxpanel but not maximized (I want to define where and how big it is). But when I run it, it doesn't become the size I want it to be (although it is positioned in the correct place).
Am I missing something here?
Thanks
Astan

import wx
import numpy as N
from wx.lib.floatcanvas import NavCanvas, FloatCanvas, Resources
import wx.html as html

######MAIN WINDOW##########
class mainWindow(wx.Frame):
    def __init__(self,parent):
        wx.Frame.__init__(self,parent,-1,"FrameCanvas",size=(1050,950),pos=(8,8))
        self.wxNoteBook1 = wx.Notebook(self,wx.NewId(),(0,0)) self.Center()

        wxNoteBookPage = wx.Panel(self.wxNoteBook1,wx.NewId())

        self.chkUndone = wx.CheckBox(wxNoteBookPage,wx.NewId(),"Change Mode",(40,40))
        wx.EVT_CHECKBOX(wxNoteBookPage,self.chkUndone.GetId(),self.OnUpdateSettings)

        self.htmlGraph = html.HtmlWindow(wxNoteBookPage,wx.NewId(),(4,387),(1030,533),style=html.HW_SCROLLBAR_NEVER|html.HW_NO_SELECTION,name="htmlGraph")

        self.points = [(0,-1),(1,-1),(2,3),(3,3),(4,3),(5,-1),(6,1)]

        self.mother = wx.Panel(wxNoteBookPage,wx.NewId(),(4,387),(1030,533),style=wx.MAXIMIZE_BOX

wx.RESIZE_BORDER,name="mother")

        self.navCanvas = NavCanvas.NavCanvas(self.mother,size=(1030,533))

        self.mother.Hide()
        self.mother.Disable()

        self.wxNoteBook1.AddPage(wxNoteBookPage,"JoBo",True)

        self.navCanvas.Canvas.InitAll()

        for point in self.points:
            self.navCanvas.Canvas.AddPoint(point)
        pos = 0
        for p in range(0,len(self.points)-1):
            xy = (self.points[pos],self.points[pos+1])
            self.navCanvas.Canvas.AddLine(xy)
            pos+=1

        self.navCanvas.Canvas.ZoomToBB()

    def OnUpdateSettings(self,event):
        if self.chkUndone.GetValue():
            self.htmlGraph.Hide()
            self.htmlGraph.Disable()

            self.mother.Enable()
            self.mother.Show() else:
            self.htmlGraph.Enable()
            self.htmlGraph.Show()

            self.mother.Hide()
            self.mother.Disable()
           
#######MAIN APP#######
  class App(wx.App):
    def OnInit(self):
        frame=mainWindow(None)
        self.SetTopWindow(frame)
        frame.Show()
        return True

if __name__=="__main__":
    app=App(0)
    app.MainLoop()

···

--
"Formulations of number theory: Complete, Consistent, Non-trivial. Choose two." -David Morgan-Mar

Animal Logic

Please think of the environment before printing this email.

This email and any attachments may be confidential and/or privileged. If you are not the intended recipient of this email, you must not disclose or use the information contained in it. Please notify the sender immediately and delete this document if you have received it in error. We do not guarantee this email is error or virus free.

Astan Chee wrote:

I have problems attaching a floatcanvas/navcanvas on a wxpanel. I've attached my code and what I'm trying to do is to is to position the navcanvas inside a wxpanel but not maximized (I want to define where and how big it is).

Honestly, I always use Sizers -- are you sure you can't use them for this?

Anyway, it seems that it should work, but you're right, it doesn't. I think it's one of those things where it depends on the order that things are created. But anyway, a work around is an extra call to SetSize:

       self.navCanvas = NavCanvas.NavCanvas(self.mother)

          self.navCanvas.SetSize( (1030, 533) )

No need to call this -- it happens in __init_ anyway.

       self.navCanvas.Canvas.InitAll()

        #for point in self.points:
        # self.navCanvas.Canvas.AddPoint(point)

you might want to use a PointSet Object:

        self.navCanvas.Canvas.AddPointSet(self.points)

and here a line object takes a sequence of point coordinates:
# pos = 0
# for p in range(0,len(self.points)-1):
# xy = (self.points[pos],self.points[pos+1])
# self.navCanvas.Canvas.AddLine(xy)
# pos+=1
        self.navCanvas.Canvas.AddLine(self.points)

I've enclosed my edited version. It's also edited for style:

http://wiki.wxpython.org/wxPython%20Style%20Guide

Another style note: you've got a lot of nested Windows all in one class here. That may be been for test purposes, but if not, you'll find it easier to manage your code of you break things out into separate classes.

-Chris

test.py (2.37 KB)

···

--
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

Chris.Barker@noaa.gov

Thanks a bunch for that.

Yes, this it just a small script for testing.

Cheers

Astan

Christopher Barker wrote:

···

http://wiki.wxpython.org/wxPython%20Style%20Guide



wxpython-users mailing list
wxpython-users@lists.wxwidgets.orghttp://lists.wxwidgets.org/mailman/listinfo/wxpython-users

-- "Formulations of number theory: Complete, Consistent, Non-trivial. Choose two." -David Morgan-Mar


Please think of the environment before printing this email.

This email and any attachments may be confidential and/or privileged.
If you are not the intended recipient of this email, you must not disclose or use the information
contained in it.
Please notify the sender immediately and delete this document if you have received it in error.
We do not guarantee this email is error or virus free.