Example #1
0
class DataSetShowGroupBox(QGroupBox):
    """Group box widget showing a read-only DataSet"""
    def __init__(self, label, klass, wordwrap=False, **kwargs):
        QGroupBox.__init__(self, label)
        self.klass = klass
        self.dataset = klass(**kwargs)
        self.layout = QVBoxLayout()
        if self.dataset.get_comment():
            label = QLabel(self.dataset.get_comment())
            label.setWordWrap(wordwrap)
            self.layout.addWidget(label)
        self.grid_layout = QGridLayout()
        self.layout.addLayout(self.grid_layout)
        self.setLayout(self.layout)
        self.edit = self.get_edit_layout()
        
    def get_edit_layout(self):
        """Return edit layout"""
        return DataSetShowLayout(self, self.dataset, self.grid_layout) 

    def get(self):
        """Update group box contents from data item values"""
        for widget in self.edit.widgets:
            widget.build_mode = True
            widget.get()
            widget.build_mode = False
Example #2
0
    def __init__(self, parent, appdata):
        super(SessionInfos, self).__init__(parent)
        self.appdata = appdata
        self.setWindowTitle( 'Information for the session' )
        self.setFixedSize(250, 300)

        self.buttonBox = QDialogButtonBox( self )
        self.buttonBox.setOrientation( Qt.Horizontal )
        self.buttonBox.setStandardButtons( QDialogButtonBox.Cancel|QDialogButtonBox.Ok )

        labelcombo = QLabel( 'Breathing Zone:' )
        self.breathzone = QComboBox()
        self.breathzone.addItem( '', '' )
        self.breathzone.addItem( 'Abdominal', 1 )
        self.breathzone.addItem( 'Thoracic', 2 )

        self.breathzone.move(10, 10)

        labelnote = QLabel( 'Note:' )
        self.note = QTextEdit()

        layout = QVBoxLayout()
        layout.addWidget( self.create_SessionType_Group() )
        layout.addWidget( labelcombo )
        layout.addWidget( self.breathzone )
        layout.addWidget( labelnote )
        layout.addWidget( self.note )
        layout.addWidget( self.buttonBox )

        self.setLayout( layout )

        self.buttonBox.accepted.connect( self.accept )
        self.buttonBox.rejected.connect( self.reject )
Example #3
0
 def __init__(self, parent, widgetclass, toolbar = None):
     super(myDockableWidget, self).__init__(parent)
     self.toolbar = toolbar
     layout = QVBoxLayout()
     self.widget = widgetclass()
     layout.addWidget(self.widget)
     self.setLayout(layout)
Example #4
0
    def __init__(self, parent):
        QWidget.__init__(self, parent)
        font = QFont(get_family(MONOSPACE), 10, QFont.Normal)

        info_icon = QLabel()
        icon = get_std_icon("MessageBoxInformation").pixmap(24, 24)
        info_icon.setPixmap(icon)
        info_icon.setFixedWidth(32)
        info_icon.setAlignment(Qt.AlignTop)

        self.service_status_label = QLabel()
        self.service_status_label.setWordWrap(True)
        self.service_status_label.setAlignment(Qt.AlignTop)
        self.service_status_label.setFont(font)

        self.desc_label = QLabel()
        self.desc_label.setWordWrap(True)
        self.desc_label.setAlignment(Qt.AlignTop)
        self.desc_label.setFont(font)

        self.group_desc = QGroupBox("Description", self)
        layout = QHBoxLayout()
        layout.addWidget(info_icon)
        layout.addWidget(self.desc_label)
        layout.addStretch()
        layout.addWidget(self.service_status_label)

        self.group_desc.setLayout(layout)

        self.editor = CodeEditor(self)
        self.editor.setup_editor(linenumbers=True, font=font)
        self.editor.setReadOnly(False)
        self.group_code = QGroupBox("Source code", self)
        layout = QVBoxLayout()
        layout.addWidget(self.editor)
        self.group_code.setLayout(layout)

        self.enable_button = QPushButton(get_icon("apply.png"), "Enable", self)

        self.save_button = QPushButton(get_icon("filesave.png"), "Save", self)

        self.disable_button = QPushButton(get_icon("delete.png"), "Disable", self)

        self.refresh_button = QPushButton(get_icon("restart.png"), "Refresh", self)
        hlayout = QHBoxLayout()
        hlayout.addWidget(self.save_button)
        hlayout.addWidget(self.enable_button)
        hlayout.addWidget(self.disable_button)
        hlayout.addWidget(self.refresh_button)

        vlayout = QVBoxLayout()
        vlayout.addWidget(self.group_desc)
        vlayout.addWidget(self.group_code)
        self.html_window = HTMLWindow()
        vlayout.addWidget(self.html_window)

        vlayout.addLayout(hlayout)
        self.setLayout(vlayout)

        self.current_file = None
Example #5
0
    def __init__(self, parent, new_size, old_size, text="", keep_original_size=False):
        QDialog.__init__(self, parent)

        intfunc = lambda tup: [int(val) for val in tup]
        if intfunc(new_size) == intfunc(old_size):
            self.keep_original_size = True
        else:
            self.keep_original_size = keep_original_size
        self.width, self.height = new_size
        self.old_width, self.old_height = old_size
        self.ratio = self.width / self.height

        layout = QVBoxLayout()
        self.setLayout(layout)

        formlayout = QFormLayout()
        layout.addLayout(formlayout)

        if text:
            label = QLabel(text)
            label.setAlignment(Qt.AlignHCenter)
            formlayout.addRow(label)

        self.w_edit = w_edit = QLineEdit(self)
        w_valid = QIntValidator(w_edit)
        w_valid.setBottom(1)
        w_edit.setValidator(w_valid)

        self.h_edit = h_edit = QLineEdit(self)
        h_valid = QIntValidator(h_edit)
        h_valid.setBottom(1)
        h_edit.setValidator(h_valid)

        zbox = QCheckBox(_("Original size"), self)

        formlayout.addRow(_("Width (pixels)"), w_edit)
        formlayout.addRow(_("Height (pixels)"), h_edit)
        formlayout.addRow("", zbox)

        formlayout.addRow(_("Original size:"), QLabel("%d x %d" % old_size))
        self.z_label = QLabel()
        formlayout.addRow(_("Zoom factor:"), self.z_label)

        # Button box
        self.bbox = bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        bbox.accepted.connect(self.accept)
        bbox.rejected.connect(self.reject)
        layout.addWidget(bbox)

        self.w_edit.setText(str(self.width))
        self.h_edit.setText(str(self.height))
        self.update_widgets()

        self.setWindowTitle(_("Resize"))

        w_edit.textChanged.connect(self.width_changed)
        h_edit.textChanged.connect(self.height_changed)
        zbox.toggled.connect(self.toggled_no_zoom)
        zbox.setChecked(self.keep_original_size)
Example #6
0
 def setup_widget_layout(self):
     vlayout = QVBoxLayout(self)
     vlayout.addWidget(self.toolbar)
     vlayout.addLayout(self.plot_layout)
     self.setLayout(vlayout)
     if self.edit:
         self.button_layout = QHBoxLayout()
         self.install_button_layout()
         vlayout.addLayout(self.button_layout)
Example #7
0
    def __init__(self, parent, new_size, old_size, text=""):
        QDialog.__init__(self, parent)
        
        self.keep_original_size = False
        self.width, self.height = new_size
        self.old_width, self.old_height = old_size
        self.ratio = self.width/self.height

        layout = QVBoxLayout()
        self.setLayout(layout)
        
        formlayout = QFormLayout()
        layout.addLayout(formlayout)
        
        if text:
            label = QLabel(text)
            label.setAlignment(Qt.AlignHCenter)
            formlayout.addRow(label)
        
        self.w_edit = w_edit = QLineEdit(self)
        w_valid = QIntValidator(w_edit)
        w_valid.setBottom(1)
        w_edit.setValidator(w_valid)
                     
        self.h_edit = h_edit = QLineEdit(self)
        h_valid = QIntValidator(h_edit)
        h_valid.setBottom(1)
        h_edit.setValidator(h_valid)
        
        zbox = QCheckBox(_("Original size"), self)

        formlayout.addRow(_("Width (pixels)"), w_edit)
        formlayout.addRow(_("Height (pixels)"), h_edit)
        formlayout.addRow('', zbox)
        
        formlayout.addRow(_("Original size:"), QLabel("%d x %d" % old_size))
        self.z_label = QLabel()
        formlayout.addRow(_("Zoom factor:"), self.z_label)
        
        # Button box
        self.bbox = bbox = QDialogButtonBox(QDialogButtonBox.Ok|
                                            QDialogButtonBox.Cancel)
        self.connect(bbox, SIGNAL("accepted()"), SLOT("accept()"))
        self.connect(bbox, SIGNAL("rejected()"), SLOT("reject()"))
        layout.addWidget(bbox)

        self.w_edit.setText(str(self.width))
        self.h_edit.setText(str(self.height))
        self.update_widgets()
        
        self.setWindowTitle(_("Resize"))
        
        self.connect(w_edit, SIGNAL("textChanged(QString)"),
                     self.width_changed)
        self.connect(h_edit, SIGNAL("textChanged(QString)"),
                     self.height_changed)
        self.connect(zbox, SIGNAL("toggled(bool)"), self.toggled_no_zoom)
Example #8
0
 def setup_widget_layout(self):
     vlayout = QVBoxLayout(self)
     vlayout.addWidget(self.toolbar)
     vlayout.addLayout(self.plot_layout)
     self.setLayout(vlayout)
     if self.edit:
         self.button_layout = QHBoxLayout()
         self.install_button_layout()
         vlayout.addLayout(self.button_layout)
