Exemplo n.º 1
0
    def insert_thumbnail(self, imgwin, thumbkey, thumbname, chname, name, path,
                         thumbpath, metadata, image_loader):
        pixmap = QPixmap.fromImage(imgwin)
        imglbl = MyLabel()
        imglbl.setPixmap(pixmap)
        imglbl.thumbs_cb = lambda: self.load_file(thumbkey, chname, name, path,
                                                  image_loader)

        text = self.query_thumb(thumbkey, name, metadata)
        imglbl.setToolTip(text)

        widget = QtGui.QWidget()
        #vbox = QtGui.QGridLayout()
        vbox = QtGui.QVBoxLayout()
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        widget.setLayout(vbox)
        namelbl = QtGui.QLabel(thumbname)
        namelbl.setAlignment(QtCore.Qt.AlignLeft)
        namelbl.setAlignment(QtCore.Qt.AlignHCenter)
        ## vbox.addWidget(namelbl, 0, 0)
        ## vbox.addWidget(imglbl,  1, 0)
        vbox.addWidget(namelbl, stretch=0)
        vbox.addWidget(imglbl, stretch=0)
        widget.setSizePolicy(
            QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
                              QtGui.QSizePolicy.Fixed))
        bnch = Bunch.Bunch(widget=widget,
                           image=imgwin,
                           layout=vbox,
                           imglbl=imglbl,
                           name=name,
                           imname=name,
                           chname=chname,
                           path=path,
                           thumbpath=thumbpath,
                           pixmap=pixmap)

        with self.thmblock:
            self.thumbDict[thumbkey] = bnch
            self.thumbList.append(thumbkey)

            self.w.thumbs.addWidget(widget, self.thumbRowCount,
                                    self.thumbColCount)
            self.thumbColCount = (self.thumbColCount + 1) % self.thumbNumCols
            if self.thumbColCount == 0:
                self.thumbRowCount += 1

        #self.w.thumbs.show()

        # force scroll to bottom of thumbs, if checkbox is set
        scrollp = self.w.auto_scroll.isChecked()
        if scrollp:
            self.fv.update_pending()
            area = self.w.thumbs_scroll
            area.verticalScrollBar().setValue(
                area.verticalScrollBar().maximum())
        self.logger.debug("added thumb for %s" % (thumbname))
Exemplo n.º 2
0
    def build_gui(self, container):
        sw = QtGui.QScrollArea()

        twidget = QtHelp.VBox()
        sp = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding,
                               QtGui.QSizePolicy.Fixed)
        twidget.setSizePolicy(sp)
        vbox1 = twidget.layout()
        vbox1.setContentsMargins(4, 4, 4, 4)
        vbox1.setSpacing(2)
        sw.setWidgetResizable(True)
        sw.setWidget(twidget)

        msgFont = QtGui.QFont("Sans", 14)
        tw = QtGui.QLabel()
        tw.setFont(msgFont)
        tw.setWordWrap(True)
        self.tw = tw

        fr = QtHelp.Frame("Instructions")
        fr.layout().addWidget(tw, stretch=1, alignment=QtCore.Qt.AlignTop)
        vbox1.addWidget(fr, stretch=0, alignment=QtCore.Qt.AlignTop)

        fr = QtHelp.Frame("HDU")

        captions = [("Num HDUs", 'label'), ("Choose HDU", 'spinbutton')]
        w, b = QtHelp.build_info(captions)
        self.w.update(b)
        self.w.numhdu = b.num_hdus
        self.w.hdu = b.choose_hdu
        self.w.hdu.valueChanged.connect(self.set_hdu_cb)

        fr.layout().addWidget(w, stretch=1, alignment=QtCore.Qt.AlignLeft)
        vbox1.addWidget(fr, stretch=0, alignment=QtCore.Qt.AlignTop)

        fr = QtHelp.Frame("NAXIS")

        self.stack = QtHelp.StackedWidget()
        self.stack.addWidget(QtGui.QLabel(''))
        fr.layout().addWidget(self.stack,
                              stretch=1,
                              alignment=QtCore.Qt.AlignLeft)
        vbox1.addWidget(fr, stretch=0, alignment=QtCore.Qt.AlignTop)

        btns = QtHelp.HBox()
        layout = btns.layout()
        layout.setSpacing(3)
        #btns.set_child_size(15, -1)

        btn = QtGui.QPushButton("Close")
        btn.clicked.connect(self.close)
        layout.addWidget(btn, stretch=0, alignment=QtCore.Qt.AlignLeft)
        vbox1.addWidget(btns, stretch=0, alignment=QtCore.Qt.AlignLeft)

        container.addWidget(sw, stretch=1)
