示例#1
0
    def _setupActions(self):
        """
        creates some actions needed on some menues and toolbars
        """
        a = self._actions["close_shell"] = qt.QAction( qt.QIconSet(qt.QPixmap(os.path.join(CONF.getIconsPath(),"newshell.png"))), "&Close Shell", qt.Qt.CTRL + qt.Qt.Key_W, self, "New Shell" )
        self.connect(a, qt.SIGNAL('activated()'), self.destroyShellTab)

        a = self._actions["new_shell"] = qt.QAction( qt.QIconSet(qt.QPixmap(os.path.join(CONF.getIconsPath(),"newshell.png"))), "&New Shell", qt.Qt.CTRL + qt.Qt.Key_T, self, "New Shell" )
        self.connect(a, qt.SIGNAL('activated()'), self.createShellTab)
示例#2
0
    def __init__(self, parent=None):

        self._window = qt.QDialog(None)
        self._window.setIcon(getPixmap("smart"))
        self._window.setCaption(_("Priorities"))
        #self._window.setModal(True)

        self._window.setMinimumSize(600, 400)

        layout = qt.QVBoxLayout(self._window)
        layout.setResizeMode(qt.QLayout.FreeResize)

        vbox = qt.QVBox(self._window)
        vbox.setMargin(10)
        vbox.setSpacing(10)
        vbox.show()

        layout.addWidget(vbox)

        self._treeview = qt.QListView(vbox)
        self._treeview.setAllColumnsShowFocus(True)
        self._treeview.show()

        qt.QObject.connect(self._treeview, qt.SIGNAL("itemRenamed(QListViewItem *, int, const QString &)"), self.itemRenamed)
        qt.QObject.connect(self._treeview, qt.SIGNAL("selectionChanged()"), self.selectionChanged)

        self._treeview.addColumn(_("Package Name"))
        self._treeview.addColumn(_("Channel Alias"))
        self._treeview.addColumn(_("Priority"))

        bbox = qt.QHBox(vbox)
        bbox.setSpacing(10)
        bbox.layout().addStretch(1)
        bbox.show()

        button = qt.QPushButton(_("New"), bbox)
        button.setEnabled(True)
        button.setIconSet(qt.QIconSet(getPixmap("crystal-add")))
        button.show()
        qt.QObject.connect(button, qt.SIGNAL("clicked()"), self.newPriority)
        self._newpriority = button

        button = qt.QPushButton(_("Delete"), bbox)
        button.setEnabled(False)
        button.setIconSet(qt.QIconSet(getPixmap("crystal-delete")))
        button.show()
        qt.QObject.connect(button, qt.SIGNAL("clicked()"), self.delPriority)
        self._delpriority = button

        button = qt.QPushButton(_("Close"), bbox)
        qt.QObject.connect(button, qt.SIGNAL("clicked()"), self._window, qt.SLOT("accept()"))
        
        button.setDefault(True)
        vbox.adjustSize()
示例#3
0
    def _init_toolbar( self ):
        basedir = matplotlib.rcParams[ 'datapath' ]
        
        for text, tooltip_text, image_file, callback in self.toolitems:
            if text == None:
                self.layout.addSpacing( 8 )
                continue
            
            fname = os.path.join( basedir, image_file )
            image = qt.QPixmap()
            image.load( fname )

            button = qt.QPushButton( qt.QIconSet( image ), "", self )
            qt.QToolTip.add( button, tooltip_text )

            # The automatic layout doesn't look that good - it's too close
            # to the images so add a margin around it.
            margin = 4
            button.setFixedSize( image.width()+margin, image.height()+margin )

            qt.QObject.connect( button, qt.SIGNAL( 'clicked()' ),
                                getattr( self, callback ) )
            self.layout.addWidget( button )

        # Add the x,y location widget at the right side of the toolbar
        # The stretch factor is 1 which means any resizing of the toolbar
        # will resize this label instead of the buttons.
        self.locLabel = qt.QLabel( "", self )
        self.locLabel.setAlignment( qt.Qt.AlignRight | qt.Qt.AlignVCenter )
        self.layout.addWidget( self.locLabel, 1 )
    def setupEditor(self, filename):
        """ setupEditor(filename) -> create the editors widgets

        """
        from eric3.QScintilla import Editor
        from eric3.Project import Project

        ## older versions
        try:
            from eric3.eric3 import initializeMimeSourceFactory
        except (ImportError, ):
            pass
        else:
            initializeMimeSourceFactory(eric3Dir)

        ## recent versions (around snapshot 20040818)
        try:
            from eric3.Utilities import Startup
        except (ImportError, ):
            pass
        else:
            Startup.initializeMimeSourceFactory(eric3Dir)

        self.layout().setAutoAdd(True)
        self.project = Project.Project()
        self.editorActGrp = qt.QWidget(self)
        self.editor = Editor.Editor(MockDebugger(), filename, parent=self)

        menu = self.editor.menu
        for i in [menu.idAt(i) for i in range(menu.count())]:
            if menu.text(i) == 'Close':
                menu.setItemEnabled(i, False)
        menu.insertSeparator()
        menu.insertItem(qt.QIconSet(PixmapCache.getPixmap('eric')),
                        'About %s' % (Info.Program, ), self.aboutEditor)
示例#5
0
    def __init__(self, parent = None, name = "task_toolbox"):
        qt.QWidget.__init__(self, parent, name)

        # Data atributes
        self.shape_history = None
        self.tree_brick = None
        self.previous_page_index = 0

        #Layout
        self.v_layout = qt.QVBoxLayout(self)
        self.v_layout.setSpacing(10)
        self.method_group_box = qt.QVGroupBox("Collection method", self)
        font = self.method_group_box.font()
        font.setPointSize(12)
        self.method_group_box.setFont(font)
    
        self.tool_box = qt.QToolBox(self.method_group_box , "tool_box")
        self.tool_box.setFixedWidth(475)
        font = self.tool_box.font()
        font.setPointSize(10)
        self.tool_box.setFont(font)
        
        self.discrete_page = CreateDiscreteWidget(self.tool_box, "Discrete",)
        self.discrete_page.setBackgroundMode(qt.QWidget.PaletteBackground)
        self.char_page = CreateCharWidget(self.tool_box, "Characterise")
        self.char_page.setBackgroundMode(qt.QWidget.PaletteBackground)
        self.helical_page = CreateHelicalWidget(self.tool_box, "helical_page")
        self.helical_page.setBackgroundMode(qt.QWidget.PaletteBackground)
        self.energy_scan_page = CreateEnergyScanWidget(self.tool_box, "energy_scan")
        self.xrf_scan_page = CreateXRFScanWidget(self.tool_box, "xrf_scan")
        self.workflow_page = CreateWorkflowWidget(self.tool_box, 'workflow')
        
        self.tool_box.addItem(self.discrete_page, "Standard Collection")
        self.tool_box.addItem(self.char_page, "Characterisation")
        self.tool_box.addItem(self.helical_page, "Helical Collection")
        self.tool_box.addItem(self.energy_scan_page, "Energy Scan")
        self.tool_box.addItem(self.xrf_scan_page, "XRF Scan")
        self.tool_box.addItem(self.workflow_page, "Advanced")

        self.add_pixmap = Icons.load("add_row.png")
        self.create_task_button = qt.QPushButton("  Add to queue", self)
        self.create_task_button.setIconSet(qt.QIconSet(self.add_pixmap))
        msg = "Add the collection method to the selected sample"
        qt.QToolTip.add(self.create_task_button, msg)
        
        self.v_layout.addWidget(self.method_group_box)

        self.button_hlayout = qt.QHBoxLayout(None)
        self.spacer = qt.QSpacerItem(1, 20, qt.QSizePolicy.Expanding,
                                     qt.QSizePolicy.Minimum)
        self.button_hlayout.addItem(self.spacer)
        self.button_hlayout.addWidget(self.create_task_button)
        self.method_group_box.layout().setSpacing(10)
        self.method_group_box.layout().addLayout(self.button_hlayout)

        qt.QObject.connect(self.create_task_button, qt.SIGNAL("clicked()"),
                           self.create_task_button_click)

        qt.QObject.connect(self.tool_box, qt.SIGNAL("currentChanged( int )"),
                           self.current_page_changed)
