Ejemplo n.º 1
0
    def initUI(self):
        self.layout = QVBoxLayout()

        # ---------------------------------------
        strategy_box = self.create_box_strategy()
        box_mplier = self.create_box_mplier()
        box_p_num = self.create_box_p_num()
        box_starting_bet = self.create_box_starting_bet()
        box_preview = self.create_box_preview()

        param_spin_box = QVBoxLayout()
        param_spin_box.addLayout(box_mplier)
        param_spin_box.addLayout(box_p_num)
        param_spin_box.addLayout(box_starting_bet)
        param_spin_box.addStretch(1)

        param_box = QHBoxLayout()
        param_box.addLayout(param_spin_box)
        param_box.insertSpacing(1, 30)
        param_box.addLayout(box_preview)
        # param_box.addStretch(1)
        self.layout.addLayout(strategy_box)
        self.layout.addLayout(param_box)
        # ----------------------------------------
        self.create_box_columns_options()
        ok_box = self.create_box_ok()
        self.layout.addLayout(ok_box)

        self.layout.addStretch(1)
        self.setLayout(self.layout)

        self.setGeometry(300, 300, 550, 600)
        self.setMinimumSize(550, 600)
Ejemplo n.º 2
0
 def __init__(self, _widg):
     """ Create widget """
     _widg.setWindowFlags(Qt.FramelessWindowHint)
     _widg.setAttribute(Qt.WA_DeleteOnClose)
     _widg.setFixedSize(460, 58)
     _widg.setObjectName("Create")
     _widg.setStyleSheet('''
         QFrame#Create {background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #f2f2f2, stop: 1.0 #e1e1e1);
         border: 1px solid #bdbdbd;}
         QLabel {font: bold 13px Verdana; color: #42688f;}
         QLineEdit {padding-left: 3px;}
     ''')
     _widg.title = QLabel()
     _widg.title.setMinimumHeight(30)
     _widg.InputValue = QLineEdit()
     _widg.InputValue.setMinimumHeight(30)
     box = QHBoxLayout()
     box.addWidget(_widg.title)
     box.insertSpacing(1, 10)
     box.addWidget(_widg.InputValue)
     box.setContentsMargins(13, 10, 13, 10)
     _widg.setLayout(box)
     effect = QGraphicsDropShadowEffect()
     effect.setBlurRadius(7)
     effect.setOffset(0)
     _widg.setGraphicsEffect(effect)
     _widg.InputValue.setFocus(True)
Ejemplo n.º 3
0
class frameTemplate(QFrame):
    def __init__(self):
        super().__init__()

    def initUI(self):
        self.definition = QPlainTextEdit()
        self.definition.setReadOnly(True)
        self.grid_layout = QGridLayout()

        #dropdown odabir metode kriptiranja/dekriptiranja
        self.cb_method = QComboBox()

        #polje za korisnikov unos
        self.plaintext = QLineEdit(self)
        self.ciphertext = QLineEdit(self)

        #Oznake polja za korisnikov unos
        self.label_plaintext = QLabel()
        self.label_ciphertext = QLabel()
        self.label_plaintext.setText("Plaintext:")
        self.label_ciphertext.setText("Ciphertext:")

        #gumb za kriptiranje/dekriptiranje
        self.btn_encrypt = QPushButton("Encrypt")

        #hbox za polja unosa
        self.h_box = QHBoxLayout()
        self.h_box.addWidget(self.plaintext)
        self.h_box.addWidget(self.ciphertext)
        self.h_box.insertSpacing(1, 7)

        #hbox za oznake
        self.label_h_box = QHBoxLayout()
        self.label_h_box.addWidget(self.label_plaintext)
        self.label_h_box.addWidget(self.label_ciphertext)

        #vbox sa hboxom oznaka i gumbom (čini sučelje za šifriranje)
        self.encryption_v_box = QVBoxLayout()
        self.encryption_v_box.addLayout(self.label_h_box)
        self.encryption_v_box.addLayout(self.h_box)
        self.encryption_v_box.addWidget(self.btn_encrypt)

        #kompletan layout, sučelje za šifriranje i objašnjenje metode kriptiranja
        self.v_box = QVBoxLayout()
        self.v_box.addWidget(self.definition)
        self.v_box.addWidget(self.cb_method)
        self.v_box.addLayout(self.encryption_v_box)
        self.v_box.setSpacing(10)
        self.v_box.addStretch(1)

        #self.container = QHBoxLayout()
        #self.container.addLayout(self.v_box)
        #self.container.addStretch(1)

        self.grid_layout.addLayout(self.v_box, 0, 0, -1, 2)
        self.setLayout(self.grid_layout)
Ejemplo n.º 4
0
    def buildUI(self):
        self.det_type_group = QButtonGroup(self)
        self.det_type_group.setExclusive(True)
        self.det_type_group.buttonClicked.connect(self.update_widget)

        self.auto_checkbox = QCheckBox()
        self.auto_checkbox.setChecked(True)
        self.auto_checkbox.setToolTip(
            'If auto is selected, the program will estimate the background f-stat from the noise region selected on in the waveform window.'
        )

        self.back_az_limit = QDoubleSpinBox()
        self.back_az_limit.setSuffix(' deg')
        self.back_az_limit.setValue(10.0)
        self.back_az_limit.setMinimum(1.0)
        self.back_az_limit.setMaximum(90.0)
        self.back_az_limit.setToolTip(
            "This is the range in degrees of variation in back azimuths used to determine if a value is part of a detection."
        )

        self.min_peak_width = QSpinBox()
        self.min_peak_width.setSuffix(' points')
        self.min_peak_width.setValue(5)
        self.min_peak_width.setMinimum(1)
        self.min_peak_width.setToolTip(
            "This determines the number of points in the f-statistic plot required for a valid detection."
        )

        self.manual_checkbox = QCheckBox()
        self.manual_value = QDoubleSpinBox()
        self.manual_value.setValue(1.0)
        self.manual_value.setEnabled(False)

        main_layout = QHBoxLayout()

        form_layout_col1 = QFormLayout()
        form_layout_col2 = QFormLayout()

        self.det_type_group.addButton(self.auto_checkbox)
        self.det_type_group.addButton(self.manual_checkbox)

        form_layout_col1.addRow("Automatically calculate threshold: ",
                                self.auto_checkbox)
        form_layout_col1.addRow("Manually calculate threshold: ",
                                self.manual_checkbox)
        form_layout_col1.addRow("Manual threshold level: ", self.manual_value)

        form_layout_col2.addRow("Back azimuth limit: ", self.back_az_limit)
        form_layout_col2.addRow("Minimum peak width: ", self.min_peak_width)

        main_layout.addLayout(form_layout_col1)
        main_layout.addLayout(form_layout_col2)
        main_layout.addStretch()
        main_layout.insertSpacing(2, 20)

        self.setLayout(main_layout)
