Beispiel #1
0
 def __init__(self, parent=None):
     QGraphicsWidget.__init__(self, parent)
     self.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
     self.setContentsMargins(10, 10, 10, 10)
     layout = QGraphicsGridLayout()
     layout.setContentsMargins(0, 0, 0, 0)
     layout.setSpacing(10)
     self.setLayout(layout)
Beispiel #2
0
    def init(self):
	#self.moduller=self.link.Network.Firewall[dbus.String("iptables")].listModules()
	
	self.tahta=[[0,0,0],[0,0,0],[0,0,0]]
	
        self.setHasConfigurationInterface(True)
        self.setAspectRatioMode(Plasma.Square)
        self.resize(450,250)
 
        self.theme = Plasma.Svg(self)
        self.theme.setImagePath("widgets/background")
        self.setBackgroundHints(Plasma.Applet.DefaultBackground)
        self.layout=QGraphicsGridLayout(self.applet)
        
        #label = Plasma.Label(self.applet)
        #label.setText("<h1>Firewall Plasmoid</h1>")
        #self.kilit=Plasma.IconWidget(self.applet)
        #self.bilgi_label=Plasma.Label(self.applet)
        
        #self.baslat_pb=Plasma.PushButton(self.applet)
        #self.baslat_pb.setText("Start")
        #self.durdur_pb=Plasma.PushButton(self.applet)
        #self.durdur_pb.setText("Stop")
        
        self.tus1=Plasma.PushButton(self.applet)
	self.tus1.setText("")
	self.tus2=Plasma.PushButton(self.applet)
	self.tus2.setText("")
	self.tus3=Plasma.PushButton(self.applet)
	self.tus3.setText("")
	
	self.tus4=Plasma.PushButton(self.applet)
	self.tus4.setText("")
	self.tus5=Plasma.PushButton(self.applet)
	self.tus5.setText("")
	self.tus6=Plasma.PushButton(self.applet)
	self.tus6.setText("")
	
	self.tus7=Plasma.PushButton(self.applet)
	self.tus7.setText("")
	self.tus8=Plasma.PushButton(self.applet)
	self.tus8.setText("")
	self.tus9=Plasma.PushButton(self.applet)
	self.tus9.setText("")
        
        self.layout.addItem(self.tus1, 0, 0)
        self.layout.addItem(self.tus2, 0, 1)
        self.layout.addItem(self.tus3, 0, 2)
        self.layout.addItem(self.tus4, 1, 0)
        self.layout.addItem(self.tus5, 1, 1)
        self.layout.addItem(self.tus6, 1, 2)
        self.layout.addItem(self.tus7, 2, 0)
        self.layout.addItem(self.tus8, 2, 1)
        self.layout.addItem(self.tus9, 2, 2)
        self.applet.setLayout(self.layout)        
Beispiel #3
0
    def __init__(self,
                 parent=None,
                 direction=Qt.LeftToRight,
                 node=None,
                 icon=None,
                 iconSize=None,
                 **args):
        QGraphicsWidget.__init__(self, parent, **args)
        self.setAcceptedMouseButtons(Qt.NoButton)
        self.__direction = direction

        self.setLayout(QGraphicsLinearLayout(Qt.Horizontal))

        # Set the maximum size, otherwise the layout can't grow beyond its
        # sizeHint (and we need it to grow so the widget can grow and keep the
        # contents centered vertically.
        self.layout().setMaximumSize(QSizeF(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX))

        self.setSizePolicy(QSizePolicy.MinimumExpanding,
                           QSizePolicy.MinimumExpanding)

        self.__iconSize = iconSize or QSize(64, 64)
        self.__icon = icon

        self.__iconItem = QGraphicsPixmapItem(self)
        self.__iconLayoutItem = GraphicsItemLayoutItem(item=self.__iconItem)

        self.__channelLayout = QGraphicsGridLayout()
        self.__channelAnchors = []

        if self.__direction == Qt.LeftToRight:
            self.layout().addItem(self.__iconLayoutItem)
            self.layout().addItem(self.__channelLayout)
            channel_alignemnt = Qt.AlignRight

        else:
            self.layout().addItem(self.__channelLayout)
            self.layout().addItem(self.__iconLayoutItem)
            channel_alignemnt = Qt.AlignLeft

        self.layout().setAlignment(self.__iconLayoutItem, Qt.AlignCenter)
        self.layout().setAlignment(self.__channelLayout,
                                   Qt.AlignVCenter | channel_alignemnt)

        if node is not None:
            self.setSchemeNode(node)
