Exemple #1
0
 def testShrinkTotallyHomogeneousPrimary(self):
     """HBoxLayout.allocateSize shrink totally homogeneous primary works."""
     requested_size = self.homo_box.requestSize(self.children)
     allocated_size = SizeAllocation((200, 100), requested_size)
     allocated_size.width = 0
     self.homo_box.allocateSize(allocated_size, requested_size,
                                self.children)
     self.assertEqual(self.widget1.allocated_size.size, Size(0, 15))
     self.assertEqual(self.widget2.allocated_size.size, Size(0, 15))
     self.assertEqual(self.widget3.allocated_size.size, Size(0, 15))
     self.assertEqual(self.widget1.allocated_size.pos, Pos(200, 100))
     self.assertEqual(self.widget2.allocated_size.pos, Pos(200, 100))
     self.assertEqual(self.widget3.allocated_size.pos, Pos(200, 100))
Exemple #2
0
 def testShrinkHomogeneousSecondary(self):
     """VBoxLayout.allocateSize shrink homogeneous secondary works."""
     requested_size = self.homo_box.requestSize(self.children)
     allocated_size = SizeAllocation((100, 200), requested_size)
     allocated_size.width = 5
     self.homo_box.allocateSize(allocated_size, requested_size,
                                self.children)
     self.assertEqual(self.widget1.allocated_size.size, Size(5, 40))
     self.assertEqual(self.widget2.allocated_size.size, Size(5, 40))
     self.assertEqual(self.widget3.allocated_size.size, Size(5, 40))
     self.assertEqual(self.widget1.allocated_size.pos, Pos(100, 200))
     self.assertEqual(self.widget2.allocated_size.pos, Pos(100, 247))
     self.assertEqual(self.widget3.allocated_size.pos, Pos(100, 294))
Exemple #3
0
 def testShrinkALotHomogeneousPrimary(self):
     """HBoxLayout.allocateSize shrink a lot homogeneous primary works."""
     requested_size = self.homo_box.requestSize(self.children)
     allocated_size = SizeAllocation((200, 100), requested_size)
     allocated_size.width = 10
     # 10 is not even enough to hold the spacing.  The children should have
     # a width of 0. Now we have to shrink the spacing.  Its length is 7.
     # There are two spacings: 7, 7 for a total of 14.  We apply a homothecy
     # to make it fit into 10. 7 * 10 / 14 = 5. 14*10/14=10. So we get 5 and
     # 10 for coords out of the homothecy, and therefore 5 and 5 for the
     # lengths of the spacing.  We don't care about the lengths but we are
     # interested in the coords since they give us the positions of our
     # children.  Just add a 0 in front of the list:  0, 5, 10.
     self.homo_box.allocateSize(allocated_size, requested_size,
                                self.children)
     self.assertEqual(self.widget1.allocated_size.size, Size(0, 15))
     self.assertEqual(self.widget2.allocated_size.size, Size(0, 15))
     self.assertEqual(self.widget3.allocated_size.size, Size(0, 15))
     self.assertEqual(self.widget1.allocated_size.pos, Pos(200, 100))
     self.assertEqual(self.widget2.allocated_size.pos, Pos(205, 100))
     self.assertEqual(self.widget3.allocated_size.pos, Pos(210, 100))