Exemplo n.º 3
0
    def insert_thumbnail(self, imgwin, thumbkey, thumbname, chname, name, path,
                         metadata):
        pixmap = QtGui.QPixmap.fromImage(imgwin)
        imglbl = MyLabel()
        imglbl.setPixmap(pixmap)
        imglbl.thumbs_cb = lambda: self.fv.switch_name(chname, name, path=path)

        text = self.query_thumb(thumbkey, name, metadata)
        imglbl.setToolTip(text)

        widget = QtGui.QWidget()
        #vbox = QtGui.QGridLayout()
        vbox = QtGui.QVBoxLayout()
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        widget.setLayout(vbox)
        namelbl = QtGui.QLabel(thumbname)
        namelbl.setAlignment(QtCore.Qt.AlignLeft)
        namelbl.setAlignment(QtCore.Qt.AlignHCenter)
        ## vbox.addWidget(namelbl, 0, 0)
        ## vbox.addWidget(imglbl,  1, 0)
        vbox.addWidget(namelbl, stretch=0)
        vbox.addWidget(imglbl, stretch=0)
        widget.setSizePolicy(
            QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
                              QtGui.QSizePolicy.Fixed))
        #widget.show()
        bnch = Bunch.Bunch(widget=widget,
                           image=imgwin,
                           layout=vbox,
                           imglbl=imglbl,
                           name=name,
                           chname=chname,
                           path=path,
                           pixmap=pixmap)

        self.thumbDict[thumbkey] = bnch
        self.thumbList.append(thumbkey)

        self.w.thumbs.addWidget(widget, self.thumbRowCount, self.thumbColCount)
        self.thumbColCount = (self.thumbColCount + 1) % self.thumbNumCols
        if self.thumbColCount == 0:
            self.thumbRowCount += 1

        #self.w.thumbs.show()

        # force scroll to bottom of thumbs
        ## rect = self.w.thumbs_w.geometry()
        ## x1, y1, x2, y2 = rect.getCoords()
        ## self.w.thumbs_scroll.ensureVisible(x1, y1)
        #self.w.thumbs_scroll.show()
        self.logger.debug("added thumb for %s" % (thumbname))
Exemplo n.º 4
0
    def build_gui(self, container):
        sw = QtGui.QScrollArea()

        twidget = QtHelp.VBox()
        sp = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding,
                               QtGui.QSizePolicy.Fixed)
        twidget.setSizePolicy(sp)
        vbox1 = twidget.layout()
        vbox1.setContentsMargins(4, 4, 4, 4)
        vbox1.setSpacing(2)
        sw.setWidgetResizable(True)
        sw.setWidget(twidget)

        msgFont = QtGui.QFont("Sans", 14)
        tw = QtGui.QLabel()
        tw.setFont(msgFont)
        tw.setWordWrap(True)
        self.tw = tw

        fr = QtHelp.Frame("Instructions")
        fr.layout().addWidget(tw, stretch=1, alignment=QtCore.Qt.AlignTop)
        vbox1.addWidget(fr, stretch=0, alignment=QtCore.Qt.AlignTop)

        fr = QtHelp.Frame("Ruler")

        captions = (('Units', 'combobox'), )
        w, b = QtHelp.build_info(captions)
        self.w = b

        combobox = b.units
        for name in self.unittypes:
            combobox.addItem(name)
        index = self.unittypes.index(self.units)
        combobox.setCurrentIndex(index)
        combobox.activated.connect(self.set_units)

        fr.layout().addWidget(w, stretch=1, alignment=QtCore.Qt.AlignLeft)
        vbox1.addWidget(fr, stretch=0, alignment=QtCore.Qt.AlignTop)

        btns = QtHelp.HBox()
        layout = btns.layout()
        layout.setSpacing(3)
        #btns.set_child_size(15, -1)

        btn = QtGui.QPushButton("Close")
        btn.clicked.connect(self.close)
        layout.addWidget(btn, stretch=0, alignment=QtCore.Qt.AlignLeft)
        vbox1.addWidget(btns, stretch=0, alignment=QtCore.Qt.AlignLeft)

        container.addWidget(sw, stretch=1)
