Beispiel #1
0
 def test_set_widget_succeeding(self):
     parent = QScrollArea()
     ChildAdder.add(QLabel(), 'fred', parent)
     self.assertTrue(isinstance(parent.widget(), QLabel))
     # We promise to setWidgetResizable(True), also.
     resizable = parent.widgetResizable()
     self.assertTrue(resizable)
Beispiel #2
0
 def test_qslider_intervention(self):
     parent = QHBoxLayout()
     slider = QSlider()  # Don't specify orientation.
     ChildAdder.add(slider, 'fred', parent)
     # We promise to give it horizontal (the non-default) orientation.
     orient = slider.orientation()
     self.assertEqual(orient, Qt.Orientation.Horizontal)
Beispiel #3
0
    def _process_line_internals(cls, line, finder, layouts_created):
        """
        The guts of the process-line logic.
        """
        is_a_comment, is_blank, indent, name, type_string, parenthesised = \
            LineParser.parse_line(line)
        if is_a_comment or is_blank:
            return

        # Amount of indentation gives us the depth at which this line lives in
        # parent-child hierarchy. Top level objects have depth=1.

        depth = 1 + indent / 2  # Integer division.
        BuilderAssertions.assert_have_not_skipped_a_level(
            depth, layouts_created)

        # Ask the QObjectMaker to create the new QObject, passing in the
        # object finder, in case it needs to find it rather than make it.
        new_qobject = QObjectMaker(finder).make(name, type_string)

        # Add then object as a child to its parent if required.
        if depth > 1:
            parent_level = depth - 1
            parent_object, parent_path = \
                layouts_created.most_recently_added_at_level(
                    parent_level)
            ChildAdder.add(new_qobject, name, parent_object)
            layouts_created.register_child(new_qobject, parent_path, name)
        else:  # A top-level object.
            layouts_created.register_top_level_object(new_qobject, name)

        # Finish up by processing any text present in the line in parenthesis.
        cls._process_parenthesised_text(parenthesised, new_qobject)
Beispiel #4
0
 def test_add_spacer_item_succeeding(self):
     parent = QHBoxLayout()
     ChildAdder.add(QSpacerItem(0, 0), 'fred', parent)
     self.assertTrue(isinstance(parent.itemAt(0), QSpacerItem))
Beispiel #5
0
 def test_add_tab_succeeding(self):
     parent = QTabWidget()
     ChildAdder.add(QLabel(), 'fred', parent)
     self.assertEqual(parent.count(), 1)
     self.assertTrue(isinstance(parent.currentWidget(), QLabel))
Beispiel #6
0
 def test_set_layout_succeeding(self):
     parent = QWidget()
     ChildAdder.add(QHBoxLayout(), 'fred', parent)
     self.assertTrue(isinstance(parent.layout(), QHBoxLayout))
Beispiel #7
0
 def test_add_layout_succeeding(self):
     parent = QVBoxLayout()
     ChildAdder.add(QHBoxLayout(), 'fred', parent)
     self.assertEqual(parent.count(), 1)
     self.assertTrue(isinstance(parent.itemAt(0), QHBoxLayout))