示例#6
0
 def tab_slot(
     self,
     hide=True,
     page={
         "widget": scrollview,
         "label": self.tabLabel(scrollview),
         "index": self.indexOf(scrollview),
         "icon": icon,
         "hidden": False
     }):
     if hide:
         if not page["hidden"]:
             self.removePage(page["widget"])
             page["hidden"] = True
     else:
         if page["hidden"]:
             if icon:
                 pixmap = Icons.load(icon)
                 self.insertTab(page["widget"],
                                qt.QIconSet(pixmap, pixmap), label,
                                page["index"])
             else:
                 self.insertTab(page["widget"], page["label"],
                                page["index"])
             self.showPage(page["widget"])
             page["hidden"] = False
         else:
             self.showPage(page["widget"])
示例#7
0
    def collect_items(self, items=[], checked_items=[]):
        self.beamline_setup_hwobj.shape_history_hwobj.de_select_all()
        for item in checked_items:
            # update the run-number text incase of re-collect
            #item.setText(0, item.get_model().get_name())

            #Clear status
            item.setText(1, "")
            item.reset_style()

        self.user_stopped = False
        self.delete_button.setEnabled(False)
        self.enable_sample_changer_widget(False)

        self.collecting = True
        self.collect_button.setText(" Stop   ")
        self.collect_button.setPaletteBackgroundColor(widget_colors.LIGHT_RED)
        self.collect_button.setIconSet(qt.QIconSet(self.stop_pixmap))
        self.parent().enable_hutch_menu(False)
        self.run_cb()

        try:
            self.queue_hwobj.execute()
        except Exception, e:
            raise e
示例#8
0
    def contextMenuEvent(self, event):
        """ contextMenuEvent(event) -> display context menu

        """
        widget = self.childAt(event.pos())
        children, labels, lcds = self.summaryChildren()

        if widget in lcds:
            key = lcds[widget]
            lcd = widget
            label = self.summaries[key][0]
        elif widget in labels:
            key = labels[widget]
            lcd = self.summaries[key][1]
            label = widget
        else:
            event.ignore()
            return

        pop = kdeui.KPopupMenu(self)
        self.context = (key, label, lcd)

        item = pop.insertItem(util.loadIconSet('up'), i18n('Move Up'),
                              self.moveSummary)
        pop.setItemParameter(item, 0)
        if not children.index(label):
            pop.setItemEnabled(item, False)

        item = pop.insertItem(util.loadIconSet('down'), i18n('Move Down'),
                              self.moveSummary)
        pop.setItemParameter(item, 1)
        if children.index(lcd) + 1 == len(children):
            pop.setItemEnabled(item, False)

        pop.insertSeparator()
        item = pop.insertItem(util.loadIconSet('remove'),
                              i18n('Remove "%s"' % (key, )),
                              self.removeSummary)
        pop.insertSeparator()
        for index, label, color in ((0, 'Background color...',
                                     lcd.paletteBackgroundColor()),
                                    (1, 'Foreground color...',
                                     lcd.paletteForegroundColor())):

            item = pop.insertItem('', self.selectColor)
            pixmap = qt.QPixmap(16, 16)
            pixmap.fill(color)
            icons = qt.QIconSet(pixmap)
            pop.changeItem(item, icons, i18n(label))
            pop.setItemParameter(item, index)

        pop.insertSeparator()
        for label, style, icon in lcdStyles:
            item = pop.insertItem(util.loadIconSet(icon), i18n(label),
                                  self.selectSegmentStyle)
            pop.setItemParameter(item, style)
            pop.setItemChecked(item, style == lcd.segmentStyle())

        pop.popup(event.globalPos())
示例#9
0
 def queue_execution_completed(self, status):
     self.collecting = False
     self.collect_button.setText("Collect Queue")
     self.collect_button.setIconSet(qt.QIconSet(self.play_pixmap))
     self.collect_button.setPaletteBackgroundColor(widget_colors.LIGHT_GREEN)
     self.delete_button.setEnabled(True)
     self.enable_sample_changer_widget(True)
     self.parent().enable_hutch_menu(True)
     self.parent().enable_command_menu(True)
     self.parent().enable_task_toolbox(True)
     self.set_sample_pin_icon()
示例#10
0
 def inserttool(toolbar, tool):
     if tool:
         action = self._actions[tool]
         #b = qt.QToolButton(toolbar, TOOL)
         #b.setTextLabel(action.toolTip())
         pixmap = getPixmap(TOOLBARICONS[tool])
         #b.setIconSet(qt.QIconSet(pixmap))
         action.setIconSet(qt.QIconSet(pixmap))
         action.addTo(toolbar)
     else:
         toolbar.addSeparator()
示例#11
0
    def __init__(self, *args, **kwargs):
        qt.QWidget.__init__(self, *args)

        self.setCaption("Hardware Repository browser")
        
        tb = qt.QHBox(self)
        self.cmdRefresh = qt.QToolButton(tb)
        self.cmdRefresh.setIconSet(qt.QIconSet(Icons.load("reload")))
        qt.QToolTip.add(self.cmdRefresh, "refresh HWR objects tree")
        self.cmdClose = qt.QToolButton(tb)
        self.cmdClose.setIconSet(qt.QIconSet(Icons.load("button_cancel")))
        qt.QToolTip.add(self.cmdClose, "close HWR browser")
        HorizontalSpacer(tb)
        tb.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Fixed)

        qt.QObject.connect(self.cmdRefresh, qt.SIGNAL("clicked()"), self.refresh)
        qt.QObject.connect(self.cmdClose, qt.SIGNAL("clicked()"), self.close)

        qt.QVBoxLayout(self)
        self.layout().addWidget(tb)
        self.add_hwr_browser()
示例#12
0
 def _init_toolbar( self ):
     self.window.setUsesTextLabel( False )
     basedir = matplotlib.rcParams[ 'datapath' ]
     
     for text, tooltip_text, image_file, callback in self.toolitems:
         if text == None:
             self.addSeparator()
             continue
         
         fname = os.path.join( basedir, image_file )
         image = qt.QPixmap()
         image.load( fname )
         a = qt.QAction( qt.QIconSet( image ), text, qt.QKeySequence('M'),
                         self.window )
         a.setToolTip( tooltip_text )
         qt.QObject.connect( a, qt.SIGNAL( 'activated()' ),
                             getattr( self, callback ) )
         a.addTo( self )
示例#13
0
    def __init__(self, parent, icon, text=None, callback=None, tooltip=None):
        qt.QToolButton.__init__(self, parent)

        self.setIconSet(qt.QIconSet(Icons.load(icon)))

        if type(text) != types.StringType:
            tooltip = callback
            callback = text
        else:
            self.setTextLabel(text)
            self.setTextPosition(qt.QToolButton.BesideIcon)
            self.setUsesTextLabel(True)

        if callback is not None:
            qt.QObject.connect(self, qt.SIGNAL("clicked()"), callback)

        if tooltip is not None:
            qt.QToolTip.add(self, tooltip)

        self.setSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Fixed)
示例#14
0
    def __init__(self, *args, **kwargs):
        qt.QWidget.__init__(self, *args)
       
        self.setCaption("Toolbox")
        self.bricksTab = {}
        self.bricks = {}
      
        topPanel = qt.QFrame(self)
        self.cmdRefresh = qt.QToolButton(topPanel)
        self.cmdRefresh.setIconSet(qt.QIconSet(Icons.load("reload")))
        qt.QToolTip.add(self.cmdRefresh, "refresh bricks list")
        qt.QHBoxLayout(topPanel)
        topPanel.layout().addWidget(qt.QLabel("Available bricks", topPanel), 0, qt.Qt.AlignLeft)
        topPanel.layout().addWidget(self.cmdRefresh, 0, qt.Qt.AlignRight)
        qt.QObject.connect(self.cmdRefresh, qt.SIGNAL("clicked()"), self.refresh)

        self.bricksToolbox = qt.QToolBox(self)
        
        qt.QVBoxLayout(self, 5, 5)
        self.layout().addWidget(topPanel)
        self.layout().addWidget(self.bricksToolbox)