Beispiel #4
0
    def __init__(self, parent=None, **kwargs):
        super().__init__(parent, **kwargs)
        self.__layoutMode = GraphicsThumbnailGrid.AutoReflow
        self.__columnCount = -1
        self.__thumbnails = []  # type: List[GraphicsThumbnailWidget]
        #: The current 'focused' thumbnail item. This is the item that last
        #: received the keyboard focus (though it does not necessarily have
        #: it now)
        self.__current = None  # type: Optional[GraphicsThumbnailWidget]
        self.__reflowPending = False

        self.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        self.setContentsMargins(10, 10, 10, 10)
        # NOTE: Keeping a reference to the layout. self.layout()
        # returns a QGraphicsLayout wrapper (i.e. strips the
        # QGraphicsGridLayout-nes of the object).
        self.__layout = QGraphicsGridLayout()
        self.__layout.setContentsMargins(0, 0, 0, 0)
        self.__layout.setSpacing(10)
        self.setLayout(self.__layout)
Beispiel #5
0
    def init(self):
        """init method for the plasmoid. GUI stuff is located here."""

        self.moduller = self.link.Network.Firewall[dbus.String(
            "iptables")].listModules()

        self.setHasConfigurationInterface(True)
        self.setAspectRatioMode(Plasma.Square)
        self.resize(450, 250)

        self.theme = Plasma.Svg(self)
        self.theme.setImagePath("widgets/background")
        self.setBackgroundHints(Plasma.Applet.DefaultBackground)
        self.layout = QGraphicsGridLayout(self.applet)

        label = Plasma.Label(self.applet)
        label.setText("<h1>Firewall Plasmoid</h1>")
        self.kilit = Plasma.IconWidget(self.applet)
        self.bilgi_label = Plasma.Label(self.applet)

        self.baslat_pb = Plasma.PushButton(self.applet)
        self.baslat_pb.setText("Start")
        self.durdur_pb = Plasma.PushButton(self.applet)
        self.durdur_pb.setText("Stop")
        print "osman"
        if self.link.Network.Firewall[dbus.String(
                "iptables")].getState() == dbus.String(u"on"):
            self.bilgi_label.setText(
                "<p style='color:green'>Firewall is working now.</p>")
            self.kilit.setIcon("object-locked")
            self.kilit.setMaximumSize(32, 32)
            self.kilit.setMinimumSize(32, 32)
            self.baslat_pb.setEnabled(False)

        else:
            self.bilgi_label.setText(
                "<p style='color:red'>Firewall is stopped now.</p>")
            self.kilit.setMaximumSize(32, 32)
            self.kilit.setMinimumSize(32, 32)
            self.kilit.setIcon("object-unlocked")
            self.durdur_pb.setEnabled(False)

        self.bilgilendirme_baslik = Plasma.Label(self.applet)
        self.bilgilendirme_baslik.setText("Latest news:")

        self.bilgilendirme = Plasma.Label(self.applet)
        self.bilgilendirme.setText("Firewall Plasmoid has been started.")

        gelen_simge = Plasma.IconWidget(self.applet)
        gelen_simge.setIcon("application-x-smb-workgroup")
        paylasim_simge = Plasma.IconWidget(self.applet)
        paylasim_simge.setIcon("application-x-smb-server")
        giden_simge = Plasma.IconWidget(self.applet)
        giden_simge.setIcon("security-medium")

        self.kutular = []
        sayi = 0
        for i in self.moduller:
            self.kutular.append(Plasma.CheckBox(self.applet))
            self.kutular[sayi].setText(self.link.Network.Firewall[dbus.String(
                "iptables")].moduleInfo(i)[0])
            sayi += 1

        self.layout.addItem(label, 0, 0, 1, 4)
        self.layout.addItem(self.kilit, 1, 0)
        self.layout.addItem(self.bilgi_label, 1, 1)
        self.layout.addItem(self.baslat_pb, 1, 2)
        self.layout.addItem(self.durdur_pb, 1, 3)
        self.layout.addItem(gelen_simge, 2, 0, 1, 1)
        self.layout.addItem(paylasim_simge, 3, 0, 1, 1)
        self.layout.addItem(giden_simge, 4, 0, 1, 1)
        self.layout.addItem(self.bilgilendirme_baslik, 5, 0, 1, 1)
        self.layout.addItem(self.bilgilendirme, 5, 1, 1, 4)
        m = 0
        for i in range(0, len(self.moduller)):
            self.layout.addItem(self.kutular[m], m + 2, 1, 1, 4)
            m += 1
        self.applet.setLayout(self.layout)

        QObject.connect(self.baslat_pb, SIGNAL("clicked()"), self.baslat)
        QObject.connect(self.durdur_pb, SIGNAL("clicked()"), self.durdur)

        fonksiyonlar = [self.blockGelen, self.paylasim, self.blockGiden]
        for i in range(0, len(self.moduller)):
            QObject.connect(self.kutular[i], SIGNAL("toggled(bool)"),
                            fonksiyonlar[i])

        self.bilgilendirme_iletileri = [
            "Incoming connections was blocked successfully.",
            "Sharing internet is successful.",
            "Outgoing connections was blocked successfully."
        ]

        self.link.listenSignals("Network.Firewall", self.handler)
