00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 import wx
00018 from objects.logic.common.globalStrings import globalStrings
00019 import mainFrameContainer
00020 from objects.logic.common.exception import exception
00021 from objects.gui.mainFrameContainer import mainFrameContainer
00022
00023
00024
00025 class mainFrameToolbar(mainFrameContainer):
00026 def __init__(self, mainFrm):
00027 mainFrameContainer.__init__(self, mainFrm)
00028 self.buildToolbar()
00029
00030
00031
00032
00033 def buildToolbar(self):
00034 self.toolbar = self.mainFrame.CreateToolBar()
00035
00036
00037 self.toolbar.SetToolBitmapSize((32,32))
00038
00039 for each in self.toolbarData():
00040 self.makeToobarButton(self.toolbar, *each)
00041
00042
00043 self.lastTool.Toggle()
00044
00045 try:
00046 self.toolbar.Realize()
00047 except wx._core.PyAssertionError:
00048 raise exception("The application could not start. Could not create toolbar.", False)
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 def makeToobarButton(self, toolbar, isRadio, label, filename, help, handler):
00059 if not label:
00060 self.toolbar.AddSeparator()
00061 return
00062 try:
00063 bmp = wx.Bitmap(filename)
00064
00065 except wx._core.PyAssertionError:
00066 raise exception("The application could not start. Could not find appropriate images for toolbar.", True)
00067
00068 if isRadio == "N":
00069 tool = self.toolbar.AddSimpleTool(-1, bmp, label, help)
00070 else:
00071 tool = self.toolbar.AddRadioTool(-1, bmp, shortHelp=help)
00072 self.lastTool = tool
00073
00074 self.mainFrame.Bind(wx.EVT_MENU, handler, tool)
00075
00076
00077
00078
00079 def toolbarData(self):
00080 return (("N", "Start Monitoring", globalStrings.toolbar_file_start_monitoring, "Start monitoring network", self.mainFrame.handleStartMonitoring),
00081 ("N", "Stop Monitoring", globalStrings.toolbar_stop_monitoring, "Stop monitoring network", self.mainFrame.handleStopMonitoring),
00082 ("N", "", "", "", ""),
00083 ("N", "Go Home", globalStrings.toolbar_go_home, "Zoom all the way out", self.mainFrame.handleGoHome),
00084 ("Y", "Set Home Location", globalStrings.toolbar_identify_self, "Set Home Location", self.mainFrame.handleSetHomeLocation),
00085 ("Y", "Pan", globalStrings.toolbar_view_pan, "Pan around", self.mainFrame.handlePan),
00086 ("Y", "Free Zoom", globalStrings.toolbar_view_free_zoom, "Free Zoom", self.mainFrame.handleFreeZoom),
00087 ("N", "Zoom in", globalStrings.toolbar_view_zoom_in, "Zoom in", self.mainFrame.handleZoomIn),
00088 ("N", "Zoom out", globalStrings.toolbar_view_zoom_out, "Zoom out", self.mainFrame.handleZoomOut),
00089 ("N", "", "", "", ""),
00090 ("N", "Configure Network", globalStrings.toolbar_configure_network, "Configure network settings", self.mainFrame.handleConfigureNetwork),
00091 ("N", "Display Settings", globalStrings.toolbar_display_settings, "Display Settings", self.mainFrame.handleDisplaySettings),
00092 ("N", "Options", globalStrings.toolbar_options, "Options", self.mainFrame.handleOptions),
00093 ("N", "Capture Screenshot", globalStrings.toolbar_capture_screenshot, "Capture and save screenshot", self.mainFrame.handleCaptureScreenshot),
00094 ("N", "", "", "", ""),
00095 ("N", "About", globalStrings.toolbar_about, "About Eyespy", self.mainFrame.handleShowAbout))
00096
00097
00098
00099