def test_selection_listener_disconnected(self): """ Check that selection listeners get correctly disconnected """ from pyface.api import GUI from pyface.qt.QtGui import QApplication, QItemSelectionModel from pyface.ui.qt4.util.event_loop_helper import EventLoopHelper from pyface.ui.qt4.util.testing import event_loop obj = ListStrEditorWithSelectedIndex(values=["value1", "value2"]) with reraise_exceptions(): qt_app = QApplication.instance() if qt_app is None: qt_app = QApplication([]) helper = EventLoopHelper(gui=GUI(), qt_app=qt_app) # open the UI and run until the dialog is closed with create_ui(obj, dict(view=single_select_item_view)) as ui: pass # now run again and change the selection with create_ui(obj, dict(view=single_select_item_view)) as ui, \ event_loop(): editor = ui.get_editors("values")[0] list_view = editor.list_view mi = editor.model.index(1) list_view.selectionModel().select( mi, QItemSelectionModel.ClearAndSelect) obj.selected = "value2"
def test_selection_listener_disconnected(): """ Check that selection listeners get correctly disconnected """ from pyface.api import GUI from pyface.qt.QtGui import QApplication, QItemSelectionModel from pyface.ui.qt4.util.event_loop_helper import EventLoopHelper from pyface.ui.qt4.util.testing import event_loop obj = ListStrEditorWithSelectedIndex(values=['value1', 'value2']) with store_exceptions_on_all_threads(): qt_app = QApplication.instance() if qt_app is None: qt_app = QApplication([]) helper = EventLoopHelper(gui=GUI(), qt_app=qt_app) # open the UI and run until the dialog is closed ui = obj.edit_traits(view=single_select_item_view) with helper.delete_widget(ui.control): press_ok_button(ui) # now run again and change the selection ui = obj.edit_traits(view=single_select_item_view) with event_loop(): editor = ui.get_editors('values')[0] list_view = editor.list_view mi = editor.model.index(1) list_view.selectionModel().select( mi, QItemSelectionModel.ClearAndSelect) obj.selected = 'value2'
def setUp(self): from pyface.qt.QtGui import QApplication from pyface.ui.qt4.util.event_loop_helper import EventLoopHelper qt_app = QApplication.instance() if qt_app is None: qt_app = QApplication([]) self.qt_app = qt_app if NativeScrollBar is None: raise unittest.SkipTest("Qt4 NativeScrollbar not available.") self.gui = GUI() self.event_loop_helper = EventLoopHelper(gui=self.gui, qt_app=qt_app) self.container = Container(position=[0, 0], bounds=[600, 600]) self.window = Window(None, size=(600, 600), component=self.container)
def test_gui_trait_expects_IGUI_interface(self): # Trivial test where we simply set the trait # and the test passes because no errors are raised. event_loop_helper = EventLoopHelper() event_loop_helper.gui = DummyGUI()