def __init__(self, ruler, parent=None):
        QWidget.__init__(self, parent)

        # colors settings
        backgroundColor = ruler.data.get('background_color')
        linesColor = ruler.data.get('lines_color')
        divisionsColor = ruler.data.get('divisions_color')

        def updateBackgroundColor(newColor):
            ruler.data.update('background_color', newColor)
            ruler.update()

        def updateLinesColor(newColor):
            ruler.data.update('lines_color', newColor)
            ruler.update()

        def updateDivisionsColor(newColor):
            ruler.data.update('divisions_color', newColor)
            ruler.update()

        backgroundColorElement = ColorButton(self, 'Background',
                                             backgroundColor,
                                             updateBackgroundColor)
        linesColorElement = ColorButton(self, 'Lines', linesColor,
                                        updateLinesColor)
        divisionsColorElement = ColorButton(self, 'Divisions', divisionsColor,
                                            updateDivisionsColor)

        layout = QGridLayout()
        layout.setSpacing(10)

        # set the same width/height for all the columns/rows
        columnWidth = 120
        rowHeight = 25
        layout.setRowMinimumHeight(0, rowHeight)
        layout.setRowMinimumHeight(1, rowHeight)
        layout.setRowMinimumHeight(2, rowHeight)
        layout.setColumnMinimumWidth(0, columnWidth)
        layout.setColumnMinimumWidth(1, columnWidth)
        layout.setColumnMinimumWidth(2, columnWidth)

        # first column
        layout.addWidget(backgroundColorElement, 1, 0)

        # second column
        layout.addWidget(linesColorElement, 1, 1)

        # third column
        layout.addWidget(divisionsColorElement, 1, 2)

        layout.setSizeConstraint(QLayout.SetFixedSize)
        self.setLayout(layout)
