예제 #1
0
파일: base.py 프로젝트: pybee/toga
    def rehint(self):
        # print("REHINT", self, self.native.get_preferred_width(), self.native.get_preferred_height())
        width = self.native.get_preferred_width()
        height = self.native.get_preferred_height()

        self.interface.intrinsic.width = at_least(width[0])
        self.interface.intrinsic.height = at_least(height[0])
예제 #2
0
파일: test_pack.py 프로젝트: pybee/toga
    def test_tutorial_1(self):
        root = TestNode(
            'app', style=Pack(direction=COLUMN, padding_top=10), children=[
                TestNode('f_box', style=Pack(direction=ROW, padding=5), children=[
                    TestNode('f_input', style=Pack(flex=1, padding_left=160), size=(at_least(100), 15)),
                    TestNode('f_label', style=Pack(width=100, padding_left=10), size=(at_least(40), 10)),
                ]),
                TestNode('c_box', style=Pack(direction=ROW, padding=5), children=[
                    TestNode('join_label', style=Pack(width=150, padding_right=10), size=(at_least(80), 10)),
                    TestNode('c_input', style=Pack(flex=1), size=(at_least(100), 15)),
                    TestNode('c_label', style=Pack(width=100, padding_left=10), size=(at_least(40), 10)),
                ]),
                TestNode('button', style=Pack(flex=1, padding=15), size=(at_least(120), 30)),
            ]
        )

        # Minimum size
        root.style.layout(root, Viewport(0, 0))
        self.assertLayout(
            root,
            (380, 120),
            {'origin': (0, 10), 'content': (380, 110), 'children': [
                {'origin': (5, 15), 'content': (370, 15), 'children': [
                    {'origin': (165, 15), 'content': (100, 15)},
                    {'origin': (275, 15), 'content': (100, 10)},
                ]},
                {'origin': (5, 40), 'content': (370, 15), 'children': [
                    {'origin': (5, 40), 'content': (150, 10)},
                    {'origin': (165, 40), 'content': (100, 15)},
                    {'origin': (275, 40), 'content': (100, 10)},
                ]},
                {'origin': (15, 75), 'content': (120, 30)}
            ]}
        )

        # Normal size
        root.style.layout(root, Viewport(640, 480))
        self.assertLayout(
            root,
            (640, 120),
            {'origin': (0, 10), 'content': (640, 110), 'children': [
                {'origin': (5, 15), 'content': (630, 15), 'children': [
                    {'origin': (165, 15), 'content': (360, 15)},
                    {'origin': (535, 15), 'content': (100, 10)},
                ]},
                {'origin': (5, 40), 'content': (630, 15), 'children': [
                    {'origin': (5, 40), 'content': (150, 10)},
                    {'origin': (165, 40), 'content': (360, 15)},
                    {'origin': (535, 40), 'content': (100, 10)},
                ]},
                {'origin': (15, 75), 'content': (610, 30)}
            ]}
        )
예제 #3
0
파일: numberinput.py 프로젝트: pybee/toga
    def rehint(self):
        # Height of a text input is known and fixed.
        stepper_size = self.input.intrinsicContentSize()
        input_size = self.input.intrinsicContentSize()

        self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
        self.interface.intrinsic.height = max(input_size.height, stepper_size.height)
예제 #4
0
파일: label.py 프로젝트: pybee/toga
    def rehint(self):
        # print("REHINT", self, self.native.get_preferred_width(), self.native.get_preferred_height(), getattr(self, '_fixed_height', False), getattr(self, '_fixed_width', False))
        width = self.native.get_preferred_width()
        height = self.native.get_preferred_height()

        self.interface.intrinsic.width = at_least(width[0])
        self.interface.intrinsic.height = height[1]
예제 #5
0
파일: test_pack.py 프로젝트: pybee/toga
    def test_tutorial_0(self):
        root = TestNode(
            'app', style=Pack(), children=[
                TestNode('button', style=Pack(flex=1, padding=50), size=(at_least(120), 30)),
            ]
        )

        # Minimum size
        root.style.layout(root, Viewport(0, 0))
        self.assertLayout(
            root,
            (220, 130),
            {'origin': (0, 0), 'content': (220, 130), 'children': [
                {'origin': (50, 50), 'content': (120, 30)}
            ]}
        )

        # Normal size
        root.style.layout(root, Viewport(640, 480))
        self.assertLayout(
            root,
            (640, 130),
            {'origin': (0, 0), 'content': (640, 130), 'children': [
                {'origin': (50, 50), 'content': (540, 30)}
            ]}
        )