Exemplo n.º 5
0
    def build_gui(self, container):

        canvas = CanvasTypes.DrawingCanvas()
        canvas.enable_draw(False)
        #canvas.set_callback('button-press', self.btndown)
        canvas.set_callback('motion', self.cursormotion)
        #canvas.set_callback('button-release', self.update)
        canvas.add_callback('key-press', self.window_key_press)
        canvas.add_callback('key-release', self.window_key_release)
        self.canvas = canvas

        vbox = QtHelp.VBox()
        sp = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding,
                               QtGui.QSizePolicy.Fixed)
        vbox.setSizePolicy(sp)

        fr = QtHelp.Frame("IRAF")

        captions = [
            ("Control", 'hbox'),
            ("Channel", 'label'),
        ]
        w, b = QtHelp.build_info(captions)
        self.w = b
        self.w.mode_d = {}
        btn = QtGui.QRadioButton("Ginga")
        btn.toggled.connect(lambda w: self.switchMode('ginga'))
        self.w.mode_d['ginga'] = btn
        self.w.control.layout().addWidget(btn,
                                          stretch=0,
                                          alignment=QtCore.Qt.AlignLeft)
        btn = QtGui.QRadioButton("IRAF")
        btn.toggled.connect(lambda w: self.switchMode('iraf'))
        self.w.mode_d['iraf'] = btn
        self.w.control.layout().addWidget(btn,
                                          stretch=0,
                                          alignment=QtCore.Qt.AlignLeft)

        fr.layout().addWidget(w, stretch=1, alignment=QtCore.Qt.AlignLeft)
        vbox.addWidget(fr, stretch=0, alignment=QtCore.Qt.AlignTop)

        fr = QtHelp.Frame("Frame/Channel")

        lbl = QtGui.QLabel("")
        self.w.frch = lbl

        fr.layout().addWidget(lbl, stretch=1, alignment=QtCore.Qt.AlignLeft)
        vbox.addWidget(fr, stretch=0, alignment=QtCore.Qt.AlignTop)

        container.addWidget(vbox, stretch=0, alignment=QtCore.Qt.AlignTop)
Exemplo n.º 6
0
    def add_viewer(self, name, settings, use_readout=False, workspace=None):

        vwidget = QtGui.QWidget()
        vbox = QtGui.QVBoxLayout()
        vbox.setContentsMargins(1, 1, 1, 1)
        vbox.setSpacing(0)
        vwidget.setLayout(vbox)

        fi = self.build_viewpane(settings)
        iw = fi.get_widget()

        fi.add_callback('focus', self.focus_cb, name)
        vbox.addWidget(iw, stretch=1)
        fi.set_name(name)

        if use_readout:
            readout = self.build_readout()
            # TEMP: hack
            readout.fitsimage = fi
            fi.add_callback('image-set', self.readout_config, readout)
            self.add_callback('field-info', self.readout_cb, readout, name)
            rw = readout.get_widget()
            rw.setSizePolicy(
                QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
                                  QtGui.QSizePolicy.Fixed))
            vbox.addWidget(rw, stretch=0, alignment=QtCore.Qt.AlignLeft)
        else:
            readout = None

        # Add a page to the specified notebook
        if not workspace:
            workspace = 'channels'
        self.ds.add_tab(workspace, vwidget, 1, name)

        self.update_pending()
        bnch = Bunch.Bunch(fitsimage=fi,
                           view=iw,
                           container=vwidget,
                           readout=readout,
                           workspace=workspace)
        return bnch