Example #9
0
    def setup_widget(self):

        self.plot = ImagePlot(self)
        self.image = make.xyimage(self.x, self.y, self.data, colormap='jet')
        self.plot.add_item(self.image)
        self.plot.set_antialiasing(True)

        vlayout = QVBoxLayout()
        vlayout.addWidget(self.plot)
        self.setLayout(vlayout)
Example #10
0
 def setup_widget(self):
     toolbar = self.toolbar
     toolbar.setOrientation(Qt.Horizontal)
     layout = QVBoxLayout()
     if self.xsection_pos == "top":
         layout.addSpacerItem(self.spacer)
     layout.addWidget(toolbar)
     layout.addWidget(self.cs_plot)
     if self.xsection_pos == "bottom":
         layout.addSpacerItem(self.spacer)
     layout.setContentsMargins(0, 0, 0, 0)
     self.setLayout(layout)
Example #11
0
    def setup_widget(self):

        self.plot = CurvePlot(self)
        self.data_cut = make.curve(self.xdata, self.ydata)
        self.data_fit = make.curve(self.xfit, self.yfit)

        self.plot.add_item(self.data_cut)
        self.plot.add_item(self.data_fit)

        vlayout = QVBoxLayout()
        vlayout.addWidget(self.plot)
        self.setLayout(vlayout)
Example #12
0
 def create_SessionType_Group( self ):
     groupBox = QGroupBox(' Session Type' )
     vbox = QVBoxLayout()
     self.sessiontypes = []
     types = [['Unconscious', 0], ['Mindfull', 1]]
     for t in types:
         self.sessiontypes.append( QRadioButton( t[0] ) )
         vbox.addWidget( self.sessiontypes[-1] )
     self.sessiontypes[0].setChecked(True)
     vbox.addStretch(1)
     groupBox.setLayout(vbox)
     return groupBox
Example #13
0
    def setTabs(self, spec=[], axisLimits=[0, 40, 0, 400]):
        self.removeTabs()
        self.spec = spec
        self.sp=[SpectrometerPanel(self,spec=n,axisLimits=axisLimits)\
            for n in self.spec] if self.spec else [SpectrometerPanel(self)]

        for sp in self.sp:
            vBoxlayout = QVBoxLayout()
            vBoxlayout.addWidget(sp)
            tab = QWidget()
            tab.setLayout(vBoxlayout)
            self.addTab(tab, sp.name)
Example #14
0
 def setup_widget(self):
     toolbar = self.toolbar
     toolbar.setOrientation(Qt.Horizontal)
     layout = QVBoxLayout()
     if self.xsection_pos == "top":
         layout.addSpacerItem(self.spacer)
     layout.addWidget(toolbar)
     layout.addWidget(self.cs_plot)
     if self.xsection_pos == "bottom":
         layout.addSpacerItem(self.spacer)
     layout.setContentsMargins(0, 0, 0, 0)
     self.setLayout(layout)
Example #15
0
    def setTabs(self, spec_names):
        self.sp = [
            SpectrometerPanel(self.parent, name=name) for name in spec_names
        ]
        for sp in self.sp:
            vBoxlayout = QVBoxLayout()
            vBoxlayout.addWidget(sp)
            tab = QWidget()
            tab.setLayout(vBoxlayout)
            self.addTab(tab, sp.name)

            sp.curves['Antenna'][0].setPen(QPen(Qt.black, 1))
            sp.curves['Antenna'][1].setPen(QPen(Qt.red, 1))
Example #16
0
    def __init__(self, parent=None, **kwargs):
        QDialog.__init__(self)
        layout = QVBoxLayout()
        self.tdms_widget = TdmsChannelSelectWidget(parent=self, **kwargs)
        layout.addWidget(self.tdms_widget)

        # OK and Cancel buttons
        buttons = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel,
            QtCore.Qt.Horizontal, self)
        buttons.accepted.connect(self.accept)
        buttons.rejected.connect(self.reject)
        layout.addWidget(buttons)
        self.setLayout(layout)
Example #17
0
File: base.py Project: mindw/guiqwt
    def __init__(self, parent, options=None):
        QWidget.__init__(self, parent=parent)

        if options is None:
            options = {}
        self.imagewidget = ImageWidget(self, **options)
        self.imagewidget.register_all_image_tools()

        hlayout = QHBoxLayout()
        self.add_buttons_to_layout(hlayout)
        
        vlayout = QVBoxLayout()
        vlayout.addWidget(self.imagewidget)
        vlayout.addLayout(hlayout)
        self.setLayout(vlayout)
Example #18
0
 def setup_widget_layout(self):
     self.fit_layout = QHBoxLayout()
     self.params_layout = QGridLayout()
     params_group = create_groupbox(self, _("Fit parameters"),
                                    layout=self.params_layout)
     if self.auto_fit_enabled:
         auto_group = self.create_autofit_group()
         self.fit_layout.addWidget(auto_group)
     self.fit_layout.addWidget(params_group)
     self.plot_layout.addLayout(self.fit_layout, 1, 0)
     
     vlayout = QVBoxLayout(self)
     vlayout.addWidget(self.toolbar)
     vlayout.addLayout(self.plot_layout)
     self.setLayout(vlayout)
Example #19
0
 def setup_widget(self, title):
     #---Create the plot widget:
     self.plot = CurvePlot(self)
     self.curve_item = make.curve([], [], color='b')
     self.plot.add_item(self.curve_item)
     self.plot.set_antialiasing(True)
     #---
     
     button = QPushButton("Test filter: %s" % title)
     button.clicked.connect(self.process_data)
     vlayout = QVBoxLayout()
     vlayout.addWidget(self.plot)
     vlayout.addWidget(button)
     self.setLayout(vlayout)
     
     self.update_curve()
Example #20
0
    def setup_widget(self, title):
        #---Create the plot widget:
        self.plot = CurvePlot(self)
        self.curve_item = make.curve([], [], color='b')
        self.plot.add_item(self.curve_item)
        self.plot.set_antialiasing(True)
        #---

        button = QPushButton("Test filter: %s" % title)
        button.clicked.connect(self.process_data)
        vlayout = QVBoxLayout()
        vlayout.addWidget(self.plot)
        vlayout.addWidget(button)
        self.setLayout(vlayout)

        self.update_curve()
Example #21
0
File: fit.py Project: gyenney/Tools
    def setup_widget_layout(self):
        self.fit_layout = QHBoxLayout()
        self.params_layout = QGridLayout()
        params_group = create_groupbox(self,
                                       _("Fit parameters"),
                                       layout=self.params_layout)
        if self.auto_fit_enabled:
            auto_group = self.create_autofit_group()
            self.fit_layout.addWidget(auto_group)
        self.fit_layout.addWidget(params_group)
        self.plot_layout.addLayout(self.fit_layout, 1, 0)

        vlayout = QVBoxLayout(self)
        vlayout.addWidget(self.toolbar)
        vlayout.addLayout(self.plot_layout)
        self.setLayout(vlayout)
Example #22
0
    def setup_widget(self):

        self.plot = ImagePlot(self)
        self.image = make.xyimage(self.x, self.y, self.data, colormap='jet')
        self.plot.add_item(self.image)
        self.plot.set_antialiasing(True)
        #--- levels ?
        for i in range(8):
            x = self.level_xy[i][0]
            y = self.level_xy[i][1]
            self.levels.append(make.curve(x, y, color="w"))
            self.plot.add_item(self.levels[-1])
        #----------------------
        vlayout = QVBoxLayout()
        vlayout.addWidget(self.plot)
        self.setLayout(vlayout)
        self.plot.adjustSize()
Example #23
0
 def __init__(self):
     QDialog.__init__(self)
     self.setWindowTitle("Data Logger")
     self.groupbox1 = DataSetEditGroupBox("Parametres de lock",Loggerdataset,show_button = False)   
     self.groupbox1.dataset.parent = self
     self.values = self.groupbox1.dataset
     self.groupbox1.dataset.parent = self
     lay = QVBoxLayout()
     lay.addWidget(self.groupbox1)
     self.setLayout(lay)
     self.resize(800,300)
     
     self.timer = QTimer()
     self.timer.timeout.connect(self.log)
     #self.timer.timeout.connect(self.update_values)
     self.timer.setInterval(100) #ms
     self.show()
    def setup_widget(self, title):
        #---Create the plot widget:
        curvewidget = CurveWidget(self)
        curvewidget.register_all_curve_tools()
        self.curve_item = make.curve([], [], color='b')
        curvewidget.plot.add_item(self.curve_item)
        curvewidget.plot.set_antialiasing(True)
        #---

        button = QPushButton("Test filter: %s" % title)
        self.connect(button, SIGNAL('clicked()'), self.process_data)
        vlayout = QVBoxLayout()
        vlayout.addWidget(curvewidget)
        vlayout.addWidget(button)
        self.setLayout(vlayout)

        self.update_curve()
Example #25
0
 def setup_widget(self, title):
     #---Create the plot widget:
     curvewidget = CurveWidget(self)
     curvewidget.register_all_curve_tools()
     self.curve_item = make.curve([], [], color='b')
     curvewidget.plot.add_item(self.curve_item)
     curvewidget.plot.set_antialiasing(True)
     #---
     
     button = QPushButton("Test filter: %s" % title)
     self.connect(button, SIGNAL('clicked()'), self.process_data)
     vlayout = QVBoxLayout()
     vlayout.addWidget(curvewidget)
     vlayout.addWidget(button)
     self.setLayout(vlayout)
     
     self.update_curve()