Ejemplo n.º 5
0
    def __init__(self, parent=None):
        super(PlaylistControls, self).__init__(parent)

        # Set the initial state of the player
        # Set initial state of player mute status
        self.playerState = QMediaPlayer.StoppedState
        self.playerMuted = False

        # Establish the Playlist Ctrl Buttons
        self.playButton = QToolButton(clicked=self.playPause)
        self.playButton.setIcon(QIcon('Images/001-play.png'))
        self.playButton.setFixedSize(32, 32)
        self.playButton.setIconSize(QSize(32, 32))

        self.stopButton = QToolButton(clicked=self.stop)
        self.stopButton.setIcon(QIcon('Images/002-stop.png'))

        self.nextButton = QToolButton(clicked=self.next)
        self.nextButton.setIcon(QIcon('Images/005-forward.png'))
        self.nextButton.setFixedSize(24, 24)
        self.nextButton.setIconSize(QSize(24, 24))

        self.previousButton = QToolButton(clicked=self.previous)
        self.previousButton.setIcon(QIcon('Images/004-rewind.png'))
        self.previousButton.setFixedSize(24, 24)
        self.previousButton.setIconSize(QSize(24, 24))

        self.muteButton = QToolButton(clicked=self.muteMedia)
        self.muteButton.setIcon(QIcon('Images/002-speaker.png'))

        self.shuffleButton = QToolButton(clicked=self.shuffleMedia)
        self.shuffleButton.setIcon(QIcon('Images/001-change.png'))

        self.repeatAllButton = QToolButton(clicked=self.repeatAllMedia)
        self.repeatAllButton.setIcon(QIcon('Images/media-repeat(all).png'))

        self.repeatOneButton = QToolButton(clicked=self.repeatOneMedia)
        self.repeatOneButton.setIcon(QIcon('Images/media-repeat(1).png'))

        self.volumeSlider = QSlider(Qt.Horizontal, sliderMoved=self.changeVolume)
        self.volumeSlider.setRange(0, 100)
        self.volumeSlider.setValue(45)

        # Setup Layout from Playlist Ctrls
        PlaylistCtrl = QHBoxLayout()
        helpAdd(PlaylistCtrl, (self.shuffleButton, self.repeatAllButton, self.repeatOneButton, self.stopButton, self.previousButton,
                               self.playButton, self.nextButton, self.muteButton, self.volumeSlider))
        PlaylistCtrl.insertSpacing(3, 4)
        PlaylistCtrl.insertSpacing(8, 5)

        self.setLayout(PlaylistCtrl)
Ejemplo n.º 6
0
    def __init__(self, parent):
        # Call superclass constructor
        super().__init__()

        # Save parent instance
        self.parent = parent

        # Box containing display button
        leftbox = QHBoxLayout()

        # Decide button
        self.button_decide = QPushButton('DECIDE', self)
        self.button_decide.clicked.connect(self.buttonClicked)
        self.button_decide.setFixedWidth(225)
        leftbox.addWidget(self.button_decide)

        # Box conatining output display and label
        rightbox = QHBoxLayout()

        # Result label
        result_label = QLabel('What should you do?:', self)
        result_label.setAlignment(Qt.AlignRight | Qt.AlignCenter)
        rightbox.addWidget(result_label)

        # Result display
        result_str = "Select some parameters and hit 'DECIDE'"
        self.result_display = QLabel(result_str, self)
        self.result_display.setAlignment(Qt.AlignCenter)
        self.result_display.setFrameStyle(QFrame.Panel | QFrame.Sunken)
        self.result_display.setLineWidth(3)
        self.result_display.setFixedWidth(300)
        rightbox.addWidget(self.result_display)

        # Animation timer
        self.anim_timer = QTimer()
        self.anim_timer.timeout.connect(self.doOutput)
        self.frame_count = 0

        # Color palettes
        self.setAutoFillBackground(True)
        palette = self.palette()
        palette.setColor(self.backgroundRole(), Qt.white)
        self.setPalette(palette)

        # Set up layout
        hbox = QHBoxLayout()
        hbox.addLayout(leftbox)
        hbox.insertSpacing(1, 57)
        hbox.addLayout(rightbox)
        hbox.setSizeConstraint(QLayout.SetFixedSize)
        self.setLayout(hbox)
Ejemplo n.º 7
0
    def __init__(self, layer):
        super().__init__()
        self.layer = weakref.proxy(layer)
        self.unselectedStyleSheet = "QFrame {border: 3px solid lightGray; background-color:lightGray; border-radius: 3px;}"
        self.selectedStyleSheet = "QFrame {border: 3px solid rgb(71,143,205); background-color:lightGray; border-radius: 3px;}"

        layout = QHBoxLayout()

        cb = QCheckBox(self)
        cb.setStyleSheet(
            "QCheckBox::indicator {width: 18px; height: 18px;}"
            #{}"QCheckBox::indicator:unchecked {image: url(" + path_off + ");}"
            "QCheckBox::indicator:checked {image: url(" + path_on + ");}")
        cb.setToolTip('Layer visibility')
        cb.setChecked(self.layer.visible)
        cb.stateChanged.connect(lambda state=cb: self.changeVisible(state))
        layout.addWidget(cb)

        layout.insertSpacing(1, 5)

        sld = QSlider(Qt.Horizontal, self)
        sld.setToolTip('Layer opacity')
        sld.setFocusPolicy(Qt.NoFocus)
        sld.setInvertedAppearance(True)
        sld.setFixedWidth(75)
        sld.setMinimum(0)
        sld.setMaximum(100)
        sld.setSingleStep(1)
        sld.setValue(self.layer.opacity * 100)
        sld.valueChanged[int].connect(
            lambda value=sld: self.changeOpacity(value))
        layout.addWidget(sld)

        textbox = QLineEdit(self)
        textbox.setStyleSheet('background-color:lightGray; border:none')
        textbox.setText(layer.name)
        textbox.setToolTip('Layer name')
        textbox.setFixedWidth(80)
        textbox.editingFinished.connect(
            lambda text=textbox: self.changeText(text))
        layout.addWidget(textbox)

        self.setLayout(layout)
        self.setFixedHeight(55)
        self.setSelected(True)
Ejemplo n.º 8
0
    def time_range_layout(self):
        instruction_label = QLabel("Use Time Range?")
        instruction_label.setObjectName("instruction")

        # time range is optional, so these radio buttons formalize that choice
        yes_rb = QRadioButton("Yes")
        no_rb = QRadioButton("No")
        no_rb.setChecked(True)

        yes_rb.toggled.connect(partial(self.rb_state, yes_rb))
        no_rb.toggled.connect(partial(self.rb_state, no_rb))

        layout = QHBoxLayout()
        layout.addWidget(instruction_label)
        layout.addWidget(yes_rb)
        layout.addWidget(no_rb)
        layout.setContentsMargins(6,8,6,8)
        layout.insertSpacing(1, 85)
        layout.insertSpacing(3, 80)

        return layout