예제 #6
0
파일: slider.py 프로젝트: pybee/toga
    def rehint(self):
        # print("REHINT", self, self.native.get_preferred_width(), self.native.get_preferred_height())
        width = self.native.get_preferred_width()
        height = self.native.get_preferred_height()

        # Set intrinsic width to at least the minimum width
        self.interface.intrinsic.width = at_least(width[0])
        # Set intrinsic height to the natural height
        self.interface.intrinsic.height = height[1]
예제 #7
0
파일: test_pack.py 프로젝트: pybee/toga
    def test_beeliza(self):
        root = TestNode(
            'app', style=Pack(direction=COLUMN), children=[
                TestNode('detailedlist', style=Pack(flex=1), size=(at_least(100), at_least(100))),
                TestNode('box', style=Pack(direction=ROW), children=[
                    TestNode('input', style=Pack(flex=1, padding=5), size=(at_least(100), 15)),
                    TestNode('button', style=Pack(padding=5), size=(at_least(40), 10)),
                ]),
            ]
        )

        # Minimum size
        root.style.layout(root, Viewport(0, 0))
        self.assertLayout(
            root,
            (160, 125),
            {'origin': (0, 0), 'content': (160, 125), 'children': [
                {'origin': (0, 0), 'content': (100, 100)},
                {'origin': (0, 100), 'content': (160, 25), 'children': [
                    {'origin': (5, 105), 'content': (100, 15)},
                    {'origin': (115, 105), 'content': (40, 10)},
                ]},
            ]}
        )

        # Normal size
        root.style.layout(root, Viewport(640, 480))
        self.assertLayout(
            root,
            (640, 480),
            {'origin': (0, 0), 'content': (640, 480), 'children': [
                {'origin': (0, 0), 'content': (640, 455)},
                {'origin': (0, 455), 'content': (640, 25), 'children': [
                    {'origin': (5, 460), 'content': (580, 15)},
                    {'origin': (595, 460), 'content': (40, 10)},
                ]},
            ]}
        )
예제 #8
0
파일: test_pack.py 프로젝트: pybee/toga
    def test_tutorial_3(self):
        root = TestNode(
            'app', style=Pack(direction=COLUMN), children=[
                TestNode('box', style=Pack(), children=[
                    TestNode('input', style=Pack(flex=1, padding=5), size=(at_least(100), 15)),
                    TestNode('button', style=Pack(width=50, padding=5), size=(at_least(40), 10)),
                ]),
                TestNode('web', style=Pack(flex=1), size=(at_least(100), at_least(100))),
            ]
        )

        # Minimum size
        root.style.layout(root, Viewport(0, 0))
        self.assertLayout(
            root,
            (170, 125),
            {'origin': (0, 0), 'content': (170, 125), 'children': [
                {'origin': (0, 0), 'content': (170, 25), 'children': [
                    {'origin': (5, 5), 'content': (100, 15)},
                    {'origin': (115, 5), 'content': (50, 10)},
                ]},
                {'origin': (0, 25), 'content': (100, 100)}
            ]}
        )

        # Normal size
        root.style.layout(root, Viewport(640, 480))
        self.assertLayout(
            root,
            (640, 480),
            {'origin': (0, 0), 'content': (640, 480), 'children': [
                {'origin': (0, 0), 'content': (640, 25), 'children': [
                    {'origin': (5, 5), 'content': (570, 15)},
                    {'origin': (585, 5), 'content': (50, 10)},
                ]},
                {'origin': (0, 25), 'content': (640, 455)}
            ]}
        )
예제 #9
0
 def rehint(self):
     # Height of a text input is known and fixed.
     # Width must be > 100
     # print("REHINT TextInput", self, self.native.PreferredSize)
     self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
     self.interface.intrinsic.height = self.native.PreferredSize.Height
예제 #10
0
 def rehint(self):
     self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
     self.interface.intrinsic.height = at_least(self.interface.MIN_HEIGHT)