Example #26
0
    def __init__(self, parent=None):
        super(ContrastAdjustment, self).__init__(parent)
        
        self.local_manager = None # local manager for the histogram plot
        self.manager = None # manager for the associated image plot
        
        # Storing min/max markers for each active image
        self.min_markers = {}
        self.max_markers = {}
        
        # Select point tools
        self.min_select_tool = None
        self.max_select_tool = None
        
        style = "<span style=\'color: #444444\'><b>%s</b></span>"
        layout, _label = get_image_layout(self.PANEL_ICON,
                                          style % self.PANEL_TITLE,
                                          alignment=Qt.AlignCenter)
        layout.setAlignment(Qt.AlignCenter)
        vlayout = QVBoxLayout()
        vlayout.addLayout(layout)
        self.local_manager = PlotManager(self)
        self.histogram = LevelsHistogram(parent)
        vlayout.addWidget(self.histogram)
        self.local_manager.add_plot(self.histogram)
        hlayout = QHBoxLayout()
        self.setLayout(hlayout)
        hlayout.addLayout(vlayout)
        
        self.toolbar = toolbar = QToolBar(self)
        toolbar.setOrientation(Qt.Vertical)
#        toolbar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        hlayout.addWidget(toolbar)
        
        # Add standard plot-related tools to the local manager
        lman = self.local_manager
        lman.add_tool(SelectTool)
        lman.add_tool(BasePlotMenuTool, "item")
        lman.add_tool(BasePlotMenuTool, "axes")
        lman.add_tool(BasePlotMenuTool, "grid")
        lman.add_tool(AntiAliasingTool)
        lman.get_default_tool().activate()
        
        self.outliers_param = EliminateOutliersParam(self.PANEL_TITLE)
Example #27
0
    def __init__(self, parent=None):
        super(ContrastAdjustment, self).__init__(parent)

        self.local_manager = None  # local manager for the histogram plot
        self.manager = None  # manager for the associated image plot

        # Storing min/max markers for each active image
        self.min_markers = {}
        self.max_markers = {}

        # Select point tools
        self.min_select_tool = None
        self.max_select_tool = None

        style = "<span style=\'color: #444444\'><b>%s</b></span>"
        layout, _label = get_image_layout(self.PANEL_ICON,
                                          style % self.PANEL_TITLE,
                                          alignment=Qt.AlignCenter)
        layout.setAlignment(Qt.AlignCenter)
        vlayout = QVBoxLayout()
        vlayout.addLayout(layout)
        self.local_manager = PlotManager(self)
        self.histogram = LevelsHistogram(parent)
        vlayout.addWidget(self.histogram)
        self.local_manager.add_plot(self.histogram)
        hlayout = QHBoxLayout()
        self.setLayout(hlayout)
        hlayout.addLayout(vlayout)

        self.toolbar = toolbar = QToolBar(self)
        toolbar.setOrientation(Qt.Vertical)
        #        toolbar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        hlayout.addWidget(toolbar)

        # Add standard plot-related tools to the local manager
        lman = self.local_manager
        lman.add_tool(SelectTool)
        lman.add_tool(BasePlotMenuTool, "item")
        lman.add_tool(BasePlotMenuTool, "axes")
        lman.add_tool(BasePlotMenuTool, "grid")
        lman.add_tool(AntiAliasingTool)
        lman.get_default_tool().activate()

        self.outliers_param = EliminateOutliersParam(self.PANEL_TITLE)
Example #28
0
    def __init__(self, parent):
        super(FileUi, self).__init__(Qt.Vertical, parent)

        layoutWidget = QWidget()
        layout = QVBoxLayout()
        layoutWidget.setLayout(layout)

        self.comment = QPlainTextEdit()
        self.fileName = None
        self.saveTxtCheck = QCheckBox('Save Txt')
        self.saveHdfCheck = QCheckBox('Save HDF5')
        self.saveTxtBtn = QPushButton('Save Txt')
        self.saveHdfBtn = QPushButton('Save HDF5')

        #############
        # stream group
        streamGroup = QGroupBox('Stream data to file:')
        streamGroup.setFlat(True)
        streamGroupLayout = QHBoxLayout()
        streamGroupLayout.addWidget(self.saveTxtCheck)
        streamGroupLayout.addWidget(self.saveHdfCheck)
        streamGroup.setLayout(streamGroupLayout)

        ##############
        # save static file
        saveGroup = QGroupBox('Save now to file:')
        saveGroup.setFlat(True)
        saveGroupLayout = QHBoxLayout()
        saveGroupLayout.addWidget(self.saveTxtBtn)
        saveGroupLayout.addWidget(self.saveHdfBtn)
        saveGroup.setLayout(saveGroupLayout)

        ##############
        # put layout together
        layout.addWidget(QLabel('Comment:'))
        layout.addWidget(self.comment)
        layout.addWidget(streamGroup)
        layout.addWidget(saveGroup)
        self.addWidget(layoutWidget)

        ##############
        # connnect stuff for functionality
        self.saveTxtCheck.stateChanged.connect(self.__makeFileName)
        self.saveHdfCheck.stateChanged.connect(self.__makeFileName)

        ##############
        # thread for streaming data to file
        #self.updateCurrPos.connect(self.__updateCurrPos)
        self.stream_thread = QThread()  # create the QThread
        self.stream_thread.start()
        self.stream_worker = GenericWorker(self.__streamFile)
        self.stream_worker.moveToThread(self.stream_thread)
Example #29
0
   def __init__(self, parent):
      super(controlWidget, self).__init__()

      self.widgetTimer = QTimer()
      self.widgetTimer.start(100)
      self.widgetTimer.timeout.connect(self.createNewDspWidgets)
      self.value =0
      self.flag = True
      
      self.mainApp = parent
      self.inactivityTimeout = True

      self.setWindowTitle('Live Telemetry Visualizer')

      self.qbtn = QPushButton('Quit', self)
      self.qbtn.clicked.connect(self.mainApp.quit)
      self.qbtn.resize(self.qbtn.sizeHint())
      self.qbtn.hide()

      qbtn1 = QPushButton('Check Performance status')
      qbtn1.clicked.connect(self.ButtonPressed)
      qbtn1.resize(qbtn1.sizeHint())

      self.performance_status = QLabel("If Performance Curve at Monitor Mic is On turn it Off")
      self.performance_status.hide()

      
      icheck = QCheckBox('Inactivity Timeout')
      icheck.stateChanged.connect(self.toggleInactivity)
      icheck.setChecked(self.inactivityTimeout)

      layout = QVBoxLayout()
      self.setLayout(layout)
      layout.addWidget(self.qbtn)
      layout.addWidget(self.performance_status)
      layout.addWidget(qbtn1)
      layout.addWidget(icheck)
      layout.addWidget(QWidget())

      self.resize(180, 100)
      self.show()
Example #30
0
 def __init__(self, parent):
     QWidget.__init__(self, parent)
     font = QFont(get_family(MONOSPACE), 10, QFont.Normal)
     
     info_icon = QLabel()
     icon = get_std_icon('MessageBoxInformation').pixmap(24, 24)
     info_icon.setPixmap(icon)
     info_icon.setFixedWidth(32)
     info_icon.setAlignment(Qt.AlignTop)
     self.desc_label = QLabel()
     self.desc_label.setWordWrap(True)
     self.desc_label.setAlignment(Qt.AlignTop)
     self.desc_label.setFont(font)
     group_desc = QGroupBox(_("Description"), self)
     layout = QHBoxLayout()
     layout.addWidget(info_icon)
     layout.addWidget(self.desc_label)
     group_desc.setLayout(layout)
     
     self.editor = CodeEditor(self)
     self.editor.setup_editor(linenumbers=True, font=font)
     self.editor.setReadOnly(True)
     group_code = QGroupBox(_("Source code"), self)
     layout = QVBoxLayout()
     layout.addWidget(self.editor)
     group_code.setLayout(layout)
     
     self.run_button = QPushButton(get_icon("apply.png"),
                                   _("Run this script"), self)
     self.quit_button = QPushButton(get_icon("exit.png"), _("Quit"), self)
     hlayout = QHBoxLayout()
     hlayout.addWidget(self.run_button)
     hlayout.addStretch()
     hlayout.addWidget(self.quit_button)
     
     vlayout = QVBoxLayout()
     vlayout.addWidget(group_desc)
     vlayout.addWidget(group_code)
     vlayout.addLayout(hlayout)
     self.setLayout(vlayout)
Example #31
0
    def __init__(self, parent):
        QWidget.__init__(self, parent)
        font = QFont(get_family(MONOSPACE), 10, QFont.Normal)

        info_icon = QLabel()
        icon = get_std_icon('MessageBoxInformation').pixmap(24, 24)
        info_icon.setPixmap(icon)
        info_icon.setFixedWidth(32)
        info_icon.setAlignment(Qt.AlignTop)
        self.desc_label = QLabel()
        self.desc_label.setWordWrap(True)
        self.desc_label.setAlignment(Qt.AlignTop)
        self.desc_label.setFont(font)
        group_desc = QGroupBox(_("Description"), self)
        layout = QHBoxLayout()
        layout.addWidget(info_icon)
        layout.addWidget(self.desc_label)
        group_desc.setLayout(layout)

        self.editor = CodeEditor(self)
        self.editor.setup_editor(linenumbers=True, font=font)
        self.editor.setReadOnly(True)
        group_code = QGroupBox(_("Source code"), self)
        layout = QVBoxLayout()
        layout.addWidget(self.editor)
        group_code.setLayout(layout)

        self.run_button = QPushButton(get_icon("apply.png"),
                                      _("Run this script"), self)
        self.quit_button = QPushButton(get_icon("exit.png"), _("Quit"), self)
        hlayout = QHBoxLayout()
        hlayout.addWidget(self.run_button)
        hlayout.addStretch()
        hlayout.addWidget(self.quit_button)

        vlayout = QVBoxLayout()
        vlayout.addWidget(group_desc)
        vlayout.addWidget(group_code)
        vlayout.addLayout(hlayout)
        self.setLayout(vlayout)
