コード例 #1
0
    def __init__(self, hutch):
        #Initialize layout
        super(HXRAYHome, self).__init__(hutch, spacing=self.horiz_spacing)

        #Set Embedded window size
        HXRAYStand.window_size = self.window_size

        #All displays not including embedded controls
        left_panels = pedl.VBoxLayout(spacing=self.vert_spacing,
                                      alignment=AlignmentChoice.Center)

        indicators = pedl.HBoxLayout(spacing=self.horiz_spacing,
                                     alignment=AlignmentChoice.Center)
        #Add all stand indicators and buttons
        for stand in self.group.subgroups:
            indicators.addLayout(self.create_stand_buttons(stand))

        #Create left panel layout
        left_panels.addLayout(indicators)
        #left_panels.addLayout(ControlTab)
        self.addLayout(left_panels)

        #Create EmbeddedControls
        self.stands = self.create_stands()
        self.window = self.create_window()
        self.addWidget(self.window)
コード例 #2
0
def test_compound_layout():
    h  = pedl.HBoxLayout()
    v1 = pedl.VBoxLayout()
    v2 = pedl.VBoxLayout()
    for l in (v1,v2):
        l.addWidget(pedl.Widget(w=100,h=200))
        l.addWidget(pedl.Widget(w=200,h=100))
        h.addLayout(l)

    #Check layout positioning
    assert h.widgets[0].x == 0
    assert h.widgets[1].x == 205
    assert h.widgets[0].y == 0
    assert h.widgets[1].y == 0
    assert h.w == 405
    assert h.h == 305

    #Move child alignment
    h.alignment = pedl.choices.AlignmentChoice.Bottom
    v1.spacing  = 30
    assert h.widgets[0].y == 0
    assert h.widgets[1].y == 25
    assert h.h == 330

    #Move parent alignment
    h.spacing  = 30
    assert h.widgets[0].x == 0
    assert h.widgets[1].x == 230
    assert h.w == 430
コード例 #3
0
ファイル: buttons.py プロジェクト: slaclab/hxdhome
    def __init__(self, group):
        #Save groups
        self.group = group

        super(StandIndicator, self).__init__()

        #Grab motors
        motors = [d for d in self.group.devices if 'MMS' in d.prefix]

        #Create overall layout
        lights = pedl.HBoxLayout(spacing=self.indicator_spacing,
                                 alignment=AlignmentChoice.Bottom)

        for column in columnize(motors, self.max_col_height):
            #Create column layout
            l = pedl.VBoxLayout(spacing=self.indicator_spacing)
            #Add each motor
            for mtr in column:
                l.addWidget(self.create_indicator(mtr))
            #Add to overall layout
            lights.addLayout(l)

        #Find proper frame dimension
        w, h = [d + 2 * self.frame_margin for d in (lights.w, lights.h)]

        #Add each frame
        for mtr in motors:
            self.addWidget(self.create_motion_indicator(mtr, w, h))

        #Add indicators
        self.addLayout(lights)

        #Add Group Selection
        self.add_menu()
コード例 #4
0
    def __init__(self, group, **kwargs):
        self.group = group
        #Initial initialization
        super(EmbeddedStand, self).__init__(title=group.name,
                                            spacing=self.type_spacing,
                                            **kwargs)
        #Find number of columns of buttons
        col_num = columns_per_page(self.target_width,
                                   self.device_button_size[0],
                                   self.button_spacing)
        #Assemble button layout
        button_layout = pedl.VBoxLayout(spacing=self.button_spacing)
        #Add each row of buttons
        for column in columnize(self.device_buttons, col_num):
            h = pedl.HBoxLayout(spacing=self.button_spacing)
            list(map(lambda b: h.addWidget(b), column))
            button_layout.addLayout(h)

        #Add buttons
        self.addLayout(button_layout)
コード例 #5
0
    def __init__(self, group, **kwargs):
        #Configuration Notes
        self.group = group

        super(EmbeddedGroup, self).__init__(title=self.group.name,
                                            spacing=self.type_spacing,
                                            **kwargs)
        #Iterate through Device Types
        for screen in self.embedded_types:

            #Find size of embedded window
            with open(screen, 'r') as handle:
                (screen_w, screen_h) = pedl.utils.find_screen_size(handle)

            #Find proper number of columns
            cols = columns_per_page(self.target_width, screen_w,
                                    self.device_spacing)
            #Initialize device layout
            device_layout = pedl.HBoxLayout(spacing=self.device_spacing)

            #Find widgets of this type
            widgets = sorted(
                [d for d in self.group.devices if d.embedded_screen == screen],
                key=lambda d: d.name)

            #Add each column of devices to device layout
            for column in np.array_split(widgets, cols):
                #Don't add empty columns
                if any(column):
                    l = pedl.VBoxLayout(spacing=self.device_spacing)
                    list(
                        map(lambda d: l.addWidget(self.embed_device(d)),
                            column))
                    device_layout.addLayout(l)

            self.addLayout(device_layout)
コード例 #6
0
def test_horizontal_layout():
    l = pedl.HBoxLayout()
    
    assert l.w == 0
    assert l.h == 0

    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 == 55
    assert l.widgets[2].x == 160

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

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

    #Adjust Spacing
    l.spacing = 10
    assert l.widgets[0].x == 0
    assert l.widgets[1].x == 60
    assert l.widgets[2].x == 170
    assert l.w            == 270

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

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

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

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

    assert l.x == 100
    assert l.y == 150