Ejemplo n.º 1
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)
Ejemplo n.º 2
0
 def add_buttons_to_layout(self, layout):
     """Add tool buttons to layout"""
     # Show crop rectangle checkbox
     show_crop = QCheckBox(_("Show cropping rectangle"), self)
     show_crop.setChecked(True)
     show_crop.toggled.connect(self.show_crop_rect)
     layout.addWidget(show_crop)
     layout.addSpacing(15)
     base.BaseTransformMixin.add_buttons_to_layout(self, layout)
Ejemplo n.º 3
0
 def add_buttons_to_layout(self, layout):
     """Add tool buttons to layout"""
     # Show crop rectangle checkbox
     show_crop = QCheckBox(_("Show cropping rectangle"), self)
     show_crop.setChecked(True)
     show_crop.toggled.connect(self.show_crop_rect)
     layout.addWidget(show_crop)
     layout.addSpacing(15)
     base.BaseTransformMixin.add_buttons_to_layout(self, layout)
Ejemplo n.º 4
0
class CheckBoxWidget(AbstractDataSetWidget):
    """
    BoolItem widget
    """
    def __init__(self, item, parent_layout):
        super(CheckBoxWidget, self).__init__(item, parent_layout)
        self.checkbox = QCheckBox(self.item.get_prop_value("display", "text"))
        self.checkbox.setToolTip(item.get_help())
        self.group = self.checkbox

        self.store = self.item.get_prop("display", "store", None)
        if self.store:
            self.checkbox.stateChanged.connect(self.do_store)

    def get(self):
        """Override AbstractDataSetWidget method"""
        value = self.item.get()
        if value:
            self.checkbox.setChecked(True)

    def set(self):
        """Override AbstractDataSetWidget method"""
        self.item.set(self.value())

    def value(self):
        return self.checkbox.isChecked()

    def place_on_grid(self,
                      layout,
                      row,
                      label_column,
                      widget_column,
                      row_span=1,
                      column_span=1):
        """Override AbstractDataSetWidget method"""
        if not self.item.get_prop_value("display", "label"):
            widget_column = label_column
            column_span += 1
        else:
            self.place_label(layout, row, label_column)
        layout.addWidget(self.group, row, widget_column, row_span, column_span)

    def do_store(self, state):
        self.store.set(self.item.instance, self.item.item, state)
        self.parent_layout.refresh_widgets()
Ejemplo n.º 5
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()
Ejemplo n.º 6
0
class CheckBoxWidget(AbstractDataSetWidget):
    """
    BoolItem widget
    """
    def __init__(self, item, parent_layout):
        super(CheckBoxWidget, self).__init__(item, parent_layout)
        self.checkbox = QCheckBox(self.item.get_prop_value("display", "text"))
        self.checkbox.setToolTip(item.get_help())
        self.group = self.checkbox
        
        self.store = self.item.get_prop("display", "store", None)
        if self.store:
            self.checkbox.stateChanged.connect(self.do_store)
        
    def get(self):
        """Override AbstractDataSetWidget method"""
        value = self.item.get()
        if value is not None:
            self.checkbox.setChecked(value)
    
    def set(self):
        """Override AbstractDataSetWidget method"""
        self.item.set(self.value())

    def value(self):
        return self.checkbox.isChecked()
        
    def place_on_grid(self, layout, row, label_column, widget_column,
                      row_span=1, column_span=1):
        """Override AbstractDataSetWidget method"""
        if not self.item.get_prop_value("display", "label"):
            widget_column = label_column
            column_span += 1
        else:
            self.place_label(layout, row, label_column)
        layout.addWidget(self.group, row, widget_column, row_span, column_span)

    def do_store(self, state):
        self.store.set(self.item.instance, self.item.item, state)
        self.parent_layout.refresh_widgets()
Ejemplo n.º 7
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)
Ejemplo n.º 8
0
    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])