Example #32
0
class DockablePlotWidget(DockableWidget):
    LOCATION = Qt.RightDockWidgetArea

    def __init__(self, parent, plotwidgetclass, toolbar=None):
        super(DockablePlotWidget, self).__init__(parent)
        self.toolbar = toolbar
        self.layout = QVBoxLayout()
        self.plotwidget = plotwidgetclass()
        self.layout.addWidget(self.plotwidget)
        self.calcFun = XAxeCalc(self)
        self.layout.addWidget(self.calcFun)
        self.setLayout(self.layout)
        if toolbar is None:
            self.setupNoTB()
        else:
            self.setup()

    def get_plot(self):
        return self.plotwidget.plot

    def setup(self):
        title = to_text_string(self.toolbar.windowTitle())
        self.plotwidget.add_toolbar(self.toolbar, title)
        if isinstance(self.plotwidget, ImageWidget):
            self.plotwidget.register_all_image_tools()
        else:
            self.plotwidget.register_all_curve_tools()

    def setupNoTB(self):
        if isinstance(self.plotwidget, ImageWidget):
            self.plotwidget.register_all_image_tools()
        else:
            self.plotwidget.register_all_curve_tools()

    #------DockableWidget API
    def visibility_changed(self, enable):
        """DockWidget visibility has changed"""
        DockableWidget.visibility_changed(self, enable)
        self.toolbar.setVisible(enable)
Example #33
0
    def setup_instance(self, instance):
        """Override DataSetEditDialog method"""
        from guidata.dataset.datatypes import DataSetGroup
        assert isinstance(instance, DataSetGroup)
        tabs = QTabWidget()
#        tabs.setUsesScrollButtons(False)
        self.layout.addWidget(tabs)
        for dataset in instance.datasets:
            layout = QVBoxLayout()
            layout.setAlignment(Qt.AlignTop)
            if dataset.get_comment():
                label = QLabel(dataset.get_comment())
                label.setWordWrap(self.wordwrap)
                layout.addWidget(label)
            grid = QGridLayout()
            self.edit_layout.append( self.layout_factory(dataset, grid) )
            layout.addLayout(grid)
            page = QWidget()
            page.setLayout(layout)
            if dataset.get_icon():
                tabs.addTab( page, get_icon(dataset.get_icon()),
                             dataset.get_title() )
            else:
                tabs.addTab( page, dataset.get_title() )
Example #34
0
    def setup_instance(self, instance):
        """Override DataSetEditDialog method"""
        from guidata.dataset.datatypes import DataSetGroup
        assert isinstance(instance, DataSetGroup)
        tabs = QTabWidget()
#        tabs.setUsesScrollButtons(False)
        self.layout.addWidget(tabs)
        for dataset in instance.datasets:
            layout = QVBoxLayout()
            layout.setAlignment(Qt.AlignTop)
            if dataset.get_comment():
                label = QLabel(dataset.get_comment())
                label.setWordWrap(self.wordwrap)
                layout.addWidget(label)
            grid = QGridLayout()
            self.edit_layout.append( self.layout_factory(dataset, grid) )
            layout.addLayout(grid)
            page = QWidget()
            page.setLayout(layout)
            if dataset.get_icon():
                tabs.addTab( page, get_icon(dataset.get_icon()),
                             dataset.get_title() )
            else:
                tabs.addTab( page, dataset.get_title() )
Example #35
0
    def setTabs(self, spec=[]):
        self.removeTabs()
        self.spec = spec
        if spec != []:
            self.sp = [
                SpectrometerPanel(self, spec=n, count=c) for n in self.spec
                for c in range(len(n.frequency))
            ]
        else:
            self.sp = [SpectrometerPanel(self)]

        for sp in self.sp:
            vBoxlayout = QVBoxLayout()
            vBoxlayout.addWidget(sp)
            tab = QWidget()
            tab.setLayout(vBoxlayout)
            self.addTab(tab, sp.name)

        tab = QWidget()
        vBoxlayout = QVBoxLayout()
        self.summary = SummaryPanel(self, tabs=self.sp)
        vBoxlayout.addWidget(self.summary)
        tab.setLayout(vBoxlayout)
        self.addTab(tab, 'Summary')
    def _generateFrame(self):
        '''
        Return the frame containing the presentation, check if the frame was created, otherwise it is created
        :return:
        '''
        # generate the frame if necessary
        if self._frame is None:
            # Generate frame and define the layout based on the frame
            self._frame = QFrame(self._parentFrame)
            _layout = QVBoxLayout()
            self._frame.setLayout(_layout)

            # Add the "Main" group box for this view, if present. It is rendered in foreground
            if self._generateGroupBox() is not None:
                _layout.addWidget(self._groupbox)
            else:
                self._frame.setFrameStyle(QFrame.Panel|QFrame.Raised)
                self._frame.setLineWidth(1)

            # Add to layout eventually the other subview
            if self._viewtype == 'Tabs':
                _tabs = QTabWidget()
                _layout.addWidget(_tabs)
            elif self._viewtype == 'Splitter':
                _splitter =QSplitter()
                _layout.addWidget(_splitter)
            else:
                _sub_frame = QFrame()
                _sub_frame_layout = QHBoxLayout()
                _sub_frame.setLayout(_sub_frame_layout)
                _layout.addWidget(_sub_frame)

            # Add all the sub view as sub frames in the layout
            for sw in self._subViewDictionary.values():
                sw.setParentView(self._frame)
                if self._viewtype == 'Tabs':
                    _tabs.addTab(sw.getFrame(), sw.viewname)
                elif self._viewtype == 'Splitter':
                    _splitter.addWidget(sw.getFrame())
                else:
                    _sub_frame_layout.addWidget(sw.getFrame())

        return self._frame
Example #37
0
    def setTabs(self, spec=[]):
        self.removeTabs()
        self.spec = spec
        if spec != []:
            self.sp = [
                SpectrometerPanel(self, spec=n, count=c) for n in self.spec
                for c in range(len(n.frequency))
            ]
        else:
            self.sp = [SpectrometerPanel(self)]

        # Spectrometer tabs
        for sp in self.sp:
            vBoxlayout = QVBoxLayout()
            vBoxlayout.addWidget(sp)
            tab = QWidget()
            tab.setLayout(vBoxlayout)
            self.addTab(tab, sp.name)

        # Summary tab
        tab = QWidget()
        vBoxlayout = QVBoxLayout()
        self.summary = SummaryPanel(self)
        vBoxlayout.addWidget(self.summary)
        tab.setLayout(vBoxlayout)
        self.addTab(tab, 'Summary')

        # Math tab
        tab = QWidget()
        vBoxlayout = QVBoxLayout()
        self.math = MathPanel(self)
        vBoxlayout.addWidget(self.math)
        tab.setLayout(vBoxlayout)
        self.addTab(tab, 'Math')

        # Retrieval tab
        tab = QWidget()
        vBoxlayout = QVBoxLayout()
        self.retrieval = RetrievalPanel(self)
        vBoxlayout.addWidget(self.retrieval)
        tab.setLayout(vBoxlayout)
        self.addTab(tab, 'Retrieval')
Example #38
0
 def create_autofit_group(self):        
     auto_button = QPushButton(get_icon('apply.png'), _("Run"), self)
     auto_button.clicked.connect(self.autofit)
     autoprm_button = QPushButton(get_icon('settings.png'), _("Settings"),
                                  self)
     autoprm_button.clicked.connect(self.edit_parameters)
     xrange_button = QPushButton(get_icon('xrange.png'), _("Bounds"), self)
     xrange_button.setCheckable(True)
     xrange_button.toggled.connect(self.toggle_xrange)
     auto_layout = QVBoxLayout()
     auto_layout.addWidget(auto_button)
     auto_layout.addWidget(autoprm_button)
     auto_layout.addWidget(xrange_button)
     self.button_list += [auto_button, autoprm_button, xrange_button]
     return create_groupbox(self, _("Automatic fit"), layout=auto_layout)
Example #39
0
File: fit.py Project: gyenney/Tools
 def create_autofit_group(self):
     auto_button = QPushButton(get_icon('apply.png'), _("Run"), self)
     auto_button.clicked.connect(self.autofit)
     autoprm_button = QPushButton(get_icon('settings.png'), _("Settings"),
                                  self)
     autoprm_button.clicked.connect(self.edit_parameters)
     xrange_button = QPushButton(get_icon('xrange.png'), _("Bounds"), self)
     xrange_button.setCheckable(True)
     xrange_button.toggled.connect(self.toggle_xrange)
     auto_layout = QVBoxLayout()
     auto_layout.addWidget(auto_button)
     auto_layout.addWidget(autoprm_button)
     auto_layout.addWidget(xrange_button)
     self.button_list += [auto_button, autoprm_button, xrange_button]
     return create_groupbox(self, _("Automatic fit"), layout=auto_layout)
