def _setup_kiwi(self): from kiwi.ui.views import set_glade_loader_func set_glade_loader_func(self._glade_loader_func) from kiwi.datatypes import get_localeconv from kiwi.ui.widgets.label import ProxyLabel ProxyLabel.replace('$CURRENCY', get_localeconv()['currency_symbol'])
def build_label(self): # This method will be overridden by some fields that don't need a # label_widget, because they carry their own label. Because of this, # we need to verify if label_widget exists everytime we use it. label_widget = ProxyLabel() if self.label: label_widget.set_markup(self.label + ':') label_widget.set_alignment(1.0, 0.5) return label_widget
def build_widget(self): if self.editable: widget = ProxyEntry() if self.max_length != 0: widget.set_width_chars(self.max_length) if self.input_mask: widget.set_mask(self.input_mask) else: widget = ProxyLabel() # This label should be left aligned. widget.set_alignment(0, 0.5) return widget
def _setup_kiwi(self): from kiwi.datatypes import get_localeconv from kiwi.ui.widgets.label import ProxyLabel ProxyLabel.replace('$CURRENCY', get_localeconv()['currency_symbol'])
def testAttr(self): label = ProxyLabel() label.set_text("test label") label.set_italic(True) self.assertEqual(label.get_label(), '<span style="italic">test label</span>') label.set_bold(True) label.set_size("xx-small") self.assertEqual( label.get_label(), '<span size="xx-small" style="italic" weight="bold">' 'test label</span>') label.set_italic(True) label.set_bold(False) label.set_size("xx-large") self.assertEqual( label.get_label(), '<span size="xx-large" style="italic">' 'test label</span>') label.set_bold(True) label.set_label("<b>different label</b>") label.set_text("test one more label") label.set_size("xx-small") self.assertEqual( label.get_label(), '<span size="xx-small" style="italic" weight="bold">' 'test one more label</span>') self.assertRaises(ValueError, label.set_size, "wrong size")
(True, bool), (42, int), (22.0/7.0, float), (3000L, long), ('THX', str), (datetime.datetime.now(), datetime.datetime), (datetime.date.today(), datetime.date), (datetime.time(11, 38, 00), datetime.time), (currency('50.1'), currency), ] for data, data_type in data_types: hbox = gtk.HBox(True) vbox.pack_start(hbox, False, False, 6) label = ProxyLabel(data_type.__name__.capitalize()) label.set_bold(True) hbox.pack_start(label) label = ProxyLabel(data_type=data_type) label.update(data) hbox.pack_start(label, False, False, 6) entry = ProxyEntry(data_type=data_type) entry.update(data) entry.validate() hbox.pack_start(entry, False, False, 6) window.show_all() gtk.main()
def testAttr(self): label = ProxyLabel() label.set_text("test label") label.set_italic(True) self.assertEqual(label.get_label(), '<span style="italic">test label</span>') label.set_bold(True) label.set_size("xx-small") self.assertEqual(label.get_label(), '<span size="xx-small" style="italic" weight="bold">' 'test label</span>') label.set_italic(True) label.set_bold(False) label.set_size("xx-large") self.assertEqual(label.get_label(), '<span size="xx-large" style="italic">' 'test label</span>') label.set_bold(True) label.set_label("<b>different label</b>") label.set_text("test one more label") label.set_size("xx-small") self.assertEqual(label.get_label(), '<span size="xx-small" style="italic" weight="bold">' 'test one more label</span>') self.assertRaises(ValueError, label.set_size, "wrong size")
(True, bool), (42, int), (22.0 / 7.0, float), (3000, int), ('THX', str), (datetime.datetime.now(), datetime.datetime), (datetime.date.today(), datetime.date), (datetime.time(11, 38, 00), datetime.time), (currency('50.1'), currency), ] for data, data_type in data_types: hbox = Gtk.HBox(True) vbox.pack_start(hbox, False, False, 6) label = ProxyLabel(data_type.__name__.capitalize()) label.set_bold(True) hbox.pack_start(label, True, True, 0) label = ProxyLabel(data_type=data_type) label.update(data) hbox.pack_start(label, False, False, 6) entry = ProxyEntry(data_type=data_type) entry.update(data) entry.validate() hbox.pack_start(entry, False, False, 6) window.show_all() Gtk.main()
def build_label(self): label_widget = ProxyLabel() label_widget.set_markup(self.label + ":") label_widget.set_alignment(1.0, 0.5) return label_widget
def __init__(self, controle, window, itens): """window é a janela que está chamando o recebimento itens a lista de itens adquiridos com descrição e preço""" self.w_receber = gtk.Dialog("CEF SHOP - Recebimento", window, gtk.DIALOG_MODAL) self.w_receber.set_position(gtk.WIN_POS_CENTER) self.w_receber.set_size_request(550,450) self.w_receber.connect("destroy", self.close) self.controle = controle #------Divisao v principal vbox_main = gtk.VBox(False, 2) self.w_receber.vbox.add(vbox_main) #------Lista self.data = [] columns = [ Column('item', data_type = str, title="Item"), Column('valor', data_type = currency, title="Valor") ] self.lista = ObjectList(columns) for iten in itens: item = iten[0] valor = iten[1] self.data.append(Receber.Item(item, valor)) self.lista.extend(self.data) #------lista de itens frame_itens = gtk.Frame("Lista de Produtos") vbox_main.pack_start(frame_itens, True, True, 2) vbox_lista = gtk.VBox(False, 2) frame_itens.add(vbox_lista) vbox_lista.pack_start(self.lista, True, True, 2) label = SummaryLabel(klist=self.lista, column='valor', label='<b>Total:</b>', value_format='<b>%s</b>') vbox_lista.pack_start(label, False, False, 4) #-----entrada valor hbox_valor = gtk.HBox() label_troco = ProxyLabel('Troco ') label_troco.set_bold(True) label_valor_troco = ProxyLabel(data_type = currency) label_valor_troco.set_bold(True) label_valor_troco.update(currency('0.00')) label_dinheiro = ProxyLabel('Dinheiro ') label_dinheiro.set_bold(True) entry_dinheiro = ProxyEntry(data_type = currency) hbox_valor.pack_start(label_troco, False, False, 2) hbox_valor.pack_start(label_valor_troco, False, False, 2) hbox_valor.pack_end(entry_dinheiro, False, False, 2) hbox_valor.pack_end(label_dinheiro, False, False, 2) self.w_receber.vbox.pack_start(hbox_valor,False, True, 4) #-------area de notificacao self.notify_box = notify_area(self.controle) self.w_receber.vbox.pack_start(self.notify_box,False, True, 4) #-------Botoes button_cancel = gtk.Button(stock=gtk.STOCK_CANCEL) button_cancel.connect("clicked", self.close) button_ok = gtk.Button(stock=gtk.STOCK_OK) button_ok.connect("clicked", self.recebido) bbox = gtk.HButtonBox () bbox.set_layout(gtk.BUTTONBOX_END) bbox.add(button_cancel) button_cancel.set_flags(gtk.CAN_DEFAULT) bbox.add(button_ok) self.w_receber.action_area.pack_start(bbox, False, True, 0) #------Mostra tudo self.w_receber.show_all() self.notify_box.hide() self.w_receber.show()