Ejemplo n.º 9
0
    def setupUi(self, Widget):

        # widgety rysujące kształty, instancje klasy Ksztalt
        self.ksztalt1 = Ksztalt(self, Ksztalty.Polygon)
        self.ksztalt2 = Ksztalt(self, Ksztalty.Ellipse)
        self.ksztaltAktywny = self.ksztalt1

        # przyciski CheckBox ###
        uklad = QVBoxLayout()  # układ pionowy
        self.grupaChk = QButtonGroup()
        for i, v in enumerate(('Kwadrat', 'Koło', 'Trójkąt', 'Linia')):
            self.chk = QCheckBox(v)
            self.grupaChk.addButton(self.chk, i)
            uklad.addWidget(self.chk)
        self.grupaChk.buttons()[self.ksztaltAktywny.ksztalt].setChecked(True)
        # CheckBox do wyboru aktywnego kształtu
        self.ksztaltChk = QCheckBox('<=')
        self.ksztaltChk.setChecked(True)
        uklad.addWidget(self.ksztaltChk)

        # układ poziomy dla kształtów oraz przycisków CheckBox
        ukladH1 = QHBoxLayout()
        ukladH1.addWidget(self.ksztalt1)
        ukladH1.addLayout(uklad)
        ukladH1.addWidget(self.ksztalt2)
        # koniec CheckBox ###

        # Slider i LCDNumber ###
        self.suwak = QSlider(Qt.Horizontal)
        self.suwak.setMinimum(0)
        self.suwak.setMaximum(255)
        self.lcd = QLCDNumber()
        self.lcd.setSegmentStyle(QLCDNumber.Flat)
        # układ poziomy (splitter) dla slajdera i lcd
        ukladH2 = QSplitter(Qt.Horizontal, self)
        ukladH2.addWidget(self.suwak)
        ukladH2.addWidget(self.lcd)
        ukladH2.setSizes((125, 75))

        # przyciski RadioButton ###
        self.ukladR = QHBoxLayout()
        for v in ('R', 'G', 'B'):
            self.radio = QRadioButton(v)
            self.ukladR.addWidget(self.radio)
        self.ukladR.itemAt(0).widget().setChecked(True)
        # grupujemy przyciski
        self.grupaRBtn = QGroupBox('Opcje RGB')
        self.grupaRBtn.setLayout(self.ukladR)
        self.grupaRBtn.setObjectName('Radio')
        self.grupaRBtn.setCheckable(True)
        # układ poziomy dla grupy Radio
        ukladH3 = QHBoxLayout()
        ukladH3.addWidget(self.grupaRBtn)
        # koniec RadioButton ###

        # Lista ComboBox i SpinBox ###
        self.listaRGB = QComboBox(self)
        for v in ('R', 'G', 'B'):
            self.listaRGB.addItem(v)
        self.listaRGB.setEnabled(False)
        # SpinBox
        self.spinRGB = QSpinBox()
        self.spinRGB.setMinimum(0)
        self.spinRGB.setMaximum(255)
        self.spinRGB.setEnabled(False)
        # układ pionowy dla ComboBox i SpinBox
        uklad = QVBoxLayout()
        uklad.addWidget(self.listaRGB)
        uklad.addWidget(self.spinRGB)
        # do układu poziomego grupy Radio dodajemy układ ComboBox i SpinBox
        ukladH3.insertSpacing(1, 25)
        ukladH3.addLayout(uklad)
        # koniec ComboBox i SpinBox ###

        # przyciski PushButton ###
        uklad = QHBoxLayout()
        self.grupaP = QButtonGroup()
        self.grupaP.setExclusive(False)
        for v in ('R', 'G', 'B'):
            self.btn = QPushButton(v)
            self.btn.setCheckable(True)
            self.grupaP.addButton(self.btn)
            uklad.addWidget(self.btn)
        # grupujemy przyciski
        self.grupaPBtn = QGroupBox('Przyciski RGB')
        self.grupaPBtn.setLayout(uklad)
        self.grupaPBtn.setObjectName('Push')
        self.grupaPBtn.setCheckable(True)
        self.grupaPBtn.setChecked(False)
        # koniec PushButton ###

        # główny układ okna, wertykalny ###
        ukladOkna = QVBoxLayout()
        ukladOkna.addLayout(ukladH1)
        ukladOkna.addWidget(ukladH2)
        ukladOkna.addLayout(ukladH3)
        ukladOkna.addWidget(self.grupaPBtn)

        self.setLayout(ukladOkna)  # przypisanie układu do okna głównego
        self.setWindowTitle('Widżety')
