示例#1
0
def test_stack_layout_buttonize():
    w = pedl.Widget(w=50, h=75)
    l = pedl.StackedLayout()
    l.addWidget(w)
    pedl.widgets.MessageButton.buttonize(l)
    assert len(l.widgets) == 2
    assert isinstance(l.widgets[0], pedl.widgets.MessageButton)
示例#2
0
def test_set_layout():
    d = pedl.Designer()
    l = pedl.StackedLayout()
    l.addWidget(pedl.Widget(w=100, h=100))
    d.window.setLayout(l, resize=True)
    assert d.widgets == [l]
    assert d.window.w == 110
    assert d.window.h == 110
示例#3
0
 def __init__(self, title, target_width=850, **kwargs):
     super(EmbeddedControl, self).__init__(alignment=AlignmentChoice.Center,
                                           **kwargs)
     #Title Shape
     self.title = title
     self.target_width = target_width
     #Create a StackedLayout so title can be buttonized later
     hd = pedl.StackedLayout()
     hd.addWidget(self.header)
     #Add to top of page
     self.addLayout(hd)
示例#4
0
def test_recursive_widget_search():
    d = pedl.Designer()
    l = pedl.StackedLayout()
    w1 = pedl.Widget()
    w2 = pedl.widgets.Rectangle(name='RECT')
    w3 = pedl.Widget()
    l.addWidget(w1)
    l.addWidget(w2)
    d.window.setLayout(l)
    d.addWidget(w3)
    assert d.widgets == [l, w3]
    assert d.findChildren() == [w1, w2, w3]
    assert d.findChildren(name='RECT') == [w2]
    assert d.findChildren(_type=pedl.widgets.Rectangle) == [w2]
示例#5
0
def test_stack_layout():
    l = pedl.StackedLayout()
    l.addWidget(pedl.Widget(w=50,  h=100))
    l.addWidget(pedl.Widget(w=100, h=50))
    l.addWidget(pedl.Widget(w=100, h=100))

    #Default locations
    assert l.widgets[0].x == 0
    assert l.widgets[1].x == -25
    assert l.widgets[2].x == -25

    assert l.widgets[0].y == 0
    assert l.widgets[1].y == 25
    assert l.widgets[2].y == 0

    assert l.w == 100
    assert l.h == 100

    #Adjust Spacing
    assert l.spacing == None
    
    with pytest.raises(ValueError):
        l.spacing = 4

    #Adjust Alignments
    l.alignment = pedl.choices.AlignmentChoice.Left
    assert l.widgets[0].x == 0
    assert l.widgets[1].x == 0
    assert l.widgets[2].x == 0
    assert l.widgets[0].y == 0
    assert l.widgets[1].y == 25
    assert l.widgets[2].y == 0
    assert l.w            == 100
    assert l.h            == 100

    l.alignment = pedl.choices.AlignmentChoice.Top
    assert l.widgets[0].x == 0
    assert l.widgets[1].x == -25
    assert l.widgets[2].x == -25
    assert l.widgets[0].y == 0
    assert l.widgets[1].y == 0
    assert l.widgets[2].y == 0
    assert l.w            == 100
    assert l.h            == 100    
    
    l.alignment = pedl.choices.AlignmentChoice.Right
    assert l.widgets[0].x == 0
    assert l.widgets[1].x == -50
    assert l.widgets[2].x == -50
    assert l.widgets[0].y == 0
    assert l.widgets[1].y == 25
    assert l.widgets[2].y == 0
    assert l.w            == 100
    assert l.h            == 100    
    
    l.alignment = pedl.choices.AlignmentChoice.Bottom
    assert l.widgets[0].x == 0
    assert l.widgets[1].x == -25
    assert l.widgets[2].x == -25
    assert l.widgets[0].y == 0
    assert l.widgets[1].y == 50
    assert l.widgets[2].y == 0
    assert l.w            == 100
    assert l.h            == 100    
    
    l.alignment = (pedl.choices.AlignmentChoice.Top,
                   pedl.choices.AlignmentChoice.Right)
    assert l.widgets[0].x == 0
    assert l.widgets[1].x == -50
    assert l.widgets[2].x == -50
    assert l.widgets[0].y == 0
    assert l.widgets[1].y == 0
    assert l.widgets[2].y == 0
    assert l.w            == 100
    assert l.h            == 100    

    #Adjust Position
    l.x = 100
    l.y = 150

    assert l.widgets[0].x == 150
    assert l.widgets[1].x == 100
    assert l.widgets[2].x == 100
    assert l.w            == 100

    assert l.widgets[0].y == 150
    assert l.widgets[1].y == 150
    assert l.widgets[2].y == 150
    assert l.h            == 100
    
    assert l.x == 100
    assert l.y == 150