Example #40
0
class ChoiceWidget(AbstractDataSetWidget):
    """
    Choice item widget
    """
    def __init__(self, item, parent_layout):
        super(ChoiceWidget, self).__init__(item, parent_layout)
        self._first_call = True
        self.is_radio = item.get_prop_value("display", "radio")
        self.store = self.item.get_prop("display", "store", None)
        if self.is_radio:
            self.group = QGroupBox()
            self.group.setToolTip(item.get_help())
            self.vbox = QVBoxLayout()
            self.group.setLayout(self.vbox)
            self._buttons = []
        else:
            self.combobox = self.group = QComboBox()
            self.combobox.setToolTip(item.get_help())
            self.combobox.currentIndexChanged.connect(self.index_changed)
        
    def index_changed(self, index):
        if self.store:
            self.store.set(self.item.instance, self.item.item, self.value())
            self.parent_layout.refresh_widgets()
        cb = self.item.get_prop_value("display", "callback", None)
        if cb is not None:
            if self.build_mode:
                self.set()
            else:
                self.parent_layout.update_dataitems()
            cb(self.item.instance, self.item.item, self.value())
            self.parent_layout.update_widgets(except_this_one=self)
    
    def initialize_widget(self):
        if self.is_radio:
            for button in self._buttons:
                button.toggled.disconnect(self.index_changed)
                self.vbox.removeWidget(button)
                button.deleteLater()
            self._buttons = []
        else:
            self.combobox.blockSignals(True)
            while self.combobox.count():
                self.combobox.removeItem(0)
        _choices = self.item.get_prop_value("data", "choices")
        for key, lbl, img in _choices:
            if self.is_radio:
                button = QRadioButton(lbl, self.group)
            if img:
                if is_text_string(img):
                    if not osp.isfile(img):
                        img = get_image_file_path(img)
                    img = QIcon(img)
                elif isinstance(img, collections.Callable):
                    img = img(key)
                if self.is_radio:
                    button.setIcon(img)
                else:
                    self.combobox.addItem(img, lbl)
            elif not self.is_radio:
                self.combobox.addItem(lbl)
            if self.is_radio:
                self._buttons.append(button)
                self.vbox.addWidget(button)
                button.toggled.connect(self.index_changed)
        if not self.is_radio:
            self.combobox.blockSignals(False)

    def set_widget_value(self, idx):
        if self.is_radio:
            for button in self._buttons:
                button.blockSignals(True)
            self._buttons[idx].setChecked(True)
            for button in self._buttons:
                button.blockSignals(False)
        else:
            self.combobox.blockSignals(True)
            self.combobox.setCurrentIndex(idx)
            self.combobox.blockSignals(False)
    
    def get_widget_value(self):
        if self.is_radio:
            for index, widget in enumerate(self._buttons):
                if widget.isChecked():
                    return index
        else:
            return self.combobox.currentIndex()

    def get(self):
        """Override AbstractDataSetWidget method"""
        self.initialize_widget()
        value = self.item.get()
        if value is not None:
            idx = 0
            _choices = self.item.get_prop_value("data", "choices")
            for key, _val, _img in _choices:
                if key == value:
                    break
                idx += 1
            self.set_widget_value(idx)
            if self._first_call:
                self.index_changed(idx)
                self._first_call = False
        
    def set(self):
        """Override AbstractDataSetWidget method"""
        try:
            value = self.value()
        except IndexError:
            return
        self.item.set(value)

    def value(self):
        index = self.get_widget_value()
        choices = self.item.get_prop_value("data", "choices")
        return choices[index][0]
Example #41
0
class DataSetEditDialog(QDialog):
    """
    Dialog box for DataSet editing
    """
    def __init__(self, instance, icon='', parent=None, apply=None,
                 wordwrap=True, size=None):
        QDialog.__init__(self, parent)
        self.wordwrap = wordwrap
        self.apply_func = apply
        self.layout = QVBoxLayout()
        if instance.get_comment():
            label = QLabel(instance.get_comment())
            label.setWordWrap(wordwrap)
            self.layout.addWidget(label)
        self.instance = instance
        self.edit_layout = [  ]

        self.setup_instance( instance )

        if apply is not None:
            apply_button = QDialogButtonBox.Apply
        else:
            apply_button = QDialogButtonBox.NoButton
        bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel
                                | apply_button )
        self.bbox = bbox
        self.connect(bbox, SIGNAL("accepted()"), SLOT("accept()"))
        self.connect(bbox, SIGNAL("rejected()"), SLOT("reject()"))
        self.connect(bbox, SIGNAL("clicked(QAbstractButton*)"), self.button_clicked)
        self.layout.addWidget(bbox)
        
        self.setLayout(self.layout)
        
        if parent is None:
            if not isinstance(icon, QIcon):
                icon = get_icon(icon, default="guidata.svg")
            self.setWindowIcon(icon)
        
        self.setModal(True)
        self.setWindowTitle(instance.get_title())
        
        if size is not None:
            if isinstance(size, QSize):
                self.resize(size)
            else:
                self.resize(*size)

    def button_clicked(self, button):
        role = self.bbox.buttonRole(button)
        if role==QDialogButtonBox.ApplyRole and self.apply_func is not None:
            if self.check():
                for edl in self.edit_layout:
                    edl.accept_changes()
                self.apply_func(self.instance)
    
    def setup_instance(self, instance):
        """Construct main layout"""
        grid = QGridLayout()
        grid.setAlignment(Qt.AlignTop)
        self.layout.addLayout(grid)
        self.edit_layout.append( self.layout_factory( instance, grid) )
        
    def layout_factory(self, instance, grid ):
        """A factory method that produces instances of DataSetEditLayout
        
        or derived classes (see DataSetShowDialog)
        """
        return DataSetEditLayout( self, instance, grid )

    def child_title(self, item):
        """Return data item title combined with QApplication title"""
        app_name = QApplication.applicationName()
        if not app_name:
            app_name = self.instance.get_title()
        return "%s - %s" % ( app_name, item.label() )

    def check(self):
        is_ok = True
        for edl in self.edit_layout:
            if not edl.check_all_values():
                is_ok = False
        if not is_ok:
            QMessageBox.warning(self, self.instance.get_title(),
                                _("Some required entries are incorrect")+".\n",
                                _("Please check highlighted fields."))
            return False
        return True

    def accept(self):
        """Validate inputs"""
        if self.check():
            for edl in self.edit_layout:
                edl.accept_changes()
            QDialog.accept(self)
Example #42
0
    def __init__(self, parent, new_size, old_size, text="",
                 keep_original_size=False):
        QDialog.__init__(self, parent)
        
        intfunc = lambda tup: [int(val) for val in tup]
        if intfunc(new_size) == intfunc(old_size):
            self.keep_original_size = True
        else:
            self.keep_original_size = keep_original_size
        self.width, self.height = new_size
        self.old_width, self.old_height = old_size
        self.ratio = self.width/self.height

        layout = QVBoxLayout()
        self.setLayout(layout)
        
        formlayout = QFormLayout()
        layout.addLayout(formlayout)
        
        if text:
            label = QLabel(text)
            label.setAlignment(Qt.AlignHCenter)
            formlayout.addRow(label)
        
        self.w_edit = w_edit = QLineEdit(self)
        w_valid = QIntValidator(w_edit)
        w_valid.setBottom(1)
        w_edit.setValidator(w_valid)
                     
        self.h_edit = h_edit = QLineEdit(self)
        h_valid = QIntValidator(h_edit)
        h_valid.setBottom(1)
        h_edit.setValidator(h_valid)
        
        zbox = QCheckBox(_("Original size"), self)

        formlayout.addRow(_("Width (pixels)"), w_edit)
        formlayout.addRow(_("Height (pixels)"), h_edit)
        formlayout.addRow('', zbox)
        
        formlayout.addRow(_("Original size:"), QLabel("%d x %d" % old_size))
        self.z_label = QLabel()
        formlayout.addRow(_("Zoom factor:"), self.z_label)
        
        # Button box
        self.bbox = bbox = QDialogButtonBox(QDialogButtonBox.Ok|
                                            QDialogButtonBox.Cancel)
        bbox.accepted.connect(self.accept)
        bbox.rejected.connect(self.reject)
        layout.addWidget(bbox)

        self.w_edit.setText(str(self.width))
        self.h_edit.setText(str(self.height))
        self.update_widgets()
        
        self.setWindowTitle(_("Resize"))
        
        w_edit.textChanged.connect(self.width_changed)
        h_edit.textChanged.connect(self.height_changed)
        zbox.toggled.connect(self.toggled_no_zoom)
        zbox.setChecked(self.keep_original_size)
