Hi,
 
I’m still a newbie in python (and wxpython),
and I’m trying to create an application that basically consists on loading a
main frame, and creating a child frame inside it (using MDI) to work with an
image. What I need to do is to draw points in this image (for which I’m using
floatcanvas) and store its coordinates. 
The problem I’m having is that when I draw the
point it only shows up if I hit the “Zoom to Fit” button that comes with
NavCanvas, and I would like for it to appear on the screen automatically. 
Another thing I wanted to do is to be able to
erase some specific point after I have drawn it, I’m not sure how would be the
best way to do it, so I would appreciate any suggestions. 
 
I’m attaching the code below, thanks in
advance. 
Nadili L. Ribeiro

import wx
import os
from floatcanvas import NavCanvas, FloatCanvas

class Frame(wx.MDIParentFrame):
    def __init__(self):

        wx.MDIParentFrame.__init__(self, None, -1, "Main Frame", size=(600,400))
        self.statusbar = self.CreateStatusBar()
        menu = wx.Menu()
        menu.Append(5000, "&New Picture")
        menubar = wx.MenuBar()
        menubar.Append(menu, "&File")
        self.SetMenuBar(menubar)
        self.Bind(wx.EVT_MENU, self.OnNewPicture, id=5000)
     


    def OnNewPicture(self, evt):
        
        """creates child frame"""
        self.ChildFrame = wx.MDIChildFrame(self, -1, "Child Frame")
        

        """create canvas"""
        NC = NavCanvas.NavCanvas(self.ChildFrame,-1,
                                 size = (5000,5000),
                                 ProjectionFun = None,
                                 Debug = 0,
                                 BackgroundColor = "White")
        self.Canvas = NC.Canvas
        
        """load image"""
        image = wx.Image("orion.jpg")
        self.temp = image.ConvertToBitmap()
        self.Canvas.AddScaledBitmap(self.temp, (0,0), Height = 
image.GetSize()[1], Position='tl')
        self.Canvas.ZoomToBB()
        self.Show()
    
    
class App(wx.App):
    

    def OnInit(self):
            
        """Load Frame"""
        self.frame = Frame()
        self.frame.Show()
        self.Bind(wx.EVT_RIGHT_DOWN, self.OnDrawDot)
        self.SetTopWindow(self.frame)
        return (True)
    
    def OnDrawDot(self, evt):
        
        mpos = evt.GetPosition()
        mposcanvas = self.frame.Canvas.PixelToWorld(mpos)
        self.frame.statusbar.SetStatusText("Pos: %s" %str(mposcanvas))
        self.frame.Canvas.AddPoint(mposcanvas, Diameter=9, Color = "Red")
        self.frame.Show()
        

def main():
    app = App()
    app.MainLoop()

if __name__ == '__main__':
    
    main()


      
_______________________________________________
FloatCanvas mailing list
[email protected]
http://mail.mithis.com/cgi-bin/mailman/listinfo/floatcanvas

Reply via email to