Exemplo n.º 7
0
    def build_gui(self, container):
        sw = QtGui.QScrollArea()

        twidget = QtHelp.VBox()
        sp = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding,
                               QtGui.QSizePolicy.Fixed)
        twidget.setSizePolicy(sp)
        vbox1 = twidget.layout()
        vbox1.setContentsMargins(4, 4, 4, 4)
        vbox1.setSpacing(2)
        sw.setWidgetResizable(True)
        sw.setWidget(twidget)

        msgFont = QtGui.QFont("Sans", 14)
        tw = QtGui.QLabel()
        tw.setFont(msgFont)
        tw.setWordWrap(True)
        self.tw = tw

        fr = QtHelp.Frame("Instructions")
        fr.layout().addWidget(tw, stretch=1, alignment=QtCore.Qt.AlignTop)
        vbox1.addWidget(fr, stretch=0, alignment=QtCore.Qt.AlignTop)
        
        fr = QtHelp.Frame("Drawing")

        captions = (('Draw type', 'combobox'), ('Draw color', 'combobox'),
                    ('Clear canvas', 'button'))
        w, b = QtHelp.build_info(captions)
        self.w = b

        combobox = b.draw_type
        options = []
        index = 0
        for name in self.drawtypes:
            options.append(name)
            combobox.addItem(name)
            index += 1
        index = self.drawtypes.index(default_drawtype)
        combobox.setCurrentIndex(index)
        combobox.activated.connect(self.set_drawparams)

        self.w.draw_color = b.draw_color
        combobox = b.draw_color
        options = []
        index = 0
        self.drawcolors = draw_colors
        for name in self.drawcolors:
            options.append(name)
            combobox.addItem(name)
            index += 1
        index = self.drawcolors.index(default_drawcolor)
        combobox.setCurrentIndex(index)
        combobox.activated.connect(self.set_drawparams)

        b.clear_canvas.clicked.connect(self.clear_canvas)

        fr.layout().addWidget(w, stretch=1, alignment=QtCore.Qt.AlignLeft)
        vbox1.addWidget(fr, stretch=0, alignment=QtCore.Qt.AlignTop)

        btns = QtHelp.HBox()
        layout = btns.layout()
        layout.setSpacing(3)

        btn = QtGui.QPushButton("Close")
        btn.clicked.connect(self.close)
        layout.addWidget(btn, stretch=0, alignment=QtCore.Qt.AlignLeft)
        vbox1.addWidget(btns, stretch=0, alignment=QtCore.Qt.AlignLeft)

        container.addWidget(sw, stretch=1)
