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 = ObjectList(self.get_columns()) self.klist.add_list(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()
def create_list(self): self._list = ObjectList([ Column('done', title=_('Done'), data_type=bool, editable=True), Column('title', title=_('Title'), data_type=str, editable=True, expand=True), Column('priority', title=_('Priority'), data_type=ChecklistStatus, editable=True) ]) self._list.connect('cell-edited', self._on_item_edit) self._list.connect('selection-changed', self._on_item_selected) self._list.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self._vbox.add(self._list) self._sort_combo = AttrSortCombo(self._list, [ ('done', _('Done')), ('title', _('Title')), ('priority', _('Priority')), ], 'title') self._vbox.pack_start(self._sort_combo, expand=False) self._list.show_all() self._sort_combo.show_all()
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) 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) hbox.pack_start(self._constant_slave.get_toplevel()) # FIXME: redesign BasicDialog self.main.remove(self.main_label) self.main.add(hbox) hbox.show_all()
def setUp(self): self.klist = ObjectList() self.klist.connect('has-rows', self._on_klist__has_rows) self.klist.connect('selection-changed', self._on_klist__selection_changed) self.rows = None self.selected = None
def _create_list(self, column_title): object_list = ObjectList([ KanbanObjectListColumn('markup', title=column_title, data_type=str, use_markup=True, expand=True), ]) object_list.connect('row-activated', self._on_row_activated) object_list.connect('right-click', self._on_right_click) sw = object_list.get_scrolled_window() sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.set_shadow_type(gtk.SHADOW_NONE) treeview = object_list.get_treeview() treeview.set_name(column_title) treeview.connect( "button-press-event", self._on_button_press_event) treeview.set_rules_hint(False) column = object_list.get_column_by_name('markup') column.treeview_column.set_clickable(False) white = gtk.gdk.color_parse('white') treeview.modify_base(gtk.STATE_ACTIVE, white) treeview.modify_base(gtk.STATE_SELECTED, white) object_list.set_cell_data_func(self._on_results__cell_data_func) return object_list
def _create_ui(self): hbox = Gtk.HBox() self.main.remove(self.main.get_child()) self.main.add(hbox) hbox.show() self.forms = ObjectList( [Column('description', title=_('Description'), sorted=True, expand=True, format_func=stoqlib_gettext)], self.store.find(UIForm), Gtk.SelectionMode.BROWSE) self.forms.connect('selection-changed', self._on_forms__selection_changed) self.forms.set_headers_visible(False) self.forms.set_size_request(200, -1) hbox.pack_start(self.forms, False, False, 0) self.forms.show() box = Gtk.VBox() hbox.pack_start(box, True, True, 0) box.show() self.fields = ObjectList(self._get_columns(), [], Gtk.SelectionMode.BROWSE) box.pack_start(self.fields, True, True, 0) self.fields.show() box.show()
def _setup_widgets(self): self.set_ok_label(_(u'Activate'), gtk.STOCK_APPLY) self.ok_button.set_sensitive(False) plugins = [] for name in sorted(self._manager.available_plugins_names): # FIXME: Remove when magento plugin is functional for end users if not is_developer_mode() and name == 'magento': continue if platform.system() == 'Windows': if name in ['ecf', 'tef']: continue desc = self._manager.get_description_by_name(name) plugins.append( _PluginModel(name, name in self._manager.installed_plugins_names, desc)) self.klist = ObjectList(self._get_columns(), plugins, gtk.SELECTION_BROWSE) self.klist.set_headers_visible(False) self.klist.connect("selection-changed", self._on_klist__selection_changed) self.main.remove(self.main.get_child()) self.main.add(self.klist) self.klist.show()
def test_export_from_object_list(self): from kiwi.ui.objectlist import ObjectList, Column fruits = ObjectList( [Column('name', data_type=str), Column('price', data_type=int)]) for name, price in [('Apple', 4), ('Pineapple', 2), ('Kiwi', 8), ('Banana', 3), ('Melon', 5)]: fruits.append(Fruit(name, price)) ofx = XLSExporter() ofx.add_from_object_list(fruits) try: temp_file = ofx.save() with open(temp_file.name, 'rb') as f: data = f.read() # We should use xlrd to 're-open' the spreadsheet and parse its content. self.assertTrue(len(data) > 0) finally: temp_file.close() os.unlink(temp_file.name)
def test_export_from_object_list(self): fruits = ObjectList([Column('name', data_type=str), Column('price', data_type=int)]) for name, price in [('Apple', 4), ('Pineapple', 2), ('Kiwi', 8), ('Banana', 3), ('Melon', 5)]: fruits.append(Fruit(name, price)) ofx = XLSExporter() ofx.add_from_object_list(fruits) try: temp_file = ofx.save() data = open(temp_file.name).read() # We should use xlrd to 're-open' the spreadsheet and parse its content. self.assertTrue(len(data) > 0) finally: temp_file.close() os.unlink(temp_file.name)
def _create_ui(self): hbox = gtk.HBox() self.main.remove(self.main.get_child()) self.main.add(hbox) hbox.show() self.forms = ObjectList( [Column('description', title=_('Description'), sorted=True, expand=True, format_func=stoqlib_gettext)], self.store.find(UIForm), gtk.SELECTION_BROWSE) self.forms.connect('selection-changed', self._on_forms__selection_changed) self.forms.set_headers_visible(False) self.forms.set_size_request(200, -1) hbox.pack_start(self.forms, False, False) self.forms.show() box = gtk.VBox() hbox.pack_start(box) box.show() self.fields = ObjectList(self._get_columns(), [], gtk.SELECTION_BROWSE) box.pack_start(self.fields) self.fields.show() box.show()
def setup_slaves(self): self.delivery_items = ObjectList( columns=self._get_delivery_items_columns(), objects=self.model.delivery_items, ) self.delivery_items_holder.add(self.delivery_items) self.delivery_items.show()
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)
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)
def add_tab(self, name): box = gtk.HBox() box.set_border_width(6) box.show() olist = ObjectList() box.pack_start(olist) olist.show() self.history_notebook.append_page(box, gtk.Label(name)) return olist
def testOneColumn(self): # column's attribute can not contain spaces self.assertRaises(AttributeError, Column, 'test column') mylist = ObjectList(Column('test_column')) self.win.add(mylist) refresh_gui() self.assertEqual(1, len(mylist.get_columns()))
def __init__(self, parent): self.parent = parent self.news_list = ObjectList([ Column('title', 'Title of article', str), Column('author', 'Author of article', str), Column('url', 'Address of article', str)]) SlaveDelegate.__init__(self, toplevel=self.news_list) self.news_list.add_list(news) self.news_list.select(self.news_list[0])
def create_objectlist(self, icon_name, text): l = ObjectList([Column('title', use_markup=True)]) l.connect('row-activated', self._on_item_activated) l.connect('selection-changed', self._on_item_selected) l.set_headers_visible(False) l.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self._books.append_page(l, tab_label=self.create_tab_label( icon_name, text)) return l
class Diary(ProxyDelegate): def __init__(self): self.entries = ObjectList([Column("title", width=120), Column("period", width=80), Column("text", expand=True)]) ProxyDelegate.__init__(self, DiaryEntry(), ['title', 'period', 'text'], gladefile="diary", delete_handler=self.quit_if_last) self.hbox.pack_start(self.entries) self.entries.show() self.entries.grab_focus() def on_add__clicked(self, button): entry = DiaryEntry() entry.title = 'New title' self.set_model(entry) self.entries.append(entry) self.title.grab_focus() def on_remove__clicked(self, button): entry = self.entries.get_selected() if entry: self.entries.remove(entry) def on_entries__selection_changed(self, entries, instance): if instance: self.set_model(instance)
class SimpleListDialog(BasicDialog): size = (500, 400) def __init__(self, columns, objects, hide_cancel_btn=True, title='', multiple=True, header_text=""): """ Create a new SimpleListDialog. :param columns: :param objects: :param hide_cancel_btn: :param title: :param multiple: if we're allowed to select multiple items :type multiple: boolean """ BasicDialog.__init__(self, size=self.size, title=title, header_text=header_text) if hide_cancel_btn: self.cancel_button.hide() if multiple: selection_mode = gtk.SELECTION_MULTIPLE else: selection_mode = gtk.SELECTION_BROWSE self.setup_slave(columns, objects, selection_mode) def setup_slave(self, columns, objects, selection_mode): self.main.remove(self.main_label) self._klist = ObjectList(columns, objects, selection_mode) self.main.add(self._klist) self._klist.show() def get_selection(self): mode = self._klist.get_selection_mode() if mode == gtk.SELECTION_MULTIPLE: return self._klist.get_selected_rows() selection = self._klist.get_selected() if not selection: return [] return [selection] # # BasicDialog # def confirm(self): super(SimpleListDialog, self).confirm() self.retval = self.retval and self.get_selection()
class Diary(ProxyDelegate): def __init__(self): self.entries = ObjectList([ Column("title", width=120), Column("period", width=80), Column("text", expand=True) ]) ProxyDelegate.__init__(self, DiaryEntry(), ['title', 'period', 'text'], gladefile="diary.ui", delete_handler=self.quit_if_last) self.hbox.pack_start(self.entries, True, True, 0) self.entries.show() self.entries.grab_focus() def on_add__clicked(self, button): entry = DiaryEntry() entry.title = 'New title' self.set_model(entry) self.entries.append(entry) self.title.grab_focus() def on_remove__clicked(self, button): entry = self.entries.get_selected() if entry: self.entries.remove(entry) def on_entries__selection_changed(self, entries, instance): if instance: self.set_model(instance)
def __init__(self, ResultClass, results): columns = [] sorted = True for field_name, FieldClass in ResultClass._field_spec.iteritems(): if not FieldClass.expensive: title = label(FieldClass) column = Column(field_name, title, data_type=str, sorted=sorted) columns.append(column) sorted = False ObjectList.__init__(self, columns, results)
def setup_side(self): columns = ['user', 'sum', 'type', 'version', 'ip'] columns = [Column(s) for s in columns] self.versionlist = ObjectList(columns) self.view.side_vbox.pack_start(gtk.Label('Version Log:'), False, False) self.view.side_vbox.add(self.versionlist) self.view.side_vbox.pack_start(gtk.Label('BackLinks:'), False, False) self.backlinks = ObjectList([Column('name')]) self.view.side_vbox.add(self.backlinks)
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 testRadioWithoutTrue(self): olist = ObjectList( [Column('foo', radio=True, data_type=bool, editable=True)]) column = olist.get_treeview().get_column(0) renderer = column.get_cells()[0] items = [Settable(foo=False) for i in range(5)] olist.add_list(items) self.assertEqual(items[0].foo, False) renderer.emit('toggled', 0) self.assertEqual(items[0].foo, True)
def __init__(self): listt = ObjectList(self.columns) listt.connect('selection-changed', self.selected) # selecting categories f = urllib.urlopen("http://pacnet.archlinux.pl/api/categories/").read() categories=json.loads(f) for category in categories: row = CategoryItem(category['fields']['name']) listt.append(row) SlaveView.__init__(self, listt)
def __init__(self): self.entries = ObjectList([Column("title", width=120, sorted=True), Column("period", width=80), Column("text", expand=True, visible=False)]) ProxyDelegate.__init__(self, DiaryEntry(), ['title', 'period', 'text', 'chars', 'words'], gladefile="diary2.ui", delete_handler=self.quit_if_last) self.hbox.pack_start(self.entries) self.entries.show() self.entries.grab_focus() self.set_editable(False)
def testRadioWithoutTrue(self): olist = ObjectList( [Column('foo', radio=True, data_type=bool, editable=True)]) column = olist.get_treeview().get_column(0) renderer = column.get_cell_renderers()[0] items = [Settable(foo=False) for i in range(5)] olist.add_list(items) self.assertEqual(items[0].foo, False) renderer.emit('toggled', 0) self.assertEqual(items[0].foo, True)
def create_objectlist(self, icon_name, text): l = ObjectList([Column('title', use_markup=True)]) l.connect('row-activated', self._on_item_activated) l.connect('selection-changed', self._on_item_selected) l.set_headers_visible(False) l.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self._books.append_page(l, tab_label=self.create_tab_label(icon_name, text)) return l
class SpykeeWifiListView(SlaveView): def __init__(self, cf): self.networks = ObjectList([Column("essid", "Network Name",), Column("encryption", "Security"), Column("strength", "Signal Strength")]) self.cf = cf self.cf.currentProtocol.getVisibleWifi() SlaveView.__init__(self, toplevel=self.networks) def wifiReceived(self, wifi): for network in wifi: n = SpykeeWifiNetwork(network, wifi[network][0], wifi[network][1]) self.networks.append(n)
def haveWidgetTree(self): self.widget = gtk.VBox() self.widget.set_border_width(6) self.properties = ObjectList( [Column('name'), Column('value')]) self.properties.set_size_request(-1, 200) self.widget.pack_start(self.properties, False, False) self.properties.show() self._reloadProperties(self.state.get('config')['properties']) return self.widget
def buildObjectList(self, mediaList): """ This method builds and initialize the ObjectList. """ self.mediaList = ObjectList(media_list_columns) self.mediaList.connect('selection_changed', self.media_selected) self.mediaList.connect('double-click', self.double_click) for media in mediaList: mf = MediaFile(media.getFilename(), uri=media.getURI(), length=media.getLengthSec()) mf.lastPlayed = media.getLastPlayed() self.mediaList.append(mf)
def __init__(self): self.entries = ObjectList([ Column("title", width=120), Column("period", width=80), Column("text", expand=True) ]) ProxyDelegate.__init__(self, DiaryEntry(), ['title', 'period', 'text'], gladefile="diary.ui", delete_handler=self.quit_if_last) self.hbox.pack_start(self.entries, True, True, 0) self.entries.show() self.entries.grab_focus()
def testInsert(self): self.klist = ObjectList([Column('name')]) self.assertEqual(list(self.klist), []) self.klist.insert(0, Settable(name='one')) self.assertEqual(self.klist[0].name, 'one') self.klist.insert(0, Settable(name='two')) self.assertEqual(self.klist[0].name, 'two') self.assertEqual(self.klist[1].name, 'one') self.klist.insert(1, Settable(name='three')) self.assertEqual(self.klist[0].name, 'two') self.assertEqual(self.klist[1].name, 'three') self.assertEqual(self.klist[2].name, 'one')
class ListSlave(SlaveDelegate): def __init__(self, parent): self.parent = parent self.news_list = ObjectList([ Column('title', 'Title of article', str), Column('author', 'Author of article', str), Column('url', 'Address of article', str)]) SlaveDelegate.__init__(self, toplevel=self.news_list) self.news_list.add_list(news) self.news_list.select(self.news_list[0]) def on_news_list__selection_changed(self, list, item): print("%s %s %s\n" % (item.title, item.author, item.url)) def on_news_list__double_click(self, the_list, selected_object): self.parent.ok.clicked()
def _setup_widgets(self): self.set_ok_label(_(u'Activate'), gtk.STOCK_APPLY) self.ok_button.set_sensitive(False) plugins = [] for name in sorted(self._manager.available_plugins_names): # FIXME: Remove when magento plugin is functional for end users if not is_developer_mode() and name == 'magento': continue if platform.system() == 'Windows': if name in ['ecf', 'tef']: continue desc = self._manager.get_description_by_name(name) plugins.append(_PluginModel(name, name in self._manager.installed_plugins_names, desc)) self.klist = ObjectList(self._get_columns(), plugins, gtk.SELECTION_BROWSE) self.klist.set_headers_visible(False) self.klist.connect("selection-changed", self._on_klist__selection_changed) self.main.remove(self.main.get_child()) self.main.add(self.klist) self.klist.show()
class ListSlave(SlaveDelegate): def __init__(self, parent): self.parent = parent self.news_list = ObjectList([ Column('title', 'Title of article', str), Column('author', 'Author of article', str), Column('url', 'Address of article', str)]) SlaveDelegate.__init__(self, toplevel=self.news_list) self.news_list.add_list(news) self.news_list.select(self.news_list[0]) def on_news_list__selection_changed(self, list, item): print "%s %s %s\n" % (item.title, item.author, item.url) def on_news_list__double_click(self, the_list, selected_object): self.parent.ok.clicked()
def test(): # pragma no cover from nose.exc import SkipTest try: import gi gi # workaround pyflakes except ImportError: raise SkipTest("can't run test without pygobject installed") from kiwi.ui.objectlist import ObjectList from stoq.api import api as stoq_api from stoqlib.api import api from stoq.gui.sales import SalesApp from stoqlib.domain.sale import SaleView stoq_api.prepare_test() store = api.new_store() class Foo(SalesApp): def __init__(self): pass a = Foo() ol = ObjectList(a.get_columns()) data = store.find(SaleView) r = SalesReport('teste.pdf', ol, list(data)) r.save_html('teste.html') r.save()
def __init__ (self, searchline="", mode=gtk.SELECTION_SINGLE): """Search for the name like searchstring""" self.window=gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.connect("destroy", self.exit) self.window.set_size_request(600, 250) self.vbox=gtk.VBox(homogeneous=False,spacing=0) self.window.add(self.vbox) self.cur=con.cursor() if searchline.count(':') !=0: search_options=dict(self.parse_search_string(searchline)) print search_options results=[[5, 'Foo2', 'yummy food'], [6, 'Foobar', 'best foobar evar!']] else: searchline="%" + searchline + "%" self.cur.execute("""SELECT recipe_id,name,description FROM recipes WHERE name LIKE %s""", (searchline,)) results=self.cur.fetchall() my_columns = [ Column("name", title="Name", sorted=True), Column("desc", title="Description") ] self.objectlist = ObjectList(my_columns, mode=mode) self.objectlist.set_size_request(600,225) recipes=[RecipeInfo(x) for x in results] self.objectlist.add_list(recipes) self.b=gtk.Button("Show Selected") self.b.connect("clicked", self.show_recipe2) self.vbox.add(self.objectlist) self.vbox.add(self.b) self.window.show_all()
class SpykeeListView(SlaveView): def __init__(self): self.robots = ObjectList([Column("name", "Name",), Column("ip", "IP Address")]) d = twistedprotocol.discover(5, self) d.addCallback(self.discovered) SlaveView.__init__(self, toplevel=self.robots) def spykeeFound(self, name, ip): r = SpykeeRobot(name, ip) self.robots.append(r) def discovered(self, spykees): if not spykees: d = gtk.MessageDialog(message_format="No Spykee Robots found") d.show()
def __init__(self, cf): self.networks = ObjectList([Column("essid", "Network Name",), Column("encryption", "Security"), Column("strength", "Signal Strength")]) self.cf = cf self.cf.currentProtocol.getVisibleWifi() SlaveView.__init__(self, toplevel=self.networks)
def create_dialog(self, titulo, parent): dialog = gtk.Dialog(titulo, parent, gtk.DIALOG_MODAL, (gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) dialog.set_position(gtk.WIN_POS_CENTER) dialog.set_size_request(520, 470) dialog.set_border_width(8) frame_pesq = gtk.Frame("Pesquisar") hbox = gtk.HBox(False, 2) label_pesq = gtk.Label("Pesquisar por:") self.entry_pesq = gtk.Entry(0) hbox.set_border_width(8) hbox.pack_start(label_pesq, False, True, 2) hbox.add(self.entry_pesq) frame_pesq.add(hbox) self.lista = ObjectList(self.recordset.columns) #scrolled_window = gtk.ScrolledWindow() #scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) #scrolled_window.add(self.lista) self.entry_pesq.connect("backspace", self.do_search) dialog.vbox.pack_start(frame_pesq, False, True, 2) dialog.vbox.add(self.lista) dialog.show_all() return dialog
class ManView(PidaView): icon_name = 'gtk-library' label_text = 'Man' def create_ui(self): self._count = 0 self.__vbox = gtk.VBox(spacing=3) self.__vbox.set_border_width(6) self.__hbox = gtk.HBox() self.__entry = gtk.Entry() self.__entry.connect('changed', self.cb_entry_changed) self.__check = gtk.CheckButton(label='-k') self.__check.connect('toggled', self.cb_entry_changed) self.__list = ObjectList([ Column('markup', title=_('Man page'), sorted=True, use_markup=True), Column('description', title=_('Description'), use_markup=True), ]) self.__list.connect('double-click', self._on_man_double_click) self.__list.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.__hbox.pack_start(self.__entry) self.__hbox.pack_start(self.__check, expand=False) self.__vbox.pack_start(self.__hbox, expand=False) self.__vbox.pack_start(self.__list) self.add_main_widget(self.__vbox) self.__vbox.show_all() def clear_items(self): self._count = 0 self.__list.clear() def add_item(self, item): self._count += 1 self.__list.append(item) def _on_man_double_click(self, olist, item): commandargs = ['/usr/bin/env', 'man', item.number, item.pattern] directory = os.path.dirname(commandargs[0]) self.svc.boss.cmd('commander', 'execute', commandargs=commandargs, cwd=directory, icon='gnome-library', title='%(pattern)s(%(number)d)' % dict( pattern=item.pattern, number=int(item.number) )) def cb_entry_changed(self, w): options = '-f' if self.__check.get_active(): options = '-k' self.svc.cmd_find(options=options, pattern=self.__entry.get_text()) def can_be_closed(self): self.svc.get_action('show_man').set_active(False)
def setup_lastchanges(self): columns = ['name', 'author', 'lastModified', 'perms', 'version', 'size'] columns = [Column(s) for s in columns] columns.append(Column('lastModified', sorted=True, order=gtk.SORT_DESCENDING)) self.lastchangeslist = ObjectList(columns) self.lastchangeslist.connect("selection-changed", self.change_selected) self.view.side_vbox.add(self.lastchangeslist)
class DeviceConstantsDialog(BasicDialog): size = (500, 300) def __init__(self, store, printer): self._constant_slave = None self.store = store self.printer = printer BasicDialog.__init__(self, hide_footer=False, title='edit', size=self.size) self.main.set_border_width(6) self._create_ui() 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) hbox.pack_start(self._constant_slave.get_toplevel(), True, True, 0) # FIXME: redesign BasicDialog self.main.remove(self.main_label) self.main.add(hbox) hbox.show_all() def _on_klist__selection_changed(self, klist, selected): self._constant_slave.switch(selected.type)
def _setup_list(self): methods = PaymentMethod.get_editable_methods(self.store) self.klist = ObjectList(self._get_columns(), methods, gtk.SELECTION_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_list(self): columns = [] for field in self.fields: if field.show_in_list: columns.append(Column(field.field_name, data_type = field.tipo, title = field.titulo)) self.lista = ObjectList(columns) self.data = self.populate_method() self.lista.extend(self.data) return self.lista
def __init__(self, model): self.__model = model #self.__model.set_view(self) BaseView.__init__(self, gladefile="virtlab", delete_handler=self.quit_if_last) # self.__col_pixbuf = gtk.TreeViewColumn("Image") # cellrenderer_pixbuf = gtk.CellRendererPixbuf() # cellrenderer_pixbuf.set_properties("pixbuf", ) # self.__col_pixbuf.pack_start(cellrenderer_pixbuf, False) # self.__col_pixbuf.add_attribute(cellrenderer_pixbuf, "pixbuf", 1) tableColumns = [ Column("image", title=" ", width=30, data_type=gtk.gdk.Pixbuf, sorted=False), Column("name", title='VM Name', width=130, sorted=True), Column("state", title='State', width=70), Column("order", title='Order (Delay/min)', width=145), Column("ordinal", visible=False), Column("delay", visible=False), Column("desc", title='Description', width=200) ] self.vmlist_widget = ObjectList(tableColumns) self.vmlist_widget.set_size_request(300, 400) self.vmlist_widget.set_selection_mode(gtk.SELECTION_SINGLE) self.hbox4.pack_start(self.vmlist_widget) store = gtk.ListStore(gobject.TYPE_STRING) self.vmlist_widget.show() self.__dialog = None self.__status_text = gtk.TextBuffer() try: self.populate_vmlist() self.populate_order_dropdown(store, len(self.__model.get_vms())) except VMLabException as exception: if exception.vme_id is c.EXCEPTION_LIBVIRT_001: error("Initialization error", "No connection to Libvirtd.\n Exiting.") exit(1) self.ordercombo.set_model(store) cell = gtk.CellRendererText() self.ordercombo.pack_start(cell, True) self.ordercombo.add_attribute(cell, 'text', 0) self.virtlab.set_size_request(800, 460) self.change_title("") self.__statusbar_ctx = self.statusbar.get_context_id("virtlab") self.virtlab.set_icon(gtk.gdk.pixbuf_new_from_file("pixmaps/about-logo.png"))
def testExportFromObjectList(self): fruits = ObjectList( [Column('name', data_type=str), Column('price', data_type=int)]) for name, price in [('Apple', 4), ('Pineapple', 2), ('Kiwi', 8), ('Banana', 3), ('Melon', 5)]: fruits.append(Fruit(name, price)) ofx = XLSExporter() ofx.add_from_object_list(fruits) temp_file = ofx.save() data = open(temp_file.name).read() # We should use xlrd to 're-open' the spreadsheet and parse its content. self.assertTrue(len(data) > 0)
def _setup_widgets(self): self.set_ok_label(_(u'Activate'), Gtk.STOCK_APPLY) self.ok_button.set_sensitive(False) plugins = [] for name in sorted(self._manager.available_plugins_names): desc = self._manager.get_description_by_name(name) plugins.append( _PluginModel(name, name in self._manager.installed_plugins_names, desc)) self.klist = ObjectList(self._get_columns(), plugins, Gtk.SelectionMode.BROWSE) self.klist.set_headers_visible(False) self.klist.connect("selection-changed", self._on_klist__selection_changed) self.main.remove(self.main.get_child()) self.main.add(self.klist) self.klist.show()
def _create_field_list(self): items = ObjectList([ Column('description', width=200), Column('len', data_type=int, editable=True) ]) 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)) descriptions[invoice_field.name] = invoice_field.description self._field_descriptions = descriptions self.left_vbox.pack_end(items, True, True) items.show()
def _run_exporter(self, sse): objectlist = ObjectList() path = 'stoqlib.gui.dialogs.spreadsheetexporterdialog.Gio.app_info_get_default_for_type' with mock.patch(path) as Gio: app_info = mock.Mock() app_info.get_name.return_value = 'App Name' Gio.return_value = app_info sse.export(object_list=objectlist, name='Title', filename_prefix='name-prefix')
def __init__(self): self._js_data = None self._js_options = None self._current = None gtk.Window.__init__(self) self.set_size_request(800, 480) self.vbox = gtk.VBox() self.add(self.vbox) self.vbox.show() hbox = gtk.HBox() self.vbox.pack_start(hbox, False, False, 6) hbox.show() label = gtk.Label('Period:') hbox.pack_start(label, False, False, 6) label.show() self.chart_type = ProxyComboBox() self.chart_type.connect('content-changed', self._on_chart_type__content_changed) hbox.pack_start(self.chart_type, False, False, 6) self.chart_type.show() self.period_values = ProxyComboBox() self.period_values.connect('content-changed', self._on_period_values__content_changed) hbox.pack_start(self.period_values, False, False, 6) self.period_values.show() self._view = WebView() self._view.get_view().connect('load-finished', self._on_view__document_load_finished) self.vbox.pack_start(self._view, True, True) self.results = ObjectList() self.results.connect('row-activated', self._on_results__row_activated) self.vbox.pack_start(self.results, True, True) self._setup_daemon()