コード例 #1
0
ファイル: test_accessors.py プロジェクト: pybee/toga
 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']
         )
コード例 #2
0
ファイル: table.py プロジェクト: SamSchott/maestral-cocoa
    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
コード例 #3
0
ファイル: test_accessors.py プロジェクト: pybee/toga
 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']
     )
コード例 #4
0
ファイル: test_accessors.py プロジェクト: pybee/toga
 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']
     )
コード例 #5
0
ファイル: test_accessors.py プロジェクト: pybee/toga
 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']
     )
コード例 #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
コード例 #7
0
ファイル: tree.py プロジェクト: 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
コード例 #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'])
コード例 #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'])
コード例 #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'])
コード例 #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'])
コード例 #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)
コード例 #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)
コード例 #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'])
コード例 #15
0
ファイル: test_accessors.py プロジェクト: pybee/toga
 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']
     )
コード例 #16
0
ファイル: test_accessors.py プロジェクト: pybee/toga
 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)
コード例 #17
0
ファイル: test_accessors.py プロジェクト: pybee/toga
 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)