Esempio n. 1
0
 def checkPixelsParam(self, widget, name, *values, **kwargs):
     if 'conv' in kwargs:
         conv = kwargs.pop('conv')
     else:
         conv = None
     if conv is None:
         conv = self._conv_pixels
     if 'keep_orig' in kwargs:
         keep_orig = kwargs.pop('keep_orig')
     else:
         keep_orig = True
     for value in values:
         expected = _sentinel
         conv1 = conv
         if isinstance(value, str):
             if conv1 and conv1 is not str:
                 expected = pixels_conv(value) * self.scaling
                 conv1 = int_round
         self.checkParam(widget,
                         name,
                         value,
                         expected=expected,
                         conv=conv1,
                         **kwargs)
     self.checkInvalidParam(widget,
                            name,
                            '6x',
                            errmsg='bad screen distance "6x"',
                            keep_orig=keep_orig)
     self.checkInvalidParam(widget,
                            name,
                            'spam',
                            errmsg='bad screen distance "spam"',
                            keep_orig=keep_orig)
 def test_grid_configure_ipady(self):
     b = tkinter.Button(self.root)
     with self.assertRaisesRegexp(TclError, 'bad ipady value "-1": '
                                  'must be positive screen distance'):
         b.grid_configure(ipady=-1)
     b.grid_configure(ipady=1)
     self.assertEqual(b.grid_info()['ipady'], self._str(1))
     b.grid_configure(ipady='.5c')
     self.assertEqual(b.grid_info()['ipady'],
             self._str(int_round(pixels_conv('.5c') * self.scaling)))
Esempio n. 3
0
 def test_grid_configure_padx(self):
     b = Tkinter.Button(self.root)
     with self.assertRaisesRegexp(TclError, 'bad pad value "-1": '
                                  'must be positive screen distance'):
         b.grid_configure(padx=-1)
     b.grid_configure(padx=1)
     self.assertEqual(b.grid_info()['padx'], self._str(1))
     b.grid_configure(padx=(10, 5))
     self.assertEqual(b.grid_info()['padx'], self._str((10, 5)))
     b.grid_configure(padx='.5c')
     self.assertEqual(b.grid_info()['padx'],
             self._str(int_round(pixels_conv('.5c') * self.scaling)))
Esempio n. 4
0
 def test_grid_configure_ipady(self):
     b = Tkinter.Button(self.root)
     with self.assertRaisesRegexp(
             TclError, 'bad ipady value "-1": '
             'must be positive screen distance'):
         b.grid_configure(ipady=-1)
     b.grid_configure(ipady=1)
     self.assertEqual(b.grid_info()['ipady'], self._str(1))
     b.grid_configure(ipady='.5c')
     self.assertEqual(
         b.grid_info()['ipady'],
         self._str(int_round(pixels_conv('.5c') * self.scaling)))
Esempio n. 5
0
 def test_grid_configure_padx(self):
     b = tkinter.Button(self.root)
     with self.assertRaisesRegexp(
             TclError, 'bad pad value "-1": '
             'must be positive screen distance'):
         b.grid_configure(padx=-1)
     b.grid_configure(padx=1)
     self.assertEqual(b.grid_info()['padx'], self._str(1))
     b.grid_configure(padx=(10, 5))
     self.assertEqual(b.grid_info()['padx'], self._str((10, 5)))
     b.grid_configure(padx='.5c')
     self.assertEqual(
         b.grid_info()['padx'],
         self._str(int_round(pixels_conv('.5c') * self.scaling)))
Esempio n. 6
0
 def checkPixelsParam(self, widget, name, *values, **kwargs):
     if "conv" in kwargs:
         conv = kwargs.pop("conv")
     else:
         conv = None
     if conv is None:
         conv = self._conv_pixels
     if "keep_orig" in kwargs:
         keep_orig = kwargs.pop("keep_orig")
     else:
         keep_orig = True
     for value in values:
         expected = _sentinel
         conv1 = conv
         if isinstance(value, str):
             if conv1 and conv1 is not str:
                 expected = pixels_conv(value) * self.scaling
                 conv1 = int_round
         self.checkParam(widget, name, value, expected=expected, conv=conv1, **kwargs)
     self.checkInvalidParam(widget, name, "6x", errmsg='bad screen distance "6x"', keep_orig=keep_orig)
     self.checkInvalidParam(widget, name, "spam", errmsg='bad screen distance "spam"', keep_orig=keep_orig)