Example #1
0
 def __init__(self):
     self.settings = MPSettings([
         MPSetting('foo',
                   int,
                   1,
                   'foo int',
                   tab='Link',
                   range=(0, 4),
                   increment=1),
         MPSetting('bar',
                   float,
                   4,
                   'bar float',
                   range=(-1, 20),
                   increment=1)
     ])
     self.completions = {"script": ["(FILENAME)"], "set": ["(SETTING)"]}
     self.command_map = {
         'script': (None, 'run a script of MAVProxy commands'),
         'set': (None, 'mavproxy settings'),
     }
     self.aliases = {}
        '''check if child is still going'''
        return self.child.is_alive()


if __name__ == "__main__":
    multiprocessing.freeze_support()

    def test_callback(setting):
        '''callback on apply'''
        print("Changing %s to %s" % (setting.name, setting.value))

    # test the settings
    import mp_settings, time
    from mp_settings import MPSetting
    settings = mp_settings.MPSettings([
        MPSetting('link', int, 1, tab='TabOne'),
        MPSetting('altreadout', int, 10, range=(-30, 1017), increment=1),
        MPSetting('pvalue',
                  float,
                  0.3,
                  range=(-3.0, 1e6),
                  increment=0.1,
                  digits=2),
        MPSetting('enable', bool, True, tab='TabTwo'),
        MPSetting('colour', str, 'Blue', choice=['Red', 'Green', 'Blue']),
        MPSetting('foostr', str, 'blah', label='Foo String')
    ])
    settings.set_callback(test_callback)
    dlg = WXSettings(settings)
    while dlg.is_alive():
        time.sleep(0.1)