Beispiel #6
0
    def __init__(self):
        super().__init__()

        self.matrix = None
        self._tree = None
        self._ordered_tree = None
        self._sorted_matrix = None
        self._sort_indices = None
        self._selection = None

        box = gui.widgetBox(self.controlArea, "Element sorting", margin=0)
        self.sorting_cb = gui.comboBox(
            box, self, "sorting",
            items=["None", "Clustering", "Clustering with ordered leaves"],
            callback=self._invalidate_ordering)

        box = gui.widgetBox(self.controlArea, "Colors")

        self.colormap_cb = gui.comboBox(
            box, self, "colormap", callback=self._update_color
        )
        self.colormap_cb.setIconSize(QSize(64, 16))
        self.palettes = list(_color_palettes)

        init_color_combo(self.colormap_cb, self.palettes, QSize(64, 16))
        self.colormap_cb.setCurrentIndex(self.colormap)

        form = QFormLayout(
            formAlignment=Qt.AlignLeft,
            labelAlignment=Qt.AlignLeft,
            fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow
        )
#         form.addRow(
#             "Gamma",
#             gui.hSlider(box, self, "color_gamma", minValue=0.0, maxValue=1.0,
#                         step=0.05, ticks=True, intOnly=False,
#                         createLabel=False, callback=self._update_color)
#         )
        form.addRow(
            "Low",
            gui.hSlider(box, self, "color_low", minValue=0.0, maxValue=1.0,
                        step=0.05, ticks=True, intOnly=False,
                        createLabel=False, callback=self._update_color)
        )
        form.addRow(
            "High",
            gui.hSlider(box, self, "color_high", minValue=0.0, maxValue=1.0,
                        step=0.05, ticks=True, intOnly=False,
                        createLabel=False, callback=self._update_color)
        )
        box.layout().addLayout(form)

        box = gui.widgetBox(self.controlArea, "Annotations")
        self.annot_combo = gui.comboBox(box, self, "annotation_idx",
                                        callback=self._invalidate_annotations,
                                        contentsLength=12)
        self.annot_combo.setModel(itemmodels.VariableListModel())
        self.annot_combo.model()[:] = ["None", "Enumeration"]
        self.controlArea.layout().addStretch()

        gui.auto_commit(self.controlArea, self, "autocommit",
                        "Send data", "Auto send is on")
        self.inline_graph_report()

        self.view = pg.GraphicsView(background="w")
        self.mainArea.layout().addWidget(self.view)

        self.grid_widget = pg.GraphicsWidget()
        self.grid = QGraphicsGridLayout()
        self.grid_widget.setLayout(self.grid)

        self.viewbox = pg.ViewBox(enableMouse=False, enableMenu=False)
        self.viewbox.setAcceptedMouseButtons(Qt.NoButton)
        self.viewbox.setAcceptHoverEvents(False)
        self.grid.addItem(self.viewbox, 1, 1)

        self.left_dendrogram = DendrogramWidget(
            self.grid_widget, orientation=DendrogramWidget.Left,
            selectionMode=DendrogramWidget.NoSelection,
            hoverHighlightEnabled=False
        )
        self.left_dendrogram.setAcceptedMouseButtons(Qt.NoButton)
        self.left_dendrogram.setAcceptHoverEvents(False)

        self.top_dendrogram = DendrogramWidget(
            self.grid_widget, orientation=DendrogramWidget.Top,
            selectionMode=DendrogramWidget.NoSelection,
            hoverHighlightEnabled=False
        )
        self.top_dendrogram.setAcceptedMouseButtons(Qt.NoButton)
        self.top_dendrogram.setAcceptHoverEvents(False)

        self.grid.addItem(self.left_dendrogram, 1, 0)
        self.grid.addItem(self.top_dendrogram, 0, 1)

        self.right_labels = TextList(
            alignment=Qt.AlignLeft)

        self.bottom_labels = TextList(
            orientation=Qt.Horizontal, alignment=Qt.AlignRight)

        self.grid.addItem(self.right_labels, 1, 2)
        self.grid.addItem(self.bottom_labels, 2, 1)

        self.view.setCentralItem(self.grid_widget)

        self.left_dendrogram.hide()
        self.top_dendrogram.hide()
        self.right_labels.hide()
        self.bottom_labels.hide()

        self.matrix_item = None
        self.dendrogram = None

        self.grid_widget.scene().installEventFilter(self)
        self.graphButton.clicked.connect(self.save_graph)
