import sys, os from wxPython.wx import * from wxPython.lib.floatbar import * import string class LakeFrame(wx.wxFrame): def __init__(self, parent, id, title): wx.wxFrame.__init__(self, parent, id, title,wxPoint(100, 100), wxSize(500, 400)) if wxPlatform == '__WXMSW__': icon = wxIcon('Starport.ico', wxBITMAP_TYPE_ICO) self.SetIcon(icon) EVT_CLOSE(self, self.OnCloseWindow) EVT_SIZE(self, self.OnSize) EVT_MOVE(self, self.OnMove) EVT_PAINT(self, self.OnPaint) self.main_menu = wxMenuBar() menu = wxMenu() exitID = wxNewId() menu.Append(exitID, 'Load Local Files', 'Load files from hard drive') EVT_MENU(self, exitID, self.OnFileLoadLocal) self.main_menu.Append(menu, '&File') self.SetMenuBar(self.main_menu) bmp = wxBitmap('SpinnyCanyonLake2.bmp', wxBITMAP_TYPE_BMP) #EVT_LEFT_DOWN(self,self.Onclick) self.LakeView = wxScrolledWindow(self,-1, wxPoint(0, 0), wxSize(500, 400), wxSUNKEN_BORDER) self.LakeView.Connect(-1, -1, wxEVT_LEFT_DOWN, self.Onclick) self.LakeView.lines = [] self.LakeView.maxWidth = 500 self.LakeView.maxHeight = 400 self.LakeView.bmp = bmp self.bmp = bmp def OnCloseWindow(self, event): self.Destroy() def OnSize(self, event): size = event.GetSize() event.Skip() def OnMove(self, event): pos = event.GetPosition() def OnPaint(self,event): LakePaintContext = wxPaintDC(self.LakeView) #self.PrepareDC(LakePaintContext) LakePaintContext.BeginDrawing() LakePaintContext.DrawBitmap(self.bmp, 0,0) LakePaintContext.EndDrawing() del LakePaintContext def Onclick(self,event): color = [] pos = event.GetPosition() LakeDeviceContext = wxClientDC(self.LakeView) self.LakeView.PrepareDC(LakeDeviceContext) LakeDeviceContext.BeginDrawing() LakeDeviceContext.DrawBitmap(self.LakeView.bmp, 0,0) LakeDeviceContext.SetPen(wxPen(wxNamedColour('MEDIUM FOREST GREEN'), 4)) LakeDeviceContext.DrawRectangle(pos.x , pos.y, 5, 5) #for y in range(pos.y,pos.y+5): # for x in range(pos.x,pos.x+5): # color.append(LakeDeviceContext.GetPixel(pos.x , pos.y)) #print color[3] LakeDeviceContext.EndDrawing() pick = FishingSpot(self,-1,"Fish!") pick.Show(true) def OnFileLoadLocal(self,event): pass class FishingSpot(wx.wxFrame): def __init__(self, parent, id, title): wx.wxFrame.__init__(self, parent, id, title,wxPoint(100, 100), wxSize(500, 400)) if wxPlatform == '__WXMSW__': icon = wxIcon('Starport.ico', wxBITMAP_TYPE_ICO) self.SetIcon(icon) EVT_CLOSE(self, self.Clospot) #EVT_SIZE(self, self.OnSize) #EVT_MOVE(self, self.OnMove) #EVT_PAINT(self, self.OnPaint) self.main_menu = wxMenuBar() menu = wxMenu() exitID = wxNewId() menu.Append(exitID, 'Load Local Files', 'Load files from hard drive') #EVT_MENU(self, exitID, self.OnFileLoadLocal) self.main_menu.Append(menu, '&File') self.SetMenuBar(self.main_menu) FishTool = wxFloatBar(self, -1) self.SetToolBar(FishTool) FishTool.SetFloatable(1) FishTool.SetTitle("Floating!") #self.CreateStatusBar() FishTool.AddTool(10, wxBitmap('bitmaps/new.bmp', wxBITMAP_TYPE_BMP), wxNullBitmap, false, -1, -1, "New", "Long help for 'New'") EVT_TOOL(self, 10, self.OnToolClick) EVT_TOOL_RCLICKED(self, 10, self.OnToolRClick) FishTool.AddTool(20, wxBitmap('bitmaps/open.bmp', wxBITMAP_TYPE_BMP), wxNullBitmap, false, -1, -1, "Open") EVT_TOOL(self, 20, self.OnToolClick) EVT_TOOL_RCLICKED(self, 20, self.OnToolRClick) FishTool.AddSeparator() FishTool.AddTool(30, wxBitmap('bitmaps/copy.bmp', wxBITMAP_TYPE_BMP), wxNullBitmap, false, -1, -1, "Copy") EVT_TOOL(self, 30, self.OnToolClick) EVT_TOOL_RCLICKED(self, 30, self.OnToolRClick) FishTool.AddTool(40, wxBitmap('bitmaps/paste.bmp', wxBITMAP_TYPE_BMP), wxNullBitmap, false, -1, -1, "Paste") EVT_TOOL(self, 40, self.OnToolClick) EVT_TOOL_RCLICKED(self, 40, self.OnToolRClick) FishTool.AddSeparator() FishTool.AddTool(60, wxBitmap('bitmaps/tog1.bmp', wxBITMAP_TYPE_BMP), wxBitmap('bitmaps/tog2.bmp', wxBITMAP_TYPE_BMP), true, -1, -1, "Toggle with 2 bitmaps") EVT_TOOL(self, 60, self.OnToolClick) EVT_TOOL_RCLICKED(self, 60, self.OnToolRClick) FishTool.Realize() self.FishTool = FishTool bmp = wxBitmap('SpinnyCanyonLake.bmp', wxBITMAP_TYPE_BMP) self.LakeView = wxScrolledWindow(self,-1, wxPoint(0, 0), wxSize(500, 400), wxSUNKEN_BORDER) #self.LakeView.Connect(-1, -1, wxEVT_LEFT_DOWN, self.Onclick) self.LakeView.lines = [] self.LakeView.maxWidth = 1000 self.LakeView.maxHeight = 1000 self.LakeView.bmp = bmp def Clospot(self, event): # tell the window to kill itself del FishTool self.Destroy() def OnToolClick(self, event): #self.log.WriteText("tool %s clicked\n" % event.GetId()) if event.GetId() == 60: if event.GetExtraLong(): self.FishTool.SetTitle("") else: self.FishTool.SetTitle("Tackle Box") def OnToolRClick(self, event): pass #self.log.WriteText("tool %s right-clicked\n" % event.GetId()) # def test(self, event): # self.log.WriteText("Button clicked!") # def OnSize(self, event):#called by the System when the window is resized (see events above) # size = event.GetSize()# tell the event system to continue looking for an event handler, # event.Skip()# so the default handler will get called. # def OnMove(self, event):# This method is called by the System when the window is moved # pos = event.GetPosition() # def OnPaint(self,event): # LakePaintContext = wxPaintDC(self.LakeView) # self.LakeView.PrepareDC(LakePaintContext) # LakePaintContext.BeginDrawing() # LakePaintContext.DrawBitmap(self.LakeView.bmp, 0,0) # LakePaintContext.EndDrawing() # del LakePaintContext # def Onclick(self,event): # pos = event.GetPosition() # LakeDeviceContext = wxClientDC(self.LakeView) # self.LakeView.PrepareDC(LakeDeviceContext) # LakeDeviceContext.BeginDrawing() # LakeDeviceContext.DrawBitmap(self.LakeView.bmp, 0,0) # LakeDeviceContext.SetPen(wxPen(wxNamedColour('MEDIUM FOREST GREEN'), 4)) # LakeDeviceContext.DrawRectangle(pos.x , pos.y, 5, 5) # LakeDeviceContext.EndDrawing() # del LakeDeviceContext #self.Blit(0, 0, bmp.GetWidth(), bmp.GetHeight(), LakeDeviceContext, 0, 0,wxCOPY, 0) # print 'The x is ',pos.x # print 'The y is ',pos.y #self.Blit(0, 0, bmp.GetWidth(), bmp.GetHeight(), LakeDeviceContext, 0, 0,wxCOPY, 0) # def OnFileExit(self,event):# exit event from file menu above # self.Destroy()# tell the window to kill itself # def OnFileLoadLocal(self,event):#local event from file menu above # get_local(self)#ca #---------------------------------------------------------------------- class TomApp(wxApp): def OnInit(self): frame = LakeFrame(NULL, -1, "Spinny Canyon Lake") frame.Show(true) self.SetTopWindow(frame) return true #--------------------------------------------------------------------------- app = TomApp(0) app.MainLoop()