示例#15
0
    def __init__(self, *args):
        BaseComponents.BlissWidget.__init__(self, *args)

        # Internal members
        self.current_cpos = None
        self.__collection_stopped = False
        self.current_view = None

        # Framework 2 hardware objects
        self._lims_hwobj = None
        self.sample_changer = None
        self.plate_manipulator_hwobj = None
        self.queue_hwobj = None

        # Properties
        self.addProperty("holderLengthMotor", "string", "")
        self.addProperty("queue", "string", "/queue")
        self.addProperty("default_centring_method", "integer", 1)
        self.addProperty("queue_model", "string", "/queue-model")
        self.addProperty("beamline_setup", "string", "/beamline-setup")
        self.addProperty("xml_rpc_server", "string", "/xml_rpc_server")

        # Qt - Slots
        # From ProposalBrick2
        self.defineSlot("logged_in", ())

        # Used from TaskToolBoxBrick
        self.defineSlot("get_tree_brick", ())
        self.defineSlot("get_selected_samples", ())

        # From SampleChangerBrick3, signal emitted when
        # the status of the hwobj changes.
        self.defineSlot("status_msg_changed", ())

        # From sample changer hwobj, emitted when the
        # load state changes.
        self.defineSlot("sample_load_state_changed", ())

        # self.defineSlot("get_mounted_sample", ())
        # self.defineSlot("new_centred_position", ())
        # self.defineSlot("add_dcg", ())
        # self.defineSlot("add_data_collection", ())
        # self.defineSlot("set_session", ())

        # Qt - Signals
        self.defineSignal("enable_hutch_menu", ())
        self.defineSignal("enable_command_menu", ())
        self.defineSignal("enable_task_toolbox", ())

        # Hiding and showing the tabs
        self.defineSignal("hide_sample_tab", ())
        self.defineSignal("hide_dc_parameters_tab", ())
        self.defineSignal("hide_sample_centring_tab", ())
        self.defineSignal("hide_dcg_tab", ())
        self.defineSignal("hide_sample_changer_tab", ())
        self.defineSignal("hide_edna_tab", ())
        self.defineSignal("hide_energy_scan_tab", ())
        self.defineSignal("hide_xrf_spectrum_tab", ())
        self.defineSignal("hide_workflow_tab", ())

        # Populating the tabs with data
        self.defineSignal("populate_parameter_widget", ())
        self.defineSignal("populate_edna_parameter_widget", ())
        self.defineSignal("populate_sample_details", ())
        self.defineSignal("populate_energy_scan_widget", ())
        self.defineSignal("populate_xrf_spectrum_widget", ())
        self.defineSignal("populate_workflow_tab", ())

        # Handle selection
        self.defineSignal("selection_changed", ())
        self.defineSignal("set_directory", ())
        self.defineSignal("set_prefix", ())
        self.defineSignal("set_sample", ())

        # self.defineSignal("clear_centred_positions", ())

        # Layout
        # self.setSizePolicy(qt.QSizePolicy(qt.QSizePolicy.Fixed,
        #                                  qt.QSizePolicy.Expanding))

        widget = qtui.QWidgetFactory.create(
            os.path.join(
                os.path.dirname(__file__),
                "widgets/ui_files/sample_changer_widget_layout.ui",
            ))

        widget.reparent(self, qt.QPoint(0, 0))
        self.sample_changer_widget = widget

        self.refresh_pixmap = Icons.load("Refresh2.png")
        self.sample_changer_widget.child("synch_button").setIconSet(
            qt.QIconSet(self.refresh_pixmap))
        self.sample_changer_widget.child("synch_button").setText("Synch ISPyB")

        self.dc_tree_widget = DataCollectTree(self)
        self.dc_tree_widget.selection_changed_cb = self.selection_changed
        self.dc_tree_widget.run_cb = self.run
        # self.dc_tree_widget.clear_centred_positions_cb = \
        #    self.clear_centred_positions

        qt.QObject.connect(
            self.sample_changer_widget.child("details_button"),
            qt.SIGNAL("clicked()"),
            self.toggle_sample_changer_tab,
        )

        qt.QObject.connect(
            self.sample_changer_widget.child("filter_cbox"),
            qt.SIGNAL("activated(int)"),
            self.dc_tree_widget.filter_sample_list,
        )

        qt.QObject.connect(
            self.sample_changer_widget.child("centring_cbox"),
            qt.SIGNAL("activated(int)"),
            self.dc_tree_widget.set_centring_method,
        )

        qt.QObject.connect(
            self.sample_changer_widget.child("synch_button"),
            qt.SIGNAL("clicked()"),
            self.refresh_sample_list,
        )

        vlayout = qt.QVBoxLayout(self, 0, 0, "main_layout")
        vlayout.setSpacing(10)
        self.layout().addWidget(self.sample_changer_widget)
        self.layout().addWidget(self.dc_tree_widget)
        self.enable_collect(False)

        self.sample_changer_widget.child("centring_cbox").setCurrentItem(1)
        self.dc_tree_widget.set_centring_method(1)
