Exemplo n.º 1
0
    def test_mousewheel(self):
        sidebar = self.shell.shell_sidebar
        text = self.shell.text

        # Enter a 100-line string to scroll the shell screen down.
        self.do_input('x = """' + '\n'*100 + '"""\n')
        yield
        self.assertGreater(get_lineno(text, '@0,0'), 1)

        last_lineno = get_end_linenumber(text)
        self.assertIsNotNone(text.dlineinfo(text.index(f'{last_lineno}.0')))

        # Scroll up using the <MouseWheel> event.
        # The meaning delta is platform-dependant.
        delta = -1 if sys.platform == 'darwin' else 120
        sidebar.canvas.event_generate('<MouseWheel>', x=0, y=0, delta=delta)
        yield
        self.assertIsNone(text.dlineinfo(text.index(f'{last_lineno}.0')))

        # Scroll back down using the <Button-5> event.
        sidebar.canvas.event_generate('<Button-5>', x=0, y=0)
        yield
        self.assertIsNotNone(text.dlineinfo(text.index(f'{last_lineno}.0')))
Exemplo n.º 2
0
 def init_shell(cls):
     cls.shell = cls.flist.open_shell()
     cls.shell.pollinterval = 10
     cls.root.update()
     cls.n_preface_lines = get_lineno(cls.shell.text, 'end-1c') - 1