Example #1
0
    def __init__(self, model, parent):
        super(DetailsTab, self).__init__()

        self.model = model
        self._parent = parent

        self.set_spacing(6)
        self.set_border_width(6)

        self.klist = ObjectTree(self.get_columns())
        self.populate()

        self.pack_start(self.klist)
        self.klist.show()

        if len(self.klist) and self.get_details_dialog_class():
            self.button_box = gtk.HButtonBox()
            self.button_box.set_layout(gtk.BUTTONBOX_START)

            details_button = gtk.Button(self.details_lbl)
            self.button_box.pack_start(details_button)
            details_button.set_sensitive(bool(self.klist.get_selected()))
            details_button.show()

            self.pack_end(self.button_box, False, False)
            self.button_box.show()

            self.button_box.details_button = details_button
            details_button.connect('clicked', self._on_details_button__clicked)

            self.klist.connect('row-activated', self._on_klist__row_activated)
            self.klist.connect('selection-changed',
                               self._on_klist__selection_changed)

        self.setup_widgets()
Example #2
0
    def __init__(self,
                 store,
                 columns=None,
                 editor_class=None,
                 klist_objects=None,
                 visual_mode=False,
                 restore_name=None,
                 tree=False):
        """ Creates a new AdditionListSlave object

        :param store:         a store
        :param columns:       column definitions
        :type columns:        sequence of :class:`kiwi.ui.objectlist.Columns`
        :param editor_class:  the window that is going to be open when user
                              clicks on add_button or edit_button.
        :type: editor_class:  a :class:`stoqlib.gui.editors.BaseEditor` subclass
        :param klist_objects: initial objects to insert into the list
        :param visual_mode:   if we are working on visual mode, that means,
                              not possible to edit the model on this object
        type visual_mode:     bool
        :param restore_name:  the name used to save and restore the columns
                              on a cache system (e.g. pickle)
        :type restore_name:   basestring
        :param tree:          Indication of which kind of list we are adding.
                              If `True` ObjectTree otherwise ObjectList will be
                              added
        """
        columns = columns or self.get_columns()
        SearchSlave.__init__(self,
                             columns=columns,
                             restore_name=restore_name,
                             store=store)
        self.tree = tree
        self.klist = ObjectTree() if tree else ObjectList()
        self.list_vbox.add(self.klist)
        self.list_vbox.show_all()

        if not self.columns:
            raise StoqlibError("columns must be specified")
        self.visual_mode = visual_mode
        self.store = store
        self.set_editor(editor_class)
        self._can_edit = True
        self._callback_id = None
        if self.visual_mode:
            self.hide_add_button()
            self.hide_edit_button()
            self.hide_del_button()
        items = klist_objects or self.get_items()
        self._setup_klist(items)
        self._update_sensitivity()
Example #3
0
    def __init__(self, parent, menubar):
        self.project_data = ObjectTree([
            Column('name', use_markup=True, data_type=str, sorted=True),
            Column('info')
        ])

        self.project_data.connect('row-activated', self.on_row_activated)
        self.model_tree = Project()
        self._set_treeview_hooks()

        self.menubar = menubar

        self.set_parent(parent)

        self.filename = ''

        self.undo_stack = UndoStack(self.model_tree.__repr__, self.import_file,
                                    self.project_data.select, menubar,
                                    self.meta, 'Initialization')

        SlaveDelegate.__init__(self, toplevel=self.project_data)
Example #4
0
import gtk

from kiwi.ui.objectlist import Column, ObjectTree


class Fruit:
    def __init__(self, name, price):
        self.name = name
        self.price = price


class FruitDesc:
    def __init__(self, name):
        self.name = name

fruits = ObjectTree([Column('name', data_type=str),
                     Column('price', data_type=int)])

for name, price in [('Apple', 4),
                    ('Pineapple', 2),
                    ('Kiwi', 8),
                    ('Banana', 3),
                    ('Melon', 5)]:
    row = fruits.append(None, FruitDesc(name))
    fruits.append(row, Fruit('Before taxes', price * 0.25))
    fruits.append(row, Fruit('After taxes', price))

window = gtk.Window()
window.connect('delete-event', gtk.main_quit)
window.set_title('Fruits')
window.set_size_request(150, 180)
Example #5
0
 def setUp(self):
     self.win = Gtk.Window()
     self.win.set_default_size(400, 400)
     self.tree = ObjectTree([Column('name'), Column('age')])
     self.win.add(self.tree)
     refresh_gui()