def test_frame_text(): frame = DirectFrame(text="Test") assert frame.hascomponent('text0') assert not frame.hascomponent('text1') assert frame.component('text0').text == "Test" # Change text frame.setText("Foo") assert frame.component('text0').text == "Foo" # Change text to unicode frame.setText(u"Foo") # Clear text frame.clearText() assert not frame.hascomponent('text0')
def test_frame_text_states(): frame = DirectFrame(text=("A", "B", "C"), numStates=3) assert frame.hascomponent('text0') assert frame.hascomponent('text1') assert frame.hascomponent('text2') assert not frame.hascomponent('text3') assert frame.component('text0').text == "A" assert frame.component('text1').text == "B" assert frame.component('text2').text == "C" # Change text for all states frame.setText("Foo") assert frame.component('text0').text == "Foo" assert frame.component('text1').text == "Foo" assert frame.component('text2').text == "Foo" # Change text per state frame.setText(("1", "2", "3")) assert frame.component('text0').text == "1" assert frame.component('text1').text == "2" assert frame.component('text2').text == "3" # Changing via list should work too frame.setText(["1", "2", "3"]) # Clear text frame.clearText() assert not frame.hascomponent('text0') assert not frame.hascomponent('text1') assert not frame.hascomponent('text2')