예제 #11
0
 def rehint(self):
     # Height of a date input is known and fixed.
     # Width must be > 100
     self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
     self.interface.intrinsic.height = self.native.PreferredSize.Height
예제 #12
0
파일: selection.py 프로젝트: pybee/toga
 def rehint(self):
     # Height of a text input is known.
     fitting_size = self.native.systemLayoutSizeFittingSize(CGSize(0, 0))
     self.interface.intrinsic.width = at_least(fitting_size.width)
     self.interface.intrinsic.height = fitting_size.height
예제 #13
0
파일: progressbar.py 프로젝트: pybee/toga
 def rehint(self):
     self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
     self.interface.intrinsic.height = self.native.intrinsicContentSize().height
예제 #14
0
파일: textinput.py 프로젝트: yuntiaoOS/toga
 def rehint(self):
     # Height of a text input is known and fixed.
     # print("REHINT text input", self, self.native.getMeasuredWidth(), self.native.getMeasuredHeight())
     self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
     self.interface.intrinsic.height = self.native.getMeasuredHeight(
     ) / self.app.native.device_scale
예제 #15
0
 def rehint(self):
     self.interface.intrinsic.width = at_least(self.interface.size[0])
     self.interface.intrinsic.height = at_least(self.interface.size[1])
예제 #16
0
 def test_at_least_repr(self):
     self.assertEqual(repr(at_least(10)), 'at least 10')
예제 #17
0
 def rehint(self):
     # Height of a text input is known.
     fitting_size = self.native.systemLayoutSizeFittingSize(CGSize(0, 0))
     self.interface.intrinsic.width = at_least(fitting_size.width)
     self.interface.intrinsic.height = fitting_size.height
예제 #18
0
    def rehint(self):
        width = self.native.get_preferred_width()
        height = self.native.get_preferred_height()

        self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
        self.interface.intrinsic.height = height[1]
예제 #19
0
파일: selection.py 프로젝트: prinzpiuz/toga
 def rehint(self):
     fitting_size = self.native.fittingSize()
     self.interface.intrinsic.height = fitting_size.height
     self.interface.intrinsic.width = at_least(fitting_size.width)
예제 #20
0
 def rehint(self):
     # Width & height of a label is known and fixed.
     # print("REHINT label", self, self.native.fittingSize().width, self.native.fittingSize().height)
     fitting_size = self.native.systemLayoutSizeFittingSize(CGSize(0, 0))
     self.interface.intrinsic.width = at_least(fitting_size.width)
     self.interface.intrinsic.height = fitting_size.height
예제 #21
0
파일: label.py 프로젝트: pybee/toga
 def rehint(self):
     # Width & height of a label is known and fixed.
     # print("REHINT label", self, self.native.fittingSize().width, self.native.fittingSize().height)
     fitting_size = self.native.systemLayoutSizeFittingSize(CGSize(0, 0))
     self.interface.intrinsic.width = at_least(fitting_size.width)
     self.interface.intrinsic.height = fitting_size.height
예제 #22
0
파일: numberinput.py 프로젝트: pybee/toga
 def rehint(self):
     width = self.native.get_preferred_width()
     height = self.native.get_preferred_height()
     if width and height:
         self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
         self.interface.intrinsic.height = height[1]
예제 #23
0
파일: textinput.py 프로젝트: pybee/toga
 def rehint(self):
     # Height of a text input is known and fixed.
     # Width must be > 100
     # print("REHINT TextInput", self, self.native.PreferredSize)
     self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
     self.interface.intrinsic.height = self.native.PreferredSize.Height
예제 #24
0
파일: label.py 프로젝트: pybee/toga
 def rehint(self):
     # Width & height of a label is known and fixed.
     content_size = self.native.intrinsicContentSize()
     # print("REHINT label", self, content_size.width, content_size.height)
     self.interface.intrinsic.width = at_least(content_size.width)
     self.interface.intrinsic.height = content_size.height
예제 #25
0
 def rehint(self):
     # print("REHINT label", self, self.native.getMeasuredWidth(), self.native.getMeasuredHeight())
     self.interface.intrinsic.width = at_least(
         self.native.getMeasuredWidth() / self.app.device_scale)
     self.interface.intrinsic.height = self.native.getMeasuredHeight(
     ) / self.app.device_scale
예제 #26
0
 def rehint(self):
     self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
     self.interface.intrinsic.height = self.native.fittingSize().height
