Exemplo n.º 1
0
	def createToolbar(self):
		"""
		Creates the toolbar for the script editor
		"""
		flags = wx.NO_BORDER | wx.TB_HORIZONTAL | wx.TB_TEXT
		self.CreateToolBar(flags)
		tb = self.GetToolBar()
		tb.SetToolBitmapSize((32, 32))
		
		iconpath = scripting.get_icon_dir()
		bmp = wx.Image(os.path.join(iconpath, "record.gif"), wx.BITMAP_TYPE_GIF).ConvertToBitmap()
		tb.DoAddTool(MenuManager.ID_RECORD_SCRIPT, "Record", bmp, shortHelp = "Record script")
		wx.EVT_TOOL(self, MenuManager.ID_RECORD_SCRIPT, self.onRecordScript)
		
		bmp = wx.Image(os.path.join(iconpath, "pause.gif"), wx.BITMAP_TYPE_GIF).ConvertToBitmap()
		tb.DoAddTool(MenuManager.ID_STOP_RECORD, "Pause", bmp, shortHelp = "Pause recording") 
		wx.EVT_TOOL(self, MenuManager.ID_STOP_RECORD, self.onStopRecord)
		tb.EnableTool(MenuManager.ID_STOP_RECORD, 0)

		bmp = wx.Image(os.path.join(iconpath, "play.gif"), wx.BITMAP_TYPE_GIF).ConvertToBitmap()
		tb.DoAddTool(MenuManager.ID_RUN_SCRIPT, "Run", bmp, shortHelp = "Run recorded script") 
		wx.EVT_TOOL(self, MenuManager.ID_RUN_SCRIPT, self.onRunScript)
		
		tb.Realize()
		self.tb = tb
Exemplo n.º 2
0
	def BuildToolbar(self):
		"""	creates one of the tool-bars
		The buttons act like radio buttons, setting a mode for the Panel
		Only one of them is pressed at a time. The SetMode() method handles this
		"""

		tb = wx.ToolBar( self, -1 )
		self.ToolBar = tb
		tb.SetToolBitmapSize( ( 16, 16 ) )# this required for non-standard size buttons on MSW

		tb.AddTool(Menu.ID_NEW_LIB, wx.Bitmap(os.path.join(ICON_PATH_16_16,'db+2.png')), shortHelpString=_('New library'), longHelpString=_('Create or import a new directory'))
		tb.AddTool(Menu.ID_DELETE_LIB, wx.Bitmap(os.path.join(ICON_PATH_16_16,'db-2.png')), shortHelpString=_('Delete library'), longHelpString=_('Delete the selected librarie'))
		tb.AddTool(Menu.ID_REFRESH_LIB, wx.Bitmap(os.path.join(ICON_PATH_16_16,'db_refresh2.png')), shortHelpString=_('Refresh library'), longHelpString=_('Force the refresh of the loaded libraries'))
		#tb.AddTool(Menu.ID_IMPORT_LIB, wx.Bitmap(os.path.join(ICON_PATH_16_16,'dbimport2.png')), shortHelpString=_('Import library'), longHelpString=_('Call the import manager'))
		tb.AddTool(Menu.ID_HELP_LIB, wx.Bitmap(os.path.join(ICON_PATH_16_16, 'dbinfo2.png')), shortHelpString=_('Help'), longHelpString=_('Information about import manager'))

		mainW = self.GetTopLevelParent()

		wx.EVT_TOOL(self, Menu.ID_NEW_LIB, mainW.OnImport)
		wx.EVT_TOOL(self, Menu.ID_DELETE_LIB, self.tree.OnDelete)
		#wx.EVT_TOOL(self, Menu.ID_IMPORT_LIB, mainW.OnImport)
		wx.EVT_TOOL(self, Menu.ID_REFRESH_LIB, self.tree.OnUpdateAll)
		wx.EVT_TOOL(self, Menu.ID_HELP_LIB, self.tree.OnInfo)

		tb.Realize()
		return tb
Exemplo n.º 3
0
    def _init_toolbar(self):
        self._NTB2_EXIT = wx.NewId()
        self._NTB2_CONVERT = wx.NewId()
        self._NTB2_REFRESH = wx.NewId()

        self.SetToolBitmapSize(wx.Size(24, 24))
        self.AddSimpleTool(
            self._NTB2_EXIT,
            wx.ArtProvider.GetBitmap(wx.ART_CROSS_MARK, wx.ART_TOOLBAR),
            message('main_close'), message('main_desc_close'))

        self.AddControl(
            wx.StaticLine(self, -1, size=(-1, 23), style=wx.LI_VERTICAL))
        self.AddSimpleTool(
            self._NTB2_CONVERT,
            wx.Bitmap(os.path.join(itrade_config.dirRes, 'convert.png')),
            message('main_view_convert'), message('main_view_desc_convert'))
        self.AddSimpleTool(
            self._NTB2_REFRESH,
            wx.Bitmap(os.path.join(itrade_config.dirRes, 'refresh.png')),
            message('main_view_refresh'), message('main_view_desc_refresh'))

        wx.EVT_TOOL(self, self._NTB2_EXIT, self.onExit)
        wx.EVT_TOOL(self, self._NTB2_CONVERT, self.onConvert)
        wx.EVT_TOOL(self, self._NTB2_REFRESH, self.onRefresh)
        self.Realize()