Example #43
0
class DataSetEditDialog(QDialog):
    """
    Dialog box for DataSet editing
    """
    def __init__(self, instance, icon='', parent=None, apply=None,
                 wordwrap=True, size=None):
        QDialog.__init__(self, parent)
        self.wordwrap = wordwrap
        self.apply_func = apply
        self.layout = QVBoxLayout()
        if instance.get_comment():
            label = QLabel(instance.get_comment())
            label.setWordWrap(wordwrap)
            self.layout.addWidget(label)
        self.instance = instance
        self.edit_layout = [  ]

        self.setup_instance( instance )

        if apply is not None:
            apply_button = QDialogButtonBox.Apply
        else:
            apply_button = QDialogButtonBox.NoButton
        bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel
                                | apply_button )
        self.bbox = bbox
        bbox.accepted.connect(self.accept)
        bbox.rejected.connect(self.reject)
        bbox.clicked.connect(self.button_clicked)
        self.layout.addWidget(bbox)
        
        self.setLayout(self.layout)
        
        if parent is None:
            if not isinstance(icon, QIcon):
                icon = get_icon(icon, default="guidata.svg")
            self.setWindowIcon(icon)
        
        self.setModal(True)
        self.setWindowTitle(instance.get_title())
        
        if size is not None:
            if isinstance(size, QSize):
                self.resize(size)
            else:
                self.resize(*size)

    def button_clicked(self, button):
        role = self.bbox.buttonRole(button)
        if role==QDialogButtonBox.ApplyRole and self.apply_func is not None:
            if self.check():
                for edl in self.edit_layout:
                    edl.accept_changes()
                self.apply_func(self.instance)
    
    def setup_instance(self, instance):
        """Construct main layout"""
        grid = QGridLayout()
        grid.setAlignment(Qt.AlignTop)
        self.layout.addLayout(grid)
        self.edit_layout.append( self.layout_factory( instance, grid) )
        
    def layout_factory(self, instance, grid ):
        """A factory method that produces instances of DataSetEditLayout
        
        or derived classes (see DataSetShowDialog)
        """
        return DataSetEditLayout( self, instance, grid )

    def child_title(self, item):
        """Return data item title combined with QApplication title"""
        app_name = QApplication.applicationName()
        if not app_name:
            app_name = self.instance.get_title()
        return "%s - %s" % ( app_name, item.label() )

    def check(self):
        is_ok = True
        for edl in self.edit_layout:
            if not edl.check_all_values():
                is_ok = False
        if not is_ok:
            QMessageBox.warning(self, self.instance.get_title(),
                        _("Some required entries are incorrect")+"\n"+\
                        _("Please check highlighted fields."))
            return False
        return True

    def accept(self):
        """Validate inputs"""
        if self.check():
            for edl in self.edit_layout:
                edl.accept_changes()
            QDialog.accept(self)
Example #44
0
    def __init__(self, parent=None):
        log_conf = get_logging_config()

        QSplitter.__init__(self, parent)
        self.setWindowTitle(MAIN_WINDOW_TITLE)
        self.setWindowIcon(get_icon("agent.svg"))

        self.sysTray = SystemTray(self)

        self.connect(self.sysTray,
                     SIGNAL("activated(QSystemTrayIcon::ActivationReason)"),
                     self.__icon_activated)

        checks = get_checks()
        datadog_conf = DatadogConf(get_config_path())
        self.create_logs_files_windows(log_conf)

        listwidget = QListWidget(self)
        listwidget.addItems([
            osp.basename(check.module_name).replace("_", " ").title()
            for check in checks
        ])

        self.properties = PropertiesWidget(self)

        self.setting_button = QPushButton(get_icon("info.png"),
                                          "Logs and Status", self)
        self.menu_button = QPushButton(get_icon("settings.png"), "Actions",
                                       self)
        self.settings = [
            ("Forwarder Logs", lambda: [
                self.properties.set_log_file(self.forwarder_log_file),
                self.show_html(self.properties.group_code, self.properties.
                               html_window, False)
            ]),
            ("Collector Logs", lambda: [
                self.properties.set_log_file(self.collector_log_file),
                self.show_html(self.properties.group_code, self.properties.
                               html_window, False)
            ]),
            ("Dogstatsd Logs", lambda: [
                self.properties.set_log_file(self.dogstatsd_log_file),
                self.show_html(self.properties.group_code, self.properties.
                               html_window, False)
            ]),
            ("JMX Fetch Logs", lambda: [
                self.properties.set_log_file(self.jmxfetch_log_file),
                self.show_html(self.properties.group_code, self.properties.
                               html_window, False)
            ]),
        ]

        if Platform.is_windows():
            self.settings.extend([
                ("Service Logs", lambda: [
                    self.properties.set_log_file(self.service_log_file),
                    self.show_html(self.properties.group_code, self.properties.
                                   html_window, False)
                ]),
            ])

        self.settings.extend([
            ("Agent Status", lambda: [
                self.properties.html_window.setHtml(self.properties.html_window
                                                    .latest_status()),
                self.show_html(self.properties.group_code, self.properties.
                               html_window, True),
                self.properties.set_status()
            ]),
        ])

        self.agent_settings = QPushButton(get_icon("edit.png"), "Settings",
                                          self)
        self.connect(
            self.agent_settings, SIGNAL("clicked()"), lambda: [
                self.properties.set_datadog_conf(datadog_conf),
                self.show_html(self.properties.group_code, self.properties.
                               html_window, False)
            ])

        self.setting_menu = SettingMenu(self.settings)
        self.connect(
            self.setting_button, SIGNAL("clicked()"),
            lambda: self.setting_menu.popup(
                self.setting_button.mapToGlobal(QPoint(0, 0))))

        self.manager_menu = Menu(self)
        self.connect(
            self.menu_button, SIGNAL("clicked()"),
            lambda: self.manager_menu.popup(
                self.menu_button.mapToGlobal(QPoint(0, 0))))

        holdingBox = QGroupBox("", self)
        Box = QVBoxLayout(self)
        Box.addWidget(self.agent_settings)
        Box.addWidget(self.setting_button)
        Box.addWidget(self.menu_button)
        Box.addWidget(listwidget)
        holdingBox.setLayout(Box)

        self.addWidget(holdingBox)
        self.addWidget(self.properties)

        self.connect(self.properties.enable_button, SIGNAL("clicked()"),
                     lambda: enable_check(self.properties))

        self.connect(self.properties.disable_button, SIGNAL("clicked()"),
                     lambda: disable_check(self.properties))

        self.connect(self.properties.save_button, SIGNAL("clicked()"),
                     lambda: save_file(self.properties))

        self.connect(
            self.properties.refresh_button, SIGNAL("clicked()"), lambda: [
                self.properties.set_log_file(self.properties.current_file),
                self.properties.html_window.setHtml(self.properties.html_window
                                                    .latest_status())
            ])

        self.connect(
            listwidget, SIGNAL('currentRowChanged(int)'), lambda row: [
                self.properties.set_item(checks[row]),
                self.show_html(self.properties.group_code, self.properties.
                               html_window, False)
            ])

        listwidget.setCurrentRow(0)

        self.setSizes([150, 1])
        self.setStretchFactor(1, 1)
        self.resize(QSize(950, 600))
        self.properties.set_datadog_conf(datadog_conf)

        self.do_refresh()
Example #45
0
    def __init__(self, parent):
        QWidget.__init__(self, parent)
        font = QFont(get_family(MONOSPACE), 10, QFont.Normal)

        info_icon = QLabel()
        icon = get_std_icon('MessageBoxInformation').pixmap(24, 24)
        info_icon.setPixmap(icon)
        info_icon.setFixedWidth(32)
        info_icon.setAlignment(Qt.AlignTop)

        self.service_status_label = QLabel()
        self.service_status_label.setWordWrap(True)
        self.service_status_label.setAlignment(Qt.AlignTop)
        self.service_status_label.setFont(font)

        self.desc_label = QLabel()
        self.desc_label.setWordWrap(True)
        self.desc_label.setAlignment(Qt.AlignTop)
        self.desc_label.setFont(font)

        self.group_desc = QGroupBox("Description", self)
        layout = QHBoxLayout()
        layout.addWidget(info_icon)
        layout.addWidget(self.desc_label)
        layout.addStretch()
        layout.addWidget(self.service_status_label)

        self.group_desc.setLayout(layout)

        self.editor = CodeEditor(self)
        self.editor.setup_editor(linenumbers=True, font=font)
        self.editor.setReadOnly(False)
        self.group_code = QGroupBox("Source code", self)
        layout = QVBoxLayout()
        layout.addWidget(self.editor)
        self.group_code.setLayout(layout)

        self.enable_button = QPushButton(get_icon("apply.png"), "Enable", self)

        self.save_button = QPushButton(get_icon("filesave.png"), "Save", self)

        self.disable_button = QPushButton(get_icon("delete.png"), "Disable",
                                          self)

        self.refresh_button = QPushButton(get_icon("restart.png"), "Refresh",
                                          self)
        hlayout = QHBoxLayout()
        hlayout.addWidget(self.save_button)
        hlayout.addWidget(self.enable_button)
        hlayout.addWidget(self.disable_button)
        hlayout.addWidget(self.refresh_button)

        vlayout = QVBoxLayout()
        vlayout.addWidget(self.group_desc)
        vlayout.addWidget(self.group_code)
        self.html_window = HTMLWindow()
        vlayout.addWidget(self.html_window)

        vlayout.addLayout(hlayout)
        self.setLayout(vlayout)

        self.current_file = None
