Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUp(self):
self.klist = ObjectList([Column('name', sorted=True)],
[Settable(name='first')])
def __init__(self):
Delegate.__init__(self, gladefile="news_shell.ui",
delete_handler=self.quit_if_last)
# paint header and footer; they are eventboxes that hold a
# label and buttonbox respectively
gadgets.set_background(self.header, "white")
gadgets.set_background(self.footer, "#A0A0A0")
gadgets.set_foreground(self.title, "blue")
# Create the delegate and set it up
objectlist = ObjectList(my_columns, news)
objectlist.connect('selection-changed', self.news_selected)
objectlist.connect('double-click', self.double_click)
slave = SlaveDelegate(toplevel=objectlist)
self.attach_slave("placeholder", slave)
slave.focus_toplevel() # Must be done after attach
self.slave = slave
def __init__(self, columns=[],
instance_list=None,
mode=gtk.SELECTION_BROWSE):
deprecationwarn(
'List is deprecated, use ObjectList instead',
stacklevel=3)
ObjectList.__init__(self, columns, instance_list, mode)
the row currently in this object list. When not None, we will use
the values of data instead of the object list. This gives the
callsite an oportunity to override the values in the object list.
"""
attributes = []
for column in self.get_visible_columns():
attributes.append(column.attribute)
for item in (data or self):
row = []
for attribute in attributes:
row.append(getattr(item, attribute, None))
yield row
type_register(ObjectList)
class ObjectTree(ObjectList):
"""
Signals
=======
- B{row-expanded} (list, object):
- Emitted when a row is "expanded", eg the littler arrow to the left
is opened. See the GtkTreeView documentation for more information.
"""
__gtype_name__ = 'ObjectTree'
gsignal('row-expanded', object)
def __init__(self, columns=[], objects=None, mode=Gtk.SelectionMode.BROWSE,
sortable=False, model=None):
def add_tab(self, name):
box = Gtk.HBox()
box.set_border_width(6)
box.show()
olist = ObjectList()
box.pack_start(olist, True, True, 0)
olist.show()
self.history_notebook.append_page(box, Gtk.Label(label=name))
return olist
def _setup_list(self):
methods = PaymentMethod.get_editable_methods(self.store)
self.klist = ObjectList(self._get_columns(), methods,
Gtk.SelectionMode.BROWSE)
self.klist.connect("selection-changed",
self._on_klist__selection_changed)
self.klist.connect("row-activated", self._on_klist__row_activated)
self.klist.connect("cell-edited", self.on_cell_edited)
self.main.remove(self.main.get_child())
self.main.add(self.klist)
self.klist.show()
def _create_ui(self):
hbox = Gtk.HBox()
self.klist = ObjectList([Column('name')])
self.klist.set_size_request(150, -1)
self.klist.get_treeview().set_headers_visible(False)
self.klist.connect('selection-changed',
self._on_klist__selection_changed)
hbox.pack_start(self.klist, True, True, 0)
hbox.show()
for name, ctype in [(_(u'Units'), DeviceConstant.TYPE_UNIT),
(_(u'Tax'), DeviceConstant.TYPE_TAX),
(_(u'Payments'), DeviceConstant.TYPE_PAYMENT)]:
self.klist.append(Settable(name=name, type=ctype))
self.klist.show()
self._constant_slave = _DeviceConstantsList(self.store, self.printer)
self._constant_slave.switch(DeviceConstant.TYPE_UNIT)
self.categories = ObjectList(
[Column('label', sorted=True, expand=True)],
get_binding_categories(),
Gtk.SelectionMode.BROWSE)
self.categories.connect('selection-changed',
self._on_categories__selection_changed)
self.categories.set_headers_visible(False)
self.categories.set_size_request(200, -1)
hbox.pack_start(self.categories, False, False, 0)
self.categories.show()
box = Gtk.VBox(spacing=6)
hbox.pack_start(box, True, True, 0)
box.show()
self.shortcuts = ObjectList(self._get_columns(), [],
Gtk.SelectionMode.BROWSE)
box.pack_start(self.shortcuts, True, True, 0)
self.shortcuts.show()
self._label = Gtk.Label(
label=_("You need to restart Stoq for the changes to take effect"))
box.pack_start(self._label, False, False, 6)
box.show()
defaults_button = Gtk.Button.new_with_label(_("Reset defaults"))
defaults_button.connect('clicked', self._on_defaults_button__clicked)
self.action_area.pack_start(defaults_button, False, False, 6)
self.action_area.reorder_child(defaults_button, 0)
defaults_button.show()
def __populate_spec(self, components):
self.frame_components.remove(self.spec_list)
if isinstance(components[0], gwp.models.Engine):
# Engine
self.spec_list = ObjectList([
Column('name', data_type=str),
Column('cost', data_type=int),
Column('tri', data_type=int),
Column('dur', data_type=int),
Column('mol', data_type=int),
Column('tech', data_type=int),
Column('fuel_use', data_type=int),
# TODO add calculated data
])
# Beam
else:
if isinstance(components[0], gwp.models.Beam):
self.spec_list = ObjectList([
Column('name', data_type=str),
Column('kill', data_type=int),
Column('damage', data_type=int),
def _create_field_list(self):
items = ObjectList([Column('category', sorted=True),
Column('description', width=200),
Column('len', data_type=int, visible=False)])
items.enable_dnd()
items.set_size_request(200, -1)
descriptions = {}
invoice_fields = get_invoice_fields()
for invoice_field in sorted(invoice_fields,
key=operator.attrgetter('name')):
items.append(
Settable(description=invoice_field.get_description(),
name=invoice_field.name,
len=invoice_field.length,
category=invoice_field.category))
descriptions[invoice_field.name] = invoice_field.description
self._field_descriptions = descriptions
self.left_vbox.pack_end(items, True, True, 0)