Exemple #2
0
 def __init__(self, parent, header):
     super(HeaderWidget, self).__init__(parent)
     layout = QGridLayout()
     layout.setContentsMargins(0, 0, 0, 0)
     layout.setVerticalSpacing(1)
     row = 0
     col = 0
     for field in header.fields:
         name = field[0]
         value = field[1]
         fieldType = ""
         if len(field) > 2:
             fieldType = field[2]
         layout.addWidget(QLabel(name + ": "), row, col * 3)
         if isinstance(value, list):
             for i in range(0, len(value)):
                 if fieldType == "ptr":
                     label = ClickableAddressLabel(value[i])
                 elif fieldType == "code":
                     label = ClickableCodeLabel(value[i])
                 else:
                     label = QLabel(value[i])
                     label.setFont(binaryninjaui.getMonospaceFont(self))
                 layout.addWidget(label, row, col * 3 + 1)
                 row += 1
         else:
             if fieldType == "ptr":
                 label = ClickableAddressLabel(value)
             elif fieldType == "code":
                 label = ClickableCodeLabel(value)
             else:
                 label = QLabel(value)
                 label.setFont(binaryninjaui.getMonospaceFont(self))
             layout.addWidget(label, row, col * 3 + 1)
             row += 1
         if (header.columns > 1) and (row >= header.rows_per_column) and (
             (col + 1) < header.columns):
             row = 0
             col += 1
     for col in range(1, header.columns):
         layout.setColumnMinimumWidth(
             col * 3 - 1,
             UIContext.getScaledWindowSize(20, 20).width())
     layout.setColumnStretch(header.columns * 3 - 1, 1)
     self.setLayout(layout)
    def __init__(self, ruler, parent=None):
        QWidget.__init__(self, parent)

        # units (cm/px/inch)
        unitsGroup = QButtonGroup(self)
        pixels = QRadioButton('Pixels')
        pixels.unit = 'px'
        centimeters = QRadioButton('Centimeters')
        centimeters.unit = 'cm'
        inches = QRadioButton('Inches')
        inches.unit = 'inch'

        selectedUnit = ruler.data.get('units')

        if selectedUnit == 'cm':
            centimeters.setChecked(True)

        elif selectedUnit == 'inch':
            inches.setChecked(True)

        else:
            pixels.setChecked(True)

        unitsGroup.addButton(pixels)
        unitsGroup.addButton(centimeters)
        unitsGroup.addButton(inches)

        def changeUnits(radioButton):
            nonlocal selectedUnit
            newUnit = radioButton.unit

            if newUnit != selectedUnit:
                ruler.data.update('units', newUnit)
                selectedUnit = newUnit
                ruler.update()

        unitsGroup.buttonClicked.connect(changeUnits)

        # orientation (horizontal/vertical)
        horizontalOrientation = ruler.data.get('horizontal_orientation')

        orientationGroup = QButtonGroup(self)
        self.horizontal_string = 'Horizontal'
        self.vertical_string = 'Vertical'
        horizontal = QRadioButton(self.horizontal_string)
        vertical = QRadioButton(self.vertical_string)

        if horizontalOrientation:
            horizontal.setChecked(True)
            self.selected_orientation = self.horizontal_string

        else:
            vertical.setChecked(True)
            self.selected_orientation = self.vertical_string

        def changeOrientation(radioButton):
            text = radioButton.text()

            if self.selected_orientation != text:

                self.selected_orientation = text
                ruler.rotate()

        orientationGroup.addButton(horizontal)
        orientationGroup.addButton(vertical)
        orientationGroup.buttonClicked.connect(changeOrientation)

        # length settings (always above + division lines + current length)
        alwaysAbove = QCheckBox('Always Above', self)
        alwaysAbove.setChecked(ruler.data.get('always_above'))

        def alwaysAboveSetting():

            if alwaysAbove.isChecked():

                ruler.data.update('always_above', True)
                ruler.setWindowFlags(ruler.windowFlags()
                                     | Qt.WindowStaysOnTopHint)

            else:
                ruler.data.update('always_above', False)
                ruler.setWindowFlags(ruler.windowFlags()
                                     & ~Qt.WindowStaysOnTopHint)

            ruler.show()

        alwaysAbove.clicked.connect(alwaysAboveSetting)

        divisionLines = QCheckBox('1/2 1/4 3/4 divisions', self)
        divisionLines.setChecked(ruler.data.get('division_lines'))

        def divisionLinesSetting():
            ruler.data.update('division_lines', divisionLines.isChecked())
            ruler.update()

        divisionLines.clicked.connect(divisionLinesSetting)

        currentLength = QLabel('0px')
        currentLength.setAlignment(Qt.AlignCenter)

        # setup the layout
        layout = QGridLayout()
        layout.setSpacing(10)

        # set the same width/height for all the columns/rows
        columnWidth = 120
        rowHeight = 25
        layout.setRowMinimumHeight(0, rowHeight)
        layout.setRowMinimumHeight(1, rowHeight)
        layout.setRowMinimumHeight(2, rowHeight)
        layout.setColumnMinimumWidth(0, columnWidth)
        layout.setColumnMinimumWidth(1, columnWidth)
        layout.setColumnMinimumWidth(2, columnWidth)

        # first column
        layout.addWidget(pixels, 0, 0)
        layout.addWidget(centimeters, 1, 0)
        layout.addWidget(inches, 2, 0)

        # second column
        layout.addWidget(horizontal, 0, 1)
        layout.addWidget(vertical, 1, 1)

        # third column
        layout.addWidget(alwaysAbove, 0, 2)
        layout.addWidget(divisionLines, 1, 2)
        layout.addWidget(currentLength, 2, 2)

        layout.setSizeConstraint(QLayout.SetFixedSize)

        self.current_length = currentLength
        self.vertical = vertical
        self.horizontal = horizontal
        self.setLayout(layout)
