コード例 #1
0
    def __init__(self, orientation='horizontal', track=False):
        super(Slider, self).__init__()

        if orientation == 'horizontal':
            w = GtkHelp.HScale()
            # TEMP: hack because scales don't seem to expand as expected
            w.set_size_request(200, -1)
        else:
            w = GtkHelp.VScale()
            w.set_size_request(-1, 200)
        self.widget = w

        w.set_draw_value(True)
        w.set_value_pos(gtk.POS_BOTTOM)
        self.set_tracking(track)
        w.sconnect('value-changed', self._cb_redirect)

        self.enable_callback('value-changed')
コード例 #2
0
    def build_gui(self, container):

        vpaned = gtk.VPaned()

        width, height = 200, 200

        # Uncomment to debug; passing parent logger generates too
        # much noise in the main logger
        #zi = FitsImageCanvasGtk.FitsImageCanvas(logger=self.logger)
        zi = FitsImageCanvasGtk.FitsImageCanvas(logger=None)
        zi.enable_autozoom('off')
        zi.enable_autocuts('off')
        zi.enable_zoom(False)
        #zi.set_scale_limits(0.001, 1000.0)
        zi.zoom_to(self.default_zoom, redraw=False)
        zi.add_callback('zoom-set', self.zoomset)
        #zi.add_callback('motion', self.showxy)
        zi.set_bg(0.4, 0.4, 0.4)
        zi.show_pan_mark(True, redraw=False)
        self.zoomimage = zi

        iw = zi.get_widget()
        iw.set_size_request(width, height)
        vpaned.pack1(iw, resize=True, shrink=True)

        vbox = gtk.VBox()
        vbox.pack_start(gtk.Label("Zoom Radius:"),
                        padding=2,
                        fill=True,
                        expand=False)

        adj = gtk.Adjustment(lower=1, upper=100)
        adj.set_value(self.zoom_radius)
        scale = GtkHelp.HScale(adj)
        scale.set_size_request(200, -1)
        scale.set_digits(0)
        scale.set_draw_value(True)
        scale.set_value_pos(gtk.POS_BOTTOM)
        #scale.set_update_policy(gtk.UPDATE_DISCONTINUOUS)
        self.w_radius = scale
        scale.connect('value-changed', self.set_radius_cb)
        vbox.pack_start(scale, padding=0, fill=True, expand=False)

        vbox.pack_start(gtk.Label("Zoom Amount:"),
                        padding=2,
                        fill=True,
                        expand=False)

        adj = gtk.Adjustment(lower=-20, upper=30)
        adj.set_value(self.zoom_amount)
        scale = GtkHelp.HScale(adj)
        scale.set_size_request(200, -1)
        scale.set_digits(0)
        scale.set_draw_value(True)
        scale.set_value_pos(gtk.POS_BOTTOM)
        #scale.set_update_policy(gtk.UPDATE_DISCONTINUOUS)
        self.w_amount = scale
        scale.connect('value-changed', self.set_amount_cb)
        vbox.pack_start(scale, padding=0, fill=True, expand=False)

        captions = (
            ('Zoom', 'label'),
            ("Relative Zoom", 'checkbutton'),
            ("Lag Time", 'spinbutton'),
            ('Defaults', 'button'),
        )

        w, b = GtkHelp.build_info(captions)
        b.zoom.set_text(self.fv.scale2text(zi.get_scale()))
        self.wzoom = b
        b.relative_zoom.set_active(not self.t_abszoom)
        b.relative_zoom.sconnect("toggled", self.set_absrel_cb)
        b.defaults.connect("clicked", lambda w: self.set_defaults())
        adj = b.lag_time.get_adjustment()
        adj.configure(0, 0, 20, 1, 1, 1)
        adj.set_value(self.lagtime)
        b.lag_time.set_digits(0)
        b.lag_time.set_wrap(True)
        b.lag_time.connect('value-changed', self.setlag_cb)
        vbox.pack_start(w, padding=4, fill=True, expand=False)

        sw = gtk.ScrolledWindow()
        sw.set_border_width(2)
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.add_with_viewport(vbox)

        vpaned.pack2(sw, resize=True, shrink=True)
        vpaned.show_all()
        vpaned.set_position(height)

        container.pack_start(vpaned, padding=0, fill=True, expand=True)