Exemplo n.º 4
0
    def BuildToolbar1(self):

        """
        creates one of the toolbars

        The buttons act like radio buttons, setting a mode for the Panel
        Only one of them is pressed at a time. The SetMOde() method handles this

        """
        
        tb = wx.ToolBar(self,-1)
        self.ToolBar = tb
        tb.SetToolBitmapSize((21,21))# this required for non-standard size buttons on MSW
        
        tool = tb.AddTool(wx.ID_ANY, bitmap=GetPlusBitmap(), isToggle=True)
        self.Bind(wx.EVT_TOOL, self.SetMode, tool)
      
        tb.AddTool(ID_ZOOM_OUT_BUTTON, GetMinusBitmap(),isToggle=True)
        wx.EVT_TOOL(self, ID_ZOOM_OUT_BUTTON, self.SetMode)
      
        tb.AddTool(ID_MOVE_MODE_BUTTON, GetHandBitmap(),isToggle=True)
        wx.EVT_TOOL(self, ID_MOVE_MODE_BUTTON, self.SetMode)
      
        tb.AddSeparator()
      
        tb.AddControl(wx.Button(tb, ID_TEST_BUTTON, "Button",wx.DefaultPosition, wx.DefaultSize))
        wx.EVT_BUTTON(self, ID_TEST_BUTTON, self.ButtonAction)
                
        tb.Realize()

        return tb