Example #46
0
    def __init__(self, parent):
        QWidget.__init__(self, parent)
        font = QFont(get_family(MONOSPACE), 10, QFont.Normal)
        
        info_icon = QLabel()
        icon = get_std_icon('MessageBoxInformation').pixmap(24, 24)
        info_icon.setPixmap(icon)
        info_icon.setFixedWidth(32)
        info_icon.setAlignment(Qt.AlignTop)

        self.service_status_label = QLabel()
        self.service_status_label.setWordWrap(True)
        self.service_status_label.setAlignment(Qt.AlignTop)
        self.service_status_label.setFont(font)

        self.desc_label = QLabel()
        self.desc_label.setWordWrap(True)
        self.desc_label.setAlignment(Qt.AlignTop)
        self.desc_label.setFont(font)

        group_desc = QGroupBox("Description", self)
        layout = QHBoxLayout()
        layout.addWidget(info_icon)
        layout.addWidget(self.desc_label)
        layout.addStretch()
        layout.addWidget(self.service_status_label  )

        group_desc.setLayout(layout)
        
        self.editor = CodeEditor(self)
        self.editor.setup_editor(linenumbers=True, font=font)
        self.editor.setReadOnly(False)
        group_code = QGroupBox("Source code", self)
        layout = QVBoxLayout()
        layout.addWidget(self.editor)
        group_code.setLayout(layout)
        
        self.enable_button = QPushButton(get_icon("apply.png"),
                                      "Enable", self)

        self.save_button = QPushButton(get_icon("filesave.png"),
                                      "Save", self)

        self.edit_datadog_conf_button = QPushButton(get_icon("edit.png"),
                                      "Edit agent settings", self)

        self.disable_button = QPushButton(get_icon("delete.png"),
                                      "Disable", self)


        self.view_log_button = QPushButton(get_icon("txt.png"), 
                                      "View log", self)

        self.menu_button = QPushButton(get_icon("settings.png"),
                                      "Manager", self)



        hlayout = QHBoxLayout()
        hlayout.addWidget(self.save_button)
        hlayout.addStretch()
        hlayout.addWidget(self.enable_button)
        hlayout.addStretch()
        hlayout.addWidget(self.disable_button)
        hlayout.addStretch()
        hlayout.addWidget(self.edit_datadog_conf_button)
        hlayout.addStretch()
        hlayout.addWidget(self.view_log_button)
        hlayout.addStretch()
        hlayout.addWidget(self.menu_button)
        
        vlayout = QVBoxLayout()
        vlayout.addWidget(group_desc)
        vlayout.addWidget(group_code)
        vlayout.addLayout(hlayout)
        self.setLayout(vlayout)

        self.current_file = None
Example #47
0
    def __init__(self, parent=None):

        QSplitter.__init__(self, parent)
        self.setWindowTitle(MAIN_WINDOW_TITLE)
        self.setWindowIcon(get_icon("agent.svg"))

        self.sysTray = SystemTray(self)

        self.connect(self.sysTray, SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), self.__icon_activated)

        checks = get_checks()
        datadog_conf = DatadogConf(get_config_path(), description="Agent settings file: datadog.conf")

        self.forwarder_log_file = ForwarderLogFile()
        self.collector_log_file = CollectorLogFile()
        self.dogstatsd_log_file = DogstatsdLogFile()
        self.jmxfetch_log_file = JMXFetchLogFile()

        listwidget = QListWidget(self)
        listwidget.addItems([osp.basename(check.module_name).replace("_", " ").title() for check in checks])

        self.properties = PropertiesWidget(self)

        self.setting_button = QPushButton(get_icon("info.png"), "Logs and Status", self)
        self.menu_button = QPushButton(get_icon("settings.png"), "Actions", self)
        self.settings = [
            (
                "Forwarder Logs",
                lambda: [
                    self.properties.set_log_file(self.forwarder_log_file),
                    self.show_html(self.properties.group_code, self.properties.html_window, False),
                ],
            ),
            (
                "Collector Logs",
                lambda: [
                    self.properties.set_log_file(self.collector_log_file),
                    self.show_html(self.properties.group_code, self.properties.html_window, False),
                ],
            ),
            (
                "Dogstatsd Logs",
                lambda: [
                    self.properties.set_log_file(self.dogstatsd_log_file),
                    self.show_html(self.properties.group_code, self.properties.html_window, False),
                ],
            ),
            (
                "JMX Fetch Logs",
                lambda: [
                    self.properties.set_log_file(self.jmxfetch_log_file),
                    self.show_html(self.properties.group_code, self.properties.html_window, False),
                ],
            ),
            (
                "Agent Status",
                lambda: [
                    self.properties.html_window.setHtml(self.properties.html_window.latest_status()),
                    self.show_html(self.properties.group_code, self.properties.html_window, True),
                    self.properties.set_status(),
                ],
            ),
        ]

        self.agent_settings = QPushButton(get_icon("edit.png"), "Settings", self)
        self.connect(
            self.agent_settings,
            SIGNAL("clicked()"),
            lambda: [
                self.properties.set_datadog_conf(datadog_conf),
                self.show_html(self.properties.group_code, self.properties.html_window, False),
            ],
        )

        self.setting_menu = SettingMenu(self.settings)
        self.connect(
            self.setting_button,
            SIGNAL("clicked()"),
            lambda: self.setting_menu.popup(self.setting_button.mapToGlobal(QPoint(0, 0))),
        )

        self.manager_menu = Menu(self)
        self.connect(
            self.menu_button,
            SIGNAL("clicked()"),
            lambda: self.manager_menu.popup(self.menu_button.mapToGlobal(QPoint(0, 0))),
        )

        holdingBox = QGroupBox("", self)
        Box = QVBoxLayout(self)
        Box.addWidget(self.agent_settings)
        Box.addWidget(self.setting_button)
        Box.addWidget(self.menu_button)
        Box.addWidget(listwidget)
        holdingBox.setLayout(Box)

        self.addWidget(holdingBox)
        self.addWidget(self.properties)

        self.connect(self.properties.enable_button, SIGNAL("clicked()"), lambda: enable_check(self.properties))

        self.connect(self.properties.disable_button, SIGNAL("clicked()"), lambda: disable_check(self.properties))

        self.connect(self.properties.save_button, SIGNAL("clicked()"), lambda: save_file(self.properties))

        self.connect(
            self.properties.refresh_button,
            SIGNAL("clicked()"),
            lambda: [
                self.properties.set_log_file(self.properties.current_file),
                self.properties.html_window.setHtml(self.properties.html_window.latest_status()),
            ],
        )

        self.connect(
            listwidget,
            SIGNAL("currentRowChanged(int)"),
            lambda row: [
                self.properties.set_item(checks[row]),
                self.show_html(self.properties.group_code, self.properties.html_window, False),
            ],
        )

        listwidget.setCurrentRow(0)

        self.setSizes([150, 1])
        self.setStretchFactor(1, 1)
        self.resize(QSize(950, 600))
        self.properties.set_datadog_conf(datadog_conf)

        self.do_refresh()
Example #48
0
    def __init__(self, parent):
        super(MakeNicerWidget, self).__init__(parent)

        self.data = np.array([]) # array which holds data
        
        # Time domain plot
        self.tdWidget = DockablePlotWidget(self, CurveWidget)
        self.tdWidget.calcFun.addFun('fs', lambda x: x,
                                           lambda x: x)
        self.tdWidget.calcFun.addFun('µm', lambda x: x*fsDelay*1e3,
                                           lambda x: x/fsDelay*1e-3)
        self.tdWidget.calcFun.addFun('mm', lambda x: x*fsDelay,
                                           lambda x: x/fsDelay)
        tdPlot = self.tdWidget.get_plot()
        self.tdSignal  = SignalFT(self, plot=tdPlot)
        self.tdFit     = SignalFT(self, plot=tdPlot, col='r')

        # Frequency domain plot
        self.fdWidget = DockablePlotWidget(self, CurveWidget)
        self.fdWidget.calcFun.addFun('PHz', lambda x: x,
                                            lambda x: x)
        self.fdWidget.calcFun.addFun('THz', lambda x: x*1e3,
                                            lambda x: x*1e-3)
        self.fdWidget.calcFun.addFun('µm', lambda x: c0/x*1e-9,
                                           lambda x: c0/x*1e-9)
        self.fdWidget.calcFun.addFun('eV', lambda x: x,
                                           lambda x: x)
        fdplot = self.fdWidget.get_plot()
        self.fdSignal  = SignalFT(self, plot=fdplot)
        self.fdFit     = SignalFT(self, plot=fdplot, col='r')

        self.smoothNum = QSpinBox() # gives number of smoothin points
        self.smoothNum.setMinimum(1)
        self.smoothNum.setSingleStep(2)

        # Put things together in layouts
        buttonLayout = QGridLayout()
        plotLayout   = QVBoxLayout()
        layout       = QHBoxLayout()
        plotLayout.addWidget(self.tdWidget)
        plotLayout.addWidget(self.fdWidget)

        buttonLayout.addWidget(QLabel('Fitting function'), 0, 0)
        buttonLayout.addWidget(
            QLineEdit("lambda x,A,f,phi: np.sin(2*np.pi*f*x+phi)"), 1, 0, 1, 2)
        buttonLayout.addWidget(QLabel('Smooth'), 2, 0)
        buttonLayout.addWidget(self.smoothNum, 2, 1)
        buttonLayout.setRowStretch(3, 20)

        layout.addLayout(buttonLayout)
        layout.addLayout(plotLayout)
        self.setLayout(layout)
        
        # connect signals
        self.updateTdPlot.connect(self.tdSignal.updatePlot)
        self.updateTdFitPlot.connect(self.tdFit.updatePlot)
        self.updateFdPlot.connect(lambda data:
            self.fdSignal.updatePlot(self.fdSignal.computeFFT(data)))
        self.updateFdFitPlot.connect(lambda data:
            self.fdFit.updatePlot(self.fdFit.computeFFT(data)))
        self.smoothNum.valueChanged.connect(self.smoothData)

        self.setData()