Ejemplo n.º 10
0
class Widget(QWidget):
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        self.setGeometry(100, 150, 1200, 600)

        self.Columns = '*'
        self.font = None
        self.HeaderList = None
        self.left_padding = 0
        self.right_padding = 0
        self.search_field_spacing = 5

        self.createDB()
        self.getHeaders()

        layout = QVBoxLayout(self)

        buttons_layout = QHBoxLayout()
        show_plant_view = QPushButton('Plant photo with details')
        font_button = QPushButton('Font')
        buttons_layout.addWidget(show_plant_view)
        buttons_layout.addWidget(font_button)

        layout.addLayout(buttons_layout)

        show_plant_view.clicked.connect(self._show_photo_view)
        font_button.clicked.connect(self.font_dialog)

        self.model = MySqlModel(self.HeaderList)
        self.SearchQuery = "select {} from {}".format(self.Columns, _DB_TABLE)
        self.model.setQuery(self.SearchQuery, self.DB)

        self.view = QTableView(self)
        self.view.setMinimumHeight(325)
        self.font = self.view.property('font')
        self.view.setModel(self.model)

        self.view.setColumnHidden(self.model.image_column, True)
        self.view.setColumnHidden(self.model.info_column, True)

        horizontal_header = self.view.horizontalHeader()
        for i in range(len(horizontal_header)):
            horizontal_header.setSectionResizeMode(i, QHeaderView.Stretch)

        self.search_layout = QHBoxLayout()
        self.search_layout.insertSpacing(0, self.left_padding)
        self.SearchFieldsGrid = QGridLayout()
        self.makeSearchFieldsGrid()
        self.search_layout.addLayout(self.SearchFieldsGrid)
        self.search_layout.insertSpacing(-1, self.right_padding)
        layout.addLayout(self.search_layout)

        #self.view.horizontalHeader().setStretchLastSection(True)
        #self.view.resizeColumnsToContents()
        #self.view.horizontalHeader().ResizeMode(QHeaderView.Interactive)

        layout.addWidget(self.view)

        self.view.resizeRowsToContents()
        self.view_vertical_header = self.view.verticalHeader()
        self.view_vertical_header.geometriesChanged.connect(
            self._align_search_layout)

    def createDB(self):
        # binding to an existing database

        self.DB = QtSql.QSqlDatabase.addDatabase('QSQLITE')

        self.DB.setDatabaseName(_PATH_TO_DB)
        self.DB.open()

    def getHeaders(self):
        # getting a list of Headers
        self.query = QtSql.QSqlQuery(db=self.DB)
        self.query.exec_("PRAGMA table_info({})".format(_DB_TABLE))

        # filling the list of headings
        self.HeaderList = []
        while self.query.next():
            self.HeaderList.append(self.query.value(1))

        # create a query parameter dictionary
        self.paramsDict = {x: ['', '', ''] for x in self.HeaderList}
        self.paramsDict[''] = ["{} {} '%{}%'", '', '']

    def makeSearchFieldsGrid(self):
        self.SearchFieldsGrid.setSpacing(self.search_field_spacing)

        self.clearLayout(self.SearchFieldsGrid)

        self.cb = QCheckBox(self)
        self.cb.stateChanged.connect(self.changeQuery)
        self.SearchFieldsGrid.addWidget(self.cb, 1, 0)

        n = len(self.HeaderList)
        qwidth = [self.view.columnWidth(i) for i in range(n)]
        self.qles = [None for i in range(n)]

        for i in range(n):
            self.qles[i] = QLineEdit(self)
            self.qles[i].setObjectName(self.HeaderList[i])
            self.qles[i].textChanged[str].connect(self.setSearchQuery)
            label = QLabel(self.HeaderList[i])

            self.SearchFieldsGrid.addWidget(label,
                                            0,
                                            i + 1,
                                            alignment=Qt.AlignCenter)
            self.SearchFieldsGrid.addWidget(self.qles[i], 1, i + 1)

    def clearLayout(self, layout):
        while layout.count():
            child = layout.takeAt(0)
            if child.widget() is not None:
                child.widget().deleteLater()
            elif child.layout() is not None:
                clearLayout(child.layout())

    # remembering the status of the switch after pressing and updating the table
    def changeQuery(self, state):

        self.state = state
        self.setSearchQuery('')

    def setSearchQuery(self, text):
        # switch handling
        try:
            if self.state == Qt.Checked:
                self.paramsDict[''] = [
                    "{0} {1} '% {2}%' or {0} {1} '{2}%'", '', ''
                ]
            else:
                self.paramsDict[''] = ["{} {} '%{}%'", '', '']
        except:
            self.paramsDict[''] = ["{} {} '%{}%'", '', '']
        # processing of more and less characters
        if text != '':
            if text[0] == '<':
                matching = '<'
                queryString = "{} {} {}"
                text = text[1:]
            elif text[0] == '>':
                matching = '>'
                queryString = "{} {} {}"
                text = text[1:]
            else:
                queryString = self.paramsDict[''][0]
                matching = 'like'
        else:
            queryString, matching, text = self.paramsDict['']

        # filling in the query parameters dictionary
        self.paramsDict[self.sender().objectName()] = [
            queryString, matching, text
        ]
        paramList = []
        # assembling query parameters into a list
        for name, value in self.paramsDict.items():
            if len(value) == 3:
                queryString, matching, text = value
                if queryString.find('%') != -1:
                    queryString = self.paramsDict[''][0]
                if text != '':
                    paramList.append(queryString.format(name, matching, text))

        # assembling query parameters into a string
        if len(paramList) == 0:
            params = ''
        elif len(paramList) == 1:
            params = 'where {}'.format(paramList[0])
        else:
            params = 'where {}'.format(" and ".join(paramList))
        # assembling the query and updating the table according to it

        self.Columns = '*' if self.Columns == '' else self.Columns
        self.searchQuery = "select {} from {} {}".format(
            self.Columns, _DB_TABLE, params)
        self.model.setQuery(self.searchQuery, self.DB)

        self.view.resizeRowsToContents()

        #header = self.view.horizontalHeader()
        #for i in range(len(header)):
        #header.setSectionResizeMode(i, QHeaderView.Stretch)

    def font_dialog(self):

        self.font, valid = QFontDialog.getFont(self.font)
        if valid:
            self.view.setFont(self.font)
            self.view.resizeRowsToContents()
            for i in self.qles:
                i.setFont(self.font)

    def _align_search_layout(self):
        vertical_header_width = self.view_vertical_header.width()
        checkbox_width = self.cb.width()
        self.left_padding = vertical_header_width - checkbox_width - self.search_field_spacing
        vertical_scrollbar_width = self.view.verticalScrollBar().width()
        self.right_padding = vertical_scrollbar_width

        left_spacer = self.search_layout.itemAt(0)
        left_spacer.changeSize(self.left_padding, 10)

        right_spacer = self.search_layout.itemAt(2)
        right_spacer.changeSize(self.right_padding, 10)

        self.search_layout.invalidate()

    def _show_photo_view(self):
        #image_data = _get_image_paths_names(self.model)
        viewer = PhotoViewe(self.model, self)
        viewer.show()
Ejemplo n.º 11
0
    def createTabs(self):
        """Create tabs in main window."""
        try:
            # Initialize tab screen
            self.tabs = QTabWidget()
            self.tab2 = QWidget()
            # self.tabs.resize(300,200)

            # Add tabs
            self.tabs.addTab(self.tab2, _("Custom Match"))

            # Create second tab

            self.tab2.layout = QVBoxLayout()

            container = QHBoxLayout()

            label = QLabel()
            label.setMinimumWidth(self.labelWidth)
            container.addWidget(label, 0)

            label = QLabel(_("Match Format:"))
            label.setMinimumWidth(80)
            container.addWidget(label, 0)

            container.addWidget(QLabel(_("Best of")), 0)

            self.cb_bestof = QComboBox()
            for idx in range(0, hwctool.settings.max_no_sets):
                self.cb_bestof.addItem(str(idx + 1))
            self.cb_bestof.setCurrentIndex(3)
            string = _('"Best of 6/4": First, a Bo5/3 is played and the'
                       ' ace map gets extended to a Bo3 if needed;'
                       ' Best of 2: Bo3 with only two maps played.')
            self.cb_bestof.setToolTip(string)
            self.cb_bestof.setMaximumWidth(40)
            self.cb_bestof.currentIndexChanged.connect(self.changeBestOf)
            container.addWidget(self.cb_bestof, 0)

            container.addWidget(QLabel(_(" but at least")), 0)

            self.cb_minSets = QComboBox()

            self.cb_minSets.setToolTip(
                _('Minimum number of maps played (even if the match'
                  ' is decided already)'))
            self.cb_minSets.setMaximumWidth(40)
            container.addWidget(self.cb_minSets, 0)
            container.addWidget(QLabel(" " + _("maps") + "  "), 0)
            self.cb_minSets.currentIndexChanged.connect(
                lambda idx: self.highlightApplyCustom())

            ###### APPLY BUTTON
            label = QLabel("")
            container.addWidget(label, 1)
            self.applycustom_is_highlighted = False
            self.pb_applycustom = QToolButton()
            action = QAction(_("Apply Format"))
            action.triggered.connect(self.applycustom_click)
            self.pb_applycustom.setDefaultAction(action)
            self.pb_applycustom.setFixedWidth(100)
            container.addWidget(self.pb_applycustom, 0)
            self.defaultButtonPalette = self.pb_applycustom.palette()
            self.tab2.layout.addLayout(container)

            ###### RESET BUTTON
            label = QLabel("")
            container.addWidget(label, 1)
            self.pb_resetdata = QPushButton(_("Reset Match Data"))
            self.pb_resetdata.setFixedWidth(100)
            self.pb_resetdata.clicked.connect(self.resetdata_click)
            container.addWidget(self.pb_resetdata, 0)
            self.tab2.layout.addLayout(container)
            self.tab2.setLayout(self.tab2.layout)

            ###### SPACING
            container.insertSpacing(-1, 100)

            ########## REMOVED CUSTOM URL

            # container = QHBoxLayout()
            # label = QLabel()
            # label.setMinimumWidth(self.labelWidth)
            # container.addWidget(label, 0)
            # label = QLabel(_("Match-URL:"))
            # label.setMinimumWidth(80)
            # container.addWidget(label, 0)

            self.le_url_custom = MonitoredLineEdit()
            # self.le_url_custom.setAlignment(Qt.AlignCenter)
            # self.le_url_custom.setToolTip(
            #     _('Optionally specify the Match-URL,'
            #       ' e.g., for Nightbot commands'))
            # self.le_url_custom.setPlaceholderText(
            #     _("Specify the Match-URL of your Custom Match"))

            # completer = QCompleter(
            #     ["http://"], self.le_url_custom)
            # completer.setCaseSensitivity(Qt.CaseInsensitive)
            # completer.setCompletionMode(
            #     QCompleter.UnfilteredPopupCompletion)
            # completer.setWrapAround(True)
            # self.le_url_custom.setCompleter(completer)
            # self.le_url_custom.setMinimumWidth(360)
            # self.le_url_custom.textModified.connect(self.highlightApplyCustom)
            # container.addWidget(self.le_url_custom, 11)

        except Exception as e:
            module_logger.exception("message")