Exemplo n.º 5
0
    def __init__(self, parent, ID, title):
        wx.Frame.__init__(self, parent, ID, title, wx.DefaultPosition,
                          wx.Size(350, 250))

        # 垂直
        vbox = wx.BoxSizer(wx.VERTICAL)
        toolbar = wx.ToolBar(self, -1, style=wx.TB_HORIZONTAL | wx.NO_BORDER)
        toolbar.AddSimpleTool(
            1,
            wx.Image('D:/PycharmProjects/taobaolive/code/wxp/555.png',
                     wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'new.', '')
        toolbar.AddSimpleTool(
            2,
            wx.Image('D:/PycharmProjects/taobaolive/code/wxp/555.png',
                     wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'open', '')
        toolbar.AddSimpleTool(
            3,
            wx.Image('D:/PycharmProjects/taobaolive/code/wxp/555.png',
                     wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'save', '')
        toolbar.AddSeparator()
        toolbar.AddSimpleTool(
            4,
            wx.Image('D:/PycharmProjects/taobaolive/code/wxp/555.png',
                     wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'exit', '')
        # 用来显示工具栏
        toolbar.Realize()
        vbox.Add(toolbar, 0, border=5)
        self.SetSizer(vbox)
        self.statusbar = self.CreateStatusBar()
        self.Centre()

        wx.EVT_TOOL(self, 1, self.OnNew)
        wx.EVT_TOOL(self, 2, self.OnOpen)
        wx.EVT_TOOL(self, 3, self.OnSave)
        wx.EVT_TOOL(self, 4, self.OnExit)
Exemplo n.º 6
0
    def __init__(self, plotCanvas, multPlots=False, allowselect=False):

        NavigationToolbar.__init__(self, plotCanvas)
        # delete the toolbar button we don't want
        if (not multPlots):
            CONFIGURE_SUBPLOTS_TOOLBAR_BTN_POSITION = 7
            self.DeleteToolByPos(CONFIGURE_SUBPLOTS_TOOLBAR_BTN_POSITION)

        # add the new toolbar buttons that we do want
        # if allowselect:
        #     self.selectbutton= self.AddSimpleTool(self.ON_CUSTOM_SEL, CreateBitmap("images\\select.png"),
        #                    'Select Points', 'Select Points')
        #     wx.EVT_TOOL(self, self.ON_CUSTOM_SEL, self._on_custom_sel_point)
        #     self.selectbutton.Enable(False)

        self.AddSimpleTool(self.ON_CUSTOM_LEFT,
                           CreateBitmap("images\\scroll left.png"),
                           'Pan to the left', 'Pan graph to the left')
        wx.EVT_TOOL(self, self.ON_CUSTOM_LEFT, self._on_custom_pan_left)
        self.AddSimpleTool(self.ON_CUSTOM_RIGHT,
                           CreateBitmap("images\\scroll right.png"),
                           'Pan to the right', 'Pan graph to the right')
        wx.EVT_TOOL(self, self.ON_CUSTOM_RIGHT, self._on_custom_pan_right)

        self.SetToolBitmapSize(wx.Size(16, 16))
        self.Realize()
Exemplo n.º 7
0
    def __init__(self, plotCanvas):
        # create the default toolbar
        NavigationToolbar2Wx.__init__(self, plotCanvas)
        # add new toolbar buttons
        temp = os.getcwd()

        logx_icon_path = os.path.join(temp, 'gui', 'icons', 'Logx.png')
        logy_icon_path = os.path.join(temp, 'gui', 'icons', 'Logy.png')

        self.AddSimpleTool(self.X_SCALE_SWITCH,
                           wx.Image(logx_icon_path,
                                    wx.BITMAP_TYPE_PNG).ConvertToBitmap(),
                           'x Log Lin Toggle',
                           'Switch the x-axis between log and linear scale',
                           isToggle=0)

        wx.EVT_TOOL(self, self.X_SCALE_SWITCH, self._x_scale_Log_Lin)

        self.AddSimpleTool(self.Y_SCALE_SWITCH,
                           wx.Image(logy_icon_path,
                                    wx.BITMAP_TYPE_PNG).ConvertToBitmap(),
                           'y Log Lin Toggle',
                           'Switch the y-axis between log and linear scale',
                           isToggle=0)

        os.chdir(temp)

        wx.EVT_TOOL(self, self.Y_SCALE_SWITCH, self._y_scale_Log_Lin)
Exemplo n.º 8
0
 def create_menu(self):
     filemenu = wx.Menu()
     fitem = filemenu.Append(wx.ID_EXIT, "Quit", "Quit Applications")
     menubar = wx.MenuBar()
     menubar.Append(filemenu, "&Option")
     self.SetMenuBar(menubar)
     self.Bind(wx.EVT_MENU, self.OnQuit, fitem)
     toolBar = self.CreateToolBar()
     toolBar.AddSimpleTool(
         1,
         wx.Image('close.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), '关闭',
         '')
     toolBar.AddSeparator()
     toolBar.AddSimpleTool(
         2,
         wx.Image('home.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), '回到首页',
         '')
     toolBar.AddSeparator()
     toolBar.AddSimpleTool(
         3,
         wx.Image('spec.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(),
         '打开定制页', '')
     toolBar.Realize()
     wx.EVT_TOOL(self, 1, self.OnQuit)
     wx.EVT_TOOL(self, 2, self.onGoHome)
     wx.EVT_TOOL(self, 3, self.onGoSpec)
Exemplo n.º 9
0
    def BuildToolbar2(self):

        """
        Creates another toolbar. It looks the same, but acts a little different:
        The buttons are independent, rather than acting like radio buttons

        It also has a custom separator, created by adding a tall skinny bitmap.

        """
        
        tb = wx.ToolBar(self,-1)
        self.ToolBar2 = tb
        tb.SetToolBitmapSize((21,21))# this required for non-standard size buttons on MSW

        tb.AddTool(ID_ZOOM_IN_BUTTON2, GetPlusBitmap(),isToggle=True)
        wx.EVT_TOOL(self, ID_ZOOM_IN_BUTTON2, self.ButtonPress2)
      
        tb.AddTool(ID_ZOOM_OUT_BUTTON2, GetMinusBitmap(),isToggle=True)
        wx.EVT_TOOL(self, ID_ZOOM_OUT_BUTTON2, self.ButtonPress2)
      
        tb.AddTool(ID_MOVE_MODE_BUTTON2, GetHandBitmap(),isToggle=True)
        wx.EVT_TOOL(self, ID_MOVE_MODE_BUTTON2, self.ButtonPress2)
      
        # a way to do a custom separator
        tb.AddControl(wx.StaticBitmap(tb, -1, GetSeparatorBitmap(), wx.DefaultPosition, wx.DefaultSize))
      
        tb.AddControl(wx.Button(tb, ID_TEST_BUTTON2, "Button",wx.DefaultPosition, wx.DefaultSize))
        wx.EVT_BUTTON(self, ID_TEST_BUTTON2, self.ButtonPress2)

        tb.Realize()

        return tb
Exemplo n.º 10
0
    def __init__(self, frame_object):
        """ Constructor for toolbar object

        @type self: Toolbar
        @type frame_object: MainFrame
            the frame object that the toolbar will be in/part of
        @rtype: None
        """
        NavigationToolbar2WxAgg.__init__(self, frame_object.canvas)
        self.frame_object = frame_object
        # Deleting unwanted icons in standard toolbar
        self.DeleteToolByPos(8)
        self.DeleteToolByPos(1)
        self.DeleteToolByPos(1)

        self.InsertSeparator(6)
        self.InsertSeparator(6)

        self.AddSimpleTool(self.ON_PREVIOUS, _load_bitmap('back.png'),
                           'Previous Run', 'Activate custom control')
        wx.EVT_TOOL(self, self.ON_PREVIOUS, self._on_previous)

        self.AddSimpleTool(self.ON_NEXT, _load_bitmap('forward.png'),
                           'Next Run', 'Activate custom control')
        wx.EVT_TOOL(self, self.ON_NEXT, self._on_next)

        self.AddSimpleTool(self.ON_EXTRACT, _load_bitmap('filesave.png'),
                           'Save to Excel', 'Activate custom control')
        wx.EVT_TOOL(self, self.ON_EXTRACT, self._on_extract)
Exemplo n.º 11
0
    def _init_toolbar(self):
        self.ClearTools()

        self._NTB2_EXIT = wx.NewId()
        self._NTB2_NEW = wx.NewId()
        self._NTB2_OPEN = wx.NewId()
        self._NTB2_EDIT = wx.NewId()
        self._NTB2_SAVE_AS = wx.NewId()
        self._NTB2_MONEY = wx.NewId()
        self._NTB2_OPERATIONS = wx.NewId()
        self._NTB2_ALERTS = wx.NewId()
        self._NTB2_QUOTE = wx.NewId()
        self._NTB2_REFRESH = wx.NewId()
        self._NTB2_ABOUT = wx.NewId()

        self.SetToolBitmapSize(wx.Size(24,24))
        self.AddSimpleTool(self._NTB2_EXIT, wx.ArtProvider.GetBitmap(wx.ART_CROSS_MARK, wx.ART_TOOLBAR),
                           message('main_exit'), message('main_desc_exit'))
        self.AddControl(wx.StaticLine(self, -1, size=(-1,23), style=wx.LI_VERTICAL))
        self.AddSimpleTool(self._NTB2_NEW, wx.ArtProvider.GetBitmap(wx.ART_NEW, wx.ART_TOOLBAR),
                           message('main_new'), message('main_desc_new'))
        self.AddSimpleTool(self._NTB2_OPEN, wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_TOOLBAR),
                           message('main_open'), message('main_desc_open'))
        self.AddSimpleTool(self._NTB2_EDIT, wx.ArtProvider.GetBitmap(wx.ART_EXECUTABLE_FILE, wx.ART_TOOLBAR),
                           message('main_edit'), message('main_desc_edit'))
        self.AddControl(wx.StaticLine(self, -1, size=(-1,23), style=wx.LI_VERTICAL))
        self.AddSimpleTool(self._NTB2_OPERATIONS, wx.ArtProvider.GetBitmap(wx.ART_REPORT_VIEW, wx.ART_TOOLBAR),
                           message('main_view_operations'), message('main_view_desc_operations'))
        self.AddSimpleTool(self._NTB2_MONEY, wx.Bitmap(os.path.join(itrade_config.dirRes, 'money.png')),
                           message('main_view_money'), message('main_view_desc_money'))
        self.EnableTool(self._NTB2_MONEY, False) # __disable_unsupported_feature
        self.AddSimpleTool(self._NTB2_ALERTS, wx.Bitmap(os.path.join(itrade_config.dirRes, 'bell.png')),
                           message('main_view_alerts'), message('main_view_desc_alerts'))
        self.EnableTool(self._NTB2_ALERTS, False) # __disable_unsupported_feature
        self.AddControl(wx.StaticLine(self, -1, size=(-1,23), style=wx.LI_VERTICAL))
        self.AddSimpleTool(self._NTB2_QUOTE, wx.Bitmap(os.path.join(itrade_config.dirRes, 'graph.png')),
                           message('main_quote_graph'), message('main_quote_desc_graph'))
        self.AddControl(wx.StaticLine(self, -1, size=(-1,23), style=wx.LI_VERTICAL))
        self.AddSimpleTool(self._NTB2_REFRESH, wx.Bitmap(os.path.join(itrade_config.dirRes, 'refresh.png')),
                           message('main_view_refresh'), message('main_view_desc_refresh'))
        self.AddSimpleTool(self._NTB2_ABOUT, wx.Bitmap(os.path.join(itrade_config.dirRes, 'about.png')),
                           message('main_about'), message('main_desc_about'))
        self.AddControl(wx.StaticLine(self, -1, size=(-1,23), style=wx.LI_VERTICAL))
        self.m_indicator = wx.TextCtrl(self, -1, "", size=(300,15), style=wx.BORDER_NONE|wx.ALIGN_LEFT|wx.TE_READONLY)
        self.AddControl(self.m_indicator)
        self.ClearIndicator()

        wx.EVT_TOOL(self, self._NTB2_EXIT, self.onExit)
        wx.EVT_TOOL(self, self._NTB2_NEW, self.onNew)
        wx.EVT_TOOL(self, self._NTB2_OPEN, self.onOpen)
        wx.EVT_TOOL(self, self._NTB2_EDIT, self.onEdit)
        wx.EVT_TOOL(self, self._NTB2_OPERATIONS, self.onOperations)
        wx.EVT_TOOL(self, self._NTB2_MONEY, self.onMoney)
        wx.EVT_TOOL(self, self._NTB2_ALERTS, self.onAlerts)
        wx.EVT_TOOL(self, self._NTB2_QUOTE, self.onQuote)
        wx.EVT_TOOL(self, self._NTB2_ABOUT, self.onAbout)
        wx.EVT_TOOL(self, self._NTB2_REFRESH, self.onRefresh)
        self.Realize()
Exemplo n.º 12
0
    def __init__(self, plotCanvas, multPlots=False, allowselect=False):
        NavigationToolbar.__init__(self, plotCanvas)
        #self.ClearTools()


        # delete the toolbar button we don't want
        if (not multPlots):
            CONFIGURE_SUBPLOTS_TOOLBAR_BTN_POSITION = 8
            self.DeleteToolByPos(CONFIGURE_SUBPLOTS_TOOLBAR_BTN_POSITION)

        #self.AddSimpleTool(self.ON_CUSTOM_LEFT, scroll_left.GetBitmap(), ' Pan to the left', 'Pan graph to the left')
        #self.AddSimpleTool(self.ON_CUSTOM_RIGHT, scroll_right.GetBitmap(), 'Pan to the right', 'Pan graph to the right')

        #wx.EVT_TOOL(self, self.ON_CUSTOM_LEFT, self._on_custom_pan_left)
        #wx.EVT_TOOL(self, self.ON_CUSTOM_RIGHT, self._on_custom_pan_right)

        if allowselect:
            """self.select_tool = self.AddSimpleTool(self.ON_LASSO_SELECT, select.GetBitmap(), 'Lasso Select',
                                                  'Select datavalues from the graph', isToggle=True)

            self.zoom_to_data = self.AddSimpleTool(self.ON_ZOOM_DATA_SELECT, zoom_data.GetBitmap(), 'Zoom to Data',
                                                  'Zoom to data without NoDataValues')

            wx.EVT_TOOL(self, self.ON_LASSO_SELECT, self.on_toggle_lasso_tool)
            wx.EVT_TOOL(self, self.ON_ZOOM_DATA_SELECT, self.on_toggle_zoom_data_tool)"""

            # Get the ids for the existing tools
            self.pan_tool = self.FindById(self.wx_ids['Pan'])
            self.zoom_tool = self.FindById(self.wx_ids['Zoom'])
            self.select_tool=self.FindById(self.wx_ids['Select'])
            self.zoom_to_data = self.FindById(self.wx_ids['Zoom to Data'])

            wx.EVT_TOOL(self, self.zoom_tool.Id, self.on_toggle_pan_zoom)
            wx.EVT_TOOL(self, self.pan_tool.Id, self.on_toggle_pan_zoom)
            self.lassoAction = None
            self.select_tool.Enable(False)
            self.zoom_to_data.Enable(False)

        else:
            ZOOM_DATA_BTN_POSITION = 1
            SELECT_DATA_BTN_POSTITION = self.ToolsCount-1
            self.DeleteToolByPos(SELECT_DATA_BTN_POSTITION)
            self.DeleteToolByPos(ZOOM_DATA_BTN_POSITION)


        self.SetToolBitmapSize(wx.Size(16, 16))

        #msg = wx.StaticText(self, -1, '|')
        #msg.SetForegroundColour((108, 123, 139))

        #self.AddControl(msg)
        self.AddSeparator()

        self.msg = wx.StaticText(self, -1, "")
        self.AddControl(self.msg)

        self.Realize()
Exemplo n.º 13
0
    def __init__(self,
                 canvas,
                 panel,
                 settings,
                 callBackHideOverlay,
                 is_admin=False):
        self.panel = panel
        self.settings = settings
        self.callbackHide = callBackHideOverlay
        self.plot = None
        self.extraTools = []
        self.panPos = None
        self.is_admin = is_admin

        NavigationToolbar2WxAgg.__init__(self, canvas)
        if matplotlib.__version__ >= '1.2':
            panId = self.wx_ids['Pan']
        else:
            panId = self.FindById(self._NTB2_PAN).GetId()

        self.ToggleTool(panId, True)
        self.pan()

        self.__add_spacer(False)

        liveId = wx.NewId()
        self.AddCheckTool(liveId,
                          load_bitmap('auto_refresh'),
                          shortHelp='Real time plotting\n(slow and buggy)')
        self.ToggleTool(liveId, settings.liveUpdate)
        wx.EVT_TOOL(self, liveId, self.__on_check_update)

        gridId = wx.NewId()
        self.AddCheckTool(gridId,
                          load_bitmap('grid'),
                          shortHelp='Toggle plot_line grid')
        self.ToggleTool(gridId, settings.grid)
        wx.EVT_TOOL(self, gridId, self.__on_check_grid)

        self.peakId = wx.NewId()
        self.peaksId = None

        self.autoFId = None
        self.autoLId = None
        self.autoTId = None

        self.maxId = None
        self.minId = None
        self.avgId = None
        self.varId = None
        self.smoothId = None
        self.diffId = None
        self.deltaId = None

        self.colourId = None
Exemplo n.º 14
0
 def __init__(self, plotCanvas):
     CONFIGURE_SUBPLOTS_TOOLBAR_BTN_POSITION = 6
     NavigationToolbar2Wx.__init__(self, plotCanvas)        
     # delete the toolbar button we don't want
     self.DeleteToolByPos(CONFIGURE_SUBPLOTS_TOOLBAR_BTN_POSITION) 
     # add the new toolbar buttons that we do want
     self.AddSimpleTool(self.ON_CUSTOM_LEFT, _load_bitmap('stock_left.xpm'),
                        'Pan to the left', 'Pan graph to the left')
     wx.EVT_TOOL(self, self.ON_CUSTOM_LEFT, self._on_custom_pan_left)
     self.AddSimpleTool(self.ON_CUSTOM_RIGHT, _load_bitmap('stock_right.xpm'),
                        'Pan to the right', 'Pan graph to the right')
     wx.EVT_TOOL(self, self.ON_CUSTOM_RIGHT, self._on_custom_pan_right)
Exemplo n.º 15
0
    def _init_toolbar(self):
        self._NTB2_EXIT = wx.NewId()
        self._NTB2_SELECT = wx.NewId()

        self.SetToolBitmapSize(wx.Size(24,24))
        self.AddSimpleTool(self._NTB2_EXIT, wx.ArtProvider.GetBitmap(wx.ART_CROSS_MARK, wx.ART_TOOLBAR),
                           message('main_close'), message('main_desc_close'))
        self.AddControl(wx.StaticLine(self, -1, size=(-1,23), style=wx.LI_VERTICAL))
        self.AddSimpleTool(self._NTB2_SELECT, wx.Bitmap(os.path.join(itrade_config.dirRes, 'quotes.png')),
                           message('quote_select_title'), message('quote_select_title'))

        wx.EVT_TOOL(self, self._NTB2_EXIT, self.exit)
        wx.EVT_TOOL(self, self._NTB2_SELECT, self.select)
        self.Realize()
    def __init__(self, parent=None, *args, **kwargs):
        """Initialize the CanvasFrame.

        The frame uses ExtendedToolbar as a toolbar, which has a save data
        button and a close button on the toolbar in addition to the normal
        buttons.

        args -- argument list
        kwargs -- keyword argument list
        """
        wx.Frame.__init__(self,
                          parent,
                          -1,
                          'ExtendedPlotFrame',
                          size=(550, 350))

        # figsize in inches
        self.figure = Figure(figsize=(0.5, 0.5), dpi=72)

        # we will manage view scale ourselves
        self.subplot = self.figure.add_subplot(111, autoscale_on=False)
        self.canvas = FigureCanvas(self, -1, self.figure)

        # Introspection data
        self.dirname = ''
        self.filename = ''

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.canvas, 1, wx.TOP | wx.LEFT | wx.EXPAND)
        self.toolbar = ExtendedToolbar(self.canvas)
        self.toolbar.Realize()

        self.coordLabel = wx.StaticText(self,
                                        -1,
                                        style=wx.ALIGN_RIGHT | wx.NO_BORDER)
        # Place coordinates textbox in a horizontal sizer next to the toolbar.
        barSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer.Add(barSizer, 0, wx.EXPAND | wx.CENTER)
        barSizer.Add(self.toolbar, 0, wx.CENTER)
        barSizer.Add((20, 10), 0)
        barSizer.Add(self.coordLabel, 0, wx.CENTER)

        # update the axes menu on the toolbar
        self.toolbar.update()
        self.SetSizer(self.sizer)
        self.Fit()
        self.SetSize((600, 400))
        # Use toolbar's color for coordinates label background.
        self.SetBackgroundColour(self.toolbar.GetBackgroundColour())
        # FIXME -- toolbar background color does not match on Mac OS X.
        # Use GIMP - picked color until a proper way is found.
        if wx.Platform == '__WXMAC__':
            self.SetBackgroundColour((200, 200, 200, 255))
        self.canvas.mpl_connect('motion_notify_event', self.UpdateStatusBar)
        self.canvas.mpl_connect('key_press_event', self.mplKeyPress)
        wx.EVT_PAINT(self, self.OnPaint)
        wx.EVT_TOOL(self, DATA_SAVE_ID, self.savePlotData)
        wx.EVT_CLOSE(self, self.onClose)

        self.datalims = {}
Exemplo n.º 17
0
	def register (self):
		BasePlugin.register (self)
		self.mwm = self.gb['clinical.manager']

		# FIXME: do proper config check for shadowing
		# FIXME: do we always want shadows and set it to 0 width via themes ?
		shadow = gmShadow.Shadow (self.mwm, -1)
		widget = self.GetWidget (shadow)
		shadow.SetContents (widget)
		self.mwm.RegisterLeftSide (self.__class__.__name__, shadow)

		icon = self.GetIcon ()
		if icon is not None:
			tb2 = self.gb['toolbar.%s' % 'gmClinicalWindowManager']
			#tb2.AddSeparator()
			self.tool_id = wx.NewId ()
			tool1 = tb2.AddTool(
				self.tool_id,
				icon,
				shortHelpString = self.name()
			)
			wx.EVT_TOOL (tb2, self.tool_id, self.OnTool)
		menuname = self.name ()
		menu = self.gb['clinical.submenu']
		self.menu_id = wx.NewId ()
		menu.Append (self.menu_id, menuname)
Exemplo n.º 18
0
    def add_tool(self, key, func=None, bitmap=None, info='', widget=None, **args):
        """
        Add a tool to the tool bar
        """
        # print 'add_tool',self,key,func

        id = wx.NewId()
        if not args.has_key('name'):
            name = string.capitalize(key)
        else:
            name = args['name']

        if widget is not None:
            # tool is a widget
            self.toolbar.AddControl(widget)
        else:
            # tools is a simple button
            if not bitmap:
                bitmap = wx.NullBitmap

            # print 'bitmap=',name,bitmap
            self.toolbar.AddSimpleTool(id, bitmap, name, info)
            #self.toolbar.AddTool(id,name, bitmap, shortHelpString=info)

            wx.EVT_TOOL(self, id, func)
            # if args.has_key('func_rclick'):
            #    wx.EVT_TOOL_RCLICKED(self.parent, id, args['func_rclick'])

        self._tools[key] = id
        # Final thing to do for a toolbar is call the Realize() method. This
        # causes it to render (more or less, that is).
        self.toolbar.Realize()
        S = self.toolbar.GetSize()
        self.toolbar.SetSizeHints(S[0], S[1])
        return id
 def BuildToolBar(self):
     toolbar = self.CreateToolBar()
     toolbar.AddSimpleTool(ID_PLAY, images.GetBitmap_Play_png(), "Start",
                           "Start with integration")
     #toolbar.AddTool(ID_PLAY, images.GetBitmap_Play_png(), isToggle=True)
     wx.EVT_TOOL(self, ID_PLAY, self.OnPlay)
     toolbar.Realize()
Exemplo n.º 20
0
 def add_option(self):
     """
     add item to the toolbar
     """
     #add button
     id_context = wx.NewId()
     context_tip = 'Graph Menu'
     context = wx.ArtProvider.GetBitmap(wx.ART_LIST_VIEW, wx.ART_TOOLBAR)
     self.InsertSimpleTool(0, id_context, context, context_tip, context_tip)
     wx.EVT_TOOL(self, id_context, self.parent.onToolContextMenu)
     self.InsertSeparator(1)
     #add print button
     id_print = wx.NewId()
     print_bmp = wx.ArtProvider.GetBitmap(wx.ART_PRINT, wx.ART_TOOLBAR)
     self.AddSimpleTool(id_print, print_bmp, 'Print', 'Activate printing')
     wx.EVT_TOOL(self, id_print, self.on_print)
Exemplo n.º 21
0
    def __init__(self,parent, id,title,position,size):
        wx.Frame.__init__(self,parent, id,title,position, size)
        

        wx.EVT_CLOSE(self, self.OnCloseWindow)


        Canvas1 = TestPanel(self,color = "RED")
        Canvas2 = TestPanel(self,color = "BLUE",NumToolbars = 2)

        #Build the Toolbar
        tb = self.CreateToolBar(wx.TB_HORIZONTAL|wx.NO_BORDER)
        self.ToolBar = tb
        tb.SetToolBitmapSize((21,21))# this required for non-standard size buttons on MSW
      
        tb.AddTool(ID_ZOOM_IN_BUTTON, GetPlusBitmap(),isToggle=True)
        wx.EVT_TOOL(self, ID_ZOOM_IN_BUTTON, self.SetMode)
      
        tb.AddTool(ID_ZOOM_OUT_BUTTON, GetMinusBitmap(),isToggle=True)
        wx.EVT_TOOL(self, ID_ZOOM_OUT_BUTTON, self.SetMode)
      
        tb.AddTool(ID_MOVE_MODE_BUTTON, GetHandBitmap(),isToggle=True)
        wx.EVT_TOOL(self, ID_MOVE_MODE_BUTTON, self.SetMode)
      
        tb.AddSeparator()
      
        tb.AddControl(wx.Button(tb, ID_TEST_BUTTON, "Button",wx.DefaultPosition, wx.DefaultSize))
        wx.EVT_BUTTON(self, ID_TEST_BUTTON, self.ButtonAction)

        tb.AddSeparator()
      
        tb.AddControl(wx.StaticText(tb, -1, "A Frame Managed Toolbar", wx.DefaultPosition, wx.DefaultSize))
                
        tb.Realize()


        ## Create the horizontal sizer for the two panels
        box = wx.BoxSizer(wx.HORIZONTAL)

        box.Add(Canvas1,1,wx.EXPAND)
        box.Add(Canvas2,2,wx.EXPAND)

        #box.Fit(self)
        self.SetAutoLayout(True)
        self.SetSizer(box)

        self.Show(True)
Exemplo n.º 22
0
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(600,600))


        self.filename = ""
        self.evt = EventHandler.EventHandler(self)
        self.toolbar = self.ToolBar()
        self.MenuBar()
        self.SetMenuBar(self.menu)
        self.statusbar = self.CreateStatusBar()
        self.statusbar.SetStatusText('Ready')


        # SideBar
        self.sidebar = wx.Panel(self)
        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox.Add(SideBar(self.sidebar),1,wx.EXPAND,0)
        self.sidebar.SetSizer(vbox)

        self.draw = DrawWindow.DrawWindow(self)

        # Combine windows
        hboxm = wx.BoxSizer(wx.HORIZONTAL)
        hboxm.Add(self.sidebar,0,wx.EXPAND,0)
        hboxm.Add(self.draw,1,wx.EXPAND,0)

        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox.Add(hboxm,1, wx.EXPAND, 0)


        wx.EVT_TOOL(self.toolbar, wx.ID_UNDO, self.evt.OnUndo)
        wx.EVT_TOOL(self.toolbar, wx.ID_REDO, self.evt.OnRedo)
        wx.EVT_MENU(self, wx.ID_UNDO, self.evt.OnUndo)
        wx.EVT_MENU(self, wx.ID_REDO, self.evt.OnRedo)

        wx.EVT_MENU(self, wx.ID_NEW, self.evt.OnNew)
        wx.EVT_MENU(self, wx.ID_OPEN, self.evt.OnLoad)
        wx.EVT_MENU(self, wx.ID_SAVE, self.evt.OnSave)
        wx.EVT_MENU(self, wx.ID_SAVEAS, self.evt.OnSaveAs)
        wx.EVT_MENU(self, wx.ID_CLOSE, self.evt.OnClose)
        wx.EVT_MENU(self, wx.ID_EXIT, self.evt.OnQuit)
        self.Bind(wx.EVT_MENU, self.evt.OnExport, self.exp)
#        wx.EVT_MENU(self, wx.ID_ABOUT, self.evt.OnAbout)
        self.zoom.Bind(wx.EVT_COMBOBOX, self.evt.OnZoom)

        self.SetSizer(vbox)
        self.Show(True)
Exemplo n.º 23
0
    def __init__(self, canvas, cankill):
        NavigationToolbar2WxAgg.__init__(self, canvas)

        # for simplicity I'm going to reuse a bitmap from wx, you'll
        # probably want to add your own.
        self.AddSimpleTool(self.ON_CUSTOM, _load_bitmap('stock_left.xpm'),
                           'Click me', 'Activate custom contol')
        wx.EVT_TOOL(self, self.ON_CUSTOM, self._on_custom)
Exemplo n.º 24
0
 def __init__(self, canvas):
     NavigationToolbar2WxAgg.__init__(self, canvas)
     self.AddSeparator()
     self.AddCheckTool(
         self.ON_ZSCALE, wx.ArtProvider.GetBitmap(wx.ART_HELP_SIDE_PANEL),
         shortHelp='Change Z scale in images',
         longHelp='Change Z scale in images')
     wx.EVT_TOOL(self, self.ON_ZSCALE, self.on_zscale)
Exemplo n.º 25
0
    def __init__(self, canvas, main):
        self.main = main

        navId = wx.NewId()
        NavigationToolbar2WxAgg.__init__(self, canvas)
        self.AddSimpleTool(navId, _load_bitmap('subplots.png'), 'Range',
                           'Set plot range')
        wx.EVT_TOOL(self, navId, self.on_range)
Exemplo n.º 26
0
 def __add_check_tool(self, bitmap, toolTip, callback, setting=None, toolId=None):
     if toolId is None:
         toolId = wx.NewId()
     self.AddCheckTool(toolId, load_bitmap(bitmap), shortHelp=toolTip)
     wx.EVT_TOOL(self, toolId, callback)
     if setting is not None:
         self.ToggleTool(toolId, setting)
     self.extraTools.append(toolId)
Exemplo n.º 27
0
 def get_toolbar(self):
     if not self.toolbar:
         self.toolbar = NavigationToolbar2WxAgg(self.figure.canvas)
         self.toolbar.Realize()
         self.id_save = wx.NewId()
         self.id_info = wx.NewId()
         self.toolbar.AddSimpleTool(
             self.id_save, wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE),
             _("Save plot as ASCII file"), 'Activate custom contol')
         wx.EVT_TOOL(self.toolbar, self.id_save, self.on_save_dat)
         self.toolbar.AddSimpleTool(
             self.id_info, wx.ArtProvider.GetBitmap(wx.ART_INFORMATION),
             _("Details"), 'Activate custom contol')
         wx.EVT_TOOL(self.toolbar, self.id_info, self.on_plot_info)
         self.toolbar.EnableTool(self.id_save, False)
         self.toolbar.EnableTool(self.id_info, False)
     return self.toolbar
Exemplo n.º 28
0
    def _create_toolbar(self):
        """create standard toolbar and add tools for toggling
        automatic scaling"""

        self.toolbar = NavigationToolbar2Wx(self.canvas)

        self.toolbar.DeleteTool(self.toolbar._NTB2_SAVE)
        self.toolbar.DeleteTool(self.toolbar._NTB2_SUBPLOT)

        self.toolbar.AddLabelTool(self.ID_Save,
                                  'Save',
                                  wx.Bitmap(
                                      os.path.join(settings.bitmappath,
                                                   'save.png'),
                                      wx.BITMAP_TYPE_PNG),
                                  shortHelp="Save Image",
                                  longHelp="Save Image to File")

        self.toolbar.AddSeparator()
        self.toolbar.AddCheckTool(self.ID_AutoscaleX,
                                  wx.Bitmap(
                                      os.path.join(settings.bitmappath,
                                                   'Xscale.png'),
                                      wx.BITMAP_TYPE_PNG),
                                  shortHelp='Autoscale X',
                                  longHelp='automatic scaling of X-axis')
        self.toolbar.AddCheckTool(self.ID_AutoscaleY,
                                  wx.Bitmap(
                                      os.path.join(settings.bitmappath,
                                                   'Yscale.png'),
                                      wx.BITMAP_TYPE_PNG),
                                  shortHelp='Autoscale Y',
                                  longHelp='automatic scaling of Y-axis')

        wx.EVT_TOOL(self, self.ID_Save, self.OnSave)
        wx.EVT_TOOL(self, self.ID_AutoscaleX, self.OnAutoscaleX)
        wx.EVT_TOOL(self, self.ID_AutoscaleY, self.OnAutoscaleY)

        self.toolbar.ToggleTool(self.ID_AutoscaleX, True)
        self.toolbar.ToggleTool(self.ID_AutoscaleY, True)

        self.autoscaleX = True
        self.autoscaleY = True

        self.toolbar.Realize()
Exemplo n.º 29
0
    def __init__(self, *args, **kw):
        _OldToolbarClass.__init__(self, *args, **kw)
        PrintToolbar.__init__(self, *args, **kw)

        self.AddSeparator()

        # Add print setup button
        self.AddSimpleTool(self.ON_PAGE_SETUP,
            wx.ArtProvider.GetBitmap(wx.ART_HELP_PAGE),
            'Page Setup',
            'Choose printer and layout page')
        wx.EVT_TOOL(self, self.ON_PAGE_SETUP, self._on_page_setup)
        # Add print button
        self.AddSimpleTool(self.ON_PRINT,
            wx.ArtProvider.GetBitmap(wx.ART_PRINT),
            'Print',
            'Print the current graph to the printer')
        wx.EVT_TOOL(self, self.ON_PRINT, self._on_print)
Exemplo n.º 30
0
    def __init__(self, panel):
        NavigationToolbar2WxAgg.__init__(self, panel.get_canvas())
        self.panel = panel

        self.AddSeparator()

        gridId = wx.NewId()
        self.AddCheckTool(gridId, load_bitmap('grid'), shortHelp='Toggle grid')
        self.ToggleTool(gridId, True)
        wx.EVT_TOOL(self, gridId, self.__on_check_grid)