예제 #1
0
 def create_ui(self):
     columns = [
         Column('name', str),
         Column('surname', str),
         Column('email', str, editable=True),
     ]
     self.objects = ObjectList(columns)
     self.widget.add(self.objects)
예제 #2
0
    def test_make_cells(self):
        col = Column(title='Test',
                     cells=[
                         Cell('name', int),
                         Cell('name2', int),
                     ])
        view_col = col.create_treecolumn(None)

        self.assertEqual(len(view_col.get_cells()), 2)
예제 #3
0
 def test_tooltip_image_size(self):
     c = Column('test',
                tooltip_attr='attr',
                tooltip_type='iconname',
                tooltip_image_size=Gtk.IconSize.MENU)
     t = MockTooltip()
     o = Fruit()
     c.render_tooltip(t, o)
     self.assertEqual(t.iconname, 'value')
     self.assertEqual(t.size, Gtk.IconSize.MENU)
예제 #4
0
    def get_trace_view(self, exc, tb):
        olist = ObjectList([Column('markup', use_markup=True)])
        olist.set_headers_visible(False)

        while tb is not None:
            olist.append(TracebackEntry(tb))
            tb = tb.tb_next
        return olist
예제 #5
0
    def test_column_title(self):
        col = Column("name")
        view_col = col.create_treecolumn(None)
        self.assertEqual(view_col.get_title(), "Name")

        title_col = Column(title="Test", cells=[])
        title_view_col = title_col.create_treecolumn(None)
        self.assertEqual(title_view_col.get_title(), 'Test')
        self.assertEqual(len(title_view_col.get_cells()), 0)
예제 #6
0
    def create_ui(self):
        self.widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        columns = [
            Column(attr=self.column_name,
                   sortable=True,
                   editable=False,
                   resizeable=True)
        ]
        self.list_box = ObjectList(columns)
        for item in self.items:
            self.add_item(item)

        s = self.list_box.get_selection()
        s.set_mode(Gtk.SelectionMode.MULTIPLE)

        self.list_box.show_all()
        self.widget.pack_start(self.list_box)
예제 #7
0
 def test_tooltip_type_pixbuf_attr(self):
     c = Column('test', tooltip_attr='attr', tooltip_type='pixbuf')
     t = MockTooltip()
     o = Fruit()
     c.render_tooltip(t, o)
     self.assertEqual(t.pixbuf, 'value')
예제 #8
0
class User(object):
    def __init__(self, name, age, sex, hair='brown', clever=False):
        self.name = name
        self.age = age
        assert sex in ('m', 'f')
        self.sex = sex
        self.hair = hair
        self.clever = clever

    def __str__(self):
        return '<User: name=%r age=%r sex=%r hair=%r clever=%r>' % (
            self.name, self.age, self.sex, self.hair, self.clever)


listing = ObjectTree([
    Column('name', str, editable=True, searchable=True),
    Column('age', int, editable=True),
    Column('sex',
           str,
           expander=True,
           choices=[
               ('m', 'Male'),
               ('f', 'Female'),
           ]),
    Column('hair', str, choices=['brown', 'blonde'], tooltip_attr='name'),
    Column('clever', bool, use_checkbox=True, editable=True),
    Column('age', int, use_spin=True, editable=True),
    Column('age', int, use_progress=True),
    Column('age', int, use_progress=True, progress_text='static_text'),
    Column('age', int, use_progress=True, mapped={'text': 'name'}),
])
예제 #9
0
 def test_tooltip_type_text_attr(self):
     c = Column('test', tooltip_attr='attr')
     t = MockTooltip()
     o = Fruit()
     c.render_tooltip(t, o)
     self.assertEqual(t.text, 'value')
예제 #10
0
 def test_column_expandable(self):
     col = Column('name', expand=True)
     tree_view_column = col.create_treecolumn(None)
     self.assertTrue(tree_view_column.props.expand)
예제 #11
0
from pyGtkHelpers.ui.objectlist import ObjectList, ObjectTree, Column


class User(object):
    def __init__(self, name, age):
        self.name = name
        self.age = age

    def __eq__(self, other):
        return self.name == other.name and self.age == other.age


items = [
    Column('name', str, editable=True, searchable=True),
    Column('age', int),
    Column('expander', expander=True),
]


def pytest_generate_tests(metafunc):
    if ('items' in metafunc.funcargnames or
            'searchcheck' in metafunc.funcargnames):
        if not hasattr(metafunc.function, 'tree_only'):
            metafunc.addcall(id='list', param=ObjectList)
        if not hasattr(metafunc.function, 'list_only'):
            metafunc.addcall(id='tree', param=ObjectTree)


