Ejemplo n.º 1
0
    def __init__(self):
        super().__init__()
        self.imgs = None
        self.result = None
        self.saved_config = []

        # GUI
        self.infoa = gui.widgetLabel(self.box_info,
                                     'No data yet, waiting to get something.')

        gui.checkBox(self.controlArea,
                     self,
                     'auto_resize',
                     'Apply automatic settings',
                     callback=self.do_auto_conf)

        self.box_custom = gui.widgetBox(self.controlArea, "Custom")
        self.info_shape = gui.widgetLabel(self.box_custom, 'Original shape: ')
        hl0 = gui.hBox(self.box_custom)
        gui.label(hl0, self, "Desired shape:")
        self.sp_w = QtWidgets.QSpinBox(
            self
        )  # gui.spin(hl0, self, 'desired_width', minv=1, maxv=5000, step=1)
        self.sp_h = QtWidgets.QSpinBox(
            self
        )  #self.sp_h = gui.spin(hl0, self, 'desired_height', minv=1, maxv=5000, step=1)
        self.sp_w.setMinimum(1)
        self.sp_h.setMinimum(1)
        #self.sp_w.valueChanged.connect(self.on_value_change)
        #self.sp_h.valueChanged.connect(self.on_value_change)
        hl0.layout().addWidget(self.sp_h)
        hl0.layout().addWidget(self.sp_w)

        gui.radioButtons(self.box_custom, self, 'selected_resize_type',
                         ["Crop top left", "Crop center", "Resize"])

        gui.toolButton(self.box_custom,
                       self,
                       "Apply and save current settings",
                       callback=self.do_save_conf)

        gui.checkBox(self.buttonsArea,
                     self,
                     'allow_propagation',
                     'Allow propagation',
                     callback=self.commit)
Ejemplo n.º 2
0
 def addSetting(self, owner, name, label=None, updateCallback=None):
     """
     :param owner: setting owner
     :type owner: OWWidget or OWComponent
     :param name: setting name
     :type name: str
     :param label: setting label
     :type label: str or None
     """
     # Label
     if label is None:
         label = '{}:'.format(name)
     # Field
     value = getdeepattr(owner, name)
     if isinstance(value, str):
         field = QtWidgets.QLineEdit()
         field.setText(value)
         if updateCallback:
             field.textChanged.connect(updateCallback)
     elif isinstance(value, numbers.Number):
         if isinstance(value, numbers.Integral):
             field = QtWidgets.QSpinBox()
             ma = sys.maxsize
             field.setRange(-ma - 1, ma)
         else:
             field = QtWidgets.QDoubleSpinBox()
         field.setValue(value)
         if updateCallback:
             field.valueChanged.connect(updateCallback)
     else:
         raise ValueError('{} does not have a Qt widget'.format(
             repr(type(value).__qualname__)))
     # Append
     policy = QtWidgets.QSizePolicy.Expanding
     field.setSizePolicy(policy, policy)
     self.layout().addRow(label, field)
     return field