示例#16
0
    def packagePopup(self, packageview, pkgs, pnt):
        
        menu = qt.QPopupMenu(packageview)
        menu.move(pnt)
        
        hasinstalled = bool([pkg for pkg in pkgs if pkg.installed
                             and self._changeset.get(pkg) is not REMOVE])
        hasnoninstalled = bool([pkg for pkg in pkgs if not pkg.installed
                                and self._changeset.get(pkg) is not INSTALL])

        class PackagesAction(object):
        
            def __init__(self, pkgs):
                self._pkgs = pkgs
                self._callback = {}
                self._userdata = {}
            
            def connect(self, item, callback, userdata=None):
                self._callback[item] = callback
                self._userdata[item] = userdata
            
            def slot(self, index):
                self._callback[index](self._pkgs, self._userdata[index])

        action = PackagesAction(pkgs)

        iconset = qt.QIconSet(getPixmap("package-install"))
        item = menu.insertItem(iconset, _("Install"), action.slot)
        action.connect(item, self.actOnPackages, INSTALL)
        if not hasnoninstalled:
            menu.setItemEnabled(item, False)

        iconset = qt.QIconSet(getPixmap("package-reinstall"))
        item = menu.insertItem(iconset, _("Reinstall"), action.slot)
        action.connect(item, self.actOnPackages, REINSTALL)
        if not hasinstalled:
            menu.setItemEnabled(item, False)

        iconset = qt.QIconSet(getPixmap("package-remove"))
        item = menu.insertItem(iconset, _("Remove"), action.slot)
        action.connect(item, self.actOnPackages, REMOVE)
        if not hasinstalled:
            menu.setItemEnabled(item, False)

        if not hasinstalled:
            iconset = qt.QIconSet(getPixmap("package-available"))
        else:
            iconset = qt.QIconSet(getPixmap("package-installed"))
        item = menu.insertItem(iconset, _("Keep"), action.slot)
        action.connect(item, self.actOnPackages, KEEP)
        if not [pkg for pkg in pkgs if pkg in self._changeset]:
            menu.setItemEnabled(item, False)

        iconset = qt.QIconSet(getPixmap("package-broken"))
        item = menu.insertItem(iconset, _("Fix problems"), action.slot)
        action.connect(item, self.actOnPackages, FIX)
        if not hasinstalled:
            menu.setItemEnabled(item, False)

        inconsistent = False
        thislocked = None
        alllocked = None
        names = pkgconf.getFlagTargets("lock")
        if [pkg for pkg in pkgs if pkg in self._changeset]:
            inconsistent = True
        else:
            for pkg in pkgs:
                if (names and pkg.name in names and 
                    ("=", pkg.version) in names[pkg.name]):
                    newthislocked = True
                    newalllocked = len(names[pkg.name]) > 1
                else:
                    newthislocked = False
                    newalllocked = pkgconf.testFlag("lock", pkg)
                if (thislocked is not None and thislocked != newthislocked or
                    alllocked is not None and alllocked != newalllocked):
                    inconsistent = True
                    break
                thislocked = newthislocked
                alllocked = newalllocked

        lockaction = PackagesAction(pkgs)

        if thislocked:
            if not hasnoninstalled:
                iconset = qt.QIconSet(getPixmap("package-installed"))
            else:
                iconset = qt.QIconSet(getPixmap("package-available"))
            item = menu.insertItem(iconset, _("Unlock this version"), lockaction.slot)
            lockaction.connect(item, self.lockPackages, False)
        else:
            if not hasnoninstalled:
                iconset = qt.QIconSet(getPixmap("package-installed-locked"))
            else:
                iconset = qt.QIconSet(getPixmap("package-available-locked"))
            item = menu.insertItem(iconset, _("Lock this version"), lockaction.slot)
            lockaction.connect(item, self.lockPackages, True)
        if inconsistent:
            menu.setItemEnabled(item, False)

        lockallaction = PackagesAction(pkgs)

        if alllocked:
            if not hasnoninstalled:
                iconset = qt.QIconSet(getPixmap("package-installed"))
            else:
                iconset = qt.QIconSet(getPixmap("package-available"))
            item = menu.insertItem(iconset, _("Unlock all versions"), lockallaction.slot)
            lockallaction.connect(item, self.lockAllPackages, False)
        else:
            if not hasnoninstalled:
                iconset = qt.QIconSet(getPixmap("package-installed-locked"))
            else:
                iconset = qt.QIconSet(getPixmap("package-available-locked"))
            item = menu.insertItem(iconset, _("Lock all versions"), lockallaction.slot)
            lockallaction.connect(item, self.lockAllPackages, True)
        if inconsistent:
            menu.setItemEnabled(item, False)

        priorityaction = PackagesAction(pkgs)
        
        item = menu.insertItem(_("Priority"), priorityaction.slot)
        priorityaction.connect(item, self.priorityPackages)
        if len(pkgs) != 1:
            menu.setItemEnabled(item, False)

        menu.show()
        menu.exec_loop(packageview.mapToGlobal(pnt))
示例#17
0
    def __init__(self, parent, name, **keys):
        BlissWidget.__init__(self, parent, name)
        self.__hMotor = None
        self.__vMotor = None
        self.__motor_pos_save = []
        self.__master_motor = None
        self.__masterPosition2Item = weakref.WeakValueDictionary()
        self.__currentCalib = None
        self.__currentBeamPos = None
        self.__camDecompNPlug = None
        self.mosaicView = None
        self.drawing = None
        self.__saveImageTreeDirName = '.'
        self.__imageMosaicPosition = None
        ####### Property #######
        self.addProperty('horizontal', 'string', '')
        self.addProperty('vertical', 'string', '')
        self.addProperty('save_motors', 'string', '')
        self.addProperty('master_motor', 'string', '')
        self.addProperty('focus_motor', 'string', '')
        self.addProperty('live_camera', 'string', '')
        self.addProperty("formatString", "formatString", "###.##")
        ####### SIGNAL #######
        self.defineSignal("getImage", ())
        self.defineSignal('getView', ())
        self.defineSignal('getMosaicView', ())
        ####### SLOT #######
        self.defineSlot("ChangePixelCalibration", ())
        self.defineSlot("ChangeBeamPosition", ())
        self.defineSlot('setMosaicImageSelected', ())

        self.__widgetTree = self.loadUIFile('CameraOffLineImageManager.ui')
        self.__frame = self.__widgetTree.child('__frame')
        self.__frame.reparent(self, qt.QPoint(0, 0))
        layout = qt.QHBoxLayout(self)
        layout.addWidget(self.__frame)

        snapButton = self.child('__snapShoot')
        iconSet = qt.QIconSet(loadIcon("snapshot.png"))
        snapButton.setIconSet(iconSet)
        qt.QObject.connect(snapButton, qt.SIGNAL('clicked()'), self.__snapCBK)

        liveCheckBox = self.child('__liveCheckBox')
        liveCheckBox.hide()
        qt.QObject.connect(liveCheckBox, qt.SIGNAL('toggled(bool)'),
                           self.__liveOnOff)

        self.__imageList = self.child('__imageList')
        self.__imageList.setSelectionMode(qt.QListView.Extended)
        self.__imageList.setSortColumn(-1)
        self.__popUpMenu = qt.QPopupMenu(self)
        self.__popUpMenu.insertItem('layer up', self.__layerUp)
        self.__popUpMenu.insertItem('layer down', self.__layerDown)
        self.__popUpMenu.insertItem('remove', self.__removeImage)

        self.__popUpMenu.insertSeparator()
        self.__popUpMenu.insertItem('load', self.__loadImageTree)
        self.__popUpMenu.insertItem('save', self.__saveImageTree)

        qt.QObject.connect(
            self.__imageList,
            qt.SIGNAL('rightButtonPressed(QListViewItem*,const QPoint &,int)'),
            self.__popUpDisplay)