Ejemplo n.º 12
0
class TestDialogWind(QDialog):
    def __init__(self, finder, data_for_edit):
        super().__init__()
        self.setWindowTitle('Формирование теста')
        self.resize(SIZE_WIDTH, SIZE_HEIGHT)
        self.list_topics = finder.list_topics_names
        self.list_content = finder.list_topics_data
        self.setStyleSheet('font-size: 16px')
        self.list_models = [None] * len(finder.list_topics_names)

        self.label_name = QLabel()
        self.label_name.setText('Название теста:')
        self.linedit_name = QLineEdit()
        self.layout_name = QHBoxLayout()
        self.layout_name.addWidget(self.label_name)
        self.layout_name.addWidget(self.linedit_name)

        self.check_random = QCheckBox()
        self.check_random.setText('Случайное перемешивание вопросов')
        self.check_study = QCheckBox()
        self.check_study.setText('Обучающий режим теста')
        self.layout_check = QHBoxLayout()
        self.layout_check.addWidget(self.check_random)
        self.layout_check.addWidget(self.check_study)

        self.table = [None] * len(self.list_topics)
        self.tool_box = QToolBox()
        for i in range(len(self.list_topics)):
            self.create_table(i)
            self.table[i] = QTableView(self)
            self.table[i].setModel(self.list_models[i])
            self.table[i].resizeColumnToContents(0)
            self.table[i].setColumnWidth(1, 100)
            self.table[i].setColumnWidth(2, 320)
            self.table[i].setColumnWidth(3, 120)
            self.table[i].setColumnWidth(4, 180)
            self.table[i].setGridStyle(QtCore.Qt.SolidLine)
            self.table[i].resizeRowsToContents()
            self.table[i].setWordWrap(True)
            self.tool_box.addItem(self.table[i], self.list_topics[i][0])
        self.tool_box.setCurrentIndex(0)

        self.button_save = QPushButton()
        self.button_save.setText("Сохранить")
        self.button_save.setDefault(True)
        self.button_save.clicked.connect(self.save_test)
        self.button_cancel = QPushButton()
        self.button_cancel.setText('Отмена')
        self.button_cancel.clicked.connect(self.reject)
        self.layout_button = QHBoxLayout()
        self.layout_button.addWidget(self.button_save)
        self.layout_button.insertSpacing(0, SIZE_WIDTH // 3)
        self.layout_button.addWidget(self.button_cancel)
        self.layout_button.addSpacing(SIZE_WIDTH // 3)

        self.layout = QVBoxLayout()
        self.layout.addLayout(self.layout_name)
        self.layout.addLayout(self.layout_check)
        self.layout.addWidget(self.tool_box)
        self.layout.addLayout(self.layout_button)
        self.setLayout(self.layout)
        self.info_challenge = None
        self.the_new_test = not data_for_edit
        if not self.the_new_test:
            self.load_params(data_for_edit)
        self.selected_items = {}

    def load_params(self, data_for_edit):
        self.info_challenge, info_items = data_for_edit
        self.linedit_name.setText(self.info_challenge[1])
        if self.info_challenge[2]:
            self.check_random.setCheckState(QtCore.Qt.Checked)
        if self.info_challenge[3]:
            self.check_study.setCheckState(QtCore.Qt.Checked)
        for i in range(len(self.list_models)):
            name_topic = self.list_topics[i]
            if name_topic[1] not in info_items:
                continue
            classes_for_find = set()
            for elem in info_items[name_topic[1]]:
                classes_for_find.add(elem[0])
            for j in range(self.list_models[i].rowCount()):
                name_class = self.list_models[i].item(j, 0)
                count_items = self.list_models[i].item(j, 1)
                if name_class.text() not in classes_for_find:
                    continue
                name_class.setCheckState(QtCore.Qt.Checked)
                new_count = None
                for elem in info_items[name_topic[1]]:
                    if elem[0] == name_class.text():
                        new_count = elem[1]
                        break
                count_items.setText(str(new_count))

    def create_table(self, index):
        count_rows = len(self.list_content[index])
        self.list_models[index] = QStandardItemModel(0, 5)
        for row in range(count_rows):
            item_name = QStandardItem(self.list_content[index][row])
            item_name.setCheckable(True)
            item_name.setEditable(False)
            item_count = QStandardItem('0')
            item_count.setEnabled(True)
            try:
                exec(f'import {self.list_topics[index][1]} as module')
                test_task = eval(f'module.{self.list_content[index][row]}()')
                test_task.make_task()
                example_text = test_task.generated_text
                answer_text = test_task.calculate_answer(
                    **test_task.values_params)
                image_text = test_task.task_image
            except Exception as e:
                example_text = 'ОШИБКА при генерации задания'
            item_text = QStandardItem(example_text)
            item_text.setEditable(False)
            item_answer = QStandardItem(answer_text)
            item_answer.setEditable(False)
            item_image = QStandardItem(image_text)
            item_image.setEditable(False)
            self.list_models[index].appendRow(
                [item_name, item_count, item_text, item_answer, item_image])

            self.list_models[index].setHorizontalHeaderLabels([
                'Название', 'Количество', 'Пример задания', 'Пример ответа',
                'Изображение'
            ])
        self.list_models[index].itemChanged.connect(self.change_count)

    def change_count(self, item):
        number_row = item.row()
        new_data = item.data(QtCore.Qt.EditRole)
        parent_model = item.model()
        check_field = parent_model.item(number_row, 0)
        count_field = parent_model.item(number_row, 1)
        if item is check_field:
            if check_field.checkState(
            ) == QtCore.Qt.Checked and count_field.data(
                    QtCore.Qt.EditRole) != '0':
                return
            if check_field.checkState(
            ) == QtCore.Qt.Checked and count_field.data(
                    QtCore.Qt.EditRole) == '0':
                count_field.setData('1', QtCore.Qt.EditRole)
                return
            if check_field.checkState(
            ) != QtCore.Qt.Checked and count_field.data(
                    QtCore.Qt.EditRole) != '0':
                count_field.setData('0', QtCore.Qt.EditRole)
                return
        else:
            if check_field.checkState(
            ) != QtCore.Qt.Checked and count_field.data(
                    QtCore.Qt.EditRole) != '0':
                check_field.setCheckState(QtCore.Qt.Checked)
                return
            if check_field.checkState(
            ) == QtCore.Qt.Checked and count_field.data(
                    QtCore.Qt.EditRole) == '0':
                check_field.setCheckState(QtCore.Qt.Unchecked)
                return

    def get_selected_items(self):
        for i in range(len(self.list_models)):
            name_topic = self.list_topics[i]
            for j in range(self.list_models[i].rowCount()):
                name_class = self.list_models[i].item(j, 0)
                count_items = self.list_models[i].item(j, 1)
                if name_class.checkState() == QtCore.Qt.Checked:
                    if name_topic not in self.selected_items:
                        self.selected_items[name_topic] = [
                            (name_class.text(), int(count_items.text()))
                        ]
                    else:
                        self.selected_items[name_topic].append(
                            (name_class.text(), int(count_items.text())))

    def validate(self):
        if len(self.linedit_name.text()) == 0 or self.linedit_name.text(
        ).isspace():
            QMessageBox.warning(
                self, 'Предупреждение',
                'Введите название теста. Это поле не должно быть пустым.')
            return False
        self.get_selected_items()
        if not self.selected_items:
            QMessageBox.warning(
                self, 'Предупреждение',
                'Не выбраны задания теста. Должно быть выбрано хотя бы одно задание.'
            )
            return False
        return True

    def save_test(self):
        id_challenge = None
        if self.validate():
            if not self.the_new_test:
                id_challenge = int(self.info_challenge[0])
                print(id_challenge)
                db = DatabaseEngine()
                res_value = db.delete_items_for_challenge(id_challenge)
                db.close()
                if res_value == -1:
                    return
                db = DatabaseEngine()
                res_value = db.update_challenges('title',
                                                 self.linedit_name.text(),
                                                 id_challenge)
                db.close()
                if res_value == -1:
                    return
                db = DatabaseEngine()
                res_value = db.update_challenges(
                    'mixing', int(self.check_random.isChecked()), id_challenge)
                db.close()
                if res_value == -1:
                    return
                db = DatabaseEngine()
                res_value = db.update_challenges(
                    'training', int(self.check_study.isChecked()),
                    id_challenge)
                db.close()
                if res_value == -1:
                    return
            else:
                db = DatabaseEngine()
                title_challenge = self.linedit_name.text()
                try:
                    db.insert_challenge(title_challenge,
                                        self.check_random.isChecked(),
                                        self.check_study.isChecked())
                except Exception as e:
                    print("Непридвиденная ошибка базы данных", e)
                    return
                id_challenge = db.search_id_challenge(title_challenge)
                db.close()
            if id_challenge is None or id_challenge == -1:
                print("Непридвиденная ошибка базы данных")
                return -1
            db = DatabaseEngine()
            for key, value in self.selected_items.items():
                for elem in value:
                    db.insert_challenge_item(elem[0], id_challenge, elem[1],
                                             key[1])
            db.close()
            if not self.the_new_test:
                QMessageBox().information(self, "Успешно",
                                          'Тест успешно изменен.')
            else:
                QMessageBox().information(self, "Успешно",
                                          'Тест добавлен в базу данных.')
            self.accept()
Ejemplo n.º 13
0
    def setupUi(self, Widget):

        # widgety rysujące kształty, instancje klasy Ksztalt
        self.ksztalt1 = Ksztalt(self, Ksztalty.Polygon)
        self.ksztalt2 = Ksztalt(self, Ksztalty.Ellipse)
        self.ksztaltAktywny = self.ksztalt1

        # przyciski CheckBox ###
        uklad = QVBoxLayout()  # układ pionowy
        self.grupaChk = QButtonGroup()
        for i, v in enumerate(('Kwadrat', 'Koło', 'Trójkąt', 'Linia')):
            self.chk = QCheckBox(v)
            self.grupaChk.addButton(self.chk, i)
            uklad.addWidget(self.chk)
        self.grupaChk.buttons()[self.ksztaltAktywny.ksztalt].setChecked(True)
        # CheckBox do wyboru aktywnego kształtu
        self.ksztaltChk = QCheckBox('<=')
        self.ksztaltChk.setChecked(True)
        uklad.addWidget(self.ksztaltChk)

        # układ poziomy dla kształtów oraz przycisków CheckBox
        ukladH1 = QHBoxLayout()
        ukladH1.addWidget(self.ksztalt1)
        ukladH1.addLayout(uklad)
        ukladH1.addWidget(self.ksztalt2)
        # koniec CheckBox ###

        # Slider i LCDNumber ###
        self.suwak = QSlider(Qt.Horizontal)
        self.suwak.setMinimum(0)
        self.suwak.setMaximum(255)
        self.lcd = QLCDNumber()
        self.lcd.setSegmentStyle(QLCDNumber.Flat)
        # układ poziomy (splitter) dla slajdera i lcd
        ukladH2 = QSplitter(Qt.Horizontal, self)
        ukladH2.addWidget(self.suwak)
        ukladH2.addWidget(self.lcd)
        ukladH2.setSizes((125, 75))

        # przyciski RadioButton ###
        self.ukladR = QHBoxLayout()
        for v in ('R', 'G', 'B'):
            self.radio = QRadioButton(v)
            self.ukladR.addWidget(self.radio)
        self.ukladR.itemAt(0).widget().setChecked(True)
        # grupujemy przyciski
        self.grupaRBtn = QGroupBox('Opcje RGB')
        self.grupaRBtn.setLayout(self.ukladR)
        self.grupaRBtn.setObjectName('Radio')
        self.grupaRBtn.setCheckable(True)
        # układ poziomy dla grupy Radio
        ukladH3 = QHBoxLayout()
        ukladH3.addWidget(self.grupaRBtn)
        # koniec RadioButton ###

        # Lista ComboBox i SpinBox ###
        self.listaRGB = QComboBox(self)
        for v in ('R', 'G', 'B'):
            self.listaRGB.addItem(v)
        self.listaRGB.setEnabled(False)
        # SpinBox
        self.spinRGB = QSpinBox()
        self.spinRGB.setMinimum(0)
        self.spinRGB.setMaximum(255)
        self.spinRGB.setEnabled(False)
        # układ pionowy dla ComboBox i SpinBox
        uklad = QVBoxLayout()
        uklad.addWidget(self.listaRGB)
        uklad.addWidget(self.spinRGB)
        # do układu poziomego grupy Radio dodajemy układ ComboBox i SpinBox
        ukladH3.insertSpacing(1, 25)
        ukladH3.addLayout(uklad)
        # koniec ComboBox i SpinBox ###

        # przyciski PushButton ###
        uklad = QHBoxLayout()
        self.grupaP = QButtonGroup()
        self.grupaP.setExclusive(False)
        for v in ('R', 'G', 'B'):
            self.btn = QPushButton(v)
            self.btn.setCheckable(True)
            self.grupaP.addButton(self.btn)
            uklad.addWidget(self.btn)
        # grupujemy przyciski
        self.grupaPBtn = QGroupBox('Przyciski RGB')
        self.grupaPBtn.setLayout(uklad)
        self.grupaPBtn.setObjectName('Push')
        self.grupaPBtn.setCheckable(True)
        self.grupaPBtn.setChecked(False)
        # koniec PushButton ###

        # etykiety QLabel i pola QLineEdit ###
        ukladH4 = QHBoxLayout()
        self.labelR = QLabel('R')
        self.labelG = QLabel('G')
        self.labelB = QLabel('B')
        self.kolorR = QLineEdit('0')
        self.kolorG = QLineEdit('0')
        self.kolorB = QLineEdit('0')
        for v in ('R', 'G', 'B'):
            label = getattr(self, 'label' + v)
            kolor = getattr(self, 'kolor' + v)
            ukladH4.addWidget(label)
            ukladH4.addWidget(kolor)
            kolor.setMaxLength(3)
        # koniec QLabel i QLineEdit ###

        # główny układ okna, wertykalny ###
        ukladOkna = QVBoxLayout()
        ukladOkna.addLayout(ukladH1)
        ukladOkna.addWidget(ukladH2)
        ukladOkna.addLayout(ukladH3)
        ukladOkna.addWidget(self.grupaPBtn)
        ukladOkna.addLayout(ukladH4)

        self.setLayout(ukladOkna)  # przypisanie układu do okna głównego
        self.setWindowTitle('Widżety')
        self.resize(200, 250)
Ejemplo n.º 14
0
    def preferences(self):
        '''Preferences for the dataviewer
        '''
        #Get initial config:
        im_sec = Config().getViewerFramerate()
        config = Config().getViewerConfig()
        ref = Config().get_referential()

        dialog = Qt.QDialog()
        dialog.setWindowTitle('Preferences')
        dialog.resize(600, 400)
        layout = Qt.QVBoxLayout()
        layout.setContentsMargins(25, 25, 25, 25)
        dialog.setLayout(layout)

        #Change Neuro/Radio configuration
        config_layout = QHBoxLayout()
        title_config = Qt.QLabel()
        title_config.setText('Configuration: ')
        box = Qt.QComboBox()
        box.addItem('Neuro')
        box.addItem('Radio')
        config_layout.addWidget(title_config)
        config_layout.addWidget(box)
        if config == 'radio':
            box.setCurrentIndex(1)

        #set automatic time frame rate
        frame_rate_layout = QHBoxLayout()
        title = Qt.QLabel()
        title.setText('Automatic time image display:')
        slider = Qt.QSlider(Qt.Qt.Horizontal)
        slider.setRange(1, 100)
        slider.setValue(int(im_sec))
        size = QtCore.QSize(180, 15)
        slider.setMinimumSize(size)
        slow_label = Qt.QLabel()
        fast_label = Qt.QLabel()
        slow_label.setText('slow')
        fast_label.setText('fast')
        frame_rate_layout.addWidget(title)
        frame_rate_layout.addWidget(slow_label)
        frame_rate_layout.addWidget(slider)
        frame_rate_layout.addWidget(fast_label)
        frame_rate_layout.insertSpacing(1, 200)

        #Change referential
        ref_layout = QHBoxLayout()
        title_ref = Qt.QLabel()
        title_ref.setText('Referential: ')
        box2 = Qt.QComboBox()
        box2.addItem('World Coordinates')
        box2.addItem('Image referential')
        ref_layout.addWidget(title_ref)
        ref_layout.addWidget(box2)
        box2.setCurrentIndex(int(ref))

        #Set general vertical layout
        layout.addLayout(config_layout)
        layout.addLayout(frame_rate_layout)
        layout.addLayout(ref_layout)
        layout.addStretch(1)

        #Save and cancel buttons
        hlay = Qt.QHBoxLayout()
        layout.addLayout(hlay)
        ok = Qt.QPushButton('Save')
        hlay.addStretch(1)
        hlay.addWidget(ok)
        ok.clicked.connect(dialog.accept)
        ok.setDefault(True)
        cancel = Qt.QPushButton('Cancel')
        hlay.addWidget(cancel)
        cancel.clicked.connect(dialog.reject)
        hlay.addStretch(1)

        res = dialog.exec_()

        if res == Qt.QDialog.Accepted:
            new_config = box.currentText().lower()
            new_ref = box2.currentIndex()

            #Save Config parameters and reload images
            #when config and referential have changed
            Config().setViewerFramerate(slider.value())
            Config().setViewerConfig(new_config)
            Config().set_referential(new_ref)
            if new_config != config:
                self.anaviewer.changeConfig(new_config)
            if new_ref != ref:
                self.anaviewer.changeRef()
Ejemplo n.º 15
0
    def __init__(self, parent):
        # Call superclass constructor
        super().__init__()

        # Save parent instance
        self.parent = parent

        # Slider box
        slider_box = QVBoxLayout()
        slider_box.addWidget(
            DecisionMakerSlider('How hungry are you?', parent.setHungerLevel))
        slider_box.addWidget(
            DecisionMakerSlider('Thirsty?', parent.setThirstLevel))
        slider_box.addWidget(
            DecisionMakerSlider('Energy level?', parent.setEnergyLevel))
        slider_box.addWidget(
            DecisionMakerSlider('Introversion level?',
                                parent.setIntrovertLevel))
        slider_box.addWidget(
            DecisionMakerSlider('Stress level?', parent.setStressLevel))

        # Box containing calendar control, time control, weather control, alone toggle and retrograde toggle
        right_box = QVBoxLayout()

        # Box containing all of the above minus calendar
        #lowerright_box = QHBoxLayout()

        # Box containing labels for contorl in lower right box
        #lowerright_label_box = QVBoxLayout()

        # Box containing controls in lower right box
        #lowerright_control_box = QVBoxLayout()

        # Calendar control
        self.calendar = QCalendarWidget()
        self.calendar.setHorizontalHeaderFormat(
            QCalendarWidget.SingleLetterDayNames)
        self.calendar.setVerticalHeaderFormat(QCalendarWidget.NoVerticalHeader)
        self.calendar.selectionChanged.connect(self.calendarChanged)
        self.calendar.setFixedWidth(325)
        right_box.addWidget(self.calendar)

        # Save today's date
        self.today = self.calendar.selectedDate()

        # Initialize day and year
        self.parent.setDay(self.today.dayOfWeek() - 1)

        # Limit year to +- 100 form current
        year = self.today.year()
        if (year > 100):
            year = 100
        elif (year < -100):
            year = -100

        self.parent.setYear(year)

        # Time control
        time_box = QHBoxLayout()
        time_label = QLabel('What time is it?', self)
        self.time_combo = QComboBox()
        self.time_combo.addItems(
         ['1:00', '2:00', '3:00', '4:00', '5:00', '6:00', \
         '7:00', '8:00', '9:00', '10:00', '11:00', '12:00' ]
        )
        hour = QTime.currentTime().hour() - 1
        hour_convert = hour
        if (hour_convert < 0):
            hour_convert = 23
        if (hour_convert > 12):
            hour_convert -= 12
        self.time_combo.setCurrentIndex(hour_convert)
        self.time_combo.currentIndexChanged.connect(self.comboChanged)

        self.ampm_combo = QComboBox()
        self.ampm_combo.addItems(['AM', 'PM'])
        if (hour > 12):
            self.ampm_combo.setCurrentIndex(1)
        else:
            self.ampm_combo.setCurrentIndex(0)
        self.ampm_combo.currentIndexChanged.connect(self.comboChanged)

        self.parent.setTime(hour)

        time_box.addWidget(time_label)
        time_box.addWidget(self.time_combo)
        time_box.addWidget(self.ampm_combo)
        right_box.addLayout(time_box)

        # Weather control
        weather_box = QHBoxLayout()
        weather_label = QLabel('What\'s the weather like?', self)
        self.weather_combo = QComboBox()
        self.weather_combo.addItems(
            ['Sunny', 'Cloudy', 'Raining', 'Snowing', 'Natural Disaster'])
        self.weather_combo.currentIndexChanged.connect(self.comboChanged)
        weather_box.addWidget(weather_label)
        weather_box.addWidget(self.weather_combo)
        right_box.addLayout(weather_box)

        # Alone toggle button
        alone_box = QHBoxLayout()
        alone_label = QLabel('Are you alone, or with someone else?', self)
        self.button_alone = QPushButton('Alone')
        self.button_alone.setCheckable(True)
        self.button_alone.clicked.connect(self.buttonClicked)
        alone_box.addWidget(alone_label)
        alone_box.addWidget(self.button_alone)
        right_box.addLayout(alone_box)

        # Retrograde toggle button
        retrograde_box = QHBoxLayout()
        retrograde_label = QLabel('Is Mercury in retrograde?', self)
        self.button_retrograde = QPushButton('Nope')
        self.button_retrograde.setCheckable(True)
        self.button_retrograde.clicked.connect(self.buttonClicked)
        retrograde_box.addWidget(retrograde_label)
        retrograde_box.addWidget(self.button_retrograde)
        right_box.addLayout(retrograde_box)

        # Color palette
        self.setAutoFillBackground(True)
        palette = self.palette()
        palette.setColor(self.backgroundRole(), Qt.white)
        self.setPalette(palette)

        # Set up layout
        hbox = QHBoxLayout()
        hbox.addLayout(slider_box)
        hbox.insertSpacing(1, 25)
        hbox.addLayout(right_box)
        hbox.setSizeConstraint(QLayout.SetFixedSize)
        self.setLayout(hbox)
Ejemplo n.º 16
0
    def setupUi(self, Widget):
        self.shape1 = Shape(self, Shapes.Polygon)
        self.shape2 = Shape(self, Shapes.Ellipse)
        self.activeShape = self.shape1

        # Check Boxex panel
        checkboxWrapper = QVBoxLayout()
        self.checkboxGroup = QButtonGroup()
        for i, value in enumerate(('Square', 'Circle', 'Triangle', 'Line')):
            self.checkbox = QCheckBox(value)
            self.checkboxGroup.addButton(self.checkbox, i)
            checkboxWrapper.addWidget(self.checkbox)
        self.checkboxGroup.buttons()[self.activeShape.shape].setChecked(True)

        self.activeShapeCheckbox = QCheckBox('<=')
        self.activeShapeCheckbox.setChecked(True)
        checkboxWrapper.addWidget(self.activeShapeCheckbox)

        checkboxContainer = QHBoxLayout()
        checkboxContainer.addWidget(self.shape1)
        checkboxContainer.addLayout(checkboxWrapper)
        checkboxContainer.addWidget(self.shape2)

        # Slider panel
        self.slider = QSlider(Qt.Horizontal)
        self.slider.setMinimum(0)
        self.slider.setMaximum(255)

        self.lcd = QLCDNumber()
        self.lcd.setSegmentStyle(QLCDNumber.Flat)

        sliderContainer = QSplitter(Qt.Horizontal, self)
        sliderContainer.addWidget(self.slider)
        sliderContainer.addWidget(self.lcd)
        sliderContainer.setSizes((125, 75))

        # Radio buttons
        self.radioContainer = QHBoxLayout()
        for v in ('R', 'G', 'B'):
            self.radio = QRadioButton(v)
            self.radioContainer.addWidget(self.radio)
        self.radioContainer.itemAt(0).widget().setChecked(True)

        self.radioGroup = QGroupBox('RGB options')
        self.radioGroup.setLayout(self.radioContainer)
        self.radioGroup.setObjectName('Radio')
        self.radioGroup.setCheckable(True)

        # ComboBox and SpinBox
        self.listRGB = QComboBox(self)
        for v in ('R', 'G', 'B'):
            self.listRGB.addItem(v)
        self.listRGB.setEnabled(False)

        # SpinBox
        self.spinRGB = QSpinBox()
        self.spinRGB.setMinimum(0)
        self.spinRGB.setMaximum(255)
        self.spinRGB.setEnabled(False)

        comboContainer = QVBoxLayout()
        comboContainer.addWidget(self.listRGB)
        comboContainer.addWidget(self.spinRGB)

        radioRow = QHBoxLayout()
        radioRow.addWidget(self.radioGroup)
        radioRow.insertSpacing(1, 25)
        radioRow.addLayout(comboContainer)

        # Push button
        pushContainer = QHBoxLayout()
        self.groupP = QButtonGroup()
        self.groupP.setExclusive(False)
        for v in ('R', 'G', 'B'):
            self.btn = QPushButton(v)
            self.btn.setCheckable(True)
            self.groupP.addButton(self.btn)
            pushContainer.addWidget(self.btn)

        self.groupPBtn = QGroupBox('RGB Buttons')
        self.groupPBtn.setLayout(pushContainer)
        self.groupPBtn.setObjectName('Push')
        self.groupPBtn.setCheckable(True)
        self.groupPBtn.setChecked(False)

        #Labels
        labelsContainer = QHBoxLayout()

        self.labelR = QLabel('R')
        self.colorR = QLineEdit('0')

        self.labelG = QLabel('G')
        self.colorG = QLineEdit('0')

        self.labelB = QLabel('B')
        self.colorB = QLineEdit('0')

        for v in ('R', 'G', 'B'):
            label = getattr(self, 'label' + v)
            color = getattr(self, 'color' + v)
            labelsContainer.addWidget(label)
            labelsContainer.addWidget(color)
            color.setMaxLength(3)

        # Main layout
        mainLayout = QVBoxLayout()
        mainLayout.addLayout(checkboxContainer)
        mainLayout.addWidget(sliderContainer)
        mainLayout.addLayout(radioRow)
        mainLayout.addWidget(self.groupPBtn)
        mainLayout.addLayout(labelsContainer)

        self.setLayout(mainLayout)
        self.setWindowTitle('Widgets')
from PyQt5.QtWidgets import QApplication, QLabel, QWidget, QBoxLayout, QPushButton, QVBoxLayout, QHBoxLayout

app = QApplication([])
app.setStyle('Fusion')
window = QWidget()

title = QHBoxLayout()
title.insertSpacing(60, 60)
title.addWidget(QLabel("Rita's conversation"))
title.insertSpacing(60, 60)

pathChooser = QHBoxLayout()
pathChooser.addWidget(QLabel('Choose path'))
pathChooser.addWidget(QPushButton('Choose'))

path = QHBoxLayout()
path.addWidget(QLabel('Path:'))
path.addWidget(QLabel('here is choosed path'))

optionsText = QHBoxLayout()
optionsText.insertSpacing(100, 100)
optionsText.addWidget(QLabel('Options'))
optionsText.insertSpacing(100, 100)

layout = QVBoxLayout()
layout.addLayout(title)
layout.addLayout(pathChooser)
layout.addLayout(path)
layout.addLayout(optionsText)
window.setLayout(layout)
window.show()