本文整理汇总了Python中kiwi.ui.widgets.entry.ProxyEntry.data_type方法的典型用法代码示例。如果您正苦于以下问题:Python ProxyEntry.data_type方法的具体用法?Python ProxyEntry.data_type怎么用?Python ProxyEntry.data_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kiwi.ui.widgets.entry.ProxyEntry
的用法示例。
在下文中一共展示了ProxyEntry.data_type方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_attach
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import data_type [as 别名]
def test_attach(self):
entry = ProxyEntry()
entry.data_type = currency
self.assertEqual(entry.get_property('secondary-icon-pixbuf'), None)
calc = CalculatorPopup(entry, CalculatorPopup.MODE_SUB)
pixbuf_pixels = calc.render_icon(STOQ_CALC,
gtk.ICON_SIZE_MENU).get_pixels()
self.assertEqual(
entry.get_property('secondary-icon-pixbuf').get_pixels(), pixbuf_pixels)
entry.set_sensitive(False)
self.assertEqual(entry.get_property('secondary-icon-pixbuf'), None)
entry.set_sensitive(True)
self.assertEqual(
entry.get_property('secondary-icon-pixbuf').get_pixels(), pixbuf_pixels)
spinbutton = ProxySpinButton()
spinbutton.data_type = currency
self.assertEqual(spinbutton.get_property('secondary-icon-pixbuf'), None)
calc = CalculatorPopup(spinbutton, CalculatorPopup.MODE_SUB)
pixbuf_pixels = calc.render_icon(STOQ_CALC,
gtk.ICON_SIZE_MENU).get_pixels()
self.assertEqual(
spinbutton.get_property('secondary-icon-pixbuf').get_pixels(), pixbuf_pixels)
spinbutton.set_sensitive(False)
self.assertEqual(spinbutton.get_property('secondary-icon-pixbuf'), None)
spinbutton.set_sensitive(True)
self.assertEqual(
spinbutton.get_property('secondary-icon-pixbuf').get_pixels(), pixbuf_pixels)
示例2: _setup_entry_slave
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import data_type [as 别名]
def _setup_entry_slave(self, box=None):
widget = ProxyEntry()
# Try to simulate insensitive appearance for non-editable entries
# while keeping them selectable
widget.set_editable(self.sensitive)
if not self.sensitive:
style = widget.get_style()
widget.modify_text(
gtk.STATE_NORMAL, style.text[gtk.STATE_INSENSITIVE])
widget.modify_base(
gtk.STATE_NORMAL, style.base[gtk.STATE_INSENSITIVE])
widget.data_type = unicode
widget.model_attribute = "field_value"
self.proxy.add_widget("field_value", widget)
if box is None:
self.container.add(widget)
else:
box.pack_start(widget)
widget.show()
widget.connect('validate', self._on_entry__validate)
widget.connect('validation-changed',
self._on_entry__validation_changed)
self._entry = widget
示例3: test_popup
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import data_type [as 别名]
def test_popup(self):
entry = ProxyEntry()
entry.data_type = currency
entry.set_text('150')
calc = CalculatorPopup(entry, CalculatorPopup.MODE_SUB)
event = gtk.gdk.Event(gtk.gdk.BUTTON_PRESS)
event.window = gtk.gdk.get_default_root_window()
with mock.patch.object(calc, 'popup') as popup:
entry.emit('icon-press', gtk.ENTRY_ICON_PRIMARY, event)
self.assertEqual(popup.call_count, 0)
entry.emit('icon-press', gtk.ENTRY_ICON_SECONDARY, event)
popup.assert_called_once()
示例4: test_apply
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import data_type [as 别名]
def test_apply(self):
entry = ProxyEntry()
entry.data_type = currency
entry.set_text('150')
calc = CalculatorPopup(entry, CalculatorPopup.MODE_SUB)
# calc.popup will not work here, so call _update_ui directly
calc._update_ui()
calc._entry.set_text('10%')
event = gtk.gdk.Event(gtk.gdk.KEY_PRESS)
event.keyval = gtk.keysyms.Return
event.window = gtk.gdk.get_default_root_window()
calc.emit('key-press-event', event)
calc.emit('key-press-event', event)
self.assertEqual(entry.read(), 135)
示例5: _setup_entry_slave
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import data_type [as 别名]
def _setup_entry_slave(self, box=None):
widget = ProxyEntry()
widget.props.sensitive = self.sensitive
widget.data_type = unicode
widget.model_attribute = "field_value"
self.proxy.add_widget("field_value", widget)
if box is None:
self.container.add(widget)
else:
box.pack_start(widget)
widget.show()
widget.connect("validate", self._on_entry__validate)
widget.connect("validation-changed", self._on_entry__validation_changed)
self._entry = widget
示例6: _create_entry
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import data_type [as 别名]
def _create_entry(self, mandatory=False):
entry = ProxyEntry()
entry.data_type = unicode
# Set as empty or kiwi will return ValueUnset on entry.read()
# and we would have to take that in consideration everywhere here
entry.update(u'')
entry.mandatory = mandatory
self.setup_entry(entry)
entry.connect_after('content-changed',
self._after_entry__content_changed)
entry.connect_after('changed', self._after_entry__changed)
entry.connect('validate', self._on_entry__validate)
entry.connect('activate', self._on_entry__activate)
return entry
示例7: test_popdown
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import data_type [as 别名]
def test_popdown(self):
entry = ProxyEntry()
entry.data_type = currency
entry.set_text('150')
calc = CalculatorPopup(entry, CalculatorPopup.MODE_SUB)
with contextlib.nested(
mock.patch.object(calc, '_maybe_apply_new_value'),
mock.patch.object(calc, 'popdown')) as (manv, popdown):
# Those keys should try to apply the value
for keyval in [gtk.keysyms.Return,
gtk.keysyms.KP_Enter,
gtk.keysyms.Tab]:
event = gtk.gdk.Event(gtk.gdk.KEY_PRESS)
event.keyval = keyval
event.window = gtk.gdk.get_default_root_window()
calc.emit('key-press-event', event)
self.assertEqual(manv.call_count, 1)
self.assertEqual(popdown.call_count, 0)
manv.reset_mock()
popdown.reset_mock()
event = gtk.gdk.Event(gtk.gdk.KEY_PRESS)
# Escape should popdown the popup
event.keyval = gtk.keysyms.Escape
event.window = gtk.gdk.get_default_root_window()
calc.emit('key-press-event', event)
self.assertEqual(popdown.call_count, 1)
self.assertEqual(manv.call_count, 0)
manv.reset_mock()
popdown.reset_mock()
event = gtk.gdk.Event(gtk.gdk.KEY_PRESS)
# Any other should not do anything
event.keyval = gtk.keysyms.A
event.window = gtk.gdk.get_default_root_window()
calc.emit('key-press-event', event)
self.assertEqual(manv.call_count, 0)
self.assertEqual(popdown.call_count, 0)
示例8: testDataMode
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import data_type [as 别名]
def testDataMode(self):
entry = ProxyEntry()
entry.data_type = str
entry.set_exact_completion()
items = {'xxx': object(),
'yyy': object()}
entry.prefill([(k, v) for k, v in items.items()])
entry.set_text('xxx')
self.assertIs(entry.read(), items['xxx'])
entry.set_text('x')
self.assertIs(entry.read(), None)
entry.set_text('xxxxx')
self.assertIs(entry.read(), None)
entry.set_text('yyy')
self.assertIs(entry.read(), items['yyy'])
entry.set_text('y')
self.assertIs(entry.read(), None)
entry.set_text('yyyyy')
self.assertIs(entry.read(), None)
示例9: _setup_entry_slave
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import data_type [as 别名]
def _setup_entry_slave(self, box=None):
widget = ProxyEntry()
# Try to simulate insensitive appearance for non-editable entries
# while keeping them selectable
widget.set_editable(self.sensitive)
if not self.sensitive:
sc = widget.get_style_context()
sc.add_class('visualmode')
widget.data_type = str
widget.model_attribute = "field_value"
self.proxy.add_widget("field_value", widget)
if box is None:
self.container.add(widget)
else:
box.pack_start(widget, True, True, 0)
widget.show()
widget.connect('validate', self._on_entry__validate)
widget.connect('validation-changed',
self._on_entry__validation_changed)
self._entry = widget
示例10: test_validate
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import data_type [as 别名]
def test_validate(self):
def validate_entry(entry, value):
if value == 100:
return ValidationError()
# FIXME: For some reason, entry is not emitting 'changed' event
# on set_text, not even if we call entry.emit('changed') by hand.
# That only happens here on the test. Figure out why
def update_entry(entry, value):
entry.set_text(value)
entry.validate(force=True)
entry = ProxyEntry()
entry.data_type = currency
entry.connect('validate', validate_entry)
entry.set_text('150')
calc = CalculatorPopup(entry, CalculatorPopup.MODE_SUB)
# calc.popup will not work here, so call _update_ui directly
calc._update_ui()
self.assertValid(calc, ['_entry'])
self.assertNotVisible(calc, ['_warning'])
for value in ['abc', '+10%', '-10%', '+10', '-10']:
update_entry(calc._entry, value)
self.assertInvalid(calc, ['_entry'])
self.assertNotVisible(calc, ['_warning'])
update_entry(calc._entry, '40')
self.assertValid(calc, ['_entry'])
self.assertNotVisible(calc, ['_warning'])
# 50 of discount will make the value invalid on entry
# (see validate_entry above)
update_entry(calc._entry, '50')
self.assertValid(calc, ['_entry'])
self.assertVisible(calc, ['_warning'])
示例11: on_entry_activate
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import data_type [as 别名]
from kiwi.ui.widgets.entry import ProxyEntry
def on_entry_activate(entry):
print 'You selected:', entry.read()
gtk.main_quit()
win = gtk.Window()
win.connect('delete-event', gtk.main_quit)
vbox = gtk.VBox()
win.add(vbox)
# Normal entry
entry = ProxyEntry()
entry.data_type = str
entry.connect('activate', on_entry_activate)
entry.prefill(['Belo Horizonte', u'São Carlos',
u'São Paulo', u'Båstad',
u'Örnsköldsvik', 'sanca', 'sampa'])
vbox.pack_start(entry)
entry = ProxyEntry()
entry.data_type = int
entry.connect('activate', on_entry_activate)
entry.prefill([('Brazil', 186),
('Sweden', 9),
('China', 1306)])
vbox.pack_start(entry)
win.show_all()