Ejemplo n.º 1
0
 def test_accessor_list_mismatch(self):
     "The number of headings must match the number of accessors if specified as a list"
     with self.assertRaises(ValueError):
         build_accessors(
             headings=['First Col', 'Second Col', 'Third Col'],
             accessors=['first', 'second']
         )
Ejemplo n.º 2
0
    def __init__(self,
                 headings,
                 id=None,
                 style=None,
                 data=None,
                 accessors=None,
                 multiple_select=False,
                 on_select=None,
                 on_double_click=None,
                 missing_value=None,
                 factory=None):
        super().__init__(id=id, style=style, factory=factory)
        self.headings = headings[:]
        self._accessors = build_accessors(self.headings, accessors)
        self._multiple_select = multiple_select
        self._on_select = None
        self._on_double_click = None
        self._data = None
        if missing_value is None:
            print(
                "WARNING: Using empty string for missing value in data. "
                "Define a 'missing_value' on the table to silence this message"
            )
        self._missing_value = missing_value or ''

        self._impl = self.factory.Table(interface=self)
        self.data = data

        self.on_select = on_select
        self.on_double_click = on_double_click
Ejemplo n.º 3
0
 def test_partial_accessor_list(self):
     "None is interpreted as a default on an accessor override list"
     self.assertEqual(
         build_accessors(
             headings=['First Col', '2nd Col', 'Third Col'],
             accessors=[None, 'second', None]
         ),
         ['first_col', 'second', 'third_col']
     )
Ejemplo n.º 4
0
 def test_accessor_dict(self):
     "Accessor overrides can be specified as a dictionary"
     self.assertEqual(
         build_accessors(
             headings=['First Col', '2nd Col', 'Third Col'],
             accessors={'2nd Col': 'second'}
         ),
         ['first_col', 'second', 'third_col']
     )
Ejemplo n.º 5
0
 def test_manual_accessor_list(self):
     "Accessors can be compltely manually specified"
     self.assertEqual(
         build_accessors(
             headings=['First Col', 'Second Col', 'Third Col'],
             accessors=['first', 'second', 'third']
         ),
         ['first', 'second', 'third']
     )
Ejemplo n.º 6
0
    def __init__(self, headings, id=None, style=None, data=None, accessors=None,
                 multiple_select=False, on_select=None, factory=None):
        super().__init__(id=id, style=style, factory=factory)
        self.headings = headings
        self._accessors = build_accessors(headings, accessors)
        self._multiple_select = multiple_select
        self._on_select = None
        self._data = None

        self._impl = self.factory.Table(interface=self)
        self.data = data

        self.on_select = on_select
Ejemplo n.º 7
0
Archivo: tree.py Proyecto: pybee/toga
    def __init__(self, headings, id=None, style=None, data=None, accessors=None,
                 multiple_select=False, on_select=None, factory=None):
        super().__init__(id=id, style=style, factory=factory)
        self.headings = headings
        self._accessors = build_accessors(headings, accessors)
        self._multiple_select = multiple_select
        self._selection = None
        self._data = None
        self._on_select = None

        self._impl = self.factory.Tree(interface=self)
        self.data = data

        self.on_select = on_select
Ejemplo n.º 8
0
 def test_accessor_dict(self):
     "Accessor overrides can be specified as a dictionary"
     self.assertEqual(
         build_accessors(headings=['First Col', '2nd Col', 'Third Col'],
                         accessors={'2nd Col': 'second'}),
         ['first_col', 'second', 'third_col'])
Ejemplo n.º 9
0
 def test_partial_accessor_list(self):
     "None is interpreted as a default on an accessor override list"
     self.assertEqual(
         build_accessors(headings=['First Col', '2nd Col', 'Third Col'],
                         accessors=[None, 'second', None]),
         ['first_col', 'second', 'third_col'])
Ejemplo n.º 10
0
 def test_manual_accessor_list(self):
     "Accessors can be compltely manually specified"
     self.assertEqual(
         build_accessors(headings=['First Col', 'Second Col', 'Third Col'],
                         accessors=['first', 'second', 'third']),
         ['first', 'second', 'third'])
Ejemplo n.º 11
0
 def test_accessor_list_mismatch(self):
     "The number of headings must match the number of accessors if specified as a list"
     with self.assertRaises(ValueError):
         build_accessors(headings=['First Col', 'Second Col', 'Third Col'],
                         accessors=['first', 'second'])
Ejemplo n.º 12
0
 def test_unique_accessors(self):
     "The final accessors must be unique"
     with self.assertRaises(ValueError):
         build_accessors(headings=['Col 1', 'Col - 1', 'Third Col'],
                         accessors=None)
Ejemplo n.º 13
0
 def test_autoconvert_failure(self):
     "If no accessors are provided, all the headings must be autoconvertable"
     with self.assertRaises(ValueError):
         build_accessors(headings=['1st Col', 'Second Col', 'Third Col'],
                         accessors=None)
Ejemplo n.º 14
0
 def test_autoconvert(self):
     "If no accessors are provided, the headings are autoconverted"
     self.assertEqual(
         build_accessors(headings=['First Col', 'Second Col', 'Third Col'],
                         accessors=None),
         ['first_col', 'second_col', 'third_col'])
Ejemplo n.º 15
0
 def test_autoconvert(self):
     "If no accessors are provided, the headings are autoconverted"
     self.assertEqual(
         build_accessors(headings=['First Col', 'Second Col', 'Third Col'], accessors=None),
         ['first_col', 'second_col', 'third_col']
     )
Ejemplo n.º 16
0
 def test_autoconvert_failure(self):
     "If no accessors are provided, all the headings must be autoconvertable"
     with self.assertRaises(ValueError):
         build_accessors(headings=['1st Col', 'Second Col', 'Third Col'], accessors=None)
Ejemplo n.º 17
0
 def test_unique_accessors(self):
     "The final accessors must be unique"
     with self.assertRaises(ValueError):
         build_accessors(headings=['Col 1', 'Col - 1', 'Third Col'], accessors=None)