def pytest_funcarg__items(request):
    return request.param(items)
예제 #12
0
 def test_column_invisiblility(self):
     col = Column('test', visible=False)
     view_col = col.create_treecolumn(None)
     self.assertFalse(view_col.get_visible())
예제 #13
0
 def test_column_width(self):
     col = Column('test', width=30)
     view_col = col.create_treecolumn(None)
     refresh_gui()
     self.assertEqual(view_col.get_sizing(), Gtk.TreeViewColumnSizing.FIXED)
     self.assertEqual(view_col.get_fixed_width(), 30)
예제 #14
0
 def test_tooltip_type_markup_value(self):
     c = Column('test', tooltip_value='banana', tooltip_type='markup')
     t = MockTooltip()
     o = Fruit()
     c.render_tooltip(t, o)
     self.assertEqual(t.markup, 'banana')
예제 #15
0
 def test_column_visiblility(self):
     col = Column('test')
     view_col = col.create_treecolumn(None)
     self.assertTrue(view_col.get_visible())
예제 #16
0
 def test_tooltip_type_markup_attr(self):
     c = Column('test', tooltip_attr='attr', tooltip_type='markup')
     t = MockTooltip()
     o = Fruit()
     c.render_tooltip(t, o)
     self.assertEqual(t.markup, 'value')
예제 #17
0
 def test_tooltip_type_custom_value(self):
     c = Column('test', tooltip_value='banana', tooltip_type='custom')
     t = MockTooltip()
     o = Fruit()
     c.render_tooltip(t, o)
     self.assertEqual(t.custom, 'banana')
예제 #18
0
 def test_tooltip_type_pixbuf_value(self):
     c = Column('test', tooltip_value='banana', tooltip_type='pixbuf')
     t = MockTooltip()
     o = Fruit()
     c.render_tooltip(t, o)
     self.assertEqual(t.pixbuf, 'banana')
예제 #19
0
 def test_tooltip_type_iconname_attr(self):
     c = Column('test', tooltip_attr='attr', tooltip_type='iconname')
     t = MockTooltip()
     o = Fruit()
     c.render_tooltip(t, o)
     self.assertEqual(t.iconname, 'value')
예제 #20
0
 def test_tooltip_type_iconname_value(self):
     c = Column('test', tooltip_value='banana', tooltip_type='iconname')
     t = MockTooltip()
     o = Fruit()
     c.render_tooltip(t, o)
     self.assertEqual(t.iconname, 'banana')
예제 #21
0
 def test_tooltip_type_stock_attr(self):
     c = Column('test', tooltip_attr='attr', tooltip_type='stock')
     t = MockTooltip()
     o = Fruit()
     c.render_tooltip(t, o)
     self.assertEqual(t.stock, 'value')
예제 #22
0
 def test_tooltip_type_stock_value(self):
     c = Column('test', tooltip_value='banana', tooltip_type='stock')
     t = MockTooltip()
     o = Fruit()
     c.render_tooltip(t, o)
     self.assertEqual(t.stock, 'banana')
예제 #23
0

class User(object):
    def __init__(self, name, age, sex):
        self.name = name
        self.age = age
        assert sex in ('m', 'f')
        self.sex = sex

    def __str__(self):
        return '<User: name=%r age=%r sex=%r>' % (self.name, self.age,
                                                  self.sex)


listing = ObjectList([
    Column('name', str, editable=False, resizable=True),
    Column('age', int, editable=True),
    Column('sex', str, choices=[
        ('m', 'Male'),
        ('f', 'Female'),
    ]),
])


def _on_left_clicked(ol, item, event):
    print 'Left clicked', item


def _on_right_clicked(ol, item, event):
    print 'Right clicked', item
예제 #24
0

class IconInfo(object):
    def __init__(self, stock_name, name):
        self.stock_name = stock_name
        self._name = name

    @property
    def name(self):
        return '<b>%s</b>' % self._name


icons = ObjectList([
    Column(title='Stock Data',
           cells=[
               Cell('stock_name', gtk.Pixmap, use_stock=True),
               Cell('stock_name', str),
           ],
           sorted=False),
    Column('name', str, 'Name', use_markup=True),
],
                   sortable=True)

for id in gtk.stock_list_ids():
    lookup = gtk.stock_lookup(id)
    if lookup is None:
        continue
    stock_name, name = gtk.stock_lookup(id)[:2]
    name = name.replace('_', '')
    icons.append(IconInfo(stock_name, name))

scroll = gtk.ScrolledWindow()