Пример #1
0
    def __init__(self, dataset, parent=None):

        self.dataset = dataset

        gtk.Dialog.__init__(self, "Edit Structure", parent,
                            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                            (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                             gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
        self.set_size_request(480,300)

        #
        # button box
        #

        buttons = [(gtk.STOCK_EDIT, self.on_row_activated),
                   (gtk.STOCK_NEW, self.on_btn_add_clicked),
                   (gtk.STOCK_REMOVE, self.on_btn_remove_clicked),
                   (gtk.STOCK_GO_UP, self.on_btn_move_clicked, -1),
                   (gtk.STOCK_GO_DOWN, self.on_btn_move_clicked, +1)
                   ]

        btnbox = uihelper.construct_vbuttonbox(buttons)
        btnbox.set_spacing(uihelper.SECTION_SPACING)
        btnbox.set_border_width(uihelper.SECTION_SPACING)
                
                
        # cview = column view
        cview = ColumnView(dataset)
        cview.connect( "row-activated", self.on_row_activated )        
        self.cview = cview

        # put cview and btnbox next to each other into a hbox
        hbox = gtk.HBox()
        hbox.set_spacing(5)
        hbox.pack_start(cview, True, True)
        hbox.pack_start(btnbox, False, True)

        self.vbox.add(hbox)
        self.show_all()
Пример #2
0
    def __init__(self, layer):
        AbstractTab.__init__(self)
        self.layer = layer

        #
        # Construct TreeView and ButtonBox
        #

        keys = ['visible', 'label', 'style', 'width', 'color', 'marker', 'marker_color', 'marker_size', 'source', 'cx', 'cy', 'row_first', 'row_last']
        self.factory = widget_factory.CTreeViewFactory(layer, 'lines')
        self.factory.add_columns(keys, source=self.create_source_column)
        self.treeview = self.factory.create_treeview()
        sw = uihelper.add_scrollbars(self.treeview)

        #
        # keybox = label + key_combo 
        #
        model = gtk.ListStore(str, object)
        key_combo = gtk.ComboBox(model)
        cell = gtk.CellRendererText()
        key_combo.pack_start(cell, True)
        key_combo.add_attribute(cell, 'text', 0)
        key_combo.connect('changed', lambda cb: self.limit_columns())
        self.key_combo = key_combo # for use in limit_columns()
        
        viewdict = {'all' : ['_all'],
                    'style' : ['visible', 'label', 'style', 'width', 'color', 'marker', 'marker_color', 'marker_size'],
                    'data' : ['visible', 'label', 'source', 'cx', 'cy', 'row_first', 'row_last']}
        for key, alist in viewdict.iteritems():
            model.append((key, alist))

        keybox = gtk.HBox(False, 5)
        keybox.pack_start(gtk.Label("Display:"), False, False)
        keybox.pack_start(key_combo, False, False)
        keybox.pack_start(gtk.Label(), True, True)

        self.key_combo.set_active(0)
        self.limit_columns()
        
        buttons = [(gtk.STOCK_ADD, self.on_insert_new),
                   (gtk.STOCK_REMOVE, self.on_remove_selection),
                   (gtk.STOCK_GO_UP, self.on_move_selection, -1),
                   (gtk.STOCK_GO_DOWN, self.on_move_selection, +1)]        
        buttonbox = uihelper.construct_vbuttonbox(buttons, labels=False)
        
        hbox = gtk.HBox(False, 5)
        hbox.pack_start(sw, True, True)
        hbox.pack_start(buttonbox, False, True)

        vbox = gtk.VBox(False, 5)
        vbox.pack_start(keybox, False, False)
        vbox.pack_start(hbox)
        
        frame1 = uihelper.new_section('Lines', vbox)
        
        #
        # Construct Group Boxes
        #
        #self.gblist = [GroupBox(self.layer, 'group_linestyle'),
        #               GroupBox(self.layer, 'group_linemarker'),
        #               GroupBox(self.layer, 'group_linewidth'),
        #               GroupBox(self.layer, 'group_linecolor')]
        self.gblist = []

        # DISABLE GROUP BOXES RIGHT NOW!
        self.gblist = []

#         # Wrap group boxes into a table       
#         table = gtk.Table(rows=len(self.gblist), columns=3)

#         n = 0
#         for widget in self.gblist:
#             # label (put into an event box to display the tooltip)
#             label = gtk.Label(widget.prop.blurb or widget.propname)
#             ebox = gtk.EventBox()
#             ebox.add(label)
#             if widget.prop.doc is not None:
#                 tooltips.set_tip(ebox, widget.prop.doc)
            
#             table.attach(ebox, 0, 1, n, n+1,
#                          xoptions=gtk.FILL, yoptions=0,
#                          xpadding=5, ypadding=1)            
#             table.attach(widget, 1, 2, n, n+1,
#                          xoptions=gtk.EXPAND|gtk.FILL, yoptions=0,
#                          xpadding=5, ypadding=1)
#             n += 1       

#         frame2 = uihelper.new_section('Group Properties', table)

        #
        # Put everything together!
        #
        self.pack_start(frame1,True,True)

        # DISABLE GROUP BOXES RIGHT NOW
        #self.pack_start(frame2,False,True)

        self.show_all()
    def __init__(self):
        gtk.VBox.__init__(self)
    
        # We create copies of all templates and put these into the
        # treeview.  This allows the user to reject the modifications
        # (RESPONSE_REJECT).  If however he wishes to use the
        # modifications (RESPONSE_ACCEPT), then we simply need to
        # replace the current templates with these temporary ones.

        # check in
        self.model = gtk.ListStore(str, object) # key, object
        model = self.model # TBR

        #
        # create gui
        #
        # columns should be created in the order given by COLUMN_xxx
        # definitions above.
        tv = gtk.TreeView(model)

        tv.set_headers_visible(False)

        cell = gtk.CellRendererText()
        column = gtk.TreeViewColumn()
        column.pack_start(cell)

        def render(column, cell, model, iter):
            object = model.get_value(iter, self.MODEL_OBJECT)
            key = model.get_value(iter, self.MODEL_KEY)

            key = "<big><b>%s</b></big>" % key

            if object.blurb is not None:
                blurb = "<i>%s</i>" % object.blurb
            else:
                blurb = "<i>no description</i>"

            if object.immutable is True:
                blurb += " <i>(immutable)</i>"

            text = "%s\n%s" % (key, blurb)

            cell.set_property('markup', text)

        column.set_cell_data_func(cell, render)
        tv.append_column(column)
            
        self.treeview = tv
        sw = uihelper.add_scrollbars(tv)

        tv.connect("row-activated", (lambda a,b,c: self.on_edit_item(a,c)))
                    
        buttons=[(gtk.STOCK_EDIT, self.on_edit_item),
                 (gtk.STOCK_ADD, self.on_add_item),
                 (gtk.STOCK_COPY, self.on_copy_item),
                 (gtk.STOCK_DELETE, self.on_delete_item)]

        btnbox = uihelper.construct_vbuttonbox(buttons)
        btnbox.set_spacing(uihelper.SECTION_SPACING)
        btnbox.set_border_width(uihelper.SECTION_SPACING)

        sw.set_border_width(uihelper.SECTION_SPACING)


        hbox = gtk.HBox()
        hbox.pack_start(sw,True,True)
        hbox.pack_start(btnbox,False,True)
        
        frame = uihelper.new_section("Import Templates", hbox)
        self.add(frame)
        self.show_all()