Пример #1
0
def test_command():
    a = App()
    
    callback_event = Event()
    def callback():
        callback_event.set()

    s = Slider(a, command = callback)
    assert not callback_event.is_set()
    # you cant invoke a tk scale - this is better than no tests!
    s._command_callback(s.value)
    assert callback_event.is_set()

    a.destroy()
Пример #2
0
def test_command_with_parameter():
    a = App()
    
    callback_event = Event()
    def callback(value):
        assert value == 0
        callback_event.set()

    s = Slider(a, command = callback)
    assert not callback_event.is_set()

    s._command_callback(s.value)
    assert callback_event.is_set()

    a.destroy()
Пример #3
0
def test_update_command_with_parameter():
    a = App()
    
    callback_event = Event()
    def callback(value):
        assert s.value == 0
        callback_event.set()

    s = Slider(a)
    
    s.update_command(callback)

    s._command_callback(s.value)
    assert callback_event.is_set()

    a.destroy()
Пример #4
0
def test_update_command():
    a = App()
    
    callback_event = Event()
    def callback():
        callback_event.set()

    s = Slider(a)
    
    s._command_callback(s.value)
    assert not callback_event.is_set()
    
    s.update_command(callback)
    s._command_callback(s.value)
    assert callback_event.is_set()
    callback_event.clear()

    s.update_command(None)
    s._command_callback(s.value)
    assert not callback_event.is_set()
    
    a.destroy()