Exemple #4
0
    def __init__(self):
        QMainWindow.__init__(self)
        # Variaveis
        self.separador = ";" # Separador padrao de colunas em um arquivo txt ou csv
        self.selected = np.array([1, 24, 48, 96]).astype('timedelta64[h]') # selecionados ao iniciar o programa, modificavel.
        self.fileformat =  '' # Reservado para o formato do arquivo a ser aberto. Pode ser .xlsx ou .odf. ou .csv e assim vai.

        # facilita o acesso a variavel.
        self.timedeltastr = ("1 Hora","2 Horas", "3 Horas", "4 Horas","12 Horas",
         "24 Horas", "48 Horas", "72 horas", "96 horas", "30 Dias")
        self.timedeltas = np.array([1, 2, 3, 4, 12, 24, 48, 72, 96, 24*30]).astype('timedelta64[h]')
        self.linktimedelta = dict([(self.timedeltas[x], self.timedeltastr[x]) for x in range(len(self.timedeltastr))])

        self.datastring = ["DD/MM/AAAA",'AAAA/MM/DD', "AAAA-MM-DD", "DD-MM-AAAA"]
        self.dataformat = ["%d/%m/%Y", "%Y/%m/%d", "%Y-%m-%d", "%d-%m-%Y"]
        self.linkdata = dict([(self.datastring[x], self.dataformat[x]) for x in range(len(self.dataformat))])

        self.timestring = ["hh:mm", "hh:mm:ss", "hh:mm:ss.ms"]
        self.timeformat = ["%H:%M", "%H:%M:%S", "%H:%M:%S.%f"]
        self.linktime = dict([(self.timestring[x], self.timeformat[x]) for x in range(len(self.timeformat))])

        #Janela Principal
        widget = QWidget()
        self.setCentralWidget(widget)

        # Inicializa os Widgets
        self.folder = QLineEdit("Salvar Como...")
        self.path = QLineEdit("Abrir arquivo...")
        #
        buttonOpen = QPushButton('Abrir')
        buttonSave = QPushButton("Destino")
        Processar = QPushButton('Executar')
        Ajuda = QPushButton('Informações')
        #
        groupBox2 = QGroupBox("Delimitador")
        self.delimitador1 = QRadioButton("Ponto-Vírgula")
        self.delimitador2 = QRadioButton("Vírgula")
        self.delimitador3 = QRadioButton("Ponto")
        self.delimitador4 = QRadioButton("Tabulação")
        #
        checkGroup = QGroupBox("Mais opções")
        text3 = QPushButton("Configurações")
        text2 = QLabel("Formato da Data")
        text1 = QLabel("Formato da Hora")
        self.FormatoTime = QComboBox()
        self.FormatoTime.addItems(self.timestring)
        self.FormatoData = QComboBox()
        self.FormatoData.addItems(self.datastring)
        #
        text = QLabel("Por favor, selecione na tabela abaixo as colunas a utilizar:")
        self.ignore = QRadioButton("Possui Cabeçalho") # True se estiver selecionado, False caso nao
        #
        self.Tabela = QTableWidget(15,15)
        self.startTable()

        # Layouts
        MainLayout = QVBoxLayout()

        Gridlayout = QGridLayout()
        Gridlayout.addWidget(self.path, 0, 0)
        Gridlayout.addWidget(self.folder, 1, 0)
        Gridlayout.addWidget(buttonOpen, 0, 1)
        Gridlayout.addWidget(buttonSave, 1, 1)
        Gridlayout.addWidget(Processar, 0, 3)
        Gridlayout.addWidget(Ajuda, 1, 3)
        Gridlayout.setColumnStretch(0, 2)
        Gridlayout.setColumnStretch(3, 1)
        Gridlayout.setColumnMinimumWidth(2, 20)

        SecondLayout = QHBoxLayout()
        SecondLayout.addWidget(groupBox2)
        SecondLayout.addSpacing(40)
        SecondLayout.addWidget(checkGroup)
        #
        SepLayout = QVBoxLayout()
        SepLayout.addWidget(self.delimitador1)
        SepLayout.addWidget(self.delimitador2)
        SepLayout.addWidget(self.delimitador3)
        SepLayout.addWidget(self.delimitador4)
        #
        OptionsLayout = QVBoxLayout()
        OptionsLayout.addWidget(text3)
        OptionsLayout.addWidget(text2)
        OptionsLayout.addWidget(self.FormatoData)
        OptionsLayout.addWidget(text1)
        OptionsLayout.addWidget(self.FormatoTime)

        ThirdLayout = QVBoxLayout()
        ThirdLayout.addWidget(self.ignore)
        ThirdLayout.addWidget(text)

        MainLayout.addLayout(Gridlayout)
        MainLayout.addLayout(SecondLayout)
        MainLayout.addLayout(ThirdLayout)
        MainLayout.addWidget(self.Tabela)

        # Coloca o Layout principal na Janela
        widget.setLayout(MainLayout)

        # Comandos dos Widgets e edicoes.
        groupBox2.setLayout(SepLayout)
        self.delimitador1.setChecked(True)
        self.folder.setReadOnly(True)
        self.path.setReadOnly(True)
        checkGroup.setLayout(OptionsLayout)

        buttonOpen.clicked.connect(self.searchFile)
        buttonSave.clicked.connect(self.getNewFile)
        self.delimitador1.clicked.connect(self.updateDelimiter)
        self.delimitador2.clicked.connect(self.updateDelimiter)
        self.delimitador3.clicked.connect(self.updateDelimiter)
        self.delimitador4.clicked.connect(self.updateDelimiter)
        Ajuda.clicked.connect(self.help)
        Processar.clicked.connect(self.taskStart)
        text3.clicked.connect(self.openSubWindow)

        # Propriedades da janela principal
        height = 480
        width = 640
        myappid = 'GePlu.release1_0.0' # arbitrary string
        ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
        self.setWindowIcon(QIcon(r'images\icon6.ico'))
        self.setFixedSize(width, height)
        self.setWindowTitle("GePlu")