Beispiel #7
0
    def __updateState(self):
        """
        Update the widget with the new source/sink node signal descriptions.
        """
        widget = QGraphicsWidget()
        widget.setLayout(QGraphicsGridLayout())

        # Space between left and right anchors
        widget.layout().setHorizontalSpacing(50)

        left_node = EditLinksNode(self,
                                  direction=Qt.LeftToRight,
                                  node=self.source)

        left_node.setSizePolicy(QSizePolicy.MinimumExpanding,
                                QSizePolicy.MinimumExpanding)

        right_node = EditLinksNode(self,
                                   direction=Qt.RightToLeft,
                                   node=self.sink)

        right_node.setSizePolicy(QSizePolicy.MinimumExpanding,
                                 QSizePolicy.MinimumExpanding)

        left_node.setMinimumWidth(150)
        right_node.setMinimumWidth(150)

        widget.layout().addItem(
            left_node,
            0,
            0,
        )
        widget.layout().addItem(
            right_node,
            0,
            1,
        )

        title_template = "<center><b>{0}<b></center>"

        left_title = GraphicsTextWidget(self)
        left_title.setHtml(title_template.format(escape(self.source.title)))
        left_title.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)

        right_title = GraphicsTextWidget(self)
        right_title.setHtml(title_template.format(escape(self.sink.title)))
        right_title.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)

        widget.layout().addItem(left_title,
                                1,
                                0,
                                alignment=Qt.AlignHCenter | Qt.AlignTop)
        widget.layout().addItem(right_title,
                                1,
                                1,
                                alignment=Qt.AlignHCenter | Qt.AlignTop)

        widget.setParentItem(self)

        max_w = max(
            left_node.sizeHint(Qt.PreferredSize).width(),
            right_node.sizeHint(Qt.PreferredSize).width())

        # fix same size
        left_node.setMinimumWidth(max_w)
        right_node.setMinimumWidth(max_w)
        left_title.setMinimumWidth(max_w)
        right_title.setMinimumWidth(max_w)

        self.layout().addItem(widget)
        self.layout().activate()

        self.sourceNodeWidget = left_node
        self.sinkNodeWidget = right_node
        self.sourceNodeTitle = left_title
        self.sinkNodeTitle = right_title
    def replot_experiments(self):
        """Replot the whole quality plot.
        """
        self.scene.clear()
        labels = []

        max_dist = numpy.nanmax(list(filter(None, self.distances)))
        rug_widgets = []

        group_pen = QPen(Qt.black)
        group_pen.setWidth(2)
        group_pen.setCapStyle(Qt.RoundCap)
        background_pen = QPen(QColor(0, 0, 250, 150))
        background_pen.setWidth(1)
        background_pen.setCapStyle(Qt.RoundCap)

        main_widget = QGraphicsWidget()
        layout = QGraphicsGridLayout()
        attributes = self.data.domain.attributes
        if self.data is not None:
            for (group, indices), dist_vec in zip(self.groups, self.distances):
                indices_set = set(indices)
                rug_items = []
                if dist_vec is not None:
                    for i, attr in enumerate(attributes):
                        # Is this a within group distance or background
                        in_group = i in indices_set
                        if in_group:
                            rug_item = ClickableRugItem(
                                dist_vec[i] / max_dist, 1.0,
                                self.on_rug_item_clicked)
                            rug_item.setPen(group_pen)
                            tooltip = experiment_description(attr)
                            rug_item.setToolTip(tooltip)
                            rug_item.group_index = indices.index(i)
                            rug_item.setZValue(rug_item.zValue() + 1)
                        else:
                            rug_item = ClickableRugItem(
                                dist_vec[i] / max_dist, 0.85,
                                self.on_rug_item_clicked)
                            rug_item.setPen(background_pen)
                            tooltip = experiment_description(attr)
                            rug_item.setToolTip(tooltip)

                        rug_item.group = group
                        rug_item.index = i
                        rug_item.in_group = in_group

                        rug_items.append(rug_item)

                rug_widget = RugGraphicsWidget(parent=main_widget)
                rug_widget.set_rug(rug_items)

                rug_widgets.append(rug_widget)

                label = group_label(self.selected_split_by_labels(), group)
                label_item = QGraphicsSimpleTextItem(label, main_widget)
                label_item = GraphicsSimpleTextLayoutItem(label_item,
                                                          parent=layout)
                label_item.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
                labels.append(label_item)

        for i, (label, rug_w) in enumerate(zip(labels, rug_widgets)):
            layout.addItem(label, i, 0, Qt.AlignVCenter)
            layout.addItem(rug_w, i, 1)
            layout.setRowMaximumHeight(i, 30)

        main_widget.setLayout(layout)
        self.scene.addItem(main_widget)
        self.main_widget = main_widget
        self.rug_widgets = rug_widgets
        self.labels = labels
        self.on_view_resize(self.scene_view.size())