示例#18
0
    def __init__(self, ctrl, argv=None):
        QtInterface.__init__(self, ctrl, argv)

        self._changeset = None

        self._window = qt.QMainWindow()
        self._window.setCaption("Smart Package Manager %s" % VERSION)
        centerWindow(self._window)
        self._window.setMinimumSize(640, 480)
        app.connect(app, qt.SIGNAL('lastWindowClosed()'), app, qt.SLOT('quit()'))

        self._undo = []
        self._redo = []

        globals = {"self": self, "qt": qt}
        group = qt.QActionGroup(self._window, "Actions")
        self._actions = compileActions(group, ACTIONS, globals)

        class ToggleAction(qt.QAction):
        
            def __init__(self, group, name, label):
                qt.QAction.__init__(self, group, name)
                self.setToggleAction(True)
                self.setMenuText(label.replace("&","&&"))
                self._name = name
            
            def connect(self, signal, callback, userdata):
                self._callback = callback
                self._userdata = userdata
                qt.QObject.connect(self, qt.SIGNAL(signal), self.slot)
            
            def slot(self):
                self._callback(self._userdata)
         
        self._filters = {}
        for name, label in [("hide-non-upgrades", _("Hide Non-upgrades")),
                            ("hide-installed", _("Hide Installed")),
                            ("hide-uninstalled", _("Hide Uninstalled")),
                            ("hide-unmarked", _("Hide Unmarked")),
                            ("hide-unlocked", _("Hide Unlocked")),
                            ("hide-requested", _("Hide Requested")),
                            ("hide-old", _("Hide Old"))]:
            act = ToggleAction(None, name, label)
            act.connect("activated()", self.toggleFilter, name)
            self._actions[name] = act

        treestyle = sysconf.get("package-tree")
        for name, label in [("groups", _("Groups")),
                            ("channels", _("Channels")),
                            ("channels-groups", _("Channels & Groups")),
                            ("none", _("None"))]:
            act = ToggleAction(group, "tree-style-"+name, label)
            if name == treestyle:
                act.setOn(True)
            act.connect("activated()", self.setTreeStyle, name)
            self._actions["tree-style-"+name] = act

        self._menubar = self._window.menuBar()
        for MENU in MENUBAR:
             def insertmenu(menubar, menu):
                item = menu[0]
                action = self._actions[item]
                m = qt.QPopupMenu(menubar)
                text = action.menuText()
                menubar.insertItem(text, m)
                for item in menu[1]:
                    if isinstance(item, tuple):
                        insertmenu(m, item)
                    elif item:
                        action = self._actions[item]
                        #i = qt.QPopupMenu(m)
                        #text = action.menuText()
                        #m.insertItem(text, i)
                        action.addTo(m)
                    else:
                        m.insertSeparator()
             insertmenu(self._menubar, MENU)

        self._toolbar = qt.QToolBar(self._window)
        for TOOL in TOOLBAR:
            def inserttool(toolbar, tool):
                if tool:
                    action = self._actions[tool]
                    #b = qt.QToolButton(toolbar, TOOL)
                    #b.setTextLabel(action.toolTip())
                    pixmap = getPixmap(TOOLBARICONS[tool])
                    #b.setIconSet(qt.QIconSet(pixmap))
                    action.setIconSet(qt.QIconSet(pixmap))
                    action.addTo(toolbar)
                else:
                    toolbar.addSeparator()
            inserttool(self._toolbar, TOOL)

        #self._window.add_accel_group(self._ui.get_accel_group())

        self._actions["exec-changes"].setAccel(qt.QKeySequence("Ctrl+C"))
        self._actions["find"].setAccel(qt.QKeySequence("Ctrl+F"))
        self._actions["expand-all"].setAccel(qt.QKeySequence("Ctrl+O"))
        self._actions["collapse-all"].setAccel(qt.QKeySequence("Ctrl+W"))
        self._actions["summary-window"].setAccel(qt.QKeySequence("Ctrl+S"))

        self._actions["exec-changes"].setEnabled(False)
        self._actions["clear-changes"].setEnabled(False)
        self._actions["undo"].setEnabled(False)
        self._actions["redo"].setEnabled(False)

        # Search bar

        self._searchbar = qt.QToolBar(self._window)
        self._searchbar.hide()
       
        label = qt.QLabel(_("Search:"), self._searchbar)
        label.show()

        self._searchentry = qt.QLineEdit(self._searchbar)
        qt.QObject.connect(self._searchentry, qt.SIGNAL("returnPressed()"), self.refreshPackages)
        self._searchentry.show()

        button = qt.QPushButton(self._searchbar)
        qt.QObject.connect(button, qt.SIGNAL("clicked()"), self.refreshPackages)
        pixmap = getPixmap("crystal-search")
        button.setIconSet(qt.QIconSet(pixmap))
        button.show()

        buttongroup = qt.QButtonGroup(self._searchbar)
        buttongroup.hide()
        
        self._searchname = qt.QRadioButton(_("Automatic"), self._searchbar)
        self._searchname.setChecked(True)
        qt.QObject.connect(self._searchname, qt.SIGNAL("clicked()"), self.refreshPackages)
        buttongroup.insert(self._searchname)
        self._searchname.show()
        self._searchdesc = qt.QRadioButton(_("Description"), self._searchbar)
        self._searchdesc.setChecked(False)
        qt.QObject.connect(self._searchdesc, qt.SIGNAL("clicked()"), self.refreshPackages)
        self._searchdesc.show()
        buttongroup.insert(self._searchdesc)

        # Packages and information

        self._splitter = qt.QSplitter(qt.Qt.Vertical, self._window)
        self._window.setCentralWidget(self._splitter)
        
        self._pv = QtPackageView(self._splitter)
        self._pv.show()

        self._pi = QtPackageInfo(self._splitter)
        self._pi.show()
        qt.QObject.connect(self._pv, qt.PYSIGNAL("packageSelected"), self._pi.setPackage)
        qt.QObject.connect(self._pv, qt.PYSIGNAL("packageActivated"), self.actOnPackages)
        qt.QObject.connect(self._pv, qt.PYSIGNAL("packagePopup"), self.packagePopup)

        self._status = self._window.statusBar()
        self._status.show()
        
        self._legend = QtLegend(self._window)
示例#19
0
    def __init__(self, parent=None):

        self._window = qt.QDialog(None)
        self._window.setIcon(getPixmap("smart"))
        self._window.setCaption(_("Flags"))
        self._window.setModal(True)

        self._window.setMinimumSize(600, 400)

        layout = qt.QVBoxLayout(self._window)
        layout.setResizeMode(qt.QLayout.FreeResize)

        topvbox = qt.QVBox(self._window)
        topvbox.setMargin(10)
        topvbox.setSpacing(10)
        topvbox.show()

        layout.addWidget(topvbox)

        tophbox = qt.QHBox(topvbox)
        tophbox.setSpacing(20)
        tophbox.show()

        # Left side
        vbox = qt.QVGroupBox(tophbox)
        vbox.setInsideSpacing(10)
        vbox.show()

        self._flagsview = qt.QListView(vbox)
        self._flagsview.show()

        qt.QObject.connect(self._flagsview, qt.SIGNAL("selectionChanged()"),
                           self.flagSelectionChanged)

        self._flagsview.addColumn(_("Flags"))

        bbox = qt.QHBox(vbox)
        bbox.setMargin(5)
        bbox.setSpacing(10)
        bbox.show()

        button = qt.QPushButton(_("New"), bbox)
        button.setEnabled(True)
        button.setIconSet(qt.QIconSet(getPixmap("crystal-add")))
        button.show()
        qt.QObject.connect(button, qt.SIGNAL("clicked()"), self.newFlag)
        self._newflag = button

        button = qt.QPushButton(_("Delete"), bbox)
        button.setEnabled(False)
        button.setIconSet(qt.QIconSet(getPixmap("crystal-delete")))
        button.show()
        qt.QObject.connect(button, qt.SIGNAL("clicked()"), self.delFlag)
        self._delflag = button

        # Right side
        vbox = qt.QVGroupBox(tophbox)
        vbox.setInsideSpacing(10)
        vbox.show()

        self._targetsview = qt.QListView(vbox)
        self._targetsview.show()

        qt.QObject.connect(self._targetsview, qt.SIGNAL("selectionChanged()"),
                           self.targetSelectionChanged)

        self._targetsview.addColumn(_("Targets"))

        bbox = qt.QHBox(vbox)
        bbox.setMargin(5)
        bbox.setSpacing(10)
        bbox.show()

        button = qt.QPushButton(_("New"), bbox)
        button.setEnabled(False)
        button.setIconSet(qt.QIconSet(getPixmap("crystal-add")))
        button.show()
        qt.QObject.connect(button, qt.SIGNAL("clicked()"), self.newTarget)
        self._newtarget = button

        button = qt.QPushButton(_("Delete"), bbox)
        button.setEnabled(False)
        button.setIconSet(qt.QIconSet(getPixmap("crystal-delete")))
        button.show()
        qt.QObject.connect(button, qt.SIGNAL("clicked()"), self.delTarget)
        self._deltarget = button

        # Bottom
        sep = qt.QFrame(topvbox)
        sep.setFrameShape(qt.QFrame.HLine)
        sep.setFrameShadow(qt.QFrame.Sunken)
        sep.show()

        bbox = qt.QHBox(topvbox)
        bbox.setSpacing(10)
        bbox.layout().addStretch(1)
        bbox.show()

        button = qt.QPushButton(_("Close"), bbox)
        button.show()
        qt.QObject.connect(button, qt.SIGNAL("clicked()"), self._window,
                           qt.SLOT("accept()"))

        button.setDefault(True)
