本文整理汇总了Python中kiwi.ui.widgets.entry.ProxyEntry.set_text方法的典型用法代码示例。如果您正苦于以下问题:Python ProxyEntry.set_text方法的具体用法?Python ProxyEntry.set_text怎么用?Python ProxyEntry.set_text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kiwi.ui.widgets.entry.ProxyEntry
的用法示例。
在下文中一共展示了ProxyEntry.set_text方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testRead
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import set_text [as 别名]
def testRead(self):
entry = ProxyEntry()
entry.set_text('1')
entry.set_property("data-type", "int")
self.assertEqual(entry.read(), 1)
entry.set_text('')
self.assertEqual(entry.read(), ValueUnset)
示例2: testDigitMask
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import set_text [as 别名]
def testDigitMask(self):
e = ProxyEntry()
e.set_mask('000.000')
self.assertEqual(e.get_text(), ' . ')
e.set_text('123.456')
self.assertEqual(e.get_text(), '123.456')
e.delete_text(0, 2)
self.assertEqual(e.get_text(), '345.6 ')
示例3: testMaskSmallFields
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import set_text [as 别名]
def testMaskSmallFields(self):
e = ProxyEntry()
e.set_mask('0.0.0')
self.assertEqual(e.get_text(), ' . . ')
self.assertEqual(e.get_fields(), ['', '', ''])
e.set_text('1.2.3')
self.assertEqual(e.get_text(), '1.2.3')
self.assertEqual(e.get_fields(), ['1', '2', '3'])
示例4: testAlphaNumericMask
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import set_text [as 别名]
def testAlphaNumericMask(self):
e = ProxyEntry()
e.set_mask('&&&-aaa')
self.assertEqual(e.get_text(), ' - ')
self.assertEqual(e.get_fields(), ['', ''])
e.set_text('aáé-á1e')
self.assertEqual(e.get_text(), 'aáé-á1e')
self.assertEqual(e.get_fields(), ['aáé', 'á1e'])
示例5: testAsciiMask
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import set_text [as 别名]
def testAsciiMask(self):
e = ProxyEntry()
e.set_mask('LLLL-L')
self.assertEqual(e.get_text(), ' - ')
self.assertEqual(e.get_fields(), ['', ''])
e.set_text('abcd-e')
self.assertEqual(e.get_text(), 'abcd-e')
self.assertEqual(e.get_fields(), ['abcd', 'e'])
示例6: testDigitMask
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import set_text [as 别名]
def testDigitMask(self):
e = ProxyEntry()
e.set_mask('000.000')
self.assertEqual(e.get_text(), ' . ')
self.assertEqual(e.get_fields(), ['', ''])
e.set_text('123.456')
self.assertEqual(e.get_text(), '123.456')
self.assertEqual(e.get_fields(), ['123', '456'])
e.delete_text(0, 2)
self.assertEqual(e.get_text(), '3 .456')
self.assertEqual(e.get_fields(), ['3', '456'])
示例7: test_popup
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import set_text [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()
示例8: _testValidDataType
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import set_text [as 别名]
def _testValidDataType(self):
entry = ProxyEntry()
entry.set_property("data-type", "date")
# let's make the entry complain!
entry.set_text("string")
self.assertEqual(entry.read(), ValueUnset)
self.assertNotEqual(entry._complaint_checker_id, -1)
# now let's put proper data
entry.set_text(self.date_format)
date = datatypes.date2str(entry.read())
self.assertEqual(date, self.date_format)
self.assertEqual(entry._background_timeout_id, -1)
locale_dictionary = datatypes.locale_dictionary
# now change the data-type and do it again
entry.set_property("data-type", "float")
if locale_dictionary["thousands_sep"] == ',':
# correct value
entry.set_text("23,400,000.2")
self.assertEqual(entry.read(), 23400000.2)
self.assertEqual(entry._background_timeout_id, -1)
# wrong value
entry.set_text("23.400.000,2")
self.assertEqual(entry.read(), ValueUnset)
示例9: test_apply
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import set_text [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)
示例10: test_popdown
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import set_text [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)
示例11: test_validate
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import set_text [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'])
示例12: testDataMode
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import set_text [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)
示例13: testAsciiMask
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import set_text [as 别名]
def testAsciiMask(self):
e = ProxyEntry()
e.set_mask('LLLL-L')
self.assertEqual(e.get_text(), ' - ')
e.set_text('abcd-e')
self.assertEqual(e.get_text(), 'abcd-e')
示例14: CalculatorPopup
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import set_text [as 别名]
#.........这里部分代码省略.........
self._main_label = gtk.Label()
self._main_label.set_ellipsize(pango.ELLIPSIZE_END)
vbox.pack_start(self._main_label, True, True)
self._main_label.show()
self._entry = ProxyEntry()
# FIXME: We need a model_attribute here or else the entry.is_valid()
# will always return None. Check proxywidget.py's FIXME to see why
self._entry.model_attribute = 'not_used'
self._entry.connect('validate', self._on_entry__validate)
self._entry.connect_after('changed', self._after_entry__changed)
self._entry.set_alignment(1.0)
vbox.pack_start(self._entry, True, True)
self._entry.show()
hbox = gtk.HBox(spacing=6)
vbox.pack_start(hbox, True, True)
hbox.show()
self._label = gtk.Label()
self._label.set_property('xalign', 1.0)
self._label.set_use_markup(True)
hbox.pack_start(self._label, True, True)
self._label.show()
self._warning = gtk.Image()
hbox.pack_start(self._warning, False, False)
self.set_resizable(False)
self.set_screen(self._popped_entry.get_screen())
def _update_ui(self):
self._new_value = self._data_type(self._popped_entry.get_text())
self._entry.set_text('')
self._entry.set_tooltip_text(_("Use absolute or percentage (%) value"))
self._preview_new_value()
self._main_label.set_text(self._get_main_label())
def _get_main_label(self):
if self._mode == self.MODE_ADD:
return (_("Surcharge") if self._data_type == currency else
_("Addition"))
elif self._mode == self.MODE_SUB:
return (_("Discount") if self._data_type == currency else
_("Subtraction"))
else:
raise AssertionError
def _set_warning(self, warning):
if warning is None:
self._warning.hide()
else:
self._warning.set_from_stock(gtk.STOCK_DIALOG_WARNING,
gtk.ICON_SIZE_MENU)
self._warning.set_tooltip_text(warning)
self._warning.show()
def _popup_grab_window(self):
activate_time = 0L
window = self.get_window()
grab_status = gtk.gdk.pointer_grab(window, True,
(gtk.gdk.BUTTON_PRESS_MASK |
gtk.gdk.BUTTON_RELEASE_MASK |
gtk.gdk.POINTER_MOTION_MASK),
None, None, activate_time)
if grab_status == gtk.gdk.GRAB_SUCCESS:
示例15: testModel
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import set_text [as 别名]
def testModel(self):
entry = ProxyEntry()
entry.set_text('value')
entry.set_property("data-type", "str")
self.assertEqual(entry.read(), 'value')