Example #49
0
class GenericOperationWidget(QWidget):
    type_mapping = {"int": {"widget": QSpinBox,
                            "display_func": "setValue",
                            "display_conversion": int,
                            "get_func": "value",
                            "get_conversion": int},
                    "float": {"widget": QLineEdit,
                              "display_func": "setText",
                              "display_conversion": str,
                              "get_func": "text",
                              "get_conversion": float},
                    "bool": {"widget": QCheckBox,
                             "display_func": "setChecked",
                             "get_func": "checkState"},
                    "slice": {"widget": QSliceInput,
                              "display_func": "setSlice",
                              "get_func": "getSlice"}}
    def __init__(self, parent=None, op=None):
        QWidget.__init__(self, parent)
        self.widget_layout = QVBoxLayout()
        self.minimumHeight = 200 # FIXME: hab noch nie verstanden warum das net einfach einfach ist...
        self.setLayout(self.widget_layout)

        self._op = None
        self._widgets = []
        self._par_names = []

    def _clear_widgets(self):
        """
        Remove any dynamically created widget
        """
        for i in reversed(range(self.widget_layout.count())):
            widget = self.widget_layout.takeAt(i).widget()
            if widget is not None:
                widget.deleteLater()
                widget.setParent(None)

        self._widgets = []
        self._par_names = []


    def _set_widgets(self):
        """
        Parse operation (function arguments) and create widgets according to
        the function annotations. Fill with default or current argument values
        and display the widgets.
        """
        self._clear_widgets()

        # Retreive operation (function detail), instantiate neccesary widgets
        package, fun = self._op["module"].rsplit('.', 1)
        module = import_module(package)
        self._op["function"] = getattr(module, fun)
        argspec = inspect.getfullargspec(self._op["function"])

        # Create widgets
        self._labels = []
        self._widgets = []
        self._none_checkbox_widgets = []
        for par_name, annotation in sorted(argspec.annotations.items()):
            label = QLabel(par_name)
            font = qtgui.QFont()
            font.setPointSize(10)
            label.setFont(font)

            # find associated widget and functions
            mapping = {}
            if "widget" in annotation:
                mapping["widget"] = widget = getattr(qtgui, annotation["widget"])
                mapping["display_func"] = annotation["display_func"]
                mapping["display_conversion"] = annotation["display_conversion"]
                mapping["get_func"] = annotation["get_func"]
            elif "type" in annotation:
                try:
                    mapping = dict(GenericOperationWidget.type_mapping[annotation["type"]])
                except KeyError:
                    print("Can't find wiget for type: {type} for parameter " +
                          "{par_name}".format(type=annotation["type"], par_name=par_name))
                    continue
            else:
                continue

            # instanciate widget and make display_function callable
            widget = mapping["widget"]()
            if not callable(mapping["display_func"]):
                mapping["display_func"] = widget.__getattribute__(mapping["display_func"])

            # save mapping and parameter name for later use
            widget.mapping = mapping
            widget.par_name = par_name

            # create checkbox to allow not to set this parameter
            checkbox = QCheckBox()
            checkbox.setChecked(True)
            checkbox.setToolTip("Set the \"%s\" parameter. If unchecked, the default value is used." % par_name)
            checkbox.par_name = widget.par_name

            # Set value of widget according to parameters of the operation
            try:
                if "display_conversion" in mapping:
                    display_value = mapping["display_conversion"](self._op["kwargs"][par_name])    
                else:
                    display_value = self._op["kwargs"][par_name]
                mapping["display_func"](display_value)
            except KeyError:
                checkbox.setChecked(False)
            
            self._labels.append(label)
            self._widgets.append(widget)
            self._none_checkbox_widgets.append(checkbox)

        # Add widgets to layout
        if not self._widgets:
            self.widget_layout.addWidget(QLabel("No operation parameters"))
        for i, widget in enumerate(self._widgets):
            self.widget_layout.addWidget(self._labels[i])
            self.widget_layout.addWidget(self._widgets[i])
            self.widget_layout.addWidget(self._none_checkbox_widgets[i])

    def set_operation(self, op):
        """
        Create widgets for operation. Accepts either a full dict for a
        operation or a dict with only package, module and function
        """
        self._op = op
        self._set_widgets()

    def get_operation(self):
        """
        Returns operation dict for the current state of the parameter widgets.
        """
        kwargs = {}
        for i, w in enumerate(self._widgets):
            if hasattr(w, "par_name"):
                if self._none_checkbox_widgets[i].isChecked():
                    kwargs[w.par_name] = self.get_operation_parameter(w)

        self._op["kwargs"] = kwargs

        package, fun = self._op["module"].rsplit('.', 1)
        module = import_module(package)
        self._op["function"] = getattr(module, fun)
        return self._op
    
    def get_operation_parameter(self, w):       
        """
        Extract a parameter from a operations widget using mapping["get_func"]. 
        If a get_conversion is provided the raw input will be converted using 
        the get_conversion.Converts "" and "None" input to None for the time 
        being.
        
        Params:
        =======
        w : OperationsWidget
            The widget containing the parameter
            
        Returns:
        ========
        param : 
            Parameter as expected for the operation which w. represents
        """         
        try:
            # Try to get as many parameters as possible. If conversion fails it
            # will be apparent when the widget is repopulated as the parameter
            # is simply not set
            parameter = w.__getattribute__(w.mapping["get_func"])()
            if parameter == "" or parameter == "None":
                # FIXME: Move this to a generic get_conversion function
                parameter= None
            if "get_conversion" in w.mapping:
                parameter = w.mapping["get_conversion"](parameter)
        except ValueError:
            parameter = None
        return parameter
Example #50
0
class OperationsWidget(QWidget):
    operations_changed = QtCore.pyqtSignal()
    operation_changed = QtCore.pyqtSignal(dict, int)
    operation_added = QtCore.pyqtSignal(dict, int)

    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        self.widget_layout = QVBoxLayout()

        title_layout = QHBoxLayout()
        title_layout.addStretch()
        style = "<span style=\'color: #444444\'><b>%s</b></span>"
        title = QLabel(style % "Operations")
        title_layout.addWidget(title)
        title_layout.addStretch()
        self.widget_layout.addLayout(title_layout)

        # Create ListWidget and add 10 items to move around.
        self.list_widget = QListWidget()

        # self.list_widget.setDragDropMode(QAbstractItemView.InternalMove)
        self.list_widget.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.list_widget.setSortingEnabled(False)
        self.list_widget.currentItemChanged.connect(self._populate_settings_update)
        self.widget_layout.addWidget(self.list_widget)

        otitle_layout = QHBoxLayout()
        otitle_layout.addStretch()
        otitle = QLabel(style % "Operation settings")
        otitle_layout.addWidget(otitle)
        otitle_layout.addStretch()
        self.widget_layout.addLayout(otitle_layout)

        self.operations_combo = QComboBox()
        self.operations_combo.currentIndexChanged.connect(self._populate_settings_add)
        self.widget_layout.addWidget(self.operations_combo)

        self.operation_settings = GenericOperationWidget()
        self.widget_layout.addWidget(self.operation_settings)

        self.toolbar = QToolBar()
        self.toolbar.addAction(get_icon('apply.png'), "Apply/Replace",
                               self._change_operation)
        self.toolbar.addAction(get_icon('editors/edit_add.png'), "Add after",
                               self._add_operation)
        self.toolbar.addAction(get_icon('trash.png'), "Remove",
                               self._remove_operation)


        self.widget_layout.addWidget(self.toolbar)
        self.setLayout(self.widget_layout)

    def populate_available_operations(self, dict):
        """
        Populate combobox with available operation names
        """
        self.operations_combo.addItems(dict)

    def set_operations(self, operations_dict):
        """
        Populate operations list with given dict of operations
        """
        self.list_widget.clear()
        for op in operations_dict:
            self.list_widget.addItem(Operation(op))

    def get_operations(self):
        """
        Return list of operations.
        """
        operations = []
        for i in range(self.list_widget.count()):
            op = self.list_widget.item(i)
            operations.append(op._op)

        return operations

    def _remove_operation(self):
        self.list_widget.takeItem(self.list_widget.currentRow())
        self.operations_changed.emit()

    def _add_operation(self):
        """
        Add operation currently in self.operation_settings to the operation
        list.

        Signals:
        ========
        Emits self.opeartion_added and self.operations_changed on success
        """
        op = self.operation_settings.get_operation()
        current_row = self.list_widget.currentRow()
        self.list_widget.insertItem(current_row + 1, Operation(op))
        index = self.list_widget.model().index(current_row + 1, 0)
        self.list_widget.setCurrentIndex(index)
        self.operation_added.emit(op, current_row + 1)
        self.operations_changed.emit()

    def _change_operation(self):
        """
        Replace currently selected operation with operation in
        self.operation_settings (apply changed settings or replace operation).

        Signals:
        ========
        Emits self.operation_changed and self.operations_changed on success
        """
        op = self.operation_settings.get_operation()
        current_row = self.list_widget.currentRow()
        self.list_widget.takeItem(self.list_widget.currentRow())
        self.list_widget.insertItem(current_row, Operation(op))
        index = self.list_widget.model().index(current_row, 0)
        self.list_widget.setCurrentIndex(index)

        self.operation_changed.emit(op, current_row)
        self.operations_changed.emit()


    def _populate_settings_update(self, item):
        """
        Fill self.operation_settings with details of currently selected
        operation.
        """
        try:
            idx = self.operations_combo.findText(item._op["module"])
            if idx >= 0:
                self.operations_combo.setCurrentIndex(idx)
            self.operation_settings.set_operation(item._op)
        except AttributeError:
            pass

    def _populate_settings_add(self, index):
        self.operation_settings.set_operation({"module": self.operations_combo.currentText()})