示例#20
0
    def addItem(self, item_cfg, parent):
        type = item_cfg["type"]
        item_name = item_cfg["name"]
        newItem = None

        try:
            klass = WindowDisplayWidget.items[type]
        except KeyError:
            # item is a brick
            newItem = item_cfg["brick"]
            newItem.reparent(parent, 0, qt.QPoint(0, 0), True)
        else:
            #print 'adding %s, executionMode=%s' % (item_cfg["name"], self.executionMode)
            newItem = klass(parent,
                            item_cfg["name"],
                            executionMode=self.executionMode)

            if type in ("vbox", "hbox", "vgroupbox", "hgroupbox"):
                if item_cfg["properties"]["color"] is not None:
                    try:
                        qtcolor = qt.QColor(item_cfg["properties"]["color"])
                        newItem.setPaletteBackgroundColor(
                            qt.QColor(qtcolor.red(), qtcolor.green(),
                                      qtcolor.blue()))
                    except:
                        logging.getLogger().exception(
                            "Could not set color on item %s", item_cfg["name"])

                if type.endswith("groupbox"):
                    newItem.setTitle(item_cfg["properties"]["label"])

                newItem.layout().setSpacing(item_cfg["properties"]["spacing"])
                newItem.layout().setMargin(item_cfg["properties"]["margin"])

                frame_style = qt.QFrame.NoFrame
                if item_cfg["properties"]["frameshape"] != "default":
                    print "frameshape... ", item_cfg["properties"][
                        "frameshape"]
                    frame_style = getattr(
                        qt.QFrame,
                        item_cfg["properties"]["frameshape"].capitalize())
                if item_cfg["properties"]["shadowstyle"] != "default":
                    frame_style = frame_style | getattr(
                        qt.QFrame,
                        item_cfg["properties"]["shadowstyle"].capitalize())
                if frame_style != qt.QFrame.NoFrame:
                    try:
                        newItem.setFrameStyle(frame_style)
                    except:
                        logging.getLogger().exception(
                            "Could not set frame style on item %s",
                            item_cfg["name"])
            elif type == "icon":
                img = qt.QPixmap()
                if img.load(item_cfg["properties"]["filename"]):
                    newItem.setPixmap(img)
            elif type == "label":
                newItem.setText(item_cfg["properties"]["text"])
            elif type == "tab":
                item_cfg.widget = newItem
                newItem.cmdCloseTab = qt.QToolButton(newItem)
                newItem.cmdCloseTab.setIconSet(
                    qt.QIconSet(Icons.load('delete_small')))
                newItem.setCornerWidget(newItem.cmdCloseTab)
                newItem.cmdCloseTab.hide()

                def close_current_page(tab=newItem):
                    slotName = "hidePage_%s" % str(
                        tab.tabLabel(tab.currentPage()))
                    slotName = slotName.replace(" ", "_")
                    getattr(tab, slotName)()
                    qt.qApp.emit(qt.PYSIGNAL('tab_closed'), (tab, slotName))

                newItem._close_current_page_cb = close_current_page
                qt.QObject.connect(newItem,
                                   qt.SIGNAL('currentChanged( QWidget * )'),
                                   item_cfg.notebookPageChanged)
                qt.QObject.connect(newItem.cmdCloseTab, qt.SIGNAL("clicked()"),
                                   close_current_page)
            elif type == "vsplitter" or type == "hsplitter":
                pass

            newItem.show()

        return newItem
示例#21
0
    def __init__(self,
                 parent=None,
                 name="data_collect",
                 selection_changed=None):
        qt.QWidget.__init__(self, parent, name)

        # Internal members
        self.collecting = False
        self.centring_method = 0
        self.queue_hwobj = None
        self.queue_model_hwobj = None
        self.beamline_setup_hwobj = None
        self.sample_centring_result = gevent.event.AsyncResult()

        # HW-Object set by TreeBrick
        self.sample_changer_hwobj = None
        self.plate_manipulator_hwobj = None
        self.hl_motor_hwobj = None
        self.tree_brick = self.parent()

        self.sample_item_list = []
        self.collect_tree_task = None
        self.user_stopped = False
        self.plate_sample_to_mount = None

        # Callbacks TODO:Document better
        self.selection_changed_cb = None
        self.collect_stop_cb = None
        #self.clear_centred_positions_cb = None
        self.run_cb = None

        # Layout
        self.setCaption("Data collect")

        self.confirm_dialog = ConfirmDialog(self, 'Confirm Dialog')
        self.confirm_dialog.setModal(True)

        self.pin_pixmap = Icons.load("sample_axis.png")
        self.task_pixmap = Icons.load("task.png")
        self.play_pixmap = Icons.load("VCRPlay.png")
        self.stop_pixmap = Icons.load("Stop.png")
        self.up_pixmap = Icons.load("Up2.png")
        self.down_pixmap = Icons.load("Down2.png")
        self.delete_pixmap = Icons.load("bin_small.png")
        self.ispyb_pixmap = Icons.load("SampleChanger2.png")
        self.caution_pixmap = Icons.load("Caution2.png")

        self.up_button = qt.QPushButton(self, "up_button")
        self.up_button.setPixmap(self.up_pixmap)
        self.up_button.setFixedHeight(25)

        self.delete_button = qt.QPushButton(self, "delete_button")
        self.delete_button.setPixmap(self.delete_pixmap)
        self.delete_button.setDisabled(True)
        qt.QToolTip.add(self.delete_button, "Delete highlighted queue entries")

        self.down_button = qt.QPushButton(self, "down_button")
        self.down_button.setPixmap(self.down_pixmap)
        self.down_button.setFixedHeight(25)

        self.collect_button = qt.QPushButton(self, "collect_button")
        self.collect_button.setText("Collect Queue")
        self.collect_button.setFixedWidth(125)
        self.collect_button.setIconSet(qt.QIconSet(self.play_pixmap))
        self.collect_button.setPaletteBackgroundColor(
            widget_colors.LIGHT_GREEN)

        self.continue_button = qt.QPushButton(self, "ok_button")
        self.continue_button.setText('Pause')
        self.continue_button.setEnabled(True)
        self.continue_button.setFixedWidth(75)
        qt.QToolTip.add(self.continue_button,
                        "Pause after current data collection")

        self.sample_list_view = qt.QListView(self, "sample_list_view")
        self.sample_list_view.setSelectionMode(qt.QListView.Extended)

        self.setSizePolicy(
            qt.QSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Expanding))
        self.sample_list_view.setSizePolicy(
            qt.QSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Expanding))

        self.sample_list_view.setSorting(-1)
        self.sample_list_view.addColumn("", 280)
        self.sample_list_view.addColumn("", 130)
        self.sample_list_view.header().hide()

        self.sample_list_view.header().hide()
        self.sample_list_view.setFrameShape(qt.QListView.StyledPanel)
        self.sample_list_view.setFrameShadow(qt.QListView.Sunken)
        self.sample_list_view.setRootIsDecorated(1)
        self.sample_list_view.setSelected(self.sample_list_view.firstChild(),
                                          True)

        layout = qt.QVBoxLayout(self, 0, 0, 'main_layout')
        button_layout = qt.QHBoxLayout(None, 0, 0, 'button_layout')
        button_layout.addWidget(self.up_button)
        button_layout.addWidget(self.down_button)
        layout.setSpacing(10)
        layout.addWidget(self.sample_list_view)
        self.buttons_grid_layout = qt.QGridLayout(2, 5)
        layout.addLayout(self.buttons_grid_layout)
        self.buttons_grid_layout.addLayout(button_layout, 0, 0)
        self.buttons_grid_layout.addWidget(self.delete_button, 0, 4)
        self.buttons_grid_layout.addWidget(self.collect_button, 1, 0)
        self.buttons_grid_layout.addWidget(self.continue_button, 1, 4)

        self.clearWState(qt.Qt.WState_Polished)

        qt.QObject.connect(self.up_button, qt.SIGNAL("clicked()"),
                           self.up_click)
        qt.QObject.connect(self.down_button, qt.SIGNAL("clicked()"),
                           self.down_click)
        qt.QObject.connect(self.delete_button, qt.SIGNAL("clicked()"),
                           self.delete_click)
        qt.QObject.connect(self.collect_button, qt.SIGNAL("clicked()"),
                           self.collect_stop_toggle)

        qt.QObject.connect(self.sample_list_view,
                           qt.SIGNAL("selectionChanged()"),
                           self.sample_list_view_selection)

        qt.QObject.connect(
            self.sample_list_view,
            qt.SIGNAL(
                "contextMenuRequested(QListViewItem *, const QPoint& , int)"),
            self.show_context_menu)

        qt.QObject.connect(
            self.sample_list_view,
            qt.SIGNAL("itemRenamed(QListViewItem *, int , const QString& )"),
            self.item_renamed)

        qt.QObject.connect(
            self.sample_list_view,
            qt.SIGNAL("doubleClicked(QListViewItem *, const QPoint &, int)"),
            self.item_double_click)

        qt.QObject.connect(
            self.sample_list_view,
            qt.SIGNAL(
                "mouseButtonClicked(int, QListViewItem *, const QPoint &, int)"
            ), self.item_click)

        qt.QObject.connect(self.confirm_dialog,
                           qt.PYSIGNAL("continue_clicked"), self.collect_items)

        qt.QObject.connect(self.continue_button, qt.SIGNAL("clicked()"),
                           self.continue_button_click)

        self.sample_list_view.viewport().installEventFilter(self)
        self.setFixedWidth(415)

        self.collect_button.setDisabled(True)
