コード例 #1
0
def writeMeter(self, openetran):
    grid = self.Meter.layout()
    status = 0

    # Status = 1 when no widgets are left to delete
    while status == 0:
        status = Add_Delete_Widgets.deleteMeter(self, grid)

    # Number of Meters in the system
    num = len(openetran['meter'])

    if num > 1:
        for k in range(num - 1):
            Add_Delete_Widgets.addMeter(self, grid)

    # Different version of writeWidgets because there are ComboBoxes in the layout
    countTotal = grid.count()
    count = 0  # current count of the elements in the layout
    i = 0  # index of the current list (each key containing a list of lists)

    rowStart = 2
    rowEnd = rowStart + 2

    while count < countTotal:
        # List of positions of each text fields in the layout
        positions = [(i, j) for i in range(rowStart, rowEnd)
                     for j in range(1, 4, 2)]
        k = 0

        for position in positions:
            count = (position[0] + 1) * (position[1] + 1)

            if position[0] == (rowEnd - 1) and position[1] == 3:
                continue

            # Slightly different function if it's a combo box to set the text
            elif position[0] == rowStart and position[1] == 1:
                v = openetran['meter'][i][k]
                widget = grid.itemAtPosition(position[0], position[1]).widget()

                if v == '':
                    widget.setCurrentIndex(0)
                else:
                    widget.setCurrentIndex(int(v))

                k += 1

            else:
                v = openetran['meter'][i][k]
                widget = grid.itemAtPosition(position[0], position[1]).widget()
                widget.setText(v)

                k += 1

        rowStart = rowEnd + 1
        rowEnd = rowStart + 2
        i += 1
        k = 0
コード例 #2
0
ファイル: GUI.py プロジェクト: lemauffcam/OpenETran
 def newMeter():
     Add_Delete_Widgets.addMeter(self, self.Meter.layout())