本文整理汇总了Python中kiwi.ui.widgets.entry.ProxyEntry.activate方法的典型用法代码示例。如果您正苦于以下问题:Python ProxyEntry.activate方法的具体用法?Python ProxyEntry.activate怎么用?Python ProxyEntry.activate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kiwi.ui.widgets.entry.ProxyEntry
的用法示例。
在下文中一共展示了ProxyEntry.activate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestSearchEntryGadget
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import activate [as 别名]
class TestSearchEntryGadget(GUITest):
def _create_interface(self, run_editor=None):
self.sale = self.create_sale()
self.window = gtk.Window()
self.entry = ProxyEntry()
self.window.add(self.entry)
self.client_gadget = SearchEntryGadget(
self.entry, self.store, model=self.sale, model_property='client',
search_columns=['name'], search_class=ClientSearch,
parent=self.window, run_editor=run_editor)
self.client_gadget.get_model_obj = lambda obj: obj and obj.client
def test_create(self):
window = gtk.Window()
box = gtk.VBox()
window.add(box)
entry = ProxyEntry()
box.pack_start(entry)
self.check_dialog(window, 'search-entry-before-replace')
sale = self.create_sale()
SearchEntryGadget(entry, self.store, model=sale,
model_property='client', search_columns=['name'],
search_class=ClientSearch, parent=window)
self.check_dialog(window, 'search-entry-after-replace')
@mock.patch('stoqlib.gui.widgets.searchentry.run_dialog')
def test_run_search(self, run_dialog):
self._create_interface()
run_dialog.return_value = None
self.click(self.client_gadget.find_button)
run_dialog.assert_called_once_with(
ClientSearch, self.window, self.store, initial_string='',
double_click_confirm=True)
@mock.patch('stoqlib.gui.widgets.searchentry.api.new_store')
@mock.patch('stoqlib.gui.widgets.searchentry.run_person_role_dialog')
def test_run_editor(self, run_dialog, new_store):
new_store.return_value = self.store
self._create_interface()
client = self.create_client(name=u'Fulano de Tal')
run_dialog.return_value = self.store.find(
ClientView, ClientView.id == client.id).one()
with mock.patch.object(self.store, 'commit'):
with mock.patch.object(self.store, 'close'):
self.click(self.client_gadget.edit_button)
run_dialog.assert_called_once_with(
ClientEditor, self.window, self.store, None)
self.assertEquals(self.entry.read(), client)
self.assertEquals(self.entry.get_text(), u'Fulano de Tal')
@mock.patch('stoqlib.gui.widgets.searchentry.api.new_store')
def test_run_editor_override(self, new_store):
new_store.return_value = self.store
run_editor = mock.MagicMock()
run_editor.return_value = None
self.assertEquals(run_editor.call_count, 0)
self._create_interface(run_editor=run_editor)
with mock.patch.object(self.store, 'commit'):
with mock.patch.object(self.store, 'close'):
self.click(self.client_gadget.edit_button)
self.assertEquals(run_editor.call_count, 1)
@mock.patch('stoqlib.gui.widgets.searchentry.api.new_store')
@mock.patch('stoqlib.gui.widgets.searchentry.run_dialog')
def test_entry_activate(self, run_dialog, new_store):
new_store.return_value = self.store
self._create_interface()
fulano = self.create_client(u'Fulano de Tal')
ciclano = self.create_client(u'Cicrano de Tal')
# There should be only one match for Fulano, then the entry should be
# updated with this only match
self.entry.set_text('Fulano')
self.entry.activate()
self.assertEquals(self.entry.get_text(), 'Fulano de Tal')
self.assertEquals(self.entry.read(), fulano)
# Now when we use 'de tal', there are two clients that match. The
# search should be displayed
run_dialog.return_value = self.store.find(
ClientView, ClientView.id == ciclano.id).one()
self.entry.set_text('de tal')
self.entry.activate()
run_dialog.assert_called_once_with(
ClientSearch, self.window, self.store, initial_string='de tal',
double_click_confirm=True)
self.assertEquals(self.entry.get_text(), 'Cicrano de Tal')
self.assertEquals(self.entry.read(), ciclano)
@mock.patch('stoqlib.gui.widgets.searchentry.api.new_store')
#.........这里部分代码省略.........