예제 #1
0
def get_icon(name):
    """Get an icon from the icons folder in the current package,
    or directly from galry."""
    path = os.path.dirname(os.path.realpath(__file__))
    path = os.path.join(path, "../icons/%s.png" % name)
    if not os.path.exists(path):
        return galry.get_icon(name)
    else:
        return QtGui.QIcon(path)
예제 #2
0
def get_icon(name):
    """Get an icon from the icons folder in the current package,
    or directly from galry."""
    path = os.path.dirname(os.path.realpath(__file__))
    path = os.path.join(path, "../icons/%s.png" % name)
    if not os.path.exists(path):
        return galry.get_icon(name)
    else:
        return QtGui.QIcon(path)
예제 #3
0
        def add_toolbar(self):
            """Add navigation toolbar"""

            # reset
            reset_action = QtGui.QAction("Reset view (R)", self)
            reset_action.setIcon(get_icon("home"))
            self.widget.connect_events(reset_action.triggered, "Reset")

            # show grid
            grid_action = QtGui.QAction("Show grid (G)", self)
            grid_action.setIcon(get_icon("grid"))
            self.widget.connect_events(grid_action.triggered, "Grid")

            # fullscreen
            fullscreen_action = QtGui.QAction("Fullscreen (F)", self)
            fullscreen_action.setIcon(get_icon("fullscreen"))
            self.widget.connect_events(fullscreen_action.triggered, "Fullscreen")

            # save image
            save_action = QtGui.QAction("Save image (S)", self)
            save_action.setIcon(get_icon("save"))
            save_action.setShortcut("S")
            save_action.triggered.connect(self.save)

            toolbar_action = QtGui.QAction("Toggle toolbar visibility (T)", self)
            toolbar_action.setIcon(get_icon("toolbar"))
            toolbar_action.setShortcut("T")
            toolbar_action.triggered.connect(self.toggle_toolbar)
            # self.toolbar_action = toolbar_action

            # help
            help_action = QtGui.QAction("Show help (H)", self)
            help_action.setIcon(get_icon("help"))
            self.widget.connect_events(help_action.triggered, "Help")

            # exit
            exit_action = QtGui.QAction("Exit (Q)", self)
            exit_action.setIcon(get_icon("exit"))
            exit_action.triggered.connect(self.close)

            # add toolbar
            mytoolbar = QtGui.QToolBar(self.widget)
            mytoolbar.setIconSize(QtCore.QSize(32, 32))

            for action in [
                reset_action,
                grid_action,
                fullscreen_action,
                toolbar_action,
                save_action,
                help_action,
                exit_action,
            ]:
                self.addAction(action)
                mytoolbar.addAction(action)

            mytoolbar.setStyleSheet(
                """
            QToolBar, QToolButton
            {
                background: #000000;
                border-color: #000000;
                color: #ffffff;
            }
            QToolButton
            {
                margin-left: 5px;
            }
            QToolButton:hover
            {
                background: #2a2a2a;
            }
            """
            )
            mytoolbar.setMovable(False)
            mytoolbar.setFloatable(False)
            self.toolbar = mytoolbar
            self.addToolBar(mytoolbar)
        def add_toolbar(self):
            """Add navigation toolbar"""
            
            # reset
            reset_action = QtGui.QAction("Reset view (R)", self)
            reset_action.setIcon(get_icon('home'))
            self.widget.connect_events(reset_action.triggered, 'Reset')
            
            # show grid
            grid_action = QtGui.QAction("Show grid (G)", self)
            grid_action.setIcon(get_icon('grid'))
            self.widget.connect_events(grid_action.triggered, 'Grid')

            # fullscreen
            fullscreen_action = QtGui.QAction("Fullscreen (F)", self)
            fullscreen_action.setIcon(get_icon('fullscreen'))
            self.widget.connect_events(fullscreen_action.triggered, 'Fullscreen')

            # save image
            save_action = QtGui.QAction("Save image (S)", self)
            save_action.setIcon(get_icon('save'))
            save_action.setShortcut("S")
            save_action.triggered.connect(self.save)            
            
            toolbar_action = QtGui.QAction("Toggle toolbar visibility (T)", self)
            toolbar_action.setIcon(get_icon('toolbar'))
            toolbar_action.setShortcut("T")
            toolbar_action.triggered.connect(self.toggle_toolbar)
            # self.toolbar_action = toolbar_action
            
            # help
            help_action = QtGui.QAction("Show help (H)", self)
            help_action.setIcon(get_icon('help'))
            self.widget.connect_events(help_action.triggered, 'Help')
            
            # exit
            exit_action = QtGui.QAction("Exit (Q)", self)
            exit_action.setIcon(get_icon('exit'))
            exit_action.triggered.connect(self.close)
            
            # add toolbar
            mytoolbar = QtGui.QToolBar(self.widget)        
            mytoolbar.setIconSize(QtCore.QSize(32, 32))
            
            for action in [reset_action, grid_action, fullscreen_action,
                toolbar_action, save_action, help_action, exit_action]:
                self.addAction(action)
                mytoolbar.addAction(action)
            
            mytoolbar.setStyleSheet("""
            QToolBar, QToolButton
            {
                background: #000000;
                border-color: #000000;
                color: #ffffff;
            }
            QToolButton
            {
                margin-left: 5px;
            }
            QToolButton:hover
            {
                background: #2a2a2a;
            }
            """)
            mytoolbar.setMovable(False)
            mytoolbar.setFloatable(False)
            self.toolbar = mytoolbar
            self.addToolBar(mytoolbar)