Esempio n. 1
0
File: gui.py Progetto: cbig/zupport
    def __init__(self):
        QMainWindow.__init__(self)
        self.setWindowIcon(get_icon(os.path.join(APP_RESOURCES, 'icons',
                                                  'python.png')))
        self.setupUi(self)
        
        # Redirect output to GUI's QTextEdit
        sys.stdout = OutLog(self.outputTextEdit, sys.stdout)
        sys.stderr = OutLog(self.outputTextEdit, sys.stderr, QColor(255,0,0) )
        
        settings = QSettings()
        size = settings.value("MainWindow/Size",
                              QVariant(QSize(600, 500))).toSize()
        self.resize(size)
        position = settings.value("MainWindow/Position",
                                  QVariant(QPoint(0, 0))).toPoint()
        self.move(position)
        self.restoreState(
        settings.value("MainWindow/State").toByteArray())
    
        self.logger = Logger('Zupport.GUIloader')
        self.logger.debugging = settings.value("Logging/debugging").toBool()
         
        # Set up a ZupportManager to deal with the plugins
        self.manager = Manager(self)
        self.plugins = {}

        # Set up the extents menu
        self.extent = ExtentContainer()
        self.menuExtent = QMenu("Extent")
        resolutions = self.extent.resolutions
        self.extenactiongroup = QActionGroup(self.menuExtent)  
        noneaction = QAction("None", self.menuExtent)
        self.extenactiongroup.addAction(noneaction)
        self.menuExtent.addAction(noneaction)
        for resolution in resolutions:
            resolution_text = str(resolution)
            submenu = self.menuExtent.addMenu(resolution_text) 
            self.menuExtent.addMenu(submenu)
            for area in self.extent.get_names(resolution):
                subaction = QAction(str(area) + ": %s" % resolution_text, 
                                    submenu)
                subaction.setCheckable(True)
                self.extenactiongroup.addAction(subaction)
                submenu.addAction(subaction)
        
        noneaction.isChecked()
        self.menuSettings.addMenu(self.menuExtent)
        
        self.actionDebugging_messages.setChecked(self.logger.debugging)

        self.setWindowTitle("Zupport GUI")
        
        self.load_tools()
        
        self.toolTreeWidget.itemSelectionChanged.connect(self.update_ui)
        self.actionDebugging_messages.toggled.connect(self._set_debugging)
        self.menuExtent.triggered.connect(self.update_ui)
        self.actionLoad_tool.triggered.connect(self.show_tool_gui)
        self.toolTreeWidget.doubleClicked.connect(self.show_tool_gui)
Esempio n. 2
0
def create_action(parent,
                  title,
                  triggered=None,
                  toggled=None,
                  shortcut=None,
                  icon=None,
                  tip=None,
                  checkable=None,
                  context=Qt.WindowShortcut,
                  enabled=None):
    """
    Create a new QAction
    """
    action = QAction(title, parent)
    if triggered:
        action.triggered.connect(triggered)
    if checkable is not None:
        # Action may be checkable even if the toggled signal is not connected
        action.setCheckable(checkable)
    if toggled:
        action.toggled.connect(toggled)
        action.setCheckable(True)
    if icon is not None:
        assert isinstance(icon, QIcon)
        action.setIcon(icon)
    if shortcut is not None:
        action.setShortcut(shortcut)
    if tip is not None:
        action.setToolTip(tip)
        action.setStatusTip(tip)
    if enabled is not None:
        action.setEnabled(enabled)
    action.setShortcutContext(context)
    return action
Esempio n. 3
0
def create_action(parent, title, triggered=None, toggled=None,
                  shortcut=None, icon=None, tip=None, checkable=None,
                  context=Qt.WindowShortcut, enabled=None):
    """
    Create a new QAction
    """
    action = QAction(title, parent)
    if triggered:
        parent.connect(action, SIGNAL("triggered(bool)"), triggered)
    if checkable is not None:
        # Action may be checkable even if the toggled signal is not connected
        action.setCheckable(checkable)
    if toggled:
        parent.connect(action, SIGNAL("toggled(bool)"), toggled)
        action.setCheckable(True)
    if icon is not None:
        assert isinstance(icon, QIcon)
        action.setIcon( icon )
    if shortcut is not None:
        action.setShortcut(shortcut)
    if tip is not None:
        action.setToolTip(tip)
        action.setStatusTip(tip)
    if enabled is not None:
        action.setEnabled(enabled)
    action.setShortcutContext(context)
    return action
Esempio n. 4
0
    def __init__(self):
        QMainWindow.__init__(self)
        self.setWindowIcon(get_icon(os.path.join(APP_RESOURCES, 'icons',
                                                  'python.png')))
        self.setupUi(self)
        
        # Redirect output to GUI's QTextEdit
        sys.stdout = OutLog(self.outputTextEdit, sys.stdout)
        sys.stderr = OutLog(self.outputTextEdit, sys.stderr, QColor(255,0,0) )
        
        settings = QSettings()
        size = settings.value("MainWindow/Size",
                              QVariant(QSize(600, 500))).toSize()
        self.resize(size)
        position = settings.value("MainWindow/Position",
                                  QVariant(QPoint(0, 0))).toPoint()
        self.move(position)
        self.restoreState(
        settings.value("MainWindow/State").toByteArray())
    
        self.logger = Logger('Zupport.GUIloader')
        self.logger.debugging = settings.value("Logging/debugging").toBool()
         
        # Set up a ZupportManager to deal with the plugins
        self.manager = Manager(self)
        self.plugins = {}

        # Set up the extents menu
        self.extent = ExtentContainer()
        self.menuExtent = QMenu("Extent")
        resolutions = self.extent.resolutions
        self.extenactiongroup = QActionGroup(self.menuExtent)  
        noneaction = QAction("None", self.menuExtent)
        self.extenactiongroup.addAction(noneaction)
        self.menuExtent.addAction(noneaction)
        for resolution in resolutions:
            resolution_text = str(resolution)
            submenu = self.menuExtent.addMenu(resolution_text) 
            self.menuExtent.addMenu(submenu)
            for area in self.extent.get_names(resolution):
                subaction = QAction(str(area) + ": %s" % resolution_text, 
                                    submenu)
                subaction.setCheckable(True)
                self.extenactiongroup.addAction(subaction)
                submenu.addAction(subaction)
        
        noneaction.isChecked()
        self.menuSettings.addMenu(self.menuExtent)
        
        self.actionDebugging_messages.setChecked(self.logger.debugging)

        self.setWindowTitle("Zupport GUI")
        
        self.load_tools()
        
        self.toolTreeWidget.itemSelectionChanged.connect(self.update_ui)
        self.actionDebugging_messages.toggled.connect(self._set_debugging)
        self.menuExtent.triggered.connect(self.update_ui)
        self.actionLoad_tool.triggered.connect(self.show_tool_gui)
        self.toolTreeWidget.doubleClicked.connect(self.show_tool_gui)