    def test_readonly(self):
        """
        Check readonly widgets work as expected.
        """
        # Create a dummy screen.
        screen = MagicMock(spec=Screen, colours=8, unicode_aware=False)
        scene = Scene([], -1)
        canvas = Canvas(screen, 10, 40, 0, 0)

        # Create the form we want to test.
        form = Frame(canvas, canvas.height, canvas.width, has_border=False, can_scroll=False)
        layout = Layout([100], fill_frame=True)
        form.add_layout(layout)
        text_box = TextBox(3, as_string=True, readonly=True)
        layout.add_widget(text_box)
        text = Text(readonly=True)
        layout.add_widget(text)
        form.fix()
        scene.add_effect(form)
        form.reset()

        # Check that entering text has no effect.
        text_box.value = "Untouchable"
        text.value = "You can't touch this..."
        self.process_keys(form, ["1234\r\n", Screen.KEY_BACK, Screen.KEY_DELETE])
        form.save()
        self.assertEqual(text_box.value, "Untouchable")
        self.process_keys(form, [Screen.KEY_TAB, "123", Screen.KEY_BACK, Screen.KEY_DELETE])
        form.save()
        self.assertEqual(text.value, "You can't touch this...")

        # Check property works.
        self.assertTrue(text.readonly)
        self.assertTrue(text_box.readonly)
        text.readonly = False
        text_box.readonly = False
        self.assertFalse(text.readonly)
        self.assertFalse(text_box.readonly)

        # Check that entering text now has an effect.
        self.process_keys(form, [Screen.KEY_TAB, "1234\r\n", Screen.KEY_BACK, Screen.KEY_DELETE])
        form.save()
        self.assertEqual(text_box.value, "Untouchable1234\n")
        self.process_keys(form, [Screen.KEY_TAB, "123", Screen.KEY_BACK, Screen.KEY_DELETE])
        form.save()
        self.assertEqual(text.value, "You can't touch this...12")
Check readonly widgets work as expected.
tests/test_widgets.py