当前位置: 首页>>代码示例>>Python>>正文


Python ProxyEntry.set_property方法代码示例

本文整理汇总了Python中kiwi.ui.widgets.entry.ProxyEntry.set_property方法的典型用法代码示例。如果您正苦于以下问题:Python ProxyEntry.set_property方法的具体用法?Python ProxyEntry.set_property怎么用?Python ProxyEntry.set_property使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kiwi.ui.widgets.entry.ProxyEntry的用法示例。


在下文中一共展示了ProxyEntry.set_property方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _testValidDataType

# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import set_property [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)
开发者ID:hackedbellini,项目名称:kiwi,代码行数:30,代码来源:test_Entry.py

示例2: testRead

# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import set_property [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)
开发者ID:gxela,项目名称:kiwi-gtk,代码行数:9,代码来源:test_Entry.py

示例3: EditorPropertyName

# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import set_property [as 别名]
class EditorPropertyName(EditorProperty):

    duplicate_name_msg = _("There is already a widget with this name")
    no_name_msg = _("The widget must have a name")

    def __init__(self, property_class, app):
        EditorProperty.__init__(self, property_class, app)

        self.input = ProxyEntry()
        self.input.set_property('data-type', str)
        self.input.connect('changed', self._changed_text)

    def load(self, widget):
        self._start_load(widget)
        self._internal_load(widget)
        self._finish_load()

    def _internal_load(self, widget):
        value = self.property.value
        pos = self.input.get_position()
        self.input.delete_text(0, -1)
        if value:
            self.input.insert_text(value)

        self.input.set_position(pos)

        # validate that the name exists and is unique
        if not value:
            self.input.set_invalid(self.no_name_msg)
        elif self._project.get_gadget_by_name(value) != widget:
            self.input.set_invalid(self.duplicate_name_msg)
        else:
            self.input.set_valid()

    def _changed_text(self, entry):
        """
        Update the name property of the widget if the name is valid.
        """
        if self.property_loading:
            return

        name = entry.get_chars(0, -1)
        if not name:
            self.input.set_invalid(self.no_name_msg)
        elif self._project.get_gadget_by_name(name):
            self.input.set_invalid(self.duplicate_name_msg)
        else:
            self.input.set_valid()
            self.set(name)
开发者ID:dsaran,项目名称:packagehelper,代码行数:51,代码来源:propertyeditor.py

示例4: testRead

# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import set_property [as 别名]
    def testRead(self):
        # int without mask
        entry = ProxyEntry()
        entry.set_text('1')
        entry.set_property("data-type", "int")
        self.assertEqual(entry.read(), 1)
        entry.set_text('')
        # empty int reads as ValueUnset
        self.assertEqual(entry.read(), ValueUnset)

        # int with mask
        entry = ProxyEntry()
        entry.set_property("data-type", "int")
        entry.set_mask('00')
        entry.set_text('12')
        self.assertEqual(entry.read(), 12)
        entry.set_text('')
        # empty int reads as ValueUnset
        self.assertEqual(entry.read(), ValueUnset)

        # str without mask
        entry = ProxyEntry()
        entry.set_property("data-type", "str")
        entry.set_text('123')
        self.assertEqual(entry.read(), '123')
        entry.set_text('')
        self.assertEqual(entry.read(), '')

        # str with mask
        entry = ProxyEntry()
        entry.set_property("data-type", "str")
        entry.set_mask('00-00.00')
        entry.set_text('123456')
        self.assertEqual(entry.read(), '12-34.56')
        entry.set_text('')
        self.assertEqual(entry.read(), '')
开发者ID:hackedbellini,项目名称:kiwi,代码行数:38,代码来源:test_Entry.py

示例5: testIdleAddedProperly

# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import set_property [as 别名]
    def testIdleAddedProperly(self):
        entry = ProxyEntry()
        entry.set_property("data-type", "int")
        while Gtk.events_pending():
            Gtk.main_iteration()
        self.assertEqual(entry.get_property('data_type'), 'int')

        entry = ProxyEntry(data_type=str)
        while Gtk.events_pending():
            Gtk.main_iteration()
        self.assertEqual(entry.get_property('data_type'), 'str')
        entry.set_property("data-type", int)
        self.assertEqual(entry.get_property('data_type'), 'int')

        entry = ProxyEntry(data_type=str)
        self.assertEqual(entry.get_property('data_type'), 'str')
        entry.set_property("data-type", int)
        while Gtk.events_pending():
            Gtk.main_iteration()
        self.assertEqual(entry.get_property('data_type'), 'int')
开发者ID:hackedbellini,项目名称:kiwi,代码行数:22,代码来源:test_Entry.py

示例6: DateEntry

# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import set_property [as 别名]
class DateEntry(Gtk.Box):
    """I am an entry which you can input a date on.
    In addition to an Gtk.Entry I also contain a button
    with an arrow you can click to get popup window with a Gtk.Calendar
    for which you can use to select the date
    """
    gsignal('changed')
    gsignal('activate')

    def __init__(self):
        super(DateEntry, self).__init__(orientation=Gtk.Orientation.HORIZONTAL)
        self.get_style_context().add_class(Gtk.STYLE_CLASS_LINKED)

        self._popping_down = False
        self._old_date = None
        self._block_changed = False

        # This will force both the entry and the button have the same height
        self._sizegroup = Gtk.SizeGroup.new(Gtk.SizeGroupMode.VERTICAL)

        # bootstrap problems, kiwi.ui.widgets.entry imports dateentry
        # we need to use a proxy entry because we want the mask
        from kiwi.ui.widgets.entry import ProxyEntry
        self.entry = ProxyEntry()
        # Set datatype before connecting to change event, to not get when the
        # mask is set
        self.entry.set_property('data-type', datetime.date)
        self.entry.connect('changed', self._on_entry__changed)
        self.entry.connect('activate', self._on_entry__activate)
        mask = self.entry.get_mask()
        if mask:
            self.entry.set_width_chars(len(mask))
        self.pack_start(self.entry, True, True, 0)
        self.entry.set_valign(Gtk.Align.CENTER)
        self._sizegroup.add_widget(self.entry)
        self.entry.show()

        self._button = Gtk.ToggleButton()
        self._button.set_valign(Gtk.Align.CENTER)
        self._button.connect('scroll-event', self._on_entry__scroll_event)
        self._button.connect('toggled', self._on_button__toggled)
        self._button.set_focus_on_click(False)
        self.pack_start(self._button, False, False, 0)
        self._sizegroup.add_widget(self._button)
        self._button.show()

        arrow = Gtk.Arrow(arrow_type=Gtk.ArrowType.DOWN, shadow_type=Gtk.ShadowType.NONE)
        self._button.add(arrow)
        arrow.show()

        self._popup = _DateEntryPopup(self)
        self._popup.connect('date-selected', self._on_popup__date_selected)
        self._popup.connect('hide', self._on_popup__hide)
        self._popup.set_size_request(-1, 24)

        self.set_valign(Gtk.Align.CENTER)

    # Virtual methods

    def do_grab_focus(self):
        self.entry.grab_focus()

    # Callbacks

    def _on_entry__changed(self, entry):
        try:
            date = self.get_date()
        except ValidationError:
            date = None
        self._changed(date)

    def _on_entry__activate(self, entry):
        self.emit('activate')

    def _on_entry__scroll_event(self, entry, event):
        if event.direction == Gdk.ScrollDirection.UP:
            days = 1
        elif event.direction == Gdk.ScrollDirection.DOWN:
            days = -1
        else:
            return

        try:
            date = self.get_date()
        except ValidationError:
            date = None

        if not date:
            newdate = datetime.date.today()
        else:
            newdate = date + datetime.timedelta(days=days)
        self.set_date(newdate)

    def _on_button__toggled(self, button):
        if self._popping_down:
            return

        try:
            date = self.get_date()
        except ValidationError:
#.........这里部分代码省略.........
开发者ID:hackedbellini,项目名称:kiwi,代码行数:103,代码来源:dateentry.py

示例7: DateEntry

# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import set_property [as 别名]
class DateEntry(gtk.HBox):
    """I am an entry which you can input a date on.
    In addition to an gtk.Entry I also contain a button
    with an arrow you can click to get popup window with a gtk.Calendar
    for which you can use to select the date
    """
    gsignal('changed')
    gsignal('activate')
    def __init__(self):
        gtk.HBox.__init__(self)

        self._popping_down = False
        self._old_date = None

        # bootstrap problems, kiwi.ui.widgets.entry imports dateentry
        # we need to use a proxy entry because we want the mask
        from kiwi.ui.widgets.entry import ProxyEntry
        self.entry = ProxyEntry()
        self.entry.connect('changed', self._on_entry__changed)
        self.entry.connect('activate', self._on_entry__activate)
        self.entry.set_property('data-type', datetime.date)
        mask = self.entry.get_mask()
        if mask:
            self.entry.set_width_chars(len(mask))
        self.pack_start(self.entry, False, False)
        self.entry.show()

        self._button = gtk.ToggleButton()
        self._button.connect('scroll-event', self._on_entry__scroll_event)
        self._button.connect('toggled', self._on_button__toggled)
        self._button.set_focus_on_click(False)
        self.pack_start(self._button, False, False)
        self._button.show()

        arrow = gtk.Arrow(gtk.ARROW_DOWN, gtk.SHADOW_NONE)
        self._button.add(arrow)
        arrow.show()

        self._popup = _DateEntryPopup(self)
        self._popup.connect('date-selected', self._on_popup__date_selected)
        self._popup.connect('hide', self._on_popup__hide)
        self._popup.set_size_request(-1, 24)

    # Virtual methods

    def do_grab_focus(self):
        self.entry.grab_focus()

    # Callbacks

    def _on_entry__changed(self, entry):
        try:
            date = self.get_date()
        except ValidationError:
            date = None
        self._changed(date)

    def _on_entry__activate(self, entry):
        self.emit('activate')

    def _on_entry__scroll_event(self, entry, event):
        if event.direction == gdk.SCROLL_UP:
            days = 1
        elif event.direction == gdk.SCROLL_DOWN:
            days = -1
        else:
            return

        try:
            date = self.get_date()
        except ValidationError:
            date = None

        if not date:
            newdate = datetime.date.today()
        else:
            newdate = date + datetime.timedelta(days=days)
        self.set_date(newdate)

    def _on_button__toggled(self, button):
        if self._popping_down:
            return

        try:
            date = self.get_date()
        except ValidationError:
            date = None

        self._popup.popup(date)

    def _on_popup__hide(self, popup):
        self._popping_down = True
        self._button.set_active(False)
        self._popping_down = False

    def _on_popup__date_selected(self, popup, date):
        self.set_date(date)
        popup.popdown()
        self.entry.grab_focus()
        self.entry.set_position(len(self.entry.get_text()))
#.........这里部分代码省略.........
开发者ID:Schevo,项目名称:kiwi,代码行数:103,代码来源:dateentry.py

示例8: testModel

# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import set_property [as 别名]
 def testModel(self):
     entry = ProxyEntry()
     entry.set_text('value')
     entry.set_property("data-type", "str")
     self.assertEqual(entry.read(), 'value')
开发者ID:hackedbellini,项目名称:kiwi,代码行数:7,代码来源:test_Entry.py


注:本文中的kiwi.ui.widgets.entry.ProxyEntry.set_property方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。