示例#22
0
        def addTab(self, page_widget, label, icon=""):
            scrollview = qt.QScrollView(self)
            scrollview.setFrameStyle(qt.QFrame.NoFrame)
            scrollview.setResizePolicy(qt.QScrollView.AutoOneFit)
            if icon != "":
                pxmap = Icons.load(icon)
                icon_set = qt.QIconSet(pxmap, pxmap)
                qt.QTabWidget.addTab(self, scrollview, icon_set, label)
            else:
                qt.QTabWidget.addTab(self, scrollview, label)
            page_widget.reparent(scrollview.viewport(), 0, qt.QPoint(0, 0),
                                 True)
            scrollview.addChild(page_widget)

            # add 'show page' slot
            slotName = "showPage_%s" % label

            def tab_slot(self, page_index=self.indexOf(scrollview)):
                #print 'tab slot', page_index
                self.showPage(self.page(page_index))

            try:
                self.__dict__[slotName.replace(" ", "_")] = new.instancemethod(
                    tab_slot, self, None)
            except:
                logging.getLogger().exception("Could not add slot %s in %s",
                                              slotName, str(self.name()))

            # add 'hide page' slot
            slotName = "hidePage_%s" % label

            def tab_slot(
                self,
                hide=True,
                page={
                    "widget": scrollview,
                    "label": self.tabLabel(scrollview),
                    "index": self.indexOf(scrollview),
                    "icon": icon,
                    "hidden": False
                }):
                if hide:
                    if not page["hidden"]:
                        self.removePage(page["widget"])
                        page["hidden"] = True
                else:
                    if page["hidden"]:
                        if icon:
                            pixmap = Icons.load(icon)
                            self.insertTab(page["widget"],
                                           qt.QIconSet(pixmap, pixmap), label,
                                           page["index"])
                        else:
                            self.insertTab(page["widget"], page["label"],
                                           page["index"])
                        self.showPage(page["widget"])
                        page["hidden"] = False
                    else:
                        self.showPage(page["widget"])
                #page_info =""
                #for i in range(self.count()):
                #  page_info+="PAGE %d: %s, %s "% (i, self.tabLabel(self.page(i)), self.page(i))
                #logging.info(page_info)

            try:
                self.__dict__[slotName.replace(" ", "_")] = new.instancemethod(
                    tab_slot, self, None)
            except:
                logging.getLogger().exception("Could not add slot %s in %s",
                                              slotName, str(self.name()))

            # add 'enable page' slot
            slotName = "enablePage_%s" % label

            def tab_slot(self, enable, page_index=self.indexOf(scrollview)):
                self.page(page_index).setEnabled(enable)

            try:
                self.__dict__[slotName.replace(" ", "_")] = new.instancemethod(
                    tab_slot, self, None)
            except:
                logging.getLogger().exception("Could not add slot %s in %s",
                                              slotName, str(self.name()))

            # add 'enable tab' slot
            slotName = "enableTab_%s" % label

            def tab_slot(self, enable, page_index=self.indexOf(scrollview)):
                self.setTabEnabled(self.page(page_index), enable)

            try:
                self.__dict__[slotName.replace(" ", "_")] = new.instancemethod(
                    tab_slot, self, None)
            except:
                logging.getLogger().exception("Could not add slot %s in %s",
                                              slotName, str(self.name()))

            # add 'tab reset count' slot
            slotName = "resetTabCount_%s" % label

            def tab_slot(self,
                         erase_count,
                         page_index=self.indexOf(scrollview)):
                tab_label = str(self.tabLabel(self.page(page_index)))
                label_list = tab_label.split()
                found = False
                try:
                    count = label_list[-1]
                    try:
                        found = count[0] == "("
                    except:
                        pass
                    else:
                        try:
                            found = count[-1] == ")"
                        except:
                            pass
                except:
                    pass
                if found:
                    try:
                        num = int(count[1:-1])
                    except:
                        pass
                    else:
                        new_label = " ".join(label_list[0:-1])
                        if not erase_count:
                            new_label += " (0)"
                        self.countChanged[page_index] = False
                        self.setTabLabel(self.page(page_index), new_label)
                else:
                    if not erase_count:
                        new_label = " ".join(label_list)
                        new_label += " (0)"
                        self.countChanged[page_index] = False
                        self.setTabLabel(self.page(page_index), new_label)

            try:
                self.__dict__[slotName.replace(" ", "_")] = new.instancemethod(
                    tab_slot, self, None)
            except:
                logging.getLogger().exception("Could not add slot %s in %s",
                                              slotName, str(self.name()))

            # add 'tab increase count' slot
            slotName = "incTabCount_%s" % label

            def tab_slot(self,
                         delta,
                         only_if_hidden,
                         page_index=self.indexOf(scrollview)):
                if only_if_hidden and page_index == self.currentPageIndex():
                    return
                tab_label = str(self.tabLabel(self.page(page_index)))
                label_list = tab_label.split()
                found = False
                try:
                    count = label_list[-1]
                    try:
                        found = count[0] == "("
                    except:
                        pass
                    else:
                        try:
                            found = count[-1] == ")"
                        except:
                            pass
                except:
                    pass
                if found:
                    try:
                        num = int(count[1:-1])
                    except:
                        pass
                    else:
                        new_label = " ".join(label_list[0:-1])
                        new_label += " (%d)" % (num + delta)
                        self.countChanged[page_index] = True
                        self.setTabLabel(self.page(page_index), new_label)
                else:
                    new_label = " ".join(label_list)
                    new_label += " (%d)" % delta
                    self.countChanged[page_index] = True
                    self.setTabLabel(self.page(page_index), new_label)

            try:
                self.__dict__[slotName.replace(" ", "_")] = new.instancemethod(
                    tab_slot, self, None)
            except:
                logging.getLogger().exception("Could not add slot %s in %s",
                                              slotName, str(self.name()))

            # that's the real page
            return scrollview