Exemplo n.º 8
0
    def build_gui(self, container):
        sw = QtGui.QScrollArea()

        twidget = QtHelp.VBox()
        sp = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding,
                               QtGui.QSizePolicy.Fixed)
        twidget.setSizePolicy(sp)
        vbox = twidget.layout()
        vbox.setContentsMargins(4, 4, 4, 4)
        vbox.setSpacing(2)
        sw.setWidgetResizable(True)
        sw.setWidget(twidget)

        # COLOR MAPPING OPTIONS
        fr = QtHelp.Frame("Colors")

        captions = (('Colormap', 'combobox', 'Intensity', 'combobox'),
                    ('Algorithm', 'combobox', 'Table Size',
                     'entry'), ('Color Defaults', 'button'))
        w, b = QtHelp.build_info(captions)
        self.w.cmap_choice = b.colormap
        self.w.imap_choice = b.intensity
        self.w.calg_choice = b.algorithm
        self.w.table_size = b.table_size
        b.color_defaults.clicked.connect(self.set_default_maps)
        b.colormap.setToolTip("Choose a color map for this image")
        b.intensity.setToolTip("Choose an intensity map for this image")
        b.algorithm.setToolTip("Choose a color mapping algorithm")
        b.table_size.setToolTip("Set size of the color mapping table")
        b.color_defaults.setToolTip("Restore default color and intensity maps")
        fr.layout().addWidget(w, stretch=1, alignment=QtCore.Qt.AlignLeft)
        vbox.addWidget(fr, stretch=0, alignment=QtCore.Qt.AlignTop)

        combobox = b.colormap
        options = []
        index = 0
        for name in self.cmap_names:
            options.append(name)
            combobox.addItem(name)
            index += 1
        cmap_name = self.t_.get('color_map', "ramp")
        try:
            index = self.cmap_names.index(cmap_name)
        except Exception:
            index = self.cmap_names.index('ramp')
        combobox.setCurrentIndex(index)
        combobox.activated.connect(self.set_cmap_cb)

        combobox = b.intensity
        options = []
        index = 0
        for name in self.imap_names:
            options.append(name)
            combobox.addItem(name)
            index += 1
        imap_name = self.t_.get('intensity_map', "ramp")
        try:
            index = self.imap_names.index(imap_name)
        except Exception:
            index = self.imap_names.index('ramp')
        combobox.setCurrentIndex(index)
        combobox.activated.connect(self.set_imap_cb)

        combobox = b.algorithm
        options = []
        index = 0
        for name in self.calg_names:
            options.append(name)
            combobox.addItem(name)
            index += 1
        index = self.calg_names.index(self.t_.get('color_algorithm', "linear"))
        combobox.setCurrentIndex(index)
        combobox.activated.connect(self.set_calg_cb)

        entry = b.table_size
        entry.setText(str(self.t_.get('color_hashsize', 65535)))
        entry.returnPressed.connect(lambda: self.set_tablesize_cb(entry))

        # ZOOM OPTIONS
        fr = QtHelp.Frame("Zoom")

        captions = (('Zoom Alg', 'combobox', 'Zoom Rate', 'spinfloat'),
                    ('Stretch XY', 'combobox', 'Stretch Factor',
                     'spinfloat'), ('Scale X', 'entry', 'Scale Y', 'entry'),
                    ('Scale Min', 'spinfloat', 'Scale Max',
                     'spinfloat'), ('Zoom Defaults', 'button'))
        w, b = QtHelp.build_info(captions)
        self.w.update(b)

        index = 0
        for name in self.zoomalg_names:
            b.zoom_alg.addItem(name.capitalize())
            index += 1
        zoomalg = self.t_.get('zoom_algorithm', "step")
        index = self.zoomalg_names.index(zoomalg)
        b.zoom_alg.setCurrentIndex(index)
        b.zoom_alg.setToolTip("Choose Zoom algorithm")
        b.zoom_alg.activated.connect(self.set_zoomalg_cb)

        index = 0
        for name in ('X', 'Y'):
            b.stretch_xy.addItem(name)
            index += 1
        b.stretch_xy.setCurrentIndex(0)
        b.stretch_xy.setToolTip("Stretch pixels in X or Y")
        b.stretch_xy.activated.connect(lambda v: self.set_stretch_cb())

        b.stretch_factor.setRange(1.0, 10.0)
        b.stretch_factor.setValue(1.0)
        b.stretch_factor.setSingleStep(0.10)
        b.stretch_factor.setDecimals(8)
        b.stretch_factor.valueChanged.connect(lambda v: self.set_stretch_cb())
        b.stretch_factor.setToolTip(
            "Length of pixel relative to 1 on other side")
        b.stretch_factor.setEnabled(zoomalg != 'step')

        zoomrate = self.t_.get('zoom_rate', math.sqrt(2.0))
        b.zoom_rate.setRange(1.1, 3.0)
        b.zoom_rate.setValue(zoomrate)
        b.zoom_rate.setSingleStep(0.1)
        b.zoom_rate.setDecimals(8)
        b.zoom_rate.setEnabled(zoomalg != 'step')
        b.zoom_rate.setToolTip("Step rate of increase/decrease per zoom level")
        b.zoom_rate.valueChanged.connect(self.set_zoomrate_cb)

        b.zoom_defaults.clicked.connect(self.set_zoom_defaults_cb)

        scale_x, scale_y = self.fitsimage.get_scale_xy()
        b.scale_x.setToolTip("Set the scale in X axis")
        b.scale_x.setText(str(scale_x))
        b.scale_x.returnPressed.connect(self.set_scale_cb)
        b.scale_y.setToolTip("Set the scale in Y axis")
        b.scale_y.setText(str(scale_y))
        b.scale_y.returnPressed.connect(self.set_scale_cb)

        scale_min, scale_max = self.t_['scale_min'], self.t_['scale_max']
        b.scale_min.setRange(0.00001, 1.0)
        b.scale_min.setValue(scale_min)
        b.scale_min.setDecimals(8)
        b.scale_min.setSingleStep(1.0)
        b.scale_min.valueChanged.connect(lambda w: self.set_scale_limit_cb())
        b.scale_min.setToolTip("Set the minimum allowed scale in any axis")

        b.scale_max.setRange(1.0, 10000.0)
        b.scale_max.setValue(scale_max)
        b.scale_max.setSingleStep(1.0)
        b.scale_max.setDecimals(8)
        b.scale_max.valueChanged.connect(lambda w: self.set_scale_limit_cb())
        b.scale_min.setToolTip("Set the maximum allowed scale in any axis")

        fr.layout().addWidget(w, stretch=1, alignment=QtCore.Qt.AlignLeft)
        vbox.addWidget(fr, stretch=0, alignment=QtCore.Qt.AlignTop)

        # PAN OPTIONS
        fr = QtHelp.Frame("Panning")

        captions = (('Pan X', 'entry'), ('Pan Y', 'entry', 'Center Image',
                                         'button'),
                    ('Reverse Pan', 'checkbutton', 'Mark Center',
                     'checkbutton'))
        w, b = QtHelp.build_info(captions)
        self.w.update(b)

        pan_x, pan_y = self.fitsimage.get_pan()
        b.pan_x.setToolTip("Set the pan position in X axis")
        b.pan_x.setText(str(pan_x + 0.5))
        b.pan_x.returnPressed.connect(self.set_pan_cb)
        b.pan_y.setToolTip("Set the pan position in Y axis")
        b.pan_y.setText(str(pan_y + 0.5))
        b.pan_y.returnPressed.connect(self.set_pan_cb)

        b.center_image.setToolTip(
            "Set the pan position to center of the image")
        b.center_image.clicked.connect(self.center_image_cb)
        b.reverse_pan.setToolTip("Reverse the pan direction")
        b.reverse_pan.stateChanged.connect(self.set_misc_cb)
        b.mark_center.setToolTip("Mark the center (pan locator)")
        b.mark_center.stateChanged.connect(self.set_misc_cb)

        fr.layout().addWidget(w, stretch=1, alignment=QtCore.Qt.AlignLeft)
        vbox.addWidget(fr, stretch=0, alignment=QtCore.Qt.AlignTop)

        # TRANSFORM OPTIONS
        fr = QtHelp.Frame("Transform")

        captions = (
            ('Flip X', 'checkbutton', 'Flip Y', 'checkbutton', 'Swap XY',
             'checkbutton'),
            ('Rotate', 'spinfloat'),
            ('Restore', 'button'),
        )
        w, b = QtHelp.build_info(captions)
        self.w.update(b)

        for name in ('flip_x', 'flip_y', 'swap_xy'):
            btn = b[name]
            btn.setChecked(self.t_.get(name, False))
            btn.stateChanged.connect(lambda w: self.set_transforms_cb())
        b.flip_x.setToolTip("Flip the image around the X axis")
        b.flip_y.setToolTip("Flip the image around the Y axis")
        b.swap_xy.setToolTip("Swap the X and Y axes in the image")
        b.rotate.setToolTip("Rotate the image around the pan position")
        b.restore.setToolTip("Clear any transforms and center image")
        b.restore.clicked.connect(self.restore_cb)

        b.rotate.setRange(0.00, 359.99999999)
        b.rotate.setValue(0.00)
        b.rotate.setSingleStep(10.0)
        b.rotate.setDecimals(8)
        b.rotate.valueChanged.connect(lambda w: self.rotate_cb())

        fr.layout().addWidget(w, stretch=1, alignment=QtCore.Qt.AlignLeft)
        vbox.addWidget(fr, stretch=0, alignment=QtCore.Qt.AlignTop)

        # AUTOCUTS OPTIONS
        fr = QtHelp.Frame("Auto Cuts")

        captions = (('Auto Method', 'combobox'), ('Hist Pct', 'spinfloat'))
        w, b = QtHelp.build_info(captions)
        self.w.update(b)

        b.auto_method.setToolTip("Choose algorithm for auto levels")
        b.hist_pct.setToolTip(
            "Percentage of image to save for Histogram algorithm")

        # Setup auto cuts method choice
        combobox = b.auto_method
        index = 0
        method = self.t_.get('autocut_method', "histogram")
        for name in self.autocut_methods:
            combobox.addItem(name)
            index += 1
        index = self.autocut_methods.index(method)
        combobox.setCurrentIndex(index)
        combobox.activated.connect(lambda w: self.set_autocut_params())

        b.hist_pct.setRange(0.90, 1.0)
        b.hist_pct.setValue(0.995)
        b.hist_pct.setSingleStep(0.001)
        b.hist_pct.setDecimals(5)
        b.hist_pct.valueChanged.connect(lambda w: self.set_autocut_params())
        b.hist_pct.setEnabled(method == 'histogram')

        fr.layout().addWidget(w, stretch=1, alignment=QtCore.Qt.AlignLeft)
        vbox.addWidget(fr, stretch=0, alignment=QtCore.Qt.AlignTop)

        fr = QtHelp.Frame("New Images")

        captions = (
            ('Cut New', 'combobox', 'Zoom New', 'combobox'),
            ('Center New', 'checkbutton', 'Follow New', 'checkbutton'),
            ('Raise New', 'checkbutton', 'Create thumbnail', 'checkbutton'),
        )
        w, b = QtHelp.build_info(captions)
        self.w.update(b)

        combobox = b.cut_new
        index = 0
        for name in self.autocut_options:
            combobox.addItem(name)
            index += 1
        option = self.t_.get('autocuts', "off")
        index = self.autocut_options.index(option)
        combobox.setCurrentIndex(index)
        combobox.activated.connect(self.set_autocuts_cb)
        b.cut_new.setToolTip("Automatically set cut levels for new images")

        combobox = b.zoom_new
        index = 0
        for name in self.autozoom_options:
            combobox.addItem(name)
            index += 1
        option = self.t_.get('autozoom', "off")
        index = self.autozoom_options.index(option)
        combobox.setCurrentIndex(index)
        combobox.activated.connect(self.set_autozoom_cb)
        b.zoom_new.setToolTip("Automatically fit new images to window")

        b.center_new.setToolTip("Automatically center new images")
        b.follow_new.setToolTip("View new images as they arrive")
        b.raise_new.setToolTip("Raise and focus tab for new images")
        b.create_thumbnail.setToolTip("Create thumbnail for new images")

        self.w.center_new.setChecked(True)
        self.w.center_new.stateChanged.connect(lambda w: self.set_chprefs_cb())
        self.w.follow_new.setChecked(True)
        self.w.follow_new.stateChanged.connect(lambda w: self.set_chprefs_cb())
        self.w.raise_new.setChecked(True)
        self.w.raise_new.stateChanged.connect(lambda w: self.set_chprefs_cb())
        self.w.create_thumbnail.setChecked(True)
        self.w.create_thumbnail.stateChanged.connect(
            lambda w: self.set_chprefs_cb())

        fr.layout().addWidget(w, stretch=1, alignment=QtCore.Qt.AlignLeft)
        vbox.addWidget(fr, stretch=0, alignment=QtCore.Qt.AlignTop)

        btns = QtHelp.HBox()
        layout = btns.layout()
        layout.setSpacing(3)
        #layout.set_child_size(15, -1)

        btn = QtGui.QPushButton("Save Settings")
        btn.clicked.connect(self.save_preferences)
        layout.addWidget(btn, stretch=0, alignment=QtCore.Qt.AlignLeft)
        btn = QtGui.QPushButton("Close")
        btn.clicked.connect(self.close)
        layout.addWidget(btn, stretch=0, alignment=QtCore.Qt.AlignLeft)
        vbox.addWidget(btns, stretch=0, alignment=QtCore.Qt.AlignLeft)

        #container.addWidget(sw, stretch=1, alignment=QtCore.Qt.AlignTop)
        container.addWidget(sw, stretch=1)

        self.gui_up = True