예제 #27
0
파일: textinput.py 프로젝트: yuntiaoOS/toga
 def rehint(self):
     # Height of a text input is known and fixed.
     # Width must be > 100
     # print("REHINT TextInput", self, self._impl.intrinsicContentSize().width, self._impl.intrinsicContentSize().height)
     self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
     self.interface.intrinsic.height = self.native.intrinsicContentSize().height
예제 #28
0
파일: button.py 프로젝트: nicoddemus/toga
 def rehint(self):
     # self.native.Size = Size(0, 0)
     # print("REHINT Button", self, self.native.PreferredSize)
     self.interface.intrinsic.width = at_least(
         self.native.PreferredSize.Width)
     self.interface.intrinsic.height = self.native.PreferredSize.Height
예제 #29
0
파일: selection.py 프로젝트: pybee/toga
 def rehint(self):
     self.interface.intrinsic.width = at_least(self.native.PreferredSize.Width)
     self.interface.intrinsic.height = self.native.PreferredSize.Height
예제 #30
0
 def test_size_repr(self):
     self.assertEqual(repr(self.size), '(1, 2)')
     self.size.width = at_least(10)
     self.assertEqual(repr(self.size), '(at least 10, 2)')
예제 #31
0
파일: datepicker.py 프로젝트: pybee/toga
 def rehint(self):
     # Height of a date input is known and fixed.
     # Width must be > 200
     self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
     self.interface.intrinsic.height = self.native.PreferredSize.Height
예제 #32
0
파일: button.py 프로젝트: pybee/toga
 def rehint(self):
     content_size = self.native.intrinsicContentSize()
     self.interface.intrinsic.width = at_least(content_size.width)
     self.interface.intrinsic.height = content_size.height
예제 #33
0
 def rehint(self):
     self.native.measure(View__MeasureSpec.UNSPECIFIED,
                         View__MeasureSpec.UNSPECIFIED)
     self.interface.intrinsic.width = at_least(
         self.native.getMeasuredWidth())
     self.interface.intrinsic.height = self.native.getMeasuredHeight()
예제 #34
0
파일: label.py 프로젝트: pybee/toga
 def rehint(self):
     # print("REHINT label", self, self.native.getMeasuredWidth(), self.native.getMeasuredHeight())
     self.interface.intrinsic.width = at_least(self.native.getMeasuredWidth() / self.app.device_scale)
     self.interface.intrinsic.height = self.native.getMeasuredHeight() / self.app.device_scale
예제 #35
0
 def rehint(self):
     fitting_size = self.native.systemLayoutSizeFittingSize_(CGSize(0, 0))
     self.interface.intrinsic.width = at_least(fitting_size.width)
     self.interface.intrinsic.height = fitting_size.height
예제 #36
0
파일: selection.py 프로젝트: pybee/toga
 def rehint(self):
     content_size = self.native.intrinsicContentSize()
     self.interface.intrinsic.height = content_size.height
     self.interface.intrinsic.width = at_least(max(self.interface.MIN_WIDTH, content_size.width))
예제 #37
0
 def rehint(self):
     content_size = self.native.intrinsicContentSize()
     self.interface.intrinsic.height = content_size.height
     self.interface.intrinsic.width = at_least(content_size.width)
예제 #38
0
파일: canvas.py 프로젝트: pybee/toga
 def rehint(self):
     fitting_size = self.native.systemLayoutSizeFittingSize(CGSize(0, 0))
     self.interface.intrinsic.width = at_least(fitting_size.width)
     self.interface.intrinsic.height = at_least(fitting_size.height)
예제 #39
0
 def rehint(self):
     self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
     self.interface.intrinsic.height = self.native.PreferredSize.Height
예제 #40
0
파일: detailedlist.py 프로젝트: pybee/toga
 def rehint(self):
     self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
     self.interface.intrinsic.height = at_least(self.interface.MIN_HEIGHT)
예제 #41
0
파일: textinput.py 프로젝트: pybee/toga
 def rehint(self):
     # Height of a text input is known and fixed.
     # print("REHINT text input", self, self.native.getMeasuredWidth(), self.native.getMeasuredHeight())
     self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
     self.interface.intrinsic.height = self.native.getMeasuredHeight() / self.app.native.device_scale