示例#23
0
    def _setupActions(self):
        """
        creates some actions needed on some menues and toolbars
        Actions are later added to different toolbars, for example in
        method _setupMainToolbar
        """

        a = self._actions["new_shell"] = qt.QAction(
            qt.QIconSet(
                qt.QPixmap(os.path.join(CONF.getIconsPath(),
                                        "newshell.png"))), "&New Shell",
            qt.Qt.CTRL + qt.Qt.SHIFT + qt.Qt.Key_T, self, "New Shell")
        self.connect(a, qt.SIGNAL('activated()'), self.createShellTab)

        a = self._actions["close_shell"] = qt.QAction(
            qt.QIconSet(
                qt.QPixmap(os.path.join(CONF.getIconsPath(),
                                        "exit.png"))), "&Close Shell",
            qt.Qt.CTRL + qt.Qt.SHIFT + qt.Qt.Key_W, self, "New Shell")
        self.connect(a, qt.SIGNAL('activated()'), self.destroyShellTab)

        a = self._actions["toggle-hosttree"] = qt.QAction(
            qt.QIconSet(
                qt.QPixmap(
                    os.path.join(CONF.getIconsPath(), "HostTreeView.png"))),
            "Toggle Host Tree", 0, self, "Toggle Log Console")
        a.setToggleAction(True)
        a.toggle()
        self.connect(a, qt.SIGNAL('activated()'), self.togglePerspectives)

        a = self._actions["toggle-logconsole"] = qt.QAction(
            qt.QIconSet(
                qt.QPixmap(os.path.join(CONF.getIconsPath(),
                                        "LogConsole.png"))),
            "Toggle Log Console", 0, self, "Toggle Log Console")
        a.setToggleAction(True)
        a.toggle()
        self.connect(a, qt.SIGNAL('activated()'), self.toggleLogConsole)

        a = self._actions["maximize-shell"] = qt.QAction(
            qt.QIconSet(
                qt.QPixmap(os.path.join(CONF.getIconsPath(), "maximize.png"))),
            "Maximize Shell", 0, self, "Maximize Shell")
        a.setToggleAction(True)

        self.connect(a, qt.SIGNAL('activated()'), self.maximizeShell)
        self._tab_manager.tabBar().addAction("maximize", self.maximizeShell)

        #a = self._actions["test"] = qt.QAction( qt.QIconSet(qt.QPixmap(os.path.join(CONF.getIconsPath(),"donotpresstheredbutton.png"))), "Test", qt.Qt.CTRL + qt.Qt.Key_H, self, "Test" )

        #self.connect(a, qt.SIGNAL('activated()'), self.test)

        a = self._actions["screenshot"] = qt.QAction(
            qt.QIconSet(
                qt.QPixmap(os.path.join(CONF.getIconsPath(),
                                        "Screenshot.png"))), "Take Screenshot",
            0, self, "Take Screenshot")
        self.connect(a, qt.SIGNAL('activated()'), self.takeScreenshot)

        a = self._actions["clear-hosttree"] = qt.QAction(
            qt.QIconSet(
                qt.QPixmap(os.path.join(CONF.getIconsPath(),
                                        "clear.png"))), "Clear Host Tree",
            qt.Qt.CTRL + qt.Qt.Key_R, self, "Clear Host Tree")
        self.connect(a, qt.SIGNAL('activated()'),
                     self._hosts_treeview.clearTree)

        a = self._actions["repo-config"] = qt.QAction(
            qt.QIconSet(
                qt.QPixmap(os.path.join(CONF.getIconsPath(), "connect.png"))),
            "Server Connection", 0, self, "Server Connection")
        self.connect(a, qt.SIGNAL('activated()'),
                     self._showRepositoryConfigDialog)

        a = self._actions["visualization"] = qt.QAction(
            qt.QIconSet(
                qt.QPixmap(os.path.join(CONF.getIconsPath(),
                                        "visualize.png"))), "Visualize", 0,
            self, "Visualize")
        self.connect(a, qt.SIGNAL('activated()'), self.runVisualization)

        a = self._actions["plugin"] = qt.QAction(
            qt.QIconSet(
                qt.QPixmap(os.path.join(CONF.getIconsPath(), "config.png"))),
            "Plugin", 0, self, "Plugin")
        self.connect(a, qt.SIGNAL('activated()'),
                     self.showPluginSettingsDialog)

        a = self._actions["documentation"] = qt.QAction(
            qt.QIconSet(
                qt.QPixmap(
                    os.path.join(CONF.getIconsPath(), "Documentation.png"))),
            "Documentation", 0, self, "Documentation")
        self.connect(a, qt.SIGNAL('activated()'), self.go2Website)

        a = self._actions["exit-faraday"] = qt.QAction(
            qt.QIconSet(
                qt.QPixmap(os.path.join(CONF.getIconsPath(), "exit.png"))),
            "Exit Faraday", 0, self, "Exit Faraday")
        self.connect(a, qt.SIGNAL('activated()'), self.exitFaraday)

        a = self._actions["create-workspace"] = qt.QAction(
            qt.QIconSet(
                qt.QPixmap(os.path.join(CONF.getIconsPath(), "sync.png"))),
            "Create", 0, self, "Create")
        self.connect(a, qt.SIGNAL('activated()'), self.createWorkspace)

        # a = self._actions["open-workspace"] = qt.QAction( qt.QIconSet(qt.QPixmap(os.path.join(CONF.getIconsPath(),"sync.png"))), "Open", 0, self, "Open" )
        # self.connect(a, qt.SIGNAL('activated()'), self.openWorkspace)

        a = self._actions["bfont"] = qt.QAction(
            qt.QIconSet(
                qt.QPixmap(os.path.join(CONF.getIconsPath(), "fontb.png"))),
            "Big Font", 0, self, "Big Font")
        self.connect(a, qt.SIGNAL('activated()'), self.setBfont)

        a = self._actions["sfont"] = qt.QAction(
            qt.QIconSet(
                qt.QPixmap(os.path.join(CONF.getIconsPath(), "fonts.png"))),
            "Small Font", 0, self, "Small Font")
        self.connect(a, qt.SIGNAL('activated()'), self.setSfont)

        if CONF.getDebugStatus():
            a = self._actions["debug"] = qt.QAction(
                qt.QIconSet(
                    qt.QPixmap(os.path.join(CONF.getIconsPath(),
                                            "debug.png"))), "Debug", 0, self,
                "Debug")
            self.connect(a, qt.SIGNAL('activated()'), self.doDebug)
示例#24
0
    def __init__(self, parent=None):

        self._changed = False

        self._window = qt.QDialog(None)
        self._window.setIcon(getPixmap("smart"))
        self._window.setCaption(_("Channels"))
        self._window.setModal(True)

        self._window.setMinimumSize(600, 400)

        layout = qt.QVBoxLayout(self._window)
        layout.setResizeMode(qt.QLayout.FreeResize)

        vbox = qt.QVBox(self._window)
        vbox.setMargin(10)
        vbox.setSpacing(10)
        vbox.show()

        layout.addWidget(vbox)

        self._treeview = qt.QListView(vbox)
        self._treeview.setSizePolicy(qt.QSizePolicy.Expanding,
                                     qt.QSizePolicy.Expanding)
        self._treeview.setAllColumnsShowFocus(True)
        self._treeview.setSelectionMode(qt.QListView.Single)
        self._treeview.show()

        qt.QObject.connect(self._treeview, qt.SIGNAL("selectionChanged()"),
                           self.selectionChanged)
        qt.QObject.connect(
            self._treeview,
            qt.SIGNAL("doubleClicked(QListViewItem *, const QPoint &, int)"),
            self.doubleClicked)

        self._treeview.addColumn("")
        self._treeview.addColumn(_("Pri"))
        self._treeview.addColumn(_("Alias"))
        self._treeview.addColumn(_("Type"))
        self._treeview.addColumn(_("Name"))

        bbox = qt.QHBox(vbox)
        bbox.setSpacing(10)
        bbox.layout().addStretch(1)
        bbox.show()

        button = qt.QPushButton(_("New"), bbox)
        button.setIconSet(qt.QIconSet(getPixmap("crystal-add")))
        button.show()
        qt.QObject.connect(button, qt.SIGNAL("clicked()"), self.newChannel)
        self._newchannel = button

        button = qt.QPushButton(_("Delete"), bbox)
        button.setEnabled(False)
        button.setIconSet(qt.QIconSet(getPixmap("crystal-delete")))
        button.show()
        qt.QObject.connect(button, qt.SIGNAL("clicked()"), self.delChannel)
        self._delchannel = button

        button = qt.QPushButton(_("Edit"), bbox)
        button.setEnabled(False)
        button.setIconSet(qt.QIconSet(getPixmap("crystal-edit")))
        button.show()
        qt.QObject.connect(button, qt.SIGNAL("clicked()"), self.editChannel)
        self._editchannel = button

        button = qt.QPushButton(_("Close"), bbox)
        qt.QObject.connect(button, qt.SIGNAL("clicked()"), self._window,
                           qt.SLOT("accept()"))

        button.setDefault(True)
        vbox.adjustSize()