def createReciept(self):
        self.recieptContainer = QFrame(self)
        self.recieptContainer.setFixedSize(500, 700)
        vbox = QVBoxLayout()
        self.recieptGroup = QGroupBox("تفاصيل الفاتورة", self)
        self.recieptGroup.setFont(QFont("urdu Typesetting", 36, 900))
        recieptGrid = QGridLayout()
        date = QDate.currentDate()
        time = QTime.currentTime()
        invNumber = QDateTime.currentDateTime()

        headerFont = QFont("Traditional Arabic", 10, 900)
        headerFont.setBold(True)
        self.recHeader = QLabel("مطعم الوجبات السريعة", self)
        self.recHeader.setFont(QFont("Traditional Arabic", 18, 900))
        self.recHeader.setAlignment(Qt.AlignCenter)
        recieptGrid.addWidget(self.recHeader, 0, 0, 1, 4)
        self.recTime = QLabel(self)
        self.recTime.setText("الوقت:" +
                             time.toString(Qt.DefaultLocaleLongDate))
        self.recDate = QLabel(self)
        self.recDate.setText("التاريخ: " + date.toString(Qt.ISODate))
        self.recNumbertext = QLabel("رقم الفاتورة : ", self)
        self.recNumberValue = QLabel(self)
        self.recNumberValue.setStyleSheet("padding-left: 2px")
        self.recNumberValue.setText(
            invNumber.toString(Qt.ISODate) + " " +
            str(RestaurantBillingSystem.invoice_no))
        titles = [
            self.recNumbertext, self.recNumberValue, self.recTime, self.recDate
        ]
        for t, title in enumerate(titles):
            title.setFont(QFont("Traditional Arabic", 12, 900))
            title.setAlignment(Qt.AlignCenter)
            recieptGrid.addWidget(title, 1, t, 1, 1)

        self.itemName = QLabel("الصنف", self)
        self.itemPrice = QLabel("السعر(ج.م)", self)
        self.itemQuantity = QLabel("الكمية", self)
        self.itemTotal = QLabel("الإجمالي", self)
        headers = [
            self.itemName, self.itemPrice, self.itemQuantity, self.itemTotal
        ]
        for h, head in enumerate(headers):
            head.setFont(headerFont)
            head.setAlignment(Qt.AlignCenter)
            head.setFixedSize(120, 30)
            recieptGrid.addWidget(head, 2, h, 1, 1)

        self.scrReciept = QLabel(self)
        self.scrReciept.setFixedSize(460, 330)
        scrFont = QFont("Arabic Transparent", 12, 900)
        scrFont.setBold(True)
        self.scrReciept.setFont(scrFont)
        self.scrReciept.setStyleSheet("padding-left: 5px")
        recieptGrid.addWidget(self.scrReciept, 3, 0, 1, 4)

        self.invTotal = QLabel("الإجمالي", self)
        recieptGrid.addWidget(self.invTotal, 4, 0, 1, 3)
        self.totalValue = QLabel(self)
        recieptGrid.addWidget(self.totalValue, 4, 3, 1, 1)

        self.invDiscount = QLabel("خصم نقدي", self)
        recieptGrid.addWidget(self.invDiscount, 5, 0, 1, 3)
        self.disValue = QLabel(self)
        recieptGrid.addWidget(self.disValue, 5, 3, 1, 1)

        self.invVAT = QLabel("ضريبة ق.م", self)
        recieptGrid.addWidget(self.invVAT, 6, 0, 1, 3)
        self.VATValue = QLabel(self)
        recieptGrid.addWidget(self.VATValue, 6, 3, 1, 1)

        self.invNetText = QLabel("صافي الفاتورة", self)
        recieptGrid.addWidget(self.invNetText, 7, 0, 1, 3)
        self.netValue = QLabel(self)
        recieptGrid.addWidget(self.netValue, 7, 3, 1, 1)

        self.totals = [
            self.invTotal, self.totalValue, self.invDiscount, self.disValue,
            self.invVAT, self.VATValue, self.invNetText, self.netValue
        ]
        for tot in self.totals:
            tot.setFont(QFont("Traditional Arabic", 12, 900))
            tot.setAlignment(Qt.AlignLeft)
            tot.setStyleSheet("padding-left: 30")
            tot.setMinimumHeight(30)
        self.totValues = [
            self.totalValue, self.disValue, self.VATValue, self.netValue
        ]
        valfont = QFont("Traditional Arabic", 14, 900)
        valfont.setBold(True)
        for val in self.totValues:
            val.setFont(valfont)
            val.setAlignment(Qt.AlignRight)
            val.setMinimumHeight(30)

        self.recieptGroup.setLayout(recieptGrid)
        vbox.addWidget(self.recieptGroup)
        vbox.addStretch()
        self.recieptContainer.setLayout(vbox)
示例#2
0
    def initUI(self):
        
        title = QLabel('活动标题:')
        title.setFont(QFont('黑体', 10))
        # title.setAlignment(Qt.AlignHCenter)
        self.titleInput = QLineEdit()

        tophbox = QHBoxLayout()
        tophbox.addStretch(1)
        tophbox.addWidget(title)
        tophbox.addWidget(self.titleInput)
        tophbox.addStretch(1)

        choice = QLabel('选项: ')
        choice.setFont(QFont('宋体'))
        self.choiceInput = QLineEdit()

        lefthbox1 = QHBoxLayout()
        lefthbox1.addWidget(choice)
        lefthbox1.addWidget(self.choiceInput)
        
        self.appendButton = QPushButton('添加')
        self.appendButton.setFont(QFont('黑体'))
        self.appendButton.setIcon(QIcon('./image/view.png'))
        self.appendButton.clicked.connect(self.onAppend)

        lefthbox2 = QHBoxLayout()
        lefthbox2.addStretch(1)
        lefthbox2.addWidget(self.appendButton)
        lefthbox2.addStretch(1)

        votelimit = QLabel('个人有效票数: ')
        self.votelimitInput = QLineEdit()
        self.votelimitInput.setPlaceholderText('1')
        intValidator = QIntValidator()
        intValidator.setRange(1, 2147483647)
        self.votelimitInput.setValidator(intValidator)

        lefthbox3 = QHBoxLayout()
        lefthbox3.addWidget(votelimit)
        lefthbox3.addWidget(self.votelimitInput)

        self.viewButton = QPushButton('预览')
        self.viewButton.setIcon(QIcon('./image/view.png'))
        self.viewButton.clicked.connect(self.onView)

        self.saveButton = QPushButton('保存')
        self.saveButton.setIcon(QIcon('./image/save.png'))
        self.saveButton.clicked.connect(self.onSave)

        lefthbox4 = QHBoxLayout()
        lefthbox4.addWidget(self.viewButton)
        lefthbox4.addWidget(self.saveButton)

        leftLayout = QVBoxLayout()
        leftLayout.addLayout(lefthbox1)
        leftLayout.addLayout(lefthbox2)
        leftLayout.addLayout(lefthbox3)
        leftLayout.addLayout(lefthbox4)

        leftFrame = QFrame()
        leftFrame.setFrameShape(QFrame.WinPanel)
        leftFrame.setLayout(leftLayout)

        self.righLayout = QVBoxLayout()

        self.tabledata = []
        self.rownum = len(self.tabledata)
        self.showtable = None

        self.createTable(self.tabledata)

        downhobx = QHBoxLayout()
        downhobx.addWidget(leftFrame)
        downhobx.addLayout(self.righLayout)
        downhobx.setStretchFactor(leftFrame, 1)
        downhobx.setStretchFactor(self.righLayout, 1)

        self.captchalbl = QLineEdit()
        self.captchalbl.setText('活动邀请码: ')

        totalLayout = QVBoxLayout()
        totalLayout.addLayout(tophbox)
        totalLayout.addLayout(downhobx)
        totalLayout.addWidget(self.captchalbl)

        self.setLayout(totalLayout)

        center(self)
        self.resize(600, 300)
        self.setWindowTitle('发起投票')
        self.setWindowIcon(QIcon('./image/launch.png'))
示例#3
0
    def initUI(self):
        self.centralFrame = QFrame(self)
        self.centralFrame.setFrameShape(QFrame.NoFrame)
        self.centralFrame.setFrameShadow(QFrame.Raised)
        self.centralFrame.setMinimumSize(QSize(0, 25))
        self.centralFrame.setMaximumSize(QSize(16777215, 25))
        self.centralFrame.setContentsMargins(0, 0, 0, 0)
        self.centralFrame.setStyleSheet(u"background-color: rgb(27, 29, 35);")

        self.labelsFrame = QFrame(self.centralFrame)
        self.labelsFrame.setFrameShape(QFrame.NoFrame)
        self.labelsFrame.setFrameShadow(QFrame.Raised)
        self.labelsFrame.setContentsMargins(0, 0, 0, 0)
        self.labelsFrame.setStyleSheet("border: none;")

        self.developerLabel = Label(self.labelsFrame)
        self.developerLabel.setText("Ashwin Sakhare")

        self.instituteLabel = Label(self.labelsFrame)
        self.instituteLabel.setText(
            "Stevens Neuroimaging and Informatics Institute")

        self.universityLabel = Label(self.labelsFrame)
        self.universityLabel.setText("University of Southern California")

        self.labelsLayout = QHBoxLayout(self.labelsFrame)
        self.labelsLayout.addWidget(self.developerLabel)
        self.labelsLayout.addWidget(self.instituteLabel)
        self.labelsLayout.addWidget(self.universityLabel)
        self.labelsLayout.setSpacing(50)
        self.labelsLayout.setContentsMargins(10, 0, 0, 0)

        self.labelsLayout.setAlignment(Qt.AlignLeft)

        self.versionFrame = QFrame(self.centralFrame)
        self.versionFrame.setFrameShape(QFrame.NoFrame)
        self.versionFrame.setFrameShadow(QFrame.Raised)
        self.versionFrame.setContentsMargins(0, 0, 0, 0)
        self.versionFrame.setStyleSheet("border: none;")

        self.versionLabel = Label(self.labelsFrame)
        self.versionLabel.setText("v1.0.0 alpha")

        self.versionLayout = QHBoxLayout(self.versionFrame)
        self.versionLayout.addWidget(self.versionLabel)
        self.versionLayout.setAlignment(Qt.AlignRight)
        self.versionLayout.setContentsMargins(0, 0, 20, 0)

        self.gripFrame = QFrame(self.centralFrame)
        self.gripFrame.setFrameShape(QFrame.NoFrame)
        self.gripFrame.setFrameShadow(QFrame.Raised)
        self.gripFrame.setMaximumSize(QSize(20, 20))
        self.gripFrame.setContentsMargins(0, 0, 0, 0)

        # path = resource_path('icons/cil-size-grip.png')
        # self.gripFrame.setStyleSheet("background-image: url(" + str(path) + "); \n"
        #                              "background-position: center; \n"
        #                              "background-repeat: no repeat")

        self.ui_sizeGrip = QSizeGrip(self.gripFrame)
        self.ui_sizeGrip.setStyleSheet(
            "width: 20px; height: 20px; margin 0px; padding: 0px;")

        self.gripLabel = QLabel(self.gripFrame)
        self.pixmap = QPixmap(resource_path('icons/cil-size-grip.png'))
        self.gripLabel.setPixmap(self.pixmap)

        self.gripLayout = QHBoxLayout(self.gripFrame)
        self.gripLayout.addWidget(self.gripLabel)
        self.gripLayout.setAlignment(Qt.AlignCenter)
        self.gripLayout.setContentsMargins(0, 0, 0, 0)

        self.centralLayout = QHBoxLayout(self.centralFrame)
        self.centralLayout.addWidget(self.labelsFrame)
        self.centralLayout.addWidget(self.versionFrame)
        self.centralLayout.addWidget(self.gripFrame)
        self.centralLayout.setSpacing(0)
        self.centralLayout.setContentsMargins(0, 0, 0, 0)

        self.uiLayout = QHBoxLayout(self)
        self.uiLayout.addWidget(self.centralFrame)
        self.uiLayout.setContentsMargins(0, 0, 0, 0)

        self.setLayout(self.uiLayout)
示例#4
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        self.interface_lng_val = parent.interface_lng_val
        self.con = parent.con
        self.full_dir = parent.full_dir
        self.par = parent

        #query = QtSql.QSqlQuery()
        #query.exec("CREATE TABLE createPatchDict(name, type, constructFrom, set, pointSync)")
        #print(self.con.lastError().text())

        #----- initial
        main_lbl = QLabel()

        patch_numb_lbl = QLabel()
        self.patch_numb_edit = QSpinBox()
        self.patch_numb_edit.setRange(1, 1000)
        self.patch_numb_edit.setFixedSize(100, 25)
        #print(self.con.tables())
        if 'createPatchDict' in self.con.tables():

            query = QtSql.QSqlQuery()
            query.exec("SELECT * FROM createPatchDict")
            if query.isActive():
                query.first()
                self.size = 0
                name_back_list = []
                type_back_list = []
                cF_back_list = []
                nets_back_list = []
                pS_back_list = []

                while query.isValid():
                    self.size += 1
                    name_res = query.value('name')
                    type_res = query.value('type')
                    cF_res = query.value('constructFrom')
                    nets_res = query.value('nets')
                    pS_res = query.value('pointSync')

                    name_back_list.append(name_res)
                    type_back_list.append(type_res)
                    cF_back_list.append(cF_res)
                    nets_back_list.append(nets_res)
                    pS_back_list.append(pS_res)

                    query.next()

            if self.size >= 1:
                #print(self.size)
                self.patch_numb_edit.setValue(self.size)

                pn = self.patch_numb_edit.value()
                patches_grid = QGridLayout()
                patches_lbl = QLabel()

                pointSync_lbl = QLabel()
                self.pointSync_edit = QComboBox()
                self.pointSync_edit.setFixedSize(150, 25)
                pointSync_list = ['false', 'true']
                self.pointSync_edit.addItems(pointSync_list)
                pointSync_hbox = QHBoxLayout()
                pointSync_hbox.addWidget(pointSync_lbl)
                pointSync_hbox.addWidget(self.pointSync_edit)

                patches_grid.addWidget(patches_lbl,
                                       0,
                                       0,
                                       alignment=QtCore.Qt.AlignCenter)
                patches_grid.addLayout(pointSync_hbox,
                                       1,
                                       0,
                                       alignment=QtCore.Qt.AlignCenter)

                k = 1
                v = 2
                y = 0

                self.name_edit_list = []
                self.type_edit_list = []
                self.constructFrom_edit_list = []
                self.set_edit_list = []

                while k <= pn:

                    name_lbl = QLabel()
                    name_hbox = QHBoxLayout()
                    name_edit = QLineEdit()
                    name_edit.setFixedSize(150, 25)
                    name_hbox.addWidget(name_lbl)
                    name_hbox.addWidget(name_edit)
                    name_edit.setText(name_back_list[y])

                    type_lbl = QLabel()
                    type_hbox = QHBoxLayout()
                    type_edit = QComboBox()
                    type_edit.setFixedSize(150, 25)
                    type_list = ["patch"]
                    type_edit.addItems(type_list)
                    type_hbox.addWidget(type_lbl)
                    type_hbox.addWidget(type_edit)
                    type_mas = type_edit.count()
                    for i in range(type_mas):
                        if type_edit.itemText(i) == type_back_list[y]:
                            type_edit.setCurrentIndex(i)

                    constructFrom_lbl = QLabel()
                    constructFrom_hbox = QHBoxLayout()
                    constructFrom_edit = QComboBox()
                    constructFrom_edit.setFixedSize(110, 25)
                    constructFrom_list = ["set"]
                    constructFrom_edit.addItems(constructFrom_list)
                    constructFrom_hbox.addWidget(constructFrom_lbl)
                    constructFrom_hbox.addWidget(constructFrom_edit)
                    constructFrom_mas = constructFrom_edit.count()
                    for i in range(constructFrom_mas):
                        if constructFrom_edit.itemText(i) == cF_back_list[y]:
                            constructFrom_edit.setCurrentIndex(i)

                    set_lbl = QLabel()
                    set_hbox = QHBoxLayout()
                    set_edit = QLineEdit()
                    set_edit.setFixedSize(140, 25)
                    set_hbox.addWidget(set_lbl)
                    set_hbox.addWidget(set_edit)
                    set_edit.setText(nets_back_list[y])

                    self.name_edit_list.append(name_edit)
                    self.type_edit_list.append(type_edit)
                    self.constructFrom_edit_list.append(constructFrom_edit)
                    self.set_edit_list.append(set_edit)

                    patch_grid = QGridLayout()
                    patch_grid.addLayout(name_hbox, 0, 0)
                    patch_grid.addLayout(type_hbox, 1, 0)
                    patch_grid.addLayout(constructFrom_hbox, 2, 0)
                    patch_grid.addLayout(set_hbox, 3, 0)

                    patch_frame = QFrame()
                    patch_frame.setFixedSize(250, 130)
                    patch_frame.setLayout(patch_grid)

                    if self.interface_lng_val == 'Russian':

                        name_lbl.setText("Имя патча:")
                        type_lbl.setText("Тип патча:")
                        constructFrom_lbl.setText("Конструирование:")
                        set_lbl.setText("Поверхность:")

                    elif self.interface_lng_val == 'English':

                        name_lbl.setText("Patch name:")
                        type_lbl.setText("Patch type:")
                        constructFrom_lbl.setText("Construct from:")
                        set_lbl.setText("Face set:")

                    patches_grid.addWidget(patch_frame,
                                           v,
                                           0,
                                           alignment=QtCore.Qt.AlignCenter)

                    k += 1
                    v += 1
                    y += 1

                patches_btnSave = QPushButton()
                patches_btnSave.setFixedSize(80, 25)

                buttons_hbox = QHBoxLayout()
                buttons_hbox.addWidget(patches_btnSave)

                patches_grid.addLayout(buttons_hbox,
                                       len(self.name_edit_list) + 3,
                                       0,
                                       alignment=QtCore.Qt.AlignCenter)
                patches_grid.setRowStretch(3, 6)

                self.patches_group = QGroupBox()
                self.patches_group.setLayout(patches_grid)

                prs_grid = QGridLayout()
                prs_grid.addWidget(patch_numb_lbl, 0, 0)
                prs_grid.addWidget(self.patch_numb_edit, 0, 1)

                prs_frame = QFrame()
                prs_frame.setFixedSize(250, 70)
                prs_frame.setLayout(prs_grid)

                initial_btnSave = QPushButton()
                initial_btnSave.setFixedSize(80, 25)

                buttons_hbox = QHBoxLayout()
                buttons_hbox.addWidget(initial_btnSave)

                initial_grid = QGridLayout()
                initial_grid.addWidget(main_lbl,
                                       0,
                                       0,
                                       alignment=QtCore.Qt.AlignCenter)
                initial_grid.addWidget(prs_frame,
                                       1,
                                       0,
                                       alignment=QtCore.Qt.AlignCenter)
                initial_grid.addLayout(buttons_hbox,
                                       2,
                                       0,
                                       alignment=QtCore.Qt.AlignCenter)
                initial_grid.setRowStretch(3, 6)

                self.initial_group = QGroupBox()
                self.initial_group.setLayout(initial_grid)

                self.tab = QTabWidget()
                self.tab.insertTab(0, self.initial_group, "&initial")
                self.tab.insertTab(1, self.patches_group, "&new_patches")
                patches_btnSave.clicked.connect(
                    self.on_patches_btnSave_clicked)
                initial_btnSave.clicked.connect(
                    self.on_initial_btnSave_clicked)

                if self.interface_lng_val == 'Russian':
                    patches_lbl.setText("Укажите параметры патчей")
                    patches_btnSave.setText("Записать")
                    pointSync_lbl.setText("Точка синхронизации:")

                elif self.interface_lng_val == 'English':
                    patches_btnSave.setText("Write")
                    patches_lbl.setText("Set patches parameters")
                    pointSync_lbl.setText("Synchronization point:")
        else:
            #self.par.listWidget.clear()
            #msg_lbl = QLabel('<span style="color:green">' + msg + '</span>')
            #self.par.item = QListWidgetItem()
            #self.par.listWidget.addItem(self.par.item)
            #self.par.listWidget.setItemWidget(self.par.item, msg_lbl)

            prs_grid = QGridLayout()
            prs_grid.addWidget(patch_numb_lbl, 0, 0)
            prs_grid.addWidget(self.patch_numb_edit, 0, 1)

            prs_frame = QFrame()
            prs_frame.setFixedSize(250, 70)
            prs_frame.setLayout(prs_grid)

            initial_btnSave = QPushButton()
            initial_btnSave.setFixedSize(80, 25)

            buttons_hbox = QHBoxLayout()
            buttons_hbox.addWidget(initial_btnSave)

            initial_grid = QGridLayout()
            initial_grid.addWidget(main_lbl,
                                   0,
                                   0,
                                   alignment=QtCore.Qt.AlignCenter)
            initial_grid.addWidget(prs_frame,
                                   1,
                                   0,
                                   alignment=QtCore.Qt.AlignCenter)
            initial_grid.addLayout(buttons_hbox,
                                   2,
                                   0,
                                   alignment=QtCore.Qt.AlignCenter)
            initial_grid.setRowStretch(3, 6)

            self.initial_group = QGroupBox()
            self.initial_group.setLayout(initial_grid)

            #-----new_patches

            ###табличный виджет для групп
            self.tab = QTabWidget()
            #initial_group, spe_edit, nospe_lbl, nospe_edit, initial_btnSave, cTM_edit, nov_edit, spp_edit, nop_lbl, nop_edit, nob_edit, mpp_lbl, mpp_edit, nompp_lbl, nompp_edit, vertices_visible, blocks_visible, edges_visible, patches_visible, mergepatchpairs_visible = initial_class.out_frame_func(int_lng, prj_path, mesh_name_txt)
            self.tab.insertTab(0, self.initial_group, "&initial")
            #spe_edit.stateChanged.connect(self.spe_state_changed)
            #spp_edit.stateChanged.connect(self.spp_state_changed)
            #mpp_edit.stateChanged.connect(self.mpp_state_changed)
            initial_btnSave.clicked.connect(self.on_initial_btnSave_clicked)

#-------------------------Главный фрейм формы с элементами--------------------------#

        btnSave = QPushButton()
        btnSave.setFixedSize(80, 25)
        btnSave.clicked.connect(self.on_btnSave_clicked)
        buttons_hbox = QHBoxLayout()
        buttons_hbox.addWidget(btnSave)

        if self.interface_lng_val == 'Russian':
            initial_btnSave.setText("Записать")
            btnSave.setText("Сохранить")
            main_lbl.setText('Укажите количество патчей')
            patch_numb_lbl.setText('Количество патчей:')
        elif self.interface_lng_val == 'English':
            initial_btnSave.setText("Write")
            btnSave.setText("Save")
            main_lbl.setText('Set patches number')
            patch_numb_lbl.setText('Patches number:')

        scrollLayout = QFormLayout()
        scrollArea = QScrollArea()
        scrollArea.setWidgetResizable(True)
        scrollArea.setWidget(self.tab)
        scrollArea.setFixedSize(650, 460)

        cPD_grid = QGridLayout()
        cPD_grid.addWidget(scrollArea, 0, 0, alignment=QtCore.Qt.AlignCenter)
        cPD_grid.addLayout(buttons_hbox, 1, 0, alignment=QtCore.Qt.AlignCenter)
        cPD_frame = QFrame()
        cPD_frame.setFixedSize(670, 510)
        cPD_frame.setStyleSheet(
            open("./styles/properties_form_style.qss", "r").read())
        cPD_frame.setFrameShape(QFrame.Panel)
        cPD_frame.setFrameShadow(QFrame.Sunken)
        cPD_frame.setLayout(cPD_grid)

        cPD_vbox = QVBoxLayout()
        cPD_vbox.addWidget(cPD_frame)

        # ---------------------Размещение на форме всех компонентов-------------------------#

        form = QFormLayout()
        form.addRow(cPD_vbox)
        self.setLayout(form)
    def initUI(self):

        self.wHLayoutWidget = QWidget(self)
        self.wHLayoutWidget.setGeometry(0, 0, 240, 50)
        self.wHLayout = QHBoxLayout(self.wHLayoutWidget)
        self.wHLayout.setContentsMargins(5, 5, 5, 5)

        self.btnStepBackward = QToolButton(self.wHLayoutWidget)
        self.btnStepBackward.setIcon(QIcon("./assets/icons/step-backward.svg"))
        self.btnStepBackward.setToolTip("Quay lại bước trước")
        self.btnStepBackward.clicked.connect(controller.debugStepBackward)
        self.wHLayout.addWidget(self.btnStepBackward)

        self.iconPlay = QIcon("./assets/icons/play.svg")
        self.iconPause = QIcon("./assets/icons/pause.svg")

        self.btnToggleRun = QToolButton(self.wHLayoutWidget)
        self.btnToggleRun.setIcon(self.iconPlay)
        self.btnToggleRun.setToolTip("Bắt đầu/Dừng quá trình tìm kiếm")
        self.btnToggleRun.clicked.connect(self.toggleRun)
        self.wHLayout.addWidget(self.btnToggleRun)

        self.btnStepForward = QToolButton(self.wHLayoutWidget)
        self.btnStepForward.setIcon(QIcon("./assets/icons/step-forward.svg"))
        self.btnStepForward.setToolTip("Bước tới một bước")
        self.btnStepForward.clicked.connect(controller.debugStepForward)
        self.wHLayout.addWidget(self.btnStepForward)

        self.btnStop = QToolButton(self.wHLayoutWidget)
        self.btnStop.setIcon(QIcon("./assets/icons/times.svg"))
        self.btnStop.setToolTip("Dừng chương trình")
        self.btnStop.clicked.connect(QCoreApplication.instance().quit)
        self.wHLayout.addWidget(self.btnStop)

        self.controlSeperator = QFrame(self)
        self.controlSeperator.setGeometry(0, 45, 240, 5)
        self.controlSeperator.setFrameShape(QFrame.HLine)
        self.controlSeperator.setFrameShadow(QFrame.Sunken)

        self.wFormLayoutWidget = QWidget(self)
        self.wFormLayoutWidget.setGeometry(0, 50, 240, 165)
        self.wFormLayout = QFormLayout(self.wFormLayoutWidget)
        self.wFormLayout.setContentsMargins(5, 5, 5, 5)

        self.labelAlg = QLabel(self.wFormLayoutWidget)
        self.labelAlg.setText("Chọn thuật toán")
        self.wFormLayout.setWidget(0, QFormLayout.LabelRole, self.labelAlg)

        self.algorithmChoice = QComboBox(self.wFormLayoutWidget)

        for algo in controller.algorithms:
            self.algorithmChoice.addItem(algo['name'])

        self.algorithmChoice.currentIndexChanged.connect(self.changeAlgo)

        self.wFormLayout.setWidget(0, QFormLayout.FieldRole,
                                   self.algorithmChoice)

        self.labelWidth, self.inpWidth = self._createLineInput(
            1, "Số ô ngang", QIntValidator(1, 9999999), self.wFormLayout,
            self.wFormLayoutWidget)

        self.labelHeight, self.inpHeight = self._createLineInput(
            2, "Số ô dọc", QIntValidator(1, 9999999), self.wFormLayout,
            self.wFormLayoutWidget)

        self.labelDelayTime, self.delayTime = self._createLineInput(
            3, "Thời gian đợi", QIntValidator(20, 9999999), self.wFormLayout,
            self.wFormLayoutWidget)

        self.labelInput = QLabel(self.wFormLayoutWidget)
        self.labelInput.setText("Input")
        self.wFormLayout.setWidget(4, QFormLayout.LabelRole, self.labelInput)

        self.chooseInputFile = QPushButton(self.wFormLayoutWidget)
        self.chooseInputFile.setText("Chọn File")
        self.chooseInputFile.clicked.connect(self.pick_input)
        self.wFormLayout.setWidget(4, QFormLayout.FieldRole,
                                   self.chooseInputFile)

        self.btnApply = QPushButton(self)
        self.btnApply.setText("Áp dụng")
        self.btnApply.setGeometry(5, 220, 230, 25)
        self.btnApply.clicked.connect(self.applySettings)

        self.infoSeperator = QFrame(self)
        self.infoSeperator.setGeometry(0, 250, 240, 5)
        self.infoSeperator.setFrameShape(QFrame.HLine)
        self.infoSeperator.setFrameShadow(QFrame.Sunken)

        self.wInfoLayoutWidget = QWidget(self)
        self.wInfoLayoutWidget.setGeometry(0, 260, 240, 300)
        self.wInfoLayout = QFormLayout(self.wInfoLayoutWidget)
        self.wInfoLayout.setContentsMargins(5, 5, 5, 5)

        self.labelCost, self.valCost = self._createInfo(
            0, "Cost", "_", self.wInfoLayout, self.wInfoLayoutWidget)

        self.labelTimeCost, self.valTimeCost = self._createInfo(
            1, "Duration", "_", self.wInfoLayout, self.wInfoLayoutWidget)

        # self.btnToggle3D = QPushButton(self)
        # self.btnToggle3D.setText("Đổi sang chế độ 3D")
        # self.btnToggle3D.setGeometry(5, 510, 230, 25)
        # self.btnToggle3D.clicked.connect(self.toggle_3D)

        self.updateValuesFromState()
示例#6
0
    def initUI(self):
        self.setWindowTitle(self.title)
        self.setWindowIcon(QtGui.QIcon("raja.jpg"))
        self.setGeometry(self.left, self.top, self.width, self.height)

        # ------------------------------------main window----------------------------------------------------
        self.single_bubble = QFrame(self)
        self.single_bubble.setObjectName("single_bubble")
        self.single_bubble.setStyleSheet(design.stylesheet)
        self.single_bubble.move(50, 100)
        self.single_bubble.mousePressEvent = self.single_bubble_clicked

        self.single_bubble_heading = QLabel(self.single_bubble)
        self.single_bubble_heading.setObjectName("label")
        self.single_bubble_heading.setText("Compress Image")
        self.single_bubble_heading.move(90, 8)

        self.single_bubble_para = QLabel(self.single_bubble)
        self.single_bubble_para.setObjectName("label_para")
        self.single_bubble_para.setStyleSheet(design.stylesheet)
        self.single_bubble_para.setText("Click here to compress single image!")
        self.single_bubble_para.move(25, 32)

        self.dir_bubble = QFrame(self)
        self.dir_bubble.setObjectName("single_bubble")
        self.dir_bubble.setStyleSheet(design.stylesheet)
        self.dir_bubble.move(50, 275)
        self.dir_bubble.mousePressEvent = self.dir_bubble_clicked

        self.dir_bubble_heading = QLabel(self.dir_bubble)
        self.dir_bubble_heading.setObjectName("label")
        self.dir_bubble_heading.setStyleSheet(design.stylesheet)

        self.dir_bubble_heading.setText("Compress Multiple Images")
        self.dir_bubble_heading.move(55, 8)

        self.dir_bubble_para = QLabel(self.dir_bubble)
        self.dir_bubble_para.setText(
            "Want to compress multiple images at once? select the folder and get compressed version of the images in another folder."
        )
        self.dir_bubble_para.setWordWrap(True)
        self.dir_bubble_para.setObjectName("label_para")
        self.dir_bubble_para.setStyleSheet(design.stylesheet)
        self.dir_bubble_para.move(10, 32)

        # -------------------------single  bubble expanded ----------------------

        self.single_bubble_expanded = QFrame(self)
        self.single_bubble_expanded.setObjectName("bubble")
        self.single_bubble_expanded.setStyleSheet(design.stylesheet)
        self.single_bubble_expanded.move(50, 100)
        self.single_bubble_expanded.setVisible(False)

        self.back_arrow_s = QLabel(self.single_bubble_expanded)
        self.back_arrow_s.move(25, 0)
        self.back_arrow_s.setObjectName("back")
        self.back_arrow_s.setStyleSheet(design.stylesheet)
        self.back_arrow_s.setTextFormat(Qt.RichText)
        self.back_arrow_s.setText("&#8592;")
        self.back_arrow_s.mousePressEvent = self.back_arrow_clicked

        self.single_bubble_heading = QLabel(self.single_bubble_expanded)
        self.single_bubble_heading.setObjectName("label")
        self.single_bubble_heading.setStyleSheet(design.stylesheet)
        self.single_bubble_heading.setText("Compress Image")
        self.single_bubble_heading.move(90, 8)

        self.select_image_label = QLabel(self.single_bubble_expanded)
        self.select_image_label.setObjectName("label_para")
        self.select_image_label.setStyleSheet(design.stylesheet)
        self.select_image_label.setText("Choose Image")
        self.select_image_label.move(30, 50)

        self.image_path = QLineEdit(self.single_bubble_expanded)
        self.image_path.setObjectName("path")
        self.image_path.setStyleSheet(design.stylesheet)
        self.image_path.move(60, 85)

        self.browse_button = QPushButton(self.single_bubble_expanded)
        self.browse_button.setText("...")
        self.browse_button.setObjectName("button")
        self.browse_button.setStyleSheet(design.stylesheet)
        self.browse_button.clicked.connect(self.select_file)
        self.browse_button.move(240, 85)

        self.select_image_quality = QLabel(self.single_bubble_expanded)
        self.select_image_quality.setObjectName("label_para")
        self.select_image_quality.setStyleSheet(design.stylesheet)
        self.select_image_quality.setText("Choose Quality")
        self.select_image_quality.move(30, 130)

        self.quality_path = QLineEdit(self.single_bubble_expanded)
        self.quality_path.setObjectName("path_quality")
        self.quality_path.setStyleSheet(design.stylesheet)
        self.quality_path.move(60, 160)

        self.quality_combo = QComboBox(self.single_bubble_expanded)
        self.quality_combo.addItem("High")
        self.quality_combo.addItem("Medium")
        self.quality_combo.addItem("Low")
        self.quality_combo.move(170, 160)
        self.quality_combo.currentIndexChanged.connect(
            self.quality_current_value)
        self.quality_combo.setObjectName("quality_combo")
        self.quality_combo.setStyleSheet(design.stylesheet)
        self.quality_combo.resize(96, 26)

        self.compress_image = QPushButton(self.single_bubble_expanded)
        self.compress_image.setText("Compress")
        self.compress_image.setObjectName("button1")
        self.compress_image.setStyleSheet(design.stylesheet)
        self.compress_image.clicked.connect(self.resize_pic)
        self.compress_image.move(100, 260)

        # ------------------------end single bubble expanded -------------------------

        # ------------------------directory bubble expanded-------------------------------

        self.dir_bubble_expanded = QFrame(self)
        self.dir_bubble_expanded.setObjectName("bubble")
        self.dir_bubble_expanded.setStyleSheet(design.stylesheet)
        self.dir_bubble_expanded.move(50, 100)
        self.dir_bubble_expanded.setVisible(False)

        self.back_arrow_d = QLabel(self.dir_bubble_expanded)
        self.back_arrow_d.move(25, 0)
        self.back_arrow_d.setObjectName("back")
        self.back_arrow_d.setStyleSheet(design.stylesheet)
        self.back_arrow_d.setTextFormat(Qt.RichText)
        self.back_arrow_d.setText("&#8592;")
        self.back_arrow_d.mousePressEvent = self.back_arrow_clicked

        self.dir_bubble_heading = QLabel(self.dir_bubble_expanded)
        self.dir_bubble_heading.setObjectName("label")
        self.dir_bubble_heading.setStyleSheet(design.stylesheet)
        self.dir_bubble_heading.setText("Compress Multiple Images")
        self.dir_bubble_heading.move(70, 8)

        self.select_source_label = QLabel(self.dir_bubble_expanded)
        self.select_source_label.setObjectName("label_para")
        self.select_source_label.setStyleSheet(design.stylesheet)
        self.select_source_label.setText("Choose source directory")
        self.select_source_label.move(30, 50)

        self.source_path = QLineEdit(self.dir_bubble_expanded)
        self.source_path.setObjectName("path")
        self.source_path.setStyleSheet(design.stylesheet)
        self.source_path.move(60, 85)

        self.browse_source_button = QPushButton(self.dir_bubble_expanded)
        self.browse_source_button.setText("...")
        self.browse_source_button.setObjectName("button")
        self.browse_source_button.setStyleSheet(design.stylesheet)
        self.browse_source_button.clicked.connect(self.select_folder_source)
        self.browse_source_button.move(240, 85)

        self.select_dest_label = QLabel(self.dir_bubble_expanded)
        self.select_dest_label.setObjectName("label_para")
        self.select_dest_label.setStyleSheet(design.stylesheet)
        self.select_dest_label.setText("Choose destination directory")
        self.select_dest_label.move(30, 130)

        self.dest_path = QLineEdit(self.dir_bubble_expanded)
        self.dest_path.setObjectName("path")
        self.dest_path.setStyleSheet(design.stylesheet)
        self.dest_path.move(60, 160)

        self.browse_dest_button = QPushButton(self.dir_bubble_expanded)
        self.browse_dest_button.setText("...")
        self.browse_dest_button.setObjectName("button")
        self.browse_dest_button.setStyleSheet(design.stylesheet)
        self.browse_dest_button.clicked.connect(self.select_folder_dest)
        self.browse_dest_button.move(240, 160)

        self.select_dir_quality = QLabel(self.dir_bubble_expanded)
        self.select_dir_quality.setObjectName("label_para")
        self.select_dir_quality.setStyleSheet(design.stylesheet)
        self.select_dir_quality.setText("Choose Quality")
        self.select_dir_quality.move(30, 205)

        self.quality_dir_path = QLineEdit(self.dir_bubble_expanded)
        self.quality_dir_path.setObjectName("path_quality")
        self.quality_dir_path.setStyleSheet(design.stylesheet)
        self.quality_dir_path.move(60, 235)

        self.quality_dir_combo = QComboBox(self.dir_bubble_expanded)
        self.quality_dir_combo.addItem("High")
        self.quality_dir_combo.addItem("Medium")
        self.quality_dir_combo.addItem("Low")
        self.quality_dir_combo.move(170, 235)
        self.quality_dir_combo.currentIndexChanged.connect(
            self.quality_current_value)
        self.quality_dir_combo.setObjectName("quality_combo")
        self.quality_dir_combo.setStyleSheet(design.stylesheet)
        self.quality_dir_combo.resize(96, 26)

        self.compress_dir = QPushButton(self.dir_bubble_expanded)
        self.compress_dir.setText("Compress")
        self.compress_dir.clicked.connect(self.resize_folder)
        self.compress_dir.setObjectName("button1")
        self.compress_dir.setStyleSheet(design.stylesheet)
        self.compress_dir.move(100, 290)

        # -----------------------directory bubble expanded------------------------------

        # -------------------------------------end main window-------------------------------------------------

        self.show()
 def initParameterFittingFrame(self):
     # --- widgets --- #
     self.peakcount_lab = QLabel('#')
     self.modeselect = QComboBox()
     self.modeselect.addItem('all')
     self.modeselect.addItem('peak by peak')
     self.choosedirectory = QPushButton('&New file')
     self.savefile_name = QLabel('Select a file')
     self.savefile_name.setWordWrap(True)
     self.savefile = QFileDialog()
     self.button_addData = QPushButton('Add data')
     self.button_addData.setStyleSheet("background-color: green")
     self.button_makefit = QPushButton('Make fit')
     self.frqcyfitting = QSpinBox()
     self.frqcyfitting.setRange(1, 12)
     self.frqcyfitting.setValue(10)
     self.fitting_xdataNbre = QSpinBox()
     self.fitting_xdataNbre.setRange(100, 5e3)
     self.fitting_xdataNbre.setValue(10**3)
     self.fitting_param_dspl = QTableWidget()
     self.fitting_param_dspl.setRowCount(5)
     self.saving_state = QLabel('###')
     self.saving_state.setWordWrap(True)
     self.save_count = QSpinBox()
     self.save_count.setRange(0, 1e4)
     self.save_count.setValue(0)
     self.button_test = QPushButton('TEST')
     # ---  --- #
     self.fittingtimer.setInterval(self.frqcyfitting.value())
     # --- connections --- #
     self.modeselect.currentIndexChanged.connect(self.setFittingMethod)
     self.choosedirectory.clicked.connect(self.setNewSaveFile)
     self.button_addData.clicked.connect(self.addDataToFile)
     self.frqcyfitting.valueChanged.connect(self.setFittingRate)
     self.fittingtimer.timeout.connect(self.updatePlots)
     self.fitting_xdataNbre.valueChanged.connect(self.setXdataPoints)
     self.button_makefit.clicked.connect(self.singleShotFittingPlot)
     self.nbrpeak.valueChanged.connect(self.initPeakByPeakFitting)
     # --- make layout --- #
     self.paramfittingframe = QFrame()
     self.param_grid = QGridLayout()
     self.param_grid.addWidget(QLabel('Activate fitting '), 0, 0)
     self.param_grid.addWidget(self.fittingactivate, 0, 1)
     self.param_grid.addWidget(QLabel('Fitting rate:'), 0, 2)
     self.param_grid.addWidget(self.frqcyfitting, 0, 3)
     self.param_grid.addWidget(QLabel('Fitting Sampling number'), 0, 4)
     self.param_grid.addWidget(self.fitting_xdataNbre, 0, 5)
     self.param_grid.addWidget(QLabel('Peak nbr:'), 1, 0)
     self.param_grid.addWidget(self.peakcount_lab, 1, 1)
     self.param_grid.addWidget(QLabel('Fitting method:'), 1, 2)
     self.param_grid.addWidget(self.modeselect, 1, 3)
     self.param_grid.addWidget(self.button_makefit, 1, 4, 1, 2)
     self.param_grid.addWidget(self.fitting_param_dspl, 2, 0, 4, 6)
     self.param_grid.setRowMinimumHeight(2, 35)
     self.param_grid.setRowMinimumHeight(3, 35)
     self.param_grid.setRowMinimumHeight(4, 35)
     self.param_grid.setRowMinimumHeight(5, 35)
     self.updateParamLayout()
     self.param_grid.addWidget(self.choosedirectory, 6, 0)
     self.param_grid.addWidget(self.savefile_name, 6, 1, 1, 6)
     self.param_grid.addWidget(self.button_addData, 7, 0, 1, 4)
     self.param_grid.addWidget(self.saving_state, 7, 4)
     self.param_grid.addWidget(self.save_count, 7, 5)
     for i in range(self.param_grid.rowCount() + 1):
         self.param_grid.setRowStretch(i, 1)
     # ---  --- #
     self.paramfittingframe.setLayout(self.param_grid)
示例#8
0
 def __init__(self):
     super(AsmTabView, self).__init__()
     self.empty_tab = QFrame()
     self.empty_tab_index = -1
     self.setStyleSheet("QTabWidget::pane { border: 1px solid red;}")
     self.zoomlevel = 0
示例#9
0
    def initUI(self):
        serverNames = ['GigaNet', 'UpCloud', 'Vultr', 'NetNut']
        actionNames = ['Create', 'Info', 'Destroy', 'Save and Quit']

        # Input Horizontal
        hbox = QVBoxLayout(self)
        splitter = QSplitter(self)
        splitter.setOrientation(Qt.Vertical)

        # Top Horizontal
        top = QFrame(splitter)
        top.setFrameShape(QFrame.StyledPanel)
        # Bottom Horizontal
        bottom = QFrame(splitter)
        bottom.setFrameShape(QFrame.StyledPanel)

        # Inputs
        # Server, NumberProxies, Location, Action
        inputBox = QHBoxLayout(top)
        serverSplitter = QSplitter(top)
        serverSplitter.setOrientation(Qt.Horizontal)
        numberSplitter = QSplitter(top)
        numberSplitter.setOrientation(Qt.Horizontal)
        locationSplitter = QSplitter(top)
        locationSplitter.setOrientation(Qt.Horizontal)
        actionSplitter = QSplitter(top)
        actionSplitter.setOrientation(Qt.Horizontal)

        # Server, NumberProxies, Location, Action Verticals
        serverBox = QFrame(serverSplitter)
        serverBox.setFrameShape(QFrame.StyledPanel)
        numberBox = QFrame(numberSplitter)
        numberBox.setFrameShape(QFrame.StyledPanel)
        locationBox = QFrame(locationSplitter)
        locationBox.setFrameShape(QFrame.StyledPanel)
        actionBox = QFrame(actionSplitter)
        actionBox.setFrameShape(QFrame.StyledPanel)

        ### Server
        self.serverLayout = QVBoxLayout(serverBox)
        self.serverButtons = [QPushButton(x) for x in serverNames]
        [x.setCheckable(True) for x in self.serverButtons]
        self.serverButtonsGroup = QButtonGroup()
        [self.serverButtonsGroup.addButton(x) for x in self.serverButtons]
        self.serverButtonsGroup.setExclusive(True)

        self.serverButtons[0].clicked.connect(self.giganet)
        self.serverButtons[1].clicked.connect(self.upcloud)
        self.serverButtons[2].clicked.connect(self.vultr)
        self.serverButtons[3].clicked.connect(self.netnut)

        # Number and Location Box
        generalInfoLayout = QVBoxLayout(numberBox)
        self.numberDisplay = QPlainTextEdit()
        self.numberDisplay.setPlaceholderText("Number of proxies.")
        self.locationDisplay = QPlainTextEdit()
        self.locationDisplay.setPlaceholderText("Location of proxies.")

        # Server specific requirements
        specificInfoLayout = QVBoxLayout(locationBox)
        self.gigaInfo = ['APIKEY', 'APIHASH']
        self.gigaInfo[0] = QPlainTextEdit()
        self.gigaInfo[0].setPlaceholderText("GigaNet API KEY.")
        self.gigaInfo[0].setVisible(False)
        self.gigaInfo[1] = QPlainTextEdit()
        self.gigaInfo[1].setPlaceholderText("GigaNet API HASH.")
        self.gigaInfo[1].setVisible(False)

        self.ucInfo = ['ucUSR', 'ucPSWD']
        self.ucInfo[0] = QPlainTextEdit()
        self.ucInfo[0].setPlaceholderText("UpCloud Username.")
        self.ucInfo[0].setVisible(False)
        self.ucInfo[1] = QPlainTextEdit()
        self.ucInfo[1].setPlaceholderText("UpCloud Password.")
        self.ucInfo[1].setVisible(False)

        self.vInfo = ['vtoken']
        self.vInfo[0] = QPlainTextEdit()
        self.vInfo[0].setPlaceholderText("Vultr.")
        self.vInfo[0].setVisible(False)

        self.nnInfo = ['nnUSR', 'nnPSWD']
        self.nnInfo[0] = QPlainTextEdit()
        self.nnInfo[0].setPlaceholderText("NetNut Username.")
        self.nnInfo[0].setVisible(False)
        self.nnInfo[1] = QPlainTextEdit()
        self.nnInfo[1].setPlaceholderText("NetNut Password.")
        self.nnInfo[1].setVisible(False)

        # Action Box
        self.actionLayout = QVBoxLayout(actionBox)
        self.actionButtons = [QPushButton(x) for x in actionNames]
        [x.setCheckable(True) for x in self.actionButtons]
        self.actionButtonsGroup = QButtonGroup()
        [self.actionButtonsGroup.addButton(x) for x in self.actionButtons]
        self.actionButtonsGroup.setExclusive(True)

        self.actionButtons[0].clicked.connect(self.create)
        self.actionButtons[1].clicked.connect(self.info)
        self.actionButtons[2].clicked.connect(self.destroy)
        self.actionButtons[3].clicked.connect(self.quit)

        # Output
        # Log, Verticals
        outputBox = QHBoxLayout(bottom)
        logSplitter = QSplitter(bottom)
        logSplitter.setOrientation(Qt.Horizontal)
        proxySplitter = QSplitter(bottom)
        proxySplitter.setOrientation(Qt.Horizontal)

        # Log, Proxy Verticals
        logBox = QFrame(logSplitter)
        logBox.setFrameShape(QFrame.StyledPanel)
        proxyBox = QFrame(proxySplitter)
        proxyBox.setFrameShape(QFrame.StyledPanel)

        # Log
        logLayout = QVBoxLayout(logBox)
        self.logDisplay = QPlainTextEdit()
        self.logDisplay.setReadOnly(True)
        self.logDisplay.setPlainText("Log will display here.")

        # Proxy
        proxyLayout = QVBoxLayout(proxyBox)
        self.proxyDisplay = QPlainTextEdit()
        self.proxyDisplay.setPlainText("Proxies:")
        self.proxyDisplay.setReadOnly(True)

        # Add widgets into layout
        [self.serverLayout.addWidget(x) for x in self.serverButtons]
        [self.actionLayout.addWidget(x) for x in self.actionButtons]

        generalInfoLayout.addWidget(self.numberDisplay)
        generalInfoLayout.addWidget(self.locationDisplay)

        [
            specificInfoLayout.addWidget(self.gigaInfo[i])
            for i in range(len(self.gigaInfo))
        ]
        [
            specificInfoLayout.addWidget(self.ucInfo[i])
            for i in range(len(self.ucInfo))
        ]
        [
            specificInfoLayout.addWidget(self.vInfo[i])
            for i in range(len(self.vInfo))
        ]
        [
            specificInfoLayout.addWidget(self.nnInfo[i])
            for i in range(len(self.nnInfo))
        ]

        logLayout.addWidget(self.logDisplay)
        proxyLayout.addWidget(self.proxyDisplay)

        inputBox.addWidget(serverSplitter)
        inputBox.addWidget(numberSplitter)
        inputBox.addWidget(locationSplitter)
        inputBox.addWidget(actionSplitter)
        outputBox.addWidget(logSplitter)
        outputBox.addWidget(proxySplitter)
        hbox.addWidget(splitter)

        # Restore Information from data/info.txt if exists
        if os.path.isfile("data/info.txt"):
            print("Info.txt found.")
            with open("data/info.txt") as fh:
                data = json.load(fh)
                for dataHandler in data['giganet']:
                    self.gigaInfo[0].setPlainText(dataHandler['apikey'])
                    self.gigaInfo[1].setPlainText(dataHandler['apihash'])
                for dataHandler in data['upcloud']:
                    self.ucInfo[0].setPlainText(dataHandler['ucuser'])
                    self.ucInfo[1].setPlainText(dataHandler['ucpass'])
                for dataHandler in data['vultr']:
                    self.vInfo[0].setPlainText(dataHandler['vtoken'])
                for dataHandler in data['netnut']:
                    self.nnInfo[0].setPlainText(dataHandler['nnuser'])
                    self.nnInfo[1].setPlainText(dataHandler['nnpass'])
示例#10
0
    def __init__(self, parent, title, reportSerializer, reportItem):
        super(EditReportWidget, self).__init__(parent)

        self.m_reportSerializer = reportSerializer
        self.m_reportItem = reportItem

        self.setWindowTitle(title)

        self.resize(859, 704)
        self.m_mainLayout = QVBoxLayout(self)
        self.m_scriptEdit = QPlainTextEdit(self)
        self.m_mainLayout.addWidget(self.m_scriptEdit)
        self.m_line1 = QFrame(self)
        self.m_line1.setFrameShape(QFrame.HLine)
        self.m_line1.setFrameShadow(QFrame.Sunken)
        self.m_mainLayout.addWidget(self.m_line1)
        self.m_attriburesWidget = QWidget(self)
        sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.m_attriburesWidget.sizePolicy().hasHeightForWidth())
        self.m_attriburesWidget.setSizePolicy(sizePolicy)
        self.m_attriburesWidget.setMinimumSize(QSize(0, 100))
        self.verticalLayout = QVBoxLayout(self.m_attriburesWidget)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.m_attributesLayout = QGridLayout()
        self.m_attributesLayout.setSizeConstraint(QLayout.SetDefaultConstraint)
        self.m_descrPTEdit = QPlainTextEdit(self.m_attriburesWidget)
        self.m_descrPTEdit.setMaximumSize(QSize(16777215, 90))
        self.m_attributesLayout.addWidget(self.m_descrPTEdit, 1, 1, 1, 1)
        self.m_descriptionLabel = QLabel(self.m_attriburesWidget)
        self.m_descriptionLabel.setAlignment(Qt.AlignLeading | Qt.AlignLeft
                                             | Qt.AlignTop)
        self.m_attributesLayout.addWidget(self.m_descriptionLabel, 1, 0, 1, 1)
        self.m_typeLabel = QLabel(self.m_attriburesWidget)
        self.m_attributesLayout.addWidget(self.m_typeLabel, 2, 0, 1, 1)
        self.m_nameLabel = QLabel(self.m_attriburesWidget)
        self.m_attributesLayout.addWidget(self.m_nameLabel, 0, 0, 1, 1)
        self.m_nameEdit = QLineEdit(self.m_attriburesWidget)
        self.m_attributesLayout.addWidget(self.m_nameEdit, 0, 1, 1, 1)
        self.m_typeLayout = QHBoxLayout()
        self.m_typeComboBox = QComboBox(self.m_attriburesWidget)
        self.m_typeComboBox.addItem("")
        self.m_typeComboBox.addItem("")
        self.m_typeLayout.addWidget(self.m_typeComboBox)
        spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                 QSizePolicy.Minimum)
        self.m_typeLayout.addItem(spacerItem)
        self.m_attributesLayout.addLayout(self.m_typeLayout, 2, 1, 1, 1)
        self.verticalLayout.addLayout(self.m_attributesLayout)
        self.m_saveLayout = QHBoxLayout()
        self.m_saveLayout.setSpacing(0)
        self.m_storeInFileCheckBox = QCheckBox(self.m_attriburesWidget)
        self.m_saveLayout.addWidget(self.m_storeInFileCheckBox)
        self.m_browseLayout = QHBoxLayout()
        self.m_browseLayout.setSpacing(0)
        self.m_filePathEdit = QLineEdit(self.m_attriburesWidget)
        self.m_browseLayout.addWidget(self.m_filePathEdit)
        self.m_filePathBrowseBtn = QPushButton(self.m_attriburesWidget)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.m_filePathBrowseBtn.sizePolicy().hasHeightForWidth())
        self.m_filePathBrowseBtn.setSizePolicy(sizePolicy)
        self.m_filePathBrowseBtn.setMaximumSize(QSize(25, 16777215))
        self.m_browseLayout.addWidget(self.m_filePathBrowseBtn)
        self.m_saveLayout.addLayout(self.m_browseLayout)
        self.verticalLayout.addLayout(self.m_saveLayout)
        self.m_mainLayout.addWidget(self.m_attriburesWidget)
        self.m_line2 = QFrame(self)
        self.m_line2.setFrameShape(QFrame.HLine)
        self.m_line2.setFrameShadow(QFrame.Sunken)
        self.m_mainLayout.addWidget(self.m_line2)
        self.m_buttonsLayout = QHBoxLayout()
        spacerItem1 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                  QSizePolicy.Minimum)
        self.m_buttonsLayout.addItem(spacerItem1)
        self.m_saveBtn = QPushButton(self)
        self.m_buttonsLayout.addWidget(self.m_saveBtn)
        self.m_saveAndCloseBtn = QPushButton(self)
        self.m_buttonsLayout.addWidget(self.m_saveAndCloseBtn)
        self.m_cancelBtn = QPushButton(self)
        self.m_buttonsLayout.addWidget(self.m_cancelBtn)
        self.m_mainLayout.addLayout(self.m_buttonsLayout)

        self.m_descriptionLabel.setText("Description:")
        self.m_typeLabel.setText("Type:")
        self.m_nameLabel.setText("Name:")
        self.m_typeComboBox.setItemText(0, "SQL")
        self.m_typeComboBox.setItemText(1, "Python")
        self.m_storeInFileCheckBox.setText("Store In File")
        self.m_filePathBrowseBtn.setText("...")
        self.m_saveBtn.setText("Save")
        self.m_saveAndCloseBtn.setText("Save And Close")
        self.m_cancelBtn.setText("Cancel")

        self.m_filePathBrowseBtn.pressed.connect(self.browse)
        self.m_storeInFileCheckBox.toggled.connect(self.storeCheckboxToggled)

        self.storeCheckboxToggled()

        self.m_saveBtn.pressed.connect(self.save)
        self.m_saveAndCloseBtn.pressed.connect(self.saveAndAccept)
        self.m_cancelBtn.pressed.connect(self.close)

        if self.m_reportItem is not None:
            self.m_nameEdit.setText(self.m_reportItem.name)
            self.m_descrPTEdit.setPlainText(self.m_reportItem.description)
            self.m_typeComboBox.setCurrentText(self.m_reportItem.type)
            self.m_filePathEdit.setText(self.m_reportItem.scriptPath)
            self.m_storeInFileCheckBox.setChecked(
                self.m_reportItem.storeInFile)
            self.m_scriptEdit.setPlainText(
                self.m_reportSerializer.load(self.m_reportItem))
示例#11
0
 def createIndicator(self):
     self.indicator = QFrame()
     self.indicator.setProperty("class", ["baseStationIndicator"])
     return self.indicator
示例#12
0
    def __init__(self, parent, container: Container, handler) -> None:
        super().__init__(parent)
        self.container = container
        self.handler = handler
        self.vertical_layout_2 = QVBoxLayout(self)
        self.vertical_layout_2.setContentsMargins(rt(20), rt(11), rt(20),
                                                  rt(11))
        self.vertical_layout_2.setSpacing(rt(6))
        self.widget = QWidget(self)
        self.widget.setSizePolicy(BQSizePolicy(v_stretch=1))
        self.horizontal_layout_2 = QHBoxLayout(self.widget)
        self.horizontal_layout_2.setContentsMargins(0, 0, 0, 0)
        self.horizontal_layout_2.setSpacing(rt(6))

        self._translate = QCoreApplication.translate
        self.pic = AppAvatar(container, parent=self, radius=rt(20))

        self.horizontal_layout_2.addWidget(self.pic)
        self.container_name = QLineEdit(self.widget)

        # Remove the border outline on focus
        self.container_name.setAttribute(Qt.WA_MacShowFocusRect, 0)
        self.container_name.setStyleSheet(
            'border: none; background-color: transparent')
        self.container_name.setFocusPolicy(Qt.StrongFocus)
        self.container_name.setFocus()
        self.horizontal_layout_2.addWidget(self.container_name)
        self.widget_5 = QWidget(self.widget)
        self.widget_5.setSizePolicy(BQSizePolicy(h_stretch=1))
        self.horizontal_layout_2.addWidget(self.widget_5)
        self.vertical_layout_2.addWidget(self.widget)
        self.line_3 = QFrame(self)
        self.line_3.setFrameShape(QFrame.HLine)
        self.line_3.setFrameShadow(QFrame.Sunken)
        self.vertical_layout_2.addWidget(self.line_3)
        self.widget_3 = QWidget(self)
        self.widget_3.setSizePolicy(BQSizePolicy(v_stretch=1))
        self.vertical_layout_4 = QVBoxLayout(self.widget_3)
        self.vertical_layout_4.setContentsMargins(0, 0, 0, 0)
        self.vertical_layout_4.setSpacing(rt(6))
        self.repo_source = QLabel(self.widget_3)
        self.vertical_layout_4.addWidget(self.repo_source)
        self.container_id = QLabel(self.widget_3)
        self.vertical_layout_4.addWidget(self.container_id)
        self.vertical_layout_2.addWidget(self.widget_3)
        self.line = QFrame(self)
        self.line.setFrameShape(QFrame.HLine)
        self.line.setFrameShadow(QFrame.Sunken)
        self.vertical_layout_2.addWidget(self.line)
        self.widget_4 = QWidget(self)
        self.widget_4.setSizePolicy(BQSizePolicy(v_stretch=2))
        self.grid_layout = QGridLayout(self.widget_4)
        self.grid_layout.setContentsMargins(0, 0, 0, rt(5))
        self.grid_layout.setSpacing(rt(6))
        self.sync = QPushButton(self.widget_4)
        self.sync.setFocusPolicy(Qt.NoFocus)
        self.grid_layout.addWidget(self.sync, 2, 4, 1, 1)
        self.widget_8 = QWidget(self.widget_4)
        self.widget_8.setSizePolicy(BQSizePolicy(h_stretch=1))
        self.grid_layout.addWidget(self.widget_8, 2, 5, 1, 1)
        self.img_tag_label = QLabel(self.widget_4)
        self.grid_layout.addWidget(self.img_tag_label, 2, 0, 1, 1)
        self.current_n_memory = QLabel(self.widget_4)
        self.grid_layout.addWidget(self.current_n_memory, 3, 4, 1, 1)
        self.current_n_cpus = QLabel(self.widget_4)
        self.grid_layout.addWidget(self.current_n_cpus, 4, 4, 1, 1)
        self.widget_7 = QWidget(self.widget_4)
        self.widget_7.setSizePolicy(BQSizePolicy(h_stretch=1))
        self.grid_layout.addWidget(self.widget_7, 3, 3, 1, 1)
        self.limit_cpu_label = QLabel(self.widget_4)
        self.grid_layout.addWidget(self.limit_cpu_label, 4, 0, 1, 1)
        self.entrypoint_label = QLabel(self.widget_4)
        self.grid_layout.addWidget(self.entrypoint_label, 5, 0, 1, 1)
        self.image_tags = QComboBox(self.widget_4)
        self.image_tags.setMinimumWidth(rt(300))
        self.grid_layout.addWidget(self.image_tags, 2, 1, 1, 3)
        self.limit_memory_label = QLabel(self.widget_4)
        self.grid_layout.addWidget(self.limit_memory_label, 3, 0, 1, 1)
        self.limit_memory = QSlider(Qt.Horizontal)
        # self.limit_memory.setSizePolicy(BQSizePolicy(h_stretch=3))
        self.grid_layout.addWidget(self.limit_memory, 3, 1, 1, 3)
        self.limit_cpu = QSlider(Qt.Horizontal)
        self.grid_layout.addWidget(self.limit_cpu, 4, 1, 1, 3)
        self.entrypoint = QLineEdit(self.widget_4)
        self.entrypoint.setAttribute(Qt.WA_MacShowFocusRect, 0)
        self.entrypoint.setFocusPolicy(Qt.ClickFocus)
        self.grid_layout.addWidget(self.entrypoint, 5, 1, 1, 5)
        self.vertical_layout_2.addWidget(self.widget_4)
        self.line_2 = QFrame(self)
        self.line_2.setFrameShape(QFrame.HLine)
        self.line_2.setFrameShadow(QFrame.Sunken)
        self.vertical_layout_2.addWidget(self.line_2)
        self.widget_2 = QWidget(self)
        self.widget_2.setSizePolicy(BQSizePolicy(v_stretch=1))
        self.vertical_layout_3 = QVBoxLayout(self.widget_2)
        self.vertical_layout_3.setContentsMargins(0, 0, 0, 0)
        self.vertical_layout_3.setSpacing(rt(6))
        self.start_with_boatswain = QCheckBox(self.widget_2)
        self.vertical_layout_3.addWidget(self.start_with_boatswain)
        self.stop_with_boatswain = QCheckBox(self.widget_2)
        self.vertical_layout_3.addWidget(self.stop_with_boatswain)
        self.vertical_layout_2.addWidget(self.widget_2)

        self.container_id.setTextInteractionFlags(Qt.TextSelectableByMouse)
示例#13
0
    def initUi(self):

        globalFont = (QtGui.QFont("Roboto", 16, QtGui.QFont.Bold))
        titulofont = (QtGui.QFont("Roboto", 20, QtGui.QFont.Bold))
        font_line = (QtGui.QFont("Roboto", 12, QtGui.QFont.Bold))
        fontCondiciones = (QtGui.QFont("Roboto", 11, QtGui.QFont.Bold))

        self.frameizquierda = QFrame(self)
        self.frameizquierda.setStyleSheet(estiloFrame)
        self.frameizquierda.setGeometry(QRect(0, 0, 400, 600))
        self.sombra = QGraphicsDropShadowEffect()
        self.sombra.setBlurRadius(100)
        self.frameizquierda.setGraphicsEffect(self.sombra)

        self.encabezado = QLabel(self)
        self.encabezado.setStyleSheet(estiloTitulo)
        self.encabezado.setGeometry(QRect(460, 50, 200, 100))
        self.encabezado.setText("REGISTRO")
        self.encabezado.setFont(titulofont)
        self.encabezado.setAlignment(QtCore.Qt.AlignRight
                                     | QtCore.Qt.AlignVCenter)

        self.boton1 = QPushButton(self)
        self.boton1.setStyleSheet(estiloR)
        self.boton1.setGeometry(QRect(650, 10, 70, 30))
        self.boton1.setFont(fontCondiciones)
        self.boton1.setText("registro")
        self.sombra3 = QGraphicsDropShadowEffect()
        self.sombra3.setBlurRadius(100)
        self.boton1.setGraphicsEffect(self.sombra3)

        self.boton2 = QPushButton(self)
        self.boton2.setStyleSheet(estiloD)
        self.boton2.setGeometry(QRect(720, 10, 70, 30))
        self.boton2.setFont(fontCondiciones)
        self.boton2.setText("inicio")
        self.sombra4 = QGraphicsDropShadowEffect()
        self.sombra4.setBlurRadius(100)
        self.boton2.setGraphicsEffect(self.sombra4)

        self.nombre = QLabel(self)
        self.nombre.setStyleSheet(estiloNombre)
        self.nombre.setGeometry(QRect(450, 100, 100, 100))
        self.nombre.setText("NOMBRE")
        self.nombre.setFont(globalFont)
        self.nombre.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)

        self.nombre_edit = QLineEdit(self)
        self.nombre_edit.setStyleSheet(estiloLine)
        self.nombre_edit.setFont(font_line)
        self.nombre_edit.setGeometry(QRect(460, 165, 100, 30))
        self.nombre_edit.setPlaceholderText("Nombre")

        self.apellido = QLabel(self)
        self.apellido.setStyleSheet(estiloNombre)
        self.apellido.setGeometry(QRect(625, 100, 100, 100))
        self.apellido.setText("APELLIDO")
        self.apellido.setFont(globalFont)
        self.apellido.setAlignment(QtCore.Qt.AlignRight
                                   | QtCore.Qt.AlignVCenter)

        self.apellido_edit = QLineEdit(self)
        self.apellido_edit.setStyleSheet(estiloLine)
        self.apellido_edit.setFont(font_line)
        self.apellido_edit.setGeometry(QRect(630, 165, 100, 30))
        self.apellido_edit.setPlaceholderText("Apellido")

        self.contrasena = QLabel(self)
        self.contrasena.setStyleSheet(estiloNombre)
        self.contrasena.setFont(globalFont)
        self.contrasena.setGeometry(QRect(450, 200, 150, 100))
        self.contrasena.setText("CONTRASEÑA")
        self.contrasena.setAlignment(QtCore.Qt.AlignRight
                                     | QtCore.Qt.AlignVCenter)

        self.contrasena_edit = QLineEdit(self)
        self.contrasena_edit.setStyleSheet(estiloLine)
        self.contrasena_edit.setFont(font_line)
        self.contrasena_edit.setGeometry(QRect(460, 265, 300, 30))
        self.contrasena_edit.setPlaceholderText("Contraseña")

        self.email = QLabel(self)
        self.email.setStyleSheet(estiloNombre)
        self.email.setFont(globalFont)
        self.email.setGeometry(QRect(465, 300, 100, 100))
        self.email.setText("Email")

        self.email_edit = QLineEdit(self)
        self.email_edit.setStyleSheet(estiloLine)
        self.email_edit.setFont(font_line)
        self.email_edit.setGeometry(QRect(465, 365, 300, 30))
        self.email_edit.setPlaceholderText("*****@*****.**")

        self.chequer = QCheckBox(self)
        self.chequer.setGeometry(QRect(465, 400, 20, 30))
        self.chequer.setStyleSheet(estiloCheck)

        self.condiciones = QLabel(self)
        self.condiciones.setStyleSheet(estilo_condiciones)
        self.condiciones.setFont(fontCondiciones)
        self.condiciones.setText("Aceptar términos y condiciones")
        self.condiciones.setGeometry(QRect(490, 365, 250, 100))

        self.btn_registro = QPushButton(self)
        self.btn_registro.setStyleSheet(estiloBoton)
        self.btn_registro.setGeometry(QRect(460, 450, 300, 50))
        self.btn_registro.setFont(globalFont)
        self.btn_registro.setText("Registrarse")
        self.sombra2 = QGraphicsDropShadowEffect()
        self.sombra2.setBlurRadius(100)
        self.btn_registro.setGraphicsEffect(self.sombra2)

        self.copyrigth = QLabel(self)
        self.copyrigth.setStyleSheet(estilo_condiciones)
        self.copyrigth.setFont(fontCondiciones)
        self.copyrigth.setText("by Cristian Cala ❤️")
        self.copyrigth.setGeometry(QRect(660, 530, 150, 100))
    def createMeals(self):
        self.mealContainer = QFrame(self)
        self.mealContainer.setFixedSize(500, 700)
        vbox = QVBoxLayout()
        self.mealGroup = QGroupBox("اختار وجبتك", self)
        self.mealGroup.setFont(QFont("urdu Typesetting", 36, 900))
        mealGrid = QGridLayout()
        self.lblMeal = QLabel("الوجبة", self)
        self.lblPrice = QLabel("السعر(ج.م)", self)
        self.lblQuantity = QLabel("الكمية", self)
        mealHeaders = [self.lblMeal, self.lblPrice, self.lblQuantity]
        for h, head in enumerate(mealHeaders):
            head.setFont(QFont("urdu Typesetting", 18, 900))
            head.setFixedSize(80, 40)
            head.setAlignment(Qt.AlignCenter)
            head.setStyleSheet(
                "background-color: grey; color: black; border: 1px solid black; border-radius:10px"
            )
            mealGrid.addWidget(head, 0, h, 1, 1)

        self.chkShrimp = QCheckBox("الجمبري مع أرز", self)
        self.chkShrimp.toggled.connect(lambda: self.selectedItem(
            self.chkShrimp, self.shrimpPrice, self.QShrimp))
        self.chkFish = QCheckBox("السمك مع أرز", self)
        self.chkFish.toggled.connect(lambda: self.selectedItem(
            self.chkFish, self.fishPrice, self.QFish))
        self.chkBeef = QCheckBox("طاجن اللحم مع أرز", self)
        self.chkBeef.toggled.connect(lambda: self.selectedItem(
            self.chkBeef, self.beefPrice, self.QBeef))
        self.chkChicken = QCheckBox("الفراخ مع أرز", self)
        self.chkChicken.toggled.connect(lambda: self.selectedItem(
            self.chkChicken, self.chickenPrice, self.QChicken))
        self.chkBeefShawarma = QCheckBox("شاروما لحم مع الأرز", self)
        self.chkBeefShawarma.toggled.connect(lambda: self.selectedItem(
            self.chkBeefShawarma, self.beefShawarmaPrice, self.QBeefShawarma))
        self.chkChickenShawarma = QCheckBox("شاورما فراخ مع الأرز", self)
        self.chkChickenShawarma.toggled.connect(lambda: self.selectedItem(
            self.chkChickenShawarma, self.chickenShawarmaPrice, self.
            QChickenShawarma))
        self.chkMeatRiceNuts = QCheckBox("لحم مع أرز بالمكسرات", self)
        self.chkMeatRiceNuts.toggled.connect(lambda: self.selectedItem(
            self.chkMeatRiceNuts, self.meatRicePrice, self.QMeatRiceNuts))
        self.chkMeatKofta = QCheckBox("كفتة لحم مع الأرز", self)
        self.chkMeatKofta.toggled.connect(lambda: self.selectedItem(
            self.chkMeatKofta, self.meatKoftaPrice, self.QMeatKofta))
        self.chkVegetables = QCheckBox("خضراوات مع الأرز", self)
        self.chkVegetables.toggled.connect(lambda: self.selectedItem(
            self.chkVegetables, self.vegetablesPrice, self.QVegetables))
        chkMeals = [
            self.chkShrimp, self.chkFish, self.chkBeef, self.chkChicken,
            self.chkBeefShawarma, self.chkChickenShawarma,
            self.chkMeatRiceNuts, self.chkMeatKofta, self.chkVegetables
        ]
        chkFont = QFont("Traditinal Arabic", 20, 900)
        # chkFont.setBold(True)
        # chkColor = QColor(30, 30, 200)
        chkStyle = "padding: 3px"
        for m, meal in enumerate(chkMeals):
            meal.setFont(chkFont)
            meal.setStyleSheet(chkStyle)
            mealGrid.addWidget(meal, m + 1, 0, 1, 1)

        self.shrimpPrice = QLabel("45.00", self)
        self.fishPrice = QLabel("45.00", self)
        self.beefPrice = QLabel("45.00", self)
        self.chickenPrice = QLabel("40.50", self)
        self.beefShawarmaPrice = QLabel("40.50", self)
        self.chickenShawarmaPrice = QLabel("40.50", self)
        self.meatRicePrice = QLabel("45.50", self)
        self.meatKoftaPrice = QLabel("45.50", self)
        self.vegetablesPrice = QLabel("35.50", self)

        lblPrices = [
            self.shrimpPrice, self.fishPrice, self.beefPrice,
            self.chickenPrice, self.beefShawarmaPrice,
            self.chickenShawarmaPrice, self.meatRicePrice, self.meatKoftaPrice,
            self.vegetablesPrice
        ]

        for p, price in enumerate(lblPrices):
            price.setFont(chkFont)
            price.setAlignment(Qt.AlignCenter)
            mealGrid.addWidget(price, p + 1, 1, 1, 1)

        self.QShrimp = QLineEdit("0", self)
        self.QFish = QLineEdit("0", self)
        self.QBeef = QLineEdit("0", self)
        self.QChicken = QLineEdit("0", self)
        self.QBeefShawarma = QLineEdit("0", self)
        self.QChickenShawarma = QLineEdit("0", self)
        self.QMeatRiceNuts = QLineEdit("0", self)
        self.QMeatKofta = QLineEdit("0", self)
        self.QVegetables = QLineEdit("0", self)
        quantities = [
            self.QShrimp, self.QFish, self.QBeef, self.QChicken,
            self.QBeefShawarma, self.QChickenShawarma, self.QMeatRiceNuts,
            self.QMeatKofta, self.QVegetables
        ]
        for q, quantity in enumerate(quantities):
            quantity.setFixedSize(80, 40)
            quantity.setAlignment(Qt.AlignCenter)
            quantity.setFont(QFont("urdu Typesetting", 20))
            mealGrid.addWidget(quantity, q + 1, 2, 1, 1)

        self.mealGroup.setLayout(mealGrid)

        vbox.addWidget(self.mealGroup)

        self.ctrlGroup = QGroupBox("إصدار فاتورة", self)
        self.ctrlGroup.setFont(QFont("urdu Typesetting", 14))
        ctrlFont = QFont("urdu Typesetting", 18, 900)
        ctrlSize = QSize(110, 60)
        ctrlbgColor = QColor(20, 70, 150)
        ctrlfgColor = QColor(200, 200, 200)
        ctrlStyle = "background-color: {}; color: {}; border: 3px solid {}; border-radius: 10px".format(
            ctrlbgColor.name(), ctrlfgColor.name(), ctrlfgColor.name())
        ctrlGrid = QGridLayout()
        self.getTotals = QPushButton("حساب الإجمالي", self)
        self.getTotals.clicked.connect(self.getTotalAction)
        self.getInvoice = QPushButton("طباعة الفاتورة", self)
        self.getInvoice.clicked.connect(self.getInvoiceAction)
        self.clearData = QPushButton("فاتورة جديدة", self)
        self.clearData.clicked.connect(self.newTransaction)
        self.exitProgram = QPushButton("خروج", self)
        self.exitProgram.clicked.connect(self.exit_pro)
        controls = [
            self.getTotals, self.getInvoice, self.clearData, self.exitProgram
        ]
        for c, ctrl in enumerate(controls):
            ctrl.setFont(ctrlFont)
            ctrl.setFixedSize(ctrlSize)
            ctrl.setStyleSheet(ctrlStyle)
            ctrlGrid.addWidget(ctrl, 0, c, 1, 1)

        self.ctrlGroup.setLayout(ctrlGrid)
        vbox.addWidget(self.ctrlGroup)
        self.mealContainer.setLayout(vbox)
示例#15
0
    def add_tx_stats(self, vbox):
        hbox_stats = QHBoxLayout()

        # left column
        vbox_left = QVBoxLayout()
        self.tx_desc = TxDetailLabel(word_wrap=True)
        vbox_left.addWidget(self.tx_desc)
        self.status_label = TxDetailLabel()
        vbox_left.addWidget(self.status_label)
        self.date_label = TxDetailLabel()
        vbox_left.addWidget(self.date_label)
        self.amount_label = TxDetailLabel()
        vbox_left.addWidget(self.amount_label)
        self.ln_amount_label = TxDetailLabel()
        vbox_left.addWidget(self.ln_amount_label)

        fee_hbox = QHBoxLayout()
        self.fee_label = TxDetailLabel()
        fee_hbox.addWidget(self.fee_label)
        self.fee_warning_icon = QLabel()
        pixmap = QPixmap(icon_path("warning"))
        pixmap_size = round(2 * char_width_in_lineedit())
        pixmap = pixmap.scaled(pixmap_size, pixmap_size, Qt.KeepAspectRatio,
                               Qt.SmoothTransformation)
        self.fee_warning_icon.setPixmap(pixmap)
        self.fee_warning_icon.setVisible(False)
        fee_hbox.addWidget(self.fee_warning_icon)
        fee_hbox.addStretch(1)
        vbox_left.addLayout(fee_hbox)

        vbox_left.addStretch(1)
        hbox_stats.addLayout(vbox_left, 50)

        # vertical line separator
        line_separator = QFrame()
        line_separator.setFrameShape(QFrame.VLine)
        line_separator.setFrameShadow(QFrame.Sunken)
        line_separator.setLineWidth(1)
        hbox_stats.addWidget(line_separator)

        # right column
        vbox_right = QVBoxLayout()
        self.size_label = TxDetailLabel()
        vbox_right.addWidget(self.size_label)
        self.rbf_label = TxDetailLabel()
        vbox_right.addWidget(self.rbf_label)
        self.rbf_cb = QCheckBox(_('Replace by fee'))
        self.rbf_cb.setChecked(bool(self.config.get('use_rbf', True)))
        vbox_right.addWidget(self.rbf_cb)

        self.locktime_final_label = TxDetailLabel()
        vbox_right.addWidget(self.locktime_final_label)

        locktime_setter_hbox = QHBoxLayout()
        locktime_setter_hbox.setContentsMargins(0, 0, 0, 0)
        locktime_setter_hbox.setSpacing(0)
        locktime_setter_label = TxDetailLabel()
        locktime_setter_label.setText("LockTime: ")
        self.locktime_e = LockTimeEdit(self)
        locktime_setter_hbox.addWidget(locktime_setter_label)
        locktime_setter_hbox.addWidget(self.locktime_e)
        locktime_setter_hbox.addStretch(1)
        self.locktime_setter_widget = QWidget()
        self.locktime_setter_widget.setLayout(locktime_setter_hbox)
        vbox_right.addWidget(self.locktime_setter_widget)

        self.block_height_label = TxDetailLabel()
        vbox_right.addWidget(self.block_height_label)
        vbox_right.addStretch(1)
        hbox_stats.addLayout(vbox_right, 50)

        vbox.addLayout(hbox_stats)

        # below columns
        self.block_hash_label = TxDetailLabel(word_wrap=True)
        vbox.addWidget(self.block_hash_label)

        # set visibility after parenting can be determined by Qt
        self.rbf_label.setVisible(self.finalized)
        self.rbf_cb.setVisible(not self.finalized)
        self.locktime_final_label.setVisible(self.finalized)
        self.locktime_setter_widget.setVisible(not self.finalized)
示例#16
0
    def __init__(self, parent):
        super().__init__(parent)
        self.parent = parent
        self.weekdays = WEEKDAYS
        self.weekday_switches = []
        self.setObjectName('days_config')
        self.setTitle('Working days settings')
        self.setAlignment(Qt.AlignHCenter)
        self.layout = QVBoxLayout(self)

        # Weekdays selector
        week_frame = QFrame(self, Qt.Widget)
        week_layout = QHBoxLayout(week_frame)
        week_layout.setSpacing(2)
        week_layout.setContentsMargins(0, 0, 0, 0)

        # Generating weekdays checkboxes
        for day, state in self.weekdays.items():
            checkbox = QCheckBox()
            checkbox.setText(day)
            checkbox.setChecked(state)
            checkbox.stateChanged.connect(self.update_weekdays)
            week_layout.addWidget(checkbox, 0, Qt.AlignHCenter)
            self.weekday_switches.append(checkbox)

        # Misc options
        misc_frame = QFrame(self, Qt.Widget)
        misc_layout = QFormLayout(misc_frame)
        misc_layout.setSpacing(5)
        misc_layout.setContentsMargins(0, 0, 0, 0)

        # Process daily tasks only control
        self.daily_only = QCheckBox()
        self.daily_only.setChecked(get_main_window().params['daily_only'])
        self.daily_only.setToolTip(
            'If checked only Daily Tasks will be processed and logged\n'
            'Still they won\'t exceed target hours per day')

        # Target hours per day
        self.target_hrs = QDoubleSpinBox()
        self.target_hrs.setSingleStep(0.1)
        self.target_hrs.setDecimals(1)
        self.target_hrs.setRange(0, 24)
        self.target_hrs.setToolTip(
            'Amount of working hours that logger will\nattempt to fill for each day.'
        )
        self.target_hrs.setFixedWidth(50)
        self.target_hrs.setRange(1, 24)
        self.target_hrs.setValue(8)

        # Daily tasks
        tasks_frame = QFrame(self, Qt.Widget)
        tasks_layout = QFormLayout(tasks_frame)
        tasks_layout.setSpacing(5)
        tasks_layout.setContentsMargins(0, 0, 0, 0)
        self.daily_tasks = QLineEdit()
        regex = QRegExp(
            '^[A-Z]+-[0-9]+:[0-9]+[smh]( [A-Z]+-[0-9]+:[0-9]+[smh])*$'
        )  # BR-408:30m BR-7630:2h BR-2345:1h
        validator = QRegExpValidator(regex)
        self.daily_tasks.setValidator(validator)
        self.daily_tasks.textChanged.connect(self.validate_input)
        self.daily_tasks.setText(
            tasks_dict_to_string(get_main_window().params['daily_tasks']))
        self.daily_tasks.setToolTip(
            'List of daily task:time that will be\nexplicitly logged for each day.\n'
            'Example: "BR-222:30m BR-555:1h"')

        # Tasks comment
        self.tasks_comment = QLineEdit()
        self.tasks_comment.setToolTip(
            'Comment that will be added for every daily task')
        self.tasks_comment.setText(get_main_window().params['tasks_comment'])

        # Tasks to be ignored
        self.ignore_tasks = QLineEdit()
        regex = QRegExp(
            '^[A-Z]+-[0-9]+( [A-Z]+-[0-9]+)*$')  # BR-408 BR-234 BR-7758
        validator = QRegExpValidator(regex)
        self.ignore_tasks.setValidator(validator)
        self.ignore_tasks.textChanged.connect(self.validate_input)
        self.ignore_tasks.setText(
            tasks_list_to_string(get_main_window().params['ignore_tasks']))
        self.ignore_tasks.setToolTip(
            'List of tasks to be ignored during processing.\nExample: "BR-555 BR-777"'
        )

        tasks_layout.addRow('Daily tasks', self.daily_tasks)
        tasks_layout.addRow('Comment', self.tasks_comment)
        tasks_layout.addRow('Ignore tasks', self.ignore_tasks)
        misc_layout.addRow('Process Daily Tasks only', self.daily_only)
        misc_layout.addRow('Target working hours per day:', self.target_hrs)

        # Placing sub-widgets to root layout
        self.layout.addWidget(week_frame, 0, Qt.AlignTop)
        self.layout.addWidget(tasks_frame, 0, Qt.AlignTop)
        self.layout.addWidget(misc_frame, 0, Qt.AlignTop)
示例#17
0
    def initUI(self, wlet_pars):
        """
        Gets called from the parent DataViewer
        """

        self.setWindowTitle("Batch Processing")
        self.setGeometry(310, 330, 600, 200)

        # from the DataViewer
        self.wlet_pars = wlet_pars

        # for the status bar
        main_widget = QWidget()
        self.statusBar()

        main_layout = QGridLayout()

        # -- Ridge Analysis Options --

        ridge_options = QGroupBox("Ridge Detection")

        thresh_label = QLabel("Ridge Threshold:")
        thresh_edit = QLineEdit()
        thresh_edit.setValidator(posfloatV)
        thresh_edit.insert("0")
        thresh_edit.setMaximumWidth(60)
        thresh_edit.setStatusTip(
            "Ridge points below that power value will be filtered out ")
        self.thresh_edit = thresh_edit

        smooth_label = QLabel("Ridge Smoothing:")
        smooth_edit = QLineEdit()
        smooth_edit.setMaximumWidth(60)
        smooth_edit.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        smooth_edit.setValidator(QIntValidator(bottom=3, top=99999999))
        smooth_edit.setStatusTip(
            """Savitkzy-Golay window size for smoothing the ridge,
            leave blank for no smoothing""")
        self.smooth_edit = smooth_edit

        ridge_options_layout = QGridLayout()
        ridge_options_layout.addWidget(thresh_label, 0, 0)
        ridge_options_layout.addWidget(thresh_edit, 0, 1)
        ridge_options_layout.addWidget(smooth_label, 1, 0)
        ridge_options_layout.addWidget(smooth_edit, 1, 1)
        ridge_options.setLayout(ridge_options_layout)

        # -- Plotting Options --

        plotting_options = QGroupBox("Summary Statistics")
        self.cb_power_dis = QCheckBox("Ridge Power Distribution")
        self.cb_power_dis.setStatusTip(
            "Show time-averaged distribution of ridge powers")
        self.cb_plot_ens_dynamics = QCheckBox("Ensemble Dynamics")
        self.cb_plot_ens_dynamics.setStatusTip(
            "Show period, amplitude and phase distribution over time")
        self.cb_plot_Fourier_dis = QCheckBox("Fourier Spectra Distribution")
        self.cb_plot_Fourier_dis.setStatusTip(
            "Ensemble power distribution of the time averaged Wavelet spectra")

        lo = QGridLayout()
        lo.addWidget(self.cb_plot_ens_dynamics, 0, 0)
        lo.addWidget(self.cb_plot_Fourier_dis, 1, 0)
        lo.addWidget(self.cb_power_dis, 2, 0)
        plotting_options.setLayout(lo)

        # -- Save Out Results --

        export_options = QGroupBox("Export Results")
        export_options.setStatusTip("Creates various figures and csv's")
        export_options.setCheckable(True)
        export_options.setChecked(False)

        self.cb_filtered_sigs = QCheckBox("Filtered Signals")
        self.cb_filtered_sigs.setStatusTip(
            "Saves detrended and amplitude normalized signals to disc as csv's"
        )

        self.cb_specs = QCheckBox("Wavelet Spectra")
        self.cb_specs.setStatusTip(
            "Saves the individual wavelet spectra as images")

        self.cb_specs_noridge = QCheckBox("Wavelet Spectra w/o ridges")
        self.cb_specs_noridge.setStatusTip(
            "Saves the individual wavelet spectra without the ridges as images"
        )

        self.cb_readout = QCheckBox("Ridge Readouts")
        self.cb_readout.setStatusTip(
            "Saves one analysis result per signal to disc as csv")

        self.cb_readout_plots = QCheckBox("Ridge Readout Plots")
        self.cb_readout_plots.setStatusTip(
            "Saves the individual readout plots to disc")
        self.cb_sorted_powers = QCheckBox("Sorted Average Powers")
        self.cb_sorted_powers.setStatusTip(
            "Saves the time-averaged ridge powers in descending order")
        self.cb_save_ensemble_dynamics = QCheckBox("Ensemble Dynamics")
        self.cb_save_ensemble_dynamics.setStatusTip(
            "Separately saves period, amplitude, power and phase summary statistics to a csv file"
        )

        self.cb_save_Fourier_dis = QCheckBox("Fourier Distribution")
        self.cb_save_Fourier_dis.setStatusTip(
            "Saves median and quartiles of the ensemble Fourier power spectral distribution"
        )

        # defaults to HOME
        self.OutPath_edit = QLineEdit(expanduser("~"))

        PathButton = QPushButton("Select Path..")
        PathButton.setMaximumWidth(100)
        PathButton.clicked.connect(self.select_export_dir)

        line1 = QFrame()
        line1.setFrameShape(QFrame.HLine)
        line1.setFrameShadow(QFrame.Sunken)

        line2 = QFrame()
        line2.setFrameShape(QFrame.HLine)
        line2.setFrameShadow(QFrame.Sunken)

        lo = QGridLayout()
        lo.setSpacing(1.5)

        lo.addWidget(self.cb_filtered_sigs, 0, 0)

        lo.addWidget(self.cb_specs, 1, 0)
        lo.addWidget(self.cb_specs_noridge, 2, 0)

        lo.addWidget(self.cb_readout, 3, 0)
        lo.addWidget(self.cb_readout_plots, 4, 0)
        # lo.addWidget(line1, 3,0)
        lo.addWidget(self.cb_sorted_powers, 5, 0)
        lo.addWidget(self.cb_save_ensemble_dynamics, 6, 0)
        lo.addWidget(self.cb_save_Fourier_dis, 7, 0)
        # lo.addWidget(line2, 6,0)
        lo.addWidget(PathButton, 8, 0)
        lo.addWidget(self.OutPath_edit, 9, 0)
        export_options.setLayout(lo)
        self.export_options = export_options

        # -- Progress and Run --
        Nsignals = self.parentDV.df.shape[1]

        RunButton = QPushButton(f"Run for {Nsignals} Signals!", self)
        RunButton.setStyleSheet("background-color: orange")
        RunButton.clicked.connect(self.run_batch)
        # RunButton.setMaximumWidth(60)

        # the progress bar
        self.progress = QProgressBar(self)
        self.progress.setRange(0, Nsignals - 1)
        # self.progress.setGeometry(0,0, 300, 20)
        self.progress.setMinimumWidth(200)

        # nsig_label = QLabel(f'{Nsignals} Signals')

        process_box = QGroupBox("Processing")
        process_box.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        lo = QHBoxLayout()
        lo.addWidget(self.progress)
        lo.addItem(QSpacerItem(30, 2))
        # lo.addStretch(0)
        lo.addWidget(RunButton)
        lo.addStretch(0)
        process_box.setLayout(lo)

        # -- main layout --

        main_layout.addWidget(plotting_options, 0, 0, 1, 1)
        main_layout.addWidget(ridge_options, 1, 0, 1, 1)
        main_layout.addWidget(export_options, 0, 1, 2, 1)
        main_layout.addWidget(process_box, 2, 0, 1, 2)

        # set main layout
        main_widget.setLayout(main_layout)
        self.setCentralWidget(main_widget)

        self.show()
示例#18
0
def dialog_box(title, icon, errorText, warningText):
    dlg = QDialog()
    scroll = QScrollArea(dlg)
    widget = QWidget()
    vbox = QVBoxLayout()
    labelN = QLabel(notice, objectName='labelN')
    lineE = QFrame(objectName='lineE')
    lineE.setFrameShape(QFrame.HLine)
    labelE1 = QLabel(objectName='labelE1')
    labelE2 = QLabel()
    lineW = QFrame(objectName='lineW')
    lineW.setFrameShape(QFrame.HLine)
    labelW1 = QLabel(objectName='labelW1')
    labelW2 = QLabel()
    vbox.addWidget(labelN)
    vbox.addWidget(lineE)
    vbox.addWidget(labelE1)
    vbox.addWidget(labelE2)
    vbox.addWidget(lineW)
    vbox.addWidget(labelW1)
    vbox.addWidget(labelW2)
    widget.setLayout(vbox)
    btn = QPushButton('OK', dlg)
    dlg.setWindowTitle(title)
    dlg.setWindowIcon(QIcon(dlg.style().standardIcon(icon)))
    dlg.setWindowFlags(Qt.WindowStaysOnTopHint)
    dlg.setModal(False)
    dlg.setFixedWidth(600)
    dlg.setFixedHeight(310)
    scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
    scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
    scroll.setWidgetResizable(True)
    scroll.setWidget(widget)
    scroll.setGeometry(5, 5, 590, 250)
    btn.move(270, 260)
    btn.clicked.connect(lambda w: dlg_ok_clicked(dlg))
    if errorText:
        labelE1.setText(errors)
        labelE2.setText(errorText)
    else:
        lineE.hide()
        labelE1.hide()
        labelE2.hide()
    if warningText:
        labelW1.setText(warnings)
        labelW2.setText(warningText)
    else:
        lineW.hide()
        labelW1.hide()
        labelW2.hide()
    dlg.setStyleSheet(' \
                      * {{ color: {0}; background: {1}}} \
                      QScrollArea {{color:{0}; background:{1}; border:1px solid {0}; border-radius:4px; padding:4px}} \
                      QPushButton {{border:2px solid {0}; border-radius:4px; font:12pt; width:60px; height:40px}} \
                      QPushButton:pressed {{border:1px solid {0}}} \
                      QScrollBar:vertical {{background:{2}; border:0px; border-radius:4px; margin: 0px; width:20px}} \
                      QScrollBar::handle:vertical {{background:{0}; border:2px solid {0}; border-radius:4px; margin:2px; min-height:40px}} \
                      QScrollBar::add-line:vertical {{height:0px}} \
                      QScrollBar::sub-line:vertical {{height:0px}} \
                      QVboxLayout {{margin:100}} \
                      #labelN {{font-style:italic}} \
                      #lineE, #lineW {{border:1px solid {0}}} \
                      #labelE1, #labelW1 {{font-weight:bold}}'.format(
        fgColor, bgColor, bgAltColor))
    dlg.exec()
示例#19
0
    def initUi(self):
        # Stilos
        #=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#
        frame = ("QFrame{\n"
                 "color:#1b231f;\n"
                 "background-color: rgba(255,255,255,0.8);\n"
                 "border-radius: 22px;\n"
                 "}")
        frame_2 = ("QFrame{\n"
                   "color:#1b231f;\n"
                   "background-color: rgba(255,255,255,1);\n"
                   "border-radius: 10px;\n"
                   "}")
        frame_pantalla = ("QLineEdit{\n"
                          "color:white;\n"
                          "background-color: rgba(0,0,0,0.8);\n"
                          "border-radius: 10px;\n"
                          "}")

        label_titulo = ("QLabel{\n" "color:rgb(24, 24, 24);\n" "}")

        botonCierre = (
            "QPushButton{\n"
            "border:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(0, 0, 0, 0), stop:1 rgba(255, 255, 255, 0));\n"
            "background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(0, 0, 0, 0), stop:1 rgba(255, 255, 255, 0));\n"
            "color:rgb(255, 255, 255);\n"
            "}\n"
            "QPushButton:hover{\n"
            "background-color:rgb(255, 0, 0);\n"
            "color:rgb(255, 255, 255);\n"
            "}")

        botonStandar = (
            "QPushButton{\n"
            "border:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(0, 0, 0, 0), stop:1 rgba(255, 255, 255, 0));\n"
            "background-color: rgba(255,255,255,1);\n"
            "border-radius: 10px;"
            "color:rgb(0, 0, 0);\n"
            "}\n"
            "QPushButton:hover{\n"
            "background-color:rgb(10, 0, 0);\n"
            "color:rgb(255, 255, 255);\n"
            "}")
        botonSpecial = (
            "QPushButton{\n"
            "border:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(0, 0, 0, 0), stop:1 rgba(255, 255, 255, 0));\n"
            "background-color: rgba(207, 0, 89);\n"
            "border-radius: 10px;"
            "color:rgb(0, 0, 0);\n"
            "}\n"
            "QPushButton:hover{\n"
            "background-color:rgb(71,13,191);\n"
            "color:rgb(255, 255, 255);\n"
            "}")
        #=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#

        self.frame_principal = QFrame(self)
        self.frame_principal.setGeometry(QRect(30, 120, 610, 500))
        self.frame_principal.setStyleSheet(frame)
        self.frame_principal.move(30, 100)

        # Label y frame del encabezado
        self.frame_titulo = QFrame(self)
        self.frame_titulo.setGeometry(QRect(30, 30, 135, 50))
        self.frame_titulo.setStyleSheet(frame_2)
        self.frame_titulo.move(268, 20)
        self.sombra_2 = QGraphicsDropShadowEffect()
        self.sombra_2.setBlurRadius(23)
        self.frame_titulo.setGraphicsEffect(self.sombra_2)

        self.Label = QLabel(self)
        self.Label.setGeometry(QRect(30, 30, 121, 51))
        self.Label.setText("G-Calculator")
        self.Label.setStyleSheet(label_titulo)
        self.Label.setFont(QtGui.QFont("Lobster", 17, QtGui.QFont.Bold))
        self.Label.move(280, 20)
        self.sombra = QGraphicsDropShadowEffect()
        self.sombra.setBlurRadius(22)
        self.Label.setGraphicsEffect(self.sombra)

        self.botonCerrar = QPushButton(self)
        self.botonCerrar.setGeometry(QRect(30, 30, 40, 30))
        self.botonCerrar.setIcon(QIcon("icons/close.svg"))
        self.botonCerrar.move(590, 10)
        self.botonCerrar.setStyleSheet(botonCierre)

        self.botonMinimizar = QPushButton(self)
        self.botonMinimizar.setIcon(QIcon("icons/shuffle.svg"))
        self.botonMinimizar.setGeometry(QRect(30, 30, 30, 30))
        self.botonMinimizar.move(560, 10)
        self.botonMinimizar.setStyleSheet(botonCierre)

        self.acercaDe = QPushButton(self)
        self.acercaDe.setIcon(QIcon("icons/menu.svg"))
        self.acercaDe.setGeometry(QRect(30, 30, 30, 30))
        self.acercaDe.move(10, 10)
        self.acercaDe.setStyleSheet(botonCierre)

        # botones del contenido numérico#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#
        self.frame_pantalla = QtWidgets.QLineEdit(self.frame_principal)
        self.frame_pantalla.setGeometry(QRect(40, 40, 520, 120))
        self.frame_pantalla.setStyleSheet(frame_pantalla)
        self.frame_pantalla.move(45, 10)
        self.frame_pantalla.setFont(QtGui.QFont("Roboto", 50,
                                                QtGui.QFont.Bold))
        self.frame_pantalla.setReadOnly(True)
        self.frame_pantalla.setCursor(QtGui.QCursor(QtCore.Qt.IBeamCursor))
        self.frame_pantalla.setMaxLength(100)
        self.frame_pantalla.setAlignment(QtCore.Qt.AlignRight
                                         | QtCore.Qt.AlignTrailing
                                         | QtCore.Qt.AlignVCenter)
        self.sombra_3 = QGraphicsDropShadowEffect()
        self.sombra_3.setBlurRadius(22)
        self.frame_pantalla.setGraphicsEffect(self.sombra_3)

        self.boton_Nro1 = QPushButton(self.frame_principal)
        self.boton_Nro1.setGeometry(QRect(40, 40, 50, 50))
        self.boton_Nro1.setStyleSheet(botonStandar)
        self.boton_Nro1.setFont(QtGui.QFont("Lobster", 14, QtGui.QFont.Bold))
        self.boton_Nro1.setText("1")
        self.boton_Nro1.move(45, 160)
        self.sombra_4 = QGraphicsDropShadowEffect()
        self.sombra_4.setBlurRadius(22)
        self.boton_Nro1.setGraphicsEffect(self.sombra_4)

        self.boton_Nro2 = QPushButton(self.frame_principal)
        self.boton_Nro2.setGeometry(QRect(40, 40, 50, 50))
        self.boton_Nro2.setStyleSheet(botonStandar)
        self.boton_Nro2.setFont(QtGui.QFont("Lobster", 14, QtGui.QFont.Bold))
        self.boton_Nro2.setText("2")
        self.boton_Nro2.move(110, 160)
        self.sombra_5 = QGraphicsDropShadowEffect()
        self.sombra_5.setBlurRadius(22)
        self.boton_Nro2.setGraphicsEffect(self.sombra_5)

        self.boton_Nro3 = QPushButton(self.frame_principal)
        self.boton_Nro3.setGeometry(QRect(40, 40, 50, 50))
        self.boton_Nro3.setStyleSheet(botonStandar)
        self.boton_Nro3.setFont(QtGui.QFont("Lobster", 14, QtGui.QFont.Bold))
        self.boton_Nro3.setText("3")
        self.boton_Nro3.move(175, 160)
        self.sombra_6 = QGraphicsDropShadowEffect()
        self.sombra_6.setBlurRadius(22)
        self.boton_Nro3.setGraphicsEffect(self.sombra_6)

        self.boton_Nro4 = QPushButton(self.frame_principal)
        self.boton_Nro4.setGeometry(QRect(40, 40, 50, 50))
        self.boton_Nro4.setStyleSheet(botonStandar)
        self.boton_Nro4.setFont(QtGui.QFont("Lobster", 14, QtGui.QFont.Bold))
        self.boton_Nro4.setText("4")
        self.boton_Nro4.move(45, 230)
        self.sombra_7 = QGraphicsDropShadowEffect()
        self.sombra_7.setBlurRadius(22)
        self.boton_Nro4.setGraphicsEffect(self.sombra_7)

        self.boton_Nro5 = QPushButton(self.frame_principal)
        self.boton_Nro5.setGeometry(QRect(40, 40, 50, 50))
        self.boton_Nro5.setStyleSheet(botonStandar)
        self.boton_Nro5.setFont(QtGui.QFont("Lobster", 14, QtGui.QFont.Bold))
        self.boton_Nro5.setText("5")
        self.boton_Nro5.move(110, 230)
        self.sombra_8 = QGraphicsDropShadowEffect()
        self.sombra_8.setBlurRadius(22)
        self.boton_Nro5.setGraphicsEffect(self.sombra_8)

        self.boton_Nro6 = QPushButton(self.frame_principal)
        self.boton_Nro6.setGeometry(QRect(40, 40, 50, 50))
        self.boton_Nro6.setStyleSheet(botonStandar)
        self.boton_Nro6.setFont(QtGui.QFont("Lobster", 14, QtGui.QFont.Bold))
        self.boton_Nro6.setText("6")
        self.boton_Nro6.move(175, 230)
        self.sombra_9 = QGraphicsDropShadowEffect()
        self.sombra_9.setBlurRadius(22)
        self.boton_Nro6.setGraphicsEffect(self.sombra_9)

        self.boton_Nro7 = QPushButton(self.frame_principal)
        self.boton_Nro7.setGeometry(QRect(40, 40, 50, 50))
        self.boton_Nro7.setStyleSheet(botonStandar)
        self.boton_Nro7.setFont(QtGui.QFont("Lobster", 14, QtGui.QFont.Bold))
        self.boton_Nro7.setText("7")
        self.boton_Nro7.move(45, 300)
        self.sombra_10 = QGraphicsDropShadowEffect()
        self.sombra_10.setBlurRadius(22)
        self.boton_Nro7.setGraphicsEffect(self.sombra_10)

        self.boton_Nro8 = QPushButton(self.frame_principal)
        self.boton_Nro8.setGeometry(QRect(40, 40, 50, 50))
        self.boton_Nro8.setStyleSheet(botonStandar)
        self.boton_Nro8.setFont(QtGui.QFont("Lobster", 14, QtGui.QFont.Bold))
        self.boton_Nro8.setText("8")
        self.boton_Nro8.move(110, 300)
        self.sombra_11 = QGraphicsDropShadowEffect()
        self.sombra_11.setBlurRadius(22)
        self.boton_Nro8.setGraphicsEffect(self.sombra_11)

        self.boton_Nro9 = QPushButton(self.frame_principal)
        self.boton_Nro9.setGeometry(QRect(40, 40, 50, 50))
        self.boton_Nro9.setStyleSheet(botonStandar)
        self.boton_Nro9.setFont(QtGui.QFont("Lobster", 14, QtGui.QFont.Bold))
        self.boton_Nro9.setText("9")
        self.boton_Nro9.move(175, 300)
        self.sombra_12 = QGraphicsDropShadowEffect()
        self.sombra_12.setBlurRadius(22)
        self.boton_Nro9.setGraphicsEffect(self.sombra_12)

        self.boton_Point = QPushButton(self.frame_principal)
        self.boton_Point.setGeometry(QRect(40, 40, 50, 50))
        self.boton_Point.setStyleSheet(botonStandar)
        self.boton_Point.setFont(QtGui.QFont("Lobster", 14, QtGui.QFont.Bold))
        self.boton_Point.setText(".")
        self.boton_Point.move(45, 370)
        self.sombra_13 = QGraphicsDropShadowEffect()
        self.sombra_13.setBlurRadius(22)
        self.boton_Point.setGraphicsEffect(self.sombra_13)

        self.boton_Nro0 = QPushButton(self.frame_principal)
        self.boton_Nro0.setGeometry(QRect(40, 40, 50, 50))
        self.boton_Nro0.setStyleSheet(botonStandar)
        self.boton_Nro0.setFont(QtGui.QFont("Lobster", 14, QtGui.QFont.Bold))
        self.boton_Nro0.setText("0")
        self.boton_Nro0.move(110, 370)
        self.sombra_14 = QGraphicsDropShadowEffect()
        self.sombra_14.setBlurRadius(22)
        self.boton_Nro0.setGraphicsEffect(self.sombra_14)

        self.boton_Equal = QPushButton(self.frame_principal)
        self.boton_Equal.setGeometry(QRect(40, 40, 50, 50))
        self.boton_Equal.setStyleSheet(botonSpecial)
        self.boton_Equal.setFont(QtGui.QFont("Lobster", 14, QtGui.QFont.Bold))
        self.boton_Equal.setText("=")
        self.boton_Equal.move(175, 370)
        self.sombra_15 = QGraphicsDropShadowEffect()
        self.sombra_15.setBlurRadius(22)
        self.boton_Equal.setGraphicsEffect(self.sombra_15)

        self.boton_Clear = QPushButton(self.frame_principal)
        self.boton_Clear.setGeometry(QRect(40, 40, 50, 50))
        self.boton_Clear.setStyleSheet(botonSpecial)
        self.boton_Clear.setFont(QtGui.QFont("Lobster", 14, QtGui.QFont.Bold))
        self.boton_Clear.setText("DEL")
        self.boton_Clear.move(250, 160)
        self.sombra_16 = QGraphicsDropShadowEffect()
        self.sombra_16.setBlurRadius(22)
        self.boton_Clear.setGraphicsEffect(self.sombra_16)

        self.boton_Clear2 = QPushButton(self.frame_principal)
        self.boton_Clear2.setGeometry(QRect(40, 40, 50, 50))
        self.boton_Clear2.setStyleSheet(botonSpecial)
        self.boton_Clear2.setFont(QtGui.QFont("Lobster", 14, QtGui.QFont.Bold))
        self.boton_Clear2.setText("Clear")
        self.boton_Clear2.move(315, 160)
        self.sombra_17 = QGraphicsDropShadowEffect()
        self.sombra_17.setBlurRadius(22)
        self.boton_Clear2.setGraphicsEffect(self.sombra_17)

        self.boton_suma = QPushButton(self.frame_principal)
        self.boton_suma.setGeometry(QRect(40, 40, 50, 50))
        self.boton_suma.setStyleSheet(botonStandar)
        self.boton_suma.setFont(QtGui.QFont("Lobster", 14, QtGui.QFont.Bold))
        self.boton_suma.setText("+")
        self.boton_suma.move(250, 230)
        self.sombra_19 = QGraphicsDropShadowEffect()
        self.sombra_19.setBlurRadius(22)
        self.boton_suma.setGraphicsEffect(self.sombra_19)

        self.boton_Resta = QPushButton(self.frame_principal)
        self.boton_Resta.setGeometry(QRect(40, 40, 50, 50))
        self.boton_Resta.setStyleSheet(botonStandar)
        self.boton_Resta.setFont(QtGui.QFont("Lobster", 14, QtGui.QFont.Bold))
        self.boton_Resta.setText("-")
        self.boton_Resta.move(315, 230)
        self.sombra_20 = QGraphicsDropShadowEffect()
        self.sombra_20.setBlurRadius(22)
        self.boton_Resta.setGraphicsEffect(self.sombra_20)

        self.boton_Divide = QPushButton(self.frame_principal)
        self.boton_Divide.setGeometry(QRect(40, 40, 50, 50))
        self.boton_Divide.setStyleSheet(botonStandar)
        self.boton_Divide.setFont(QtGui.QFont("Lobster", 14, QtGui.QFont.Bold))
        self.boton_Divide.setText("/")
        self.boton_Divide.move(250, 300)
        self.sombra_21 = QGraphicsDropShadowEffect()
        self.sombra_21.setBlurRadius(22)
        self.boton_Divide.setGraphicsEffect(self.sombra_21)

        self.boton_X = QPushButton(self.frame_principal)
        self.boton_X.setGeometry(QRect(40, 40, 50, 50))
        self.boton_X.setStyleSheet(botonStandar)
        self.boton_X.setFont(QtGui.QFont("Lobster", 14, QtGui.QFont.Bold))
        self.boton_X.setText("X")
        self.boton_X.move(315, 300)
        self.sombra_18 = QGraphicsDropShadowEffect()
        self.sombra_18.setBlurRadius(22)
        self.boton_X.setGraphicsEffect(self.sombra_18)

        self.boton_parent = QPushButton(self.frame_principal)
        self.boton_parent.setGeometry(QRect(40, 40, 50, 50))
        self.boton_parent.setStyleSheet(botonStandar)
        self.boton_parent.setFont(QtGui.QFont("Lobster", 14, QtGui.QFont.Bold))
        self.boton_parent.setText("(")
        self.boton_parent.move(250, 370)
        self.sombra_19 = QGraphicsDropShadowEffect()
        self.sombra_19.setBlurRadius(22)
        self.boton_parent.setGraphicsEffect(self.sombra_19)

        self.boton_parent2 = QPushButton(self.frame_principal)
        self.boton_parent2.setGeometry(QRect(40, 40, 50, 50))
        self.boton_parent2.setStyleSheet(botonStandar)
        self.boton_parent2.setFont(QtGui.QFont("Lobster", 14,
                                               QtGui.QFont.Bold))
        self.boton_parent2.setText(")")
        self.boton_parent2.move(315, 370)
        self.sombra_20 = QGraphicsDropShadowEffect()
        self.sombra_20.setBlurRadius(22)
        self.boton_parent2.setGraphicsEffect(self.sombra_20)

        self.seno = QPushButton(self.frame_principal)
        self.seno.setGeometry(QRect(40, 40, 50, 50))
        self.seno.setStyleSheet(botonStandar)
        self.seno.setFont(QtGui.QFont("Lobster", 14, QtGui.QFont.Bold))
        self.seno.setText("Sen")
        self.seno.move(390, 160)
        self.sombra_21 = QGraphicsDropShadowEffect()
        self.sombra_21.setBlurRadius(22)
        self.seno.setGraphicsEffect(self.sombra_21)

        self.coseno = QPushButton(self.frame_principal)
        self.coseno.setGeometry(QRect(40, 40, 50, 50))
        self.coseno.setStyleSheet(botonStandar)
        self.coseno.setFont(QtGui.QFont("Lobster", 14, QtGui.QFont.Bold))
        self.coseno.setText("Cos")
        self.coseno.move(450, 160)
        self.sombra_22 = QGraphicsDropShadowEffect()
        self.sombra_22.setBlurRadius(22)
        self.coseno.setGraphicsEffect(self.sombra_22)

        self.tangente = QPushButton(self.frame_principal)
        self.tangente.setGeometry(QRect(40, 40, 50, 50))
        self.tangente.setStyleSheet(botonStandar)
        self.tangente.setFont(QtGui.QFont("Lobster", 14, QtGui.QFont.Bold))
        self.tangente.setText("Tan")
        self.tangente.move(510, 160)
        self.sombra_23 = QGraphicsDropShadowEffect()
        self.sombra_23.setBlurRadius(22)
        self.tangente.setGraphicsEffect(self.sombra_23)

        self.arcsen = QPushButton(self.frame_principal)
        self.arcsen.setGeometry(QRect(40, 40, 50, 50))
        self.arcsen.setStyleSheet(botonStandar)
        self.arcsen.setFont(QtGui.QFont("Lobster", 12, QtGui.QFont.Bold))
        self.arcsen.setText("ArcSen")
        self.arcsen.move(390, 220)
        self.sombra_24 = QGraphicsDropShadowEffect()
        self.sombra_24.setBlurRadius(22)
        self.arcsen.setGraphicsEffect(self.sombra_24)

        self.arccos = QPushButton(self.frame_principal)
        self.arccos.setGeometry(QRect(40, 40, 50, 50))
        self.arccos.setStyleSheet(botonStandar)
        self.arccos.setFont(QtGui.QFont("Lobster", 12, QtGui.QFont.Bold))
        self.arccos.setText("ArcCos")
        self.arccos.move(450, 220)
        self.sombra_25 = QGraphicsDropShadowEffect()
        self.sombra_25.setBlurRadius(22)
        self.arccos.setGraphicsEffect(self.sombra_25)

        self.arctang = QPushButton(self.frame_principal)
        self.arctang.setGeometry(QRect(40, 40, 50, 50))
        self.arctang.setStyleSheet(botonStandar)
        self.arctang.setFont(QtGui.QFont("Lobster", 12, QtGui.QFont.Bold))
        self.arctang.setText("ArcTan")
        self.arctang.move(510, 220)
        self.sombra_26 = QGraphicsDropShadowEffect()
        self.sombra_26.setBlurRadius(22)
        self.arctang.setGraphicsEffect(self.sombra_26)

        self.raiz = QPushButton(self.frame_principal)
        self.raiz.setGeometry(QRect(40, 40, 50, 50))
        self.raiz.setStyleSheet(botonStandar)
        self.raiz.setText("ELpepe")
        self.raiz.move(390, 280)
        self.sombra_27 = QGraphicsDropShadowEffect()
        self.sombra_27.setBlurRadius(22)
        self.raiz.setGraphicsEffect(self.sombra_27)

        #=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#

        #=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#
        # Eventos
        self.botonCerrar.clicked.connect(self.closeButton)
        self.botonMinimizar.clicked.connect(self.minimize)

        #Pad de Botones

        self.boton_Nro1.clicked.connect(
            lambda: self.frame_pantalla.insert('1'))
        self.boton_Nro2.clicked.connect(
            lambda: self.frame_pantalla.insert('2'))
        self.boton_Nro3.clicked.connect(
            lambda: self.frame_pantalla.insert('3'))
        self.boton_Nro4.clicked.connect(
            lambda: self.frame_pantalla.insert('4'))
        self.boton_Nro5.clicked.connect(
            lambda: self.frame_pantalla.insert('5'))
        self.boton_Nro6.clicked.connect(
            lambda: self.frame_pantalla.insert('6'))
        self.boton_Nro7.clicked.connect(
            lambda: self.frame_pantalla.insert('7'))
        self.boton_Nro8.clicked.connect(
            lambda: self.frame_pantalla.insert('8'))
        self.boton_Nro9.clicked.connect(
            lambda: self.frame_pantalla.insert('9'))
        self.boton_Nro0.clicked.connect(
            lambda: self.frame_pantalla.insert('0'))

        self.boton_Point.clicked.connect(
            lambda: self.frame_pantalla.insert('.'))
        self.boton_Equal.clicked.connect(lambda: self.evaluacion())
        self.boton_Clear.clicked.connect(
            lambda: self.frame_pantalla.backspace())
        self.boton_Clear2.clicked.connect(lambda: self.frame_pantalla.clear())

        self.boton_suma.clicked.connect(
            lambda: self.frame_pantalla.insert('+'))
        self.boton_Resta.clicked.connect(
            lambda: self.frame_pantalla.insert('-'))
        self.boton_Divide.clicked.connect(
            lambda: self.frame_pantalla.insert('/'))
        self.boton_X.clicked.connect(lambda: self.frame_pantalla.insert('*'))
        self.boton_parent.clicked.connect(
            lambda: self.frame_pantalla.insert('('))
        self.boton_parent2.clicked.connect(
            lambda: self.frame_pantalla.insert(')'))

        self.seno.clicked.connect(lambda: self.frame_pantalla.insert('sin('))
        self.coseno.clicked.connect(lambda: self.frame_pantalla.insert('cos('))
        self.tangente.clicked.connect(
            lambda: self.frame_pantalla.insert('tan('))
        self.arcsen.clicked.connect(
            lambda: self.frame_pantalla.insert('asin('))
        self.arccos.clicked.connect(
            lambda: self.frame_pantalla.insert('acos('))
        self.arctang.clicked.connect(
            lambda: self.frame_pantalla.insert('atan('))
        self.raiz.clicked.connect(lambda: self.frame_pantalla.insert('ELpepe'))
示例#20
0
    def disp_params(self, cfg_template_module, cfg_module):
        """
        Displays the parameters in the corresponding UI scrollArea.
        cfg = config module
        """

        self.clear_params()
        # Extract the parameters and their possible values from the template modules.
        params = inspect.getmembers(cfg_template_module)

        # Extract the chosen values from the subject's specific module.
        all_chosen_values = inspect.getmembers(cfg_module)

        filePath = self.ui.lineEdit_pathSearch.text()

        # Load channels
        if self.modality == 'trainer':
            subjectDataPath = Path(
                '%s/%s/%s/fif' %
                (os.environ['NEUROD_DATA'], filePath.split('/')[-2],
                 filePath.split('/')[-1]))
            self.channels = read_params_from_file(subjectDataPath,
                                                  'channelsList.txt')

        self.directions = ()

        # Iterates over the classes
        for par in range(2):
            param = inspect.getmembers(params[par][1])
            # Create layouts
            layout = QFormLayout()

            # Iterates over the list
            for p in param:
                # Remove useless attributes
                if '__' in p[0]:
                    continue

                # Iterates over the dict
                for key, values in p[1].items():
                    chosen_value = self.extract_value_from_module(
                        key, all_chosen_values)

                    # For the feedback directions [offline and online].
                    if 'DIRECTIONS' in key:
                        self.directions = values

                        if self.modality is 'offline':
                            nb_directions = 4
                            directions = Connect_Directions(
                                key, chosen_value, values, nb_directions)

                        elif self.modality is 'online':
                            chosen_events = [
                                event[1] for event in chosen_value
                            ]
                            chosen_value = [val[0] for val in chosen_value]
                            nb_directions = len(chosen_value)
                            directions = Connect_Directions_Online(
                                key, chosen_value, values, nb_directions,
                                chosen_events, [None])

                        directions.signal_paramChanged[str, list].connect(
                            self.on_guichanges)
                        self.paramsWidgets.update({key: directions})
                        layout.addRow(key, directions.l)

                    # For the special case of choosing the trigger classes to train on
                    elif 'TRIGGER_DEF' in key:

                        trigger_def = Connect_Directions(
                            key, chosen_value, [None], 4)
                        trigger_def.signal_paramChanged[str, list].connect(
                            self.on_guichanges)
                        self.paramsWidgets.update({key: trigger_def})
                        layout.addRow(key, trigger_def.l)

                    # For providing a folder path.
                    elif 'PATH' in key:
                        pathfolderfinder = PathFolderFinder(
                            key, os.environ['NEUROD_DATA'], chosen_value)
                        pathfolderfinder.signal_pathChanged[str, str].connect(
                            self.on_guichanges)
                        pathfolderfinder.signal_error[str].connect(
                            self.on_error)
                        self.paramsWidgets.update({key: pathfolderfinder})
                        layout.addRow(key, pathfolderfinder.layout)

                        if not chosen_value:
                            self.signal_error[str].emit(
                                key +
                                ' is empty! Provide a path before starting.')
                        continue

                    # For providing a file path.
                    elif 'FILE' in key:
                        pathfilefinder = PathFileFinder(key, chosen_value)
                        pathfilefinder.signal_pathChanged[str, str].connect(
                            self.on_guichanges)
                        pathfilefinder.signal_error[str].connect(self.on_error)
                        self.paramsWidgets.update({key: pathfilefinder})
                        layout.addRow(key, pathfilefinder.layout)

                        if not chosen_value:
                            self.signal_error[str].emit(
                                key +
                                ' is empty! Provide a file before starting.')

                    # To select specific electrodes
                    elif '_CHANNELS' in key or 'CHANNELS_' in key:
                        ch_select = Channel_Select(key, self.channels,
                                                   chosen_value)
                        ch_select.signal_paramChanged[str, list].connect(
                            self.on_guichanges)
                        self.paramsWidgets.update({key: ch_select})
                        layout.addRow(key, ch_select.layout)

                    elif 'BIAS' in key:
                        #  Add None to the list in case of no bias wanted
                        self.directions = tuple([None] + list(self.directions))
                        bias = Connect_Bias(key, self.directions, chosen_value)
                        bias.signal_paramChanged[str, object].connect(
                            self.on_guichanges)
                        self.paramsWidgets.update({key: bias})
                        layout.addRow(key, bias.l)

                    # For all the int values.
                    elif values is int:
                        spinBox = Connect_SpinBox(key, chosen_value)
                        spinBox.signal_paramChanged[str, int].connect(
                            self.on_guichanges)
                        self.paramsWidgets.update({key: spinBox})
                        layout.addRow(key, spinBox)

                    # For all the float values.
                    elif values is float:
                        doublespinBox = Connect_DoubleSpinBox(
                            key, chosen_value)
                        doublespinBox.signal_paramChanged[str, float].connect(
                            self.on_guichanges)
                        self.paramsWidgets.update({key: doublespinBox})
                        layout.addRow(key, doublespinBox)

                    # For parameters with multiple non-fixed values in a list (user can modify them)
                    elif values is list:
                        modifiable_list = Connect_Modifiable_List(
                            key, chosen_value)
                        modifiable_list.signal_paramChanged[str, list].connect(
                            self.on_guichanges)
                        self.paramsWidgets.update({key: modifiable_list})
                        layout.addRow(key, modifiable_list)
                        continue

                    #  For parameters containing a string to modify
                    elif values is str:
                        lineEdit = Connect_LineEdit(key, chosen_value)
                        lineEdit.signal_paramChanged[str, str].connect(
                            self.on_guichanges)
                        lineEdit.signal_paramChanged[str, type(None)].connect(
                            self.on_guichanges)
                        self.paramsWidgets.update({key: lineEdit})
                        layout.addRow(key, lineEdit)

                    # For parameters with multiple fixed values.
                    elif type(values) is tuple:
                        comboParams = Connect_ComboBox(key, chosen_value,
                                                       values)
                        comboParams.signal_paramChanged[str, object].connect(
                            self.on_guichanges)
                        comboParams.signal_additionalParamChanged[
                            str, dict].connect(self.on_guichanges)
                        self.paramsWidgets.update({key: comboParams})
                        layout.addRow(key, comboParams.layout)
                        continue

                    # For parameters with multiple non-fixed values in a dict (user can modify them)
                    elif type(values) is dict:
                        try:
                            selection = chosen_value['selected']
                            comboParams = Connect_ComboBox(
                                key, chosen_value, values)
                            comboParams.signal_paramChanged[
                                str, object].connect(self.on_guichanges)
                            comboParams.signal_additionalParamChanged[
                                str, dict].connect(self.on_guichanges)
                            self.paramsWidgets.update({key: comboParams})
                            layout.addRow(key, comboParams.layout)
                        except:
                            modifiable_dict = Connect_Modifiable_Dict(
                                key, chosen_value, values)
                            modifiable_dict.signal_paramChanged[
                                str, dict].connect(self.on_guichanges)
                            self.paramsWidgets.update({key: modifiable_dict})
                            layout.addRow(key, modifiable_dict)

                # Add a horizontal line to separate parameters' type.
                if p != param[-1]:
                    separator = QFrame()
                    separator.setFrameShape(QFrame.HLine)
                    separator.setFrameShadow(QFrame.Sunken)
                    layout.addRow(separator)

                # Display the parameters according to their types.
                if params[par][0] == 'Basic':
                    self.ui.scrollAreaWidgetContents_Basics.setLayout(layout)
                elif params[par][0] == 'Advanced':
                    self.ui.scrollAreaWidgetContents_Adv.setLayout(layout)

        # Connect inter-widgets signals and slots
        if self.modality == 'trainer':
            self.paramsWidgets['TRIGGER_FILE'].signal_pathChanged[
                str, str].connect(trigger_def.on_new_tdef_file)
            self.paramsWidgets['TRIGGER_FILE'].on_selected()

        if self.modality == 'online':
            self.paramsWidgets['TRIGGER_FILE'].signal_pathChanged[
                str, str].connect(directions.on_new_tdef_file)
            self.paramsWidgets['TRIGGER_FILE'].on_selected()

            self.paramsWidgets['DECODER_FILE'].signal_pathChanged[
                str, str].connect(directions.on_new_decoder_file)
            self.paramsWidgets['DECODER_FILE'].on_selected()
    def __init__(self, tipo):
        super(VistaPrenotazione, self).__init__()
        self.tipo = tipo
        self.controller = ControllerListaPrenotazioni()
        self.controller_clienti = ControllerListaClienti()

        # Inserisce il 'lista_orari' le informazioni contenute nel file 'lista_prenotazioni.pickle'.
        self.lista_orari = self.controller.get_lista_prenotazioni()

        self.stylesheet_frame = """
                   QFrame{
                       background-color: white;
                       border: 1px solid grey;
                   }
               """

        self.stylesheet_window = """
                   QWidget{
                       background-color: #efefef;
                   }
               """

        self.stylesheet_label = """
                   QLabel{
                       background-color: white;
                   }

                   QLineEdit{
                       background-color: white;
                       border: 2px solid #dfdfdf
                   }

                   QComboBox{
                       background-color: white;
                       border: 1px solid grey;
                       color: black;
                   }

               """

        self.stylesheet_button_back = """
                   QPushButton{
                       background-color: transparent;
                       border-radius: 15px;
                   }

                   QPushButton::Pressed{
                       background-color: grey;
                   }        
               """

        self.stylesheet_button = """
                   QPushButton{
                       background-color: #cc3234;
                       color: white;
                       border-radius: 15px;
                   }

                   QPushButton::Pressed{
                       background-color: grey
                   }        
               """

        self.stylesheet_calendar = """
                    QCalendarWidget QToolButton{
                        background-color : lightblue;
                    }
                    QCalendarWidget QWidget{
                        background-color : lightblue;
                    }
        """

        # Inserimento e impostazioni grafiche dell'immagine dello sfondo della finestra.
        self.imagePath = "Image/foto.png"
        self.image = QImage(self.imagePath)
        self.label = QLabel(self)
        self.label.setPixmap(QPixmap.fromImage(self.image))
        self.label.setScaledContents(True)
        self.label.setGeometry(0, 0, 1000, 550)

        # Inserimento e impostazioni grafiche dell'etichetta 'Nuova Prenotazione'.
        self.label = QLabel(self)
        self.font = QFont("Arial", 18, QFont.Bold)
        self.label.setText("Nuova Prenotazione")
        self.label.setFont(self.font)
        self.label.setGeometry(50, 55, 350, 40)
        self.label.setStyleSheet('background-color: transparent')

        # Inserimento e impostazioni grafiche del frame nella finestra.
        self.frame = QFrame(self)
        self.frame.setStyleSheet(self.stylesheet_frame)
        self.frame.setGeometry(50, 100, 900, 280)

        # Usa la funzione 'create_label1' per creare due etichette.
        self.create_label1("Cliente", 150)
        self.create_label1("Tipo", 250)

        # Inserimento e impostazioni grafiche dell'etichetta 'Data'.
        self.label_edit = QLabel(self)
        self.label_edit.setText("Data")
        self.label_edit.setGeometry(500, 150, 100, 20)
        self.label_edit.setStyleSheet(self.stylesheet_label)
        self.font_label1 = QFont("Times", 9)
        self.label_edit.setFont(self.font_label1)

        # Inserimento e impostazioni grafiche del menù a tendina contenente la lista dei cliente
        # che non hanno effettuato alcuna prenotazione.
        self.edit_cliente = QComboBox(self)
        for cliente in self.controller_clienti.get_lista_clienti():
            self.controller_cliente = ControllerCliente(cliente)
            if self.controller_cliente.get_esame_teorico() == "None" or \
                    self.controller_cliente.get_esame_pratico() == "None":
                if self.controller_cliente.get_id() != "None":
                    self.edit_cliente.addItem(self.controller_cliente.get_nome() + " " + \
                                              self.controller_cliente.get_cognome())
        self.edit_cliente.setGeometry(250, 150, 200, 30)
        self.edit_cliente.setStyleSheet(self.stylesheet_label)

        # Inserimento e impostazioni grafiche del menù a tendina contenente la lista dei servizi
        # per cui è possibile effettuare un pagamento.
        self.edit_tipo = QComboBox(self)
        self.edit_tipo.addItem("Lezione", self.get_data("Lezione"))
        self.edit_tipo.addItem("Esame teorico", self.get_data("Esame teorico"))
        self.edit_tipo.addItem("Lezione guida", self.get_data("Lezione guida"))
        self.edit_tipo.addItem("Esame pratico", self.get_data("Esame pratico"))
        self.edit_tipo.setGeometry(250, 250, 200, 30)
        self.edit_tipo.setStyleSheet(self.stylesheet_label)

        # Inserimento e impostazioni grafiche del menù a tendina contenente le dati per cui
        # è possibile prenotarsi.
        self.edit_data = QComboBox(self)
        self.edit_data.setStyleSheet(self.stylesheet_label)
        self.edit_data.setGeometry(600, 150, 200, 30)

        # In base al servizio scelto vengono cambiate le dati per cui è possibile prenotarsi.
        self.edit_tipo.currentIndexChanged.connect(self.update_data)
        self.update_data(self.edit_tipo.currentIndex())

        # Inserimento e impostazioni grafiche del bottone per tornare alla vista precedente.
        self.button_back = QPushButton(self)
        self.button_back.setIcon(QIcon('Image/back.png'))
        self.button_back.setIconSize(QSize(90, 90))
        self.button_back.setGeometry(50, 420, 90, 90)
        self.button_back.setStyleSheet(self.stylesheet_button_back)
        self.button_back.clicked.connect(self.go_back)

        # Inserimento e impostazioni grafiche del bottone che permette di confermare la prenotazione.
        self.button_new_prenotazione = QPushButton(self)
        self.button_new_prenotazione.setText("Salva")
        self.font_button = QFont("Arial", 11)
        self.button_new_prenotazione.setFont(self.font_button)
        self.button_new_prenotazione.setGeometry(800, 440, 120, 50)
        self.button_new_prenotazione.setStyleSheet(self.stylesheet_button)
        self.button_new_prenotazione.clicked.connect(self.salva_prenotazione)

        # Impostazioni grafiche generali della finestra del programma.
        self.setWindowTitle("Nuova Prenotazione")
        self.setStyleSheet(self.stylesheet_window)
        self.resize(1000, 550)
        self.setFixedSize(self.size())
示例#22
0
    def createUI(self):
        """Set up the user interface, signals & slots
        """
        self.widget = QWidget(self)
        self.setCentralWidget(self.widget)

        # In this widget, the video will be drawn
        if sys.platform == "darwin":  # for MacOS
            from PyQt5.QtWidgets import QMacCocoaViewContainer
            self.videoframe = QMacCocoaViewContainer(0)
        else:
            self.videoframe = QFrame()
        self.palette = self.videoframe.palette()
        self.palette.setColor(QPalette.Window, QColor(0, 0, 0))
        self.videoframe.setPalette(self.palette)
        self.videoframe.setAutoFillBackground(True)
        self.label = QtWidgets.QLabel(self.videoframe)
        #self.label.setGeometry(QtCore.QRect(0, 0, 1024, 631))
        self.label.setText("")
        self.label.setScaledContents(True)
        self.label.setObjectName("label")

        #         self.positionslider = QSlider(Qt.Horizontal, self)
        #         self.positionslider.setToolTip("Position")
        #         self.positionslider.setMaximum(1000)
        #         self.positionslider.sliderMoved.connect(self.setPosition)
        #
        #         self.hbuttonbox = QHBoxLayout()
        #         self.playbutton = QPushButton("Play")
        #         self.hbuttonbox.addWidget(self.playbutton)
        #         self.playbutton.clicked.connect(self.PlayPause)
        #
        #         self.stopbutton = QPushButton("Stop")
        #         self.hbuttonbox.addWidget(self.stopbutton)
        #         self.stopbutton.clicked.connect(self.Stop)
        #
        #         self.hbuttonbox.addStretch(1)
        #         self.volumeslider = QSlider(Qt.Horizontal, self)
        #         self.volumeslider.setMaximum(100)
        #         self.volumeslider.setValue(self.mediaplayer.audio_get_volume())
        #         self.volumeslider.setToolTip("Volume")
        #         self.hbuttonbox.addWidget(self.volumeslider)
        #         self.volumeslider.valueChanged.connect(self.setVolume)

        self.vboxlayout = QVBoxLayout()
        self.vboxlayout.setContentsMargins(0, 0, 0, 0)
        self.videoframe.setStyleSheet(
            "background: black; border: 0px; padding: 0px;")

        self.vboxlayout.addWidget(self.videoframe)
        #         self.vboxlayout.addWidget(self.positionslider)
        #         self.vboxlayout.addLayout(self.hbuttonbox)

        self.widget.setLayout(self.vboxlayout)

        #         open = QAction("&Open", self)
        #         open.triggered.connect(self.OpenFile)
        #         exit = QAction("&Exit", self)
        #         exit.triggered.connect(sys.exit)
        #         menubar = self.menuBar()
        #         filemenu = menubar.addMenu("&File")
        #         #filemenu.addAction(open)
        #         filemenu.addSeparator()
        #         filemenu.addAction(exit)

        self.timer = QTimer(self)
        self.timer.setInterval(200)
        self.timer.timeout.connect(self.updateUI)
示例#23
0
    def on_initial_btnSave_clicked(self):
        #print('вах')
        #global name_edit_list, type_edit_list, constructFrom_edit_list, set_edit_list
        #, pointSync_edit
        self.tab.removeTab(1)
        pn = self.patch_numb_edit.value()
        patches_grid = QGridLayout()
        patches_lbl = QLabel()

        pointSync_lbl = QLabel()
        self.pointSync_edit = QComboBox()
        self.pointSync_edit.setFixedSize(150, 25)
        pointSync_list = ['false', 'true']
        self.pointSync_edit.addItems(pointSync_list)
        pointSync_hbox = QHBoxLayout()
        pointSync_hbox.addWidget(pointSync_lbl)
        pointSync_hbox.addWidget(self.pointSync_edit)

        patches_grid.addWidget(patches_lbl,
                               0,
                               0,
                               alignment=QtCore.Qt.AlignCenter)
        patches_grid.addLayout(pointSync_hbox,
                               1,
                               0,
                               alignment=QtCore.Qt.AlignCenter)

        k = 1
        v = 2
        self.name_edit_list = []
        self.type_edit_list = []
        self.constructFrom_edit_list = []
        self.set_edit_list = []

        while k <= pn:

            name_lbl = QLabel()
            name_hbox = QHBoxLayout()
            name_edit = QLineEdit()
            name_edit.setFixedSize(150, 25)
            name_hbox.addWidget(name_lbl)
            name_hbox.addWidget(name_edit)

            type_lbl = QLabel()
            type_hbox = QHBoxLayout()
            type_edit = QComboBox()
            type_edit.setFixedSize(150, 25)
            type_list = ["patch"]
            type_edit.addItems(type_list)
            type_hbox.addWidget(type_lbl)
            type_hbox.addWidget(type_edit)

            constructFrom_lbl = QLabel()
            constructFrom_hbox = QHBoxLayout()
            constructFrom_edit = QComboBox()
            constructFrom_edit.setFixedSize(110, 25)
            constructFrom_list = ["set"]
            constructFrom_edit.addItems(constructFrom_list)
            constructFrom_hbox.addWidget(constructFrom_lbl)
            constructFrom_hbox.addWidget(constructFrom_edit)

            set_lbl = QLabel()
            set_hbox = QHBoxLayout()
            set_edit = QLineEdit()
            set_edit.setFixedSize(140, 25)
            set_hbox.addWidget(set_lbl)
            set_hbox.addWidget(set_edit)

            self.name_edit_list.append(name_edit)
            self.type_edit_list.append(type_edit)
            self.constructFrom_edit_list.append(constructFrom_edit)
            self.set_edit_list.append(set_edit)

            patch_grid = QGridLayout()
            patch_grid.addLayout(name_hbox, 0, 0)
            patch_grid.addLayout(type_hbox, 1, 0)
            patch_grid.addLayout(constructFrom_hbox, 2, 0)
            patch_grid.addLayout(set_hbox, 3, 0)

            patch_frame = QFrame()
            patch_frame.setFixedSize(250, 130)
            patch_frame.setLayout(patch_grid)

            if self.interface_lng_val == 'Russian':

                name_lbl.setText("Имя патча:")
                type_lbl.setText("Тип патча:")
                constructFrom_lbl.setText("Конструирование:")
                set_lbl.setText("Поверхность:")

            elif self.interface_lng_val == 'English':

                name_lbl.setText("Patch name:")
                type_lbl.setText("Patch type:")
                constructFrom_lbl.setText("Construct from:")
                set_lbl.setText("Face set:")

            patches_grid.addWidget(patch_frame,
                                   v,
                                   0,
                                   alignment=QtCore.Qt.AlignCenter)

            k += 1
            v += 1

        patches_btnSave = QPushButton()
        patches_btnSave.setFixedSize(80, 25)

        buttons_hbox = QHBoxLayout()
        buttons_hbox.addWidget(patches_btnSave)

        patches_grid.addLayout(buttons_hbox,
                               len(self.name_edit_list) + 3,
                               0,
                               alignment=QtCore.Qt.AlignCenter)
        patches_grid.setRowStretch(3, 6)

        patches_group = QGroupBox()
        patches_group.setLayout(patches_grid)

        self.tab.insertTab(1, patches_group, "&new_patches")
        patches_btnSave.clicked.connect(self.on_patches_btnSave_clicked)

        if self.interface_lng_val == 'Russian':
            patches_lbl.setText("Укажите параметры патчей")
            patches_btnSave.setText("Записать")
            msg = 'Начальные данные сохранены'
            pointSync_lbl.setText("Точка синхронизации:")

        elif self.interface_lng_val == 'English':
            patches_btnSave.setText("Write")
            msg = 'Initial data saved'
            patches_lbl.setText("Set patches parameters")
            pointSync_lbl.setText("Synchronization point:")

        self.par.listWidget.clear()
        msg_lbl = QLabel('<span style="color:green">' + msg + '</span>')
        self.par.item = QListWidgetItem()
        self.par.listWidget.addItem(self.par.item)
        self.par.listWidget.setItemWidget(self.par.item, msg_lbl)
    def contenu(self):
        # || c'est le button pour envoyer les emails ||
        self.my_button = QPushButton("Envoyer !", self)
        self.my_button.setGeometry(QRect(555, 405, 70, 50))
        self.my_button.setObjectName("envoyer")
        self.my_button.setEnabled(False)
        self.my_button.clicked.connect(self.on_click)

        #  || c'est le button pour afficher a propos ||
        self.apropos_button = QPushButton("à propos", self)
        self.apropos_button.setGeometry(QRect(460, 405, 75, 25))
        self.apropos_button.setObjectName("apropos")
        self.apropos_button.clicked.connect(self.apropos)

        # || c'est le button pour afficher les limitations ||
        self.limitation_button = QPushButton("Limitations", self)
        self.limitation_button.setGeometry(QRect(460, 430, 75, 25))
        self.limitation_button.setObjectName("limit")
        self.limitation_button.clicked.connect(self.limitation)

        # || c'est une barre de progres (les emails envoyés) ||
        self.progres = QProgressBar(self)
        self.progres.setGeometry(QRect(10, 425, 400, 30))

        # || c'est pour l'effet Drag and Drop (Trainez puis Relacher) ||
        self.trainez = DnD(self)
        self.trainez.setAcceptDrops(True)
        self.trainez.setText("Trainez votre Fichier .xlsx ici")

        font = QFont()
        font.setPointSize(10)
        self.trainez.setFont(font)

        self.trainez.setAlignment(Qt.AlignCenter)
        self.trainez.setGeometry(QRect(10, 10, 258, 212))
        self.trainez.setStyleSheet("QLabel{border: 4px dashed #aaa}")
        self.trainez.setObjectName("leffet_dnd")

        # || c'est pour savoir combien de lignes ||
        self.ch7al = QLabel(self)
        self.ch7al.setGeometry(QRect(285, 390, 30, 30))

        # || c'est pour Introduire un l'email ||
        self.avoir_email = QLineEdit(self)
        self.avoir_email.setGeometry(QRect(10, 240, 284, 31))
        self.avoir_email.setObjectName("pour_email")

        font = QFont()
        font.setPointSize(12)
        self.avoir_email.setFont(font)

        self.avoir_email.setText("")
        self.avoir_email.setPlaceholderText("Email")

        # || c'est pour Introduire le mot de passe pour l'email ||
        self.avoir_mot_de_passe = QLineEdit(self)
        self.avoir_mot_de_passe.setGeometry(QRect(10, 280, 284, 31))
        self.avoir_mot_de_passe.setObjectName("pour_mot_de_passe")

        font = QFont()
        font.setPointSize(12)
        self.avoir_mot_de_passe.setFont(font)

        self.avoir_mot_de_passe.setText("")
        self.avoir_mot_de_passe.setPlaceholderText("Mot de passe")
        self.avoir_mot_de_passe.setEchoMode(QLineEdit.Password)

        # || c'est pour le choix du serveur SMTP ||
        self.choisir_serveur = QComboBox(self)
        self.choisir_serveur.setGeometry(QRect(20, 325, 250, 31))
        self.choisir_serveur.setObjectName("Serveur")

        font = QFont()
        font.setPointSize(12)
        self.choisir_serveur.setFont(font)

        self.choisir_serveur.addItem("Choisissez Votre Serveur SMTP")
        self.choisir_serveur.addItem("Gmail")
        self.choisir_serveur.addItem("Outlook")
        self.choisir_serveur.addItem("Yahoo")

        # || c'est pour le choix de la feuille du travail ||
        text_feuille = QLabel("Choisissez Votre xlsx feuille", self)
        text_feuille.setGeometry(QRect(20, 360, 250, 31))
        font = QFont()
        font.setPointSize(12)
        text_feuille.setFont(font)
        # || c'est pour le choix de la feuille du travail ||
        self.choisir_feuille = QComboBox(self)
        self.choisir_feuille.setGeometry(QRect(20, 390, 250, 31))
        self.choisir_feuille.setObjectName("Feuilles")
        self.choisir_feuille.setEnabled(False)
        self.choisir_feuille.activated.connect(self.charger_ch7al)
        font = QFont()
        font.setPointSize(12)
        self.choisir_feuille.setFont(font)

        # || c'est pour les notes supplimentaires ||
        self.notabene = QPlainTextEdit(self)
        self.notabene.setGeometry(QRect(310, 20, 300, 90))
        self.notabene.setObjectName("pourconsultation")

        font = QFont()
        font.setPointSize(12)
        self.notabene.setFont(font)

        self.notabene.setPlaceholderText(
            "Ajouter des Notes; commme pour \n la date de la Consultation")
        self.notabene.setAcceptDrops(False)

        # || c'est pour choisir les information à envoyer au étudiant ||
        self.les_colonnes = QFrame(
            self)  # construire une FRAME special pour les CheckBox
        self.les_colonnes.setGeometry(QRect(310, 120, 300, 270))
        ## self.les_colonnes.setStyleSheet("background-color: rgb(255, 255, 255);")

        self.titre_des_checks = QLabel(
            "Choisir les informations à envoyer a \n vos étudiants : ",
            self.les_colonnes)
        font = QFont()
        font.setPointSize(10)
        self.titre_des_checks.setFont(font)
        ## self.les_colonnes.setGeometry(QRect(0, 0, 200, 60))

        self.examen = QCheckBox("examen", self.les_colonnes)
        self.examen.setGeometry(QRect(5, 30, 150, 30))

        self.rattrapage = QCheckBox("Rattrapage", self.les_colonnes)
        self.rattrapage.setGeometry(QRect(5, 60, 150, 30))

        self.exam_de_remp = QCheckBox("examen de remplaçement",
                                      self.les_colonnes)
        self.exam_de_remp.setGeometry(QRect(5, 90, 150, 30))

        self.assiduity = QCheckBox("L'assiduité", self.les_colonnes)
        self.assiduity.setGeometry(QRect(5, 120, 150, 30))

        self.presence = QCheckBox("La présence", self.les_colonnes)
        self.presence.setGeometry(QRect(5, 150, 150, 30))

        self.test_01 = QCheckBox("Test 01", self.les_colonnes)
        self.test_01.setGeometry(QRect(5, 180, 150, 30))

        self.test_02 = QCheckBox("Test 02", self.les_colonnes)
        self.test_02.setGeometry(QRect(75, 180, 150, 30))

        self.test_03 = QCheckBox("Test 03", self.les_colonnes)
        self.test_03.setGeometry(QRect(145, 180, 150, 30))

        self.test_04 = QCheckBox("Test 04", self.les_colonnes)
        self.test_04.setGeometry(QRect(215, 180, 150, 30))

        self.moy_des_tests = QCheckBox("Moyenne des tests", self.les_colonnes)
        self.moy_des_tests.setGeometry(QRect(5, 210, 150, 30))

        self.mean = QCheckBox("La moyenne génerale", self.les_colonnes)
        self.mean.setGeometry(QRect(5, 240, 150, 30))
示例#25
0
    def __init__(self,
                 show=True,
                 app=None,
                 window_size=None,
                 off_screen=None,
                 **kwargs):
        """Initialize the qt plotter."""
        if not has_pyqt:
            raise AssertionError('Requires PyQt5')
        self.active = True
        self.counters = []

        if window_size is None:
            window_size = rcParams['window_size']

        # Remove notebook argument in case user passed it
        kwargs.pop('notebook', None)

        # ipython magic
        if scooby.in_ipython():  # pragma: no cover
            from IPython import get_ipython
            ipython = get_ipython()
            ipython.magic('gui qt')

            from IPython.external.qt_for_kernel import QtGui
            QtGui.QApplication.instance()
        else:
            ipython = None

        # run within python
        if app is None:
            from PyQt5.QtWidgets import QApplication
            app = QApplication.instance()
            if not app:  # pragma: no cover
                app = QApplication([''])

        self.app = app
        self.app_window = MainWindow()
        self.app_window.setWindowTitle(kwargs.get('title', rcParams['title']))

        self.frame = QFrame()
        self.frame.setFrameStyle(QFrame.NoFrame)

        super(BackgroundPlotter, self).__init__(parent=self.frame,
                                                off_screen=off_screen,
                                                **kwargs)
        self.app_window.signal_close.connect(self._close)
        self.add_toolbars(self.app_window)

        # build main menu
        self.main_menu = QMenuBar(parent=self.app_window)
        self.app_window.setMenuBar(self.main_menu)
        self.app_window.signal_close.connect(self.main_menu.clear)

        file_menu = self.main_menu.addMenu('File')
        file_menu.addAction('Take Screenshot', self._qt_screenshot)
        file_menu.addAction('Export as VTKjs', self._qt_export_vtkjs)
        file_menu.addSeparator()
        file_menu.addAction('Exit', self.app_window.close)

        view_menu = self.main_menu.addMenu('View')
        view_menu.addAction('Toggle Eye Dome Lighting', self._toggle_edl)
        view_menu.addAction('Scale Axes', self.scale_axes_dialog)
        view_menu.addAction('Clear All', self.clear)

        tool_menu = self.main_menu.addMenu('Tools')
        tool_menu.addAction('Enable Cell Picking (through)',
                            self.enable_cell_picking)
        tool_menu.addAction('Enable Cell Picking (visible)',
                            lambda: self.enable_cell_picking(through=False))

        cam_menu = view_menu.addMenu('Camera')
        cam_menu.addAction('Toggle Parallel Projection',
                           self._toggle_parallel_projection)

        view_menu.addSeparator()
        # Orientation marker
        orien_menu = view_menu.addMenu('Orientation Marker')
        orien_menu.addAction('Show All', self.show_axes_all)
        orien_menu.addAction('Hide All', self.hide_axes_all)
        # Bounds axes
        axes_menu = view_menu.addMenu('Bounds Axes')
        axes_menu.addAction('Add Bounds Axes (front)', self.show_bounds)
        axes_menu.addAction('Add Bounds Grid (back)', self.show_grid)
        axes_menu.addAction('Add Bounding Box', self.add_bounding_box)
        axes_menu.addSeparator()
        axes_menu.addAction('Remove Bounding Box', self.remove_bounding_box)
        axes_menu.addAction('Remove Bounds', self.remove_bounds_axes)

        # A final separator to separate OS options
        view_menu.addSeparator()

        vlayout = QVBoxLayout()
        vlayout.addWidget(self.interactor)

        self.frame.setLayout(vlayout)
        self.app_window.setCentralWidget(self.frame)

        if off_screen is None:
            off_screen = pyvista.OFF_SCREEN

        if show and not off_screen:  # pragma: no cover
            self.app_window.show()
            self.show()

        self._spawn_background_rendering()

        self.window_size = window_size
        self._last_update_time = time.time(
        ) - BackgroundPlotter.ICON_TIME_STEP / 2
        self._last_window_size = self.window_size
        self._last_camera_pos = self.camera_position

        self.add_callback(self.update_app_icon)

        # Keypress events
        self.add_key_event("S", self._qt_screenshot)  # shift + s
示例#26
0
def getHLine():
    devideLine = QFrame()
    devideLine.setFrameShape(QFrame.HLine)
    devideLine.setMaximumHeight(1)
    return devideLine
示例#27
0
    def initUI(self):
        screen = QApplication.desktop().screenNumber(
            QApplication.desktop().cursor().pos())
        centerPoint = QApplication.desktop().screenGeometry(screen).center()

        # should fit in 1024x768 (old computer screens)
        window_width = 900
        window_height = 700
        self.setGeometry(
            QtCore.QRect(
                centerPoint.x() - int(window_width / 2),
                centerPoint.y() - int(window_height / 2), window_width,
                window_height))  # should I rather center on the screen

        # zoom parameters
        self.scale = 1.0
        self.min_scaling_factor = 0.1
        self.max_scaling_factor = 20
        self.zoom_increment = 0.05

        self.setWindowTitle(__NAME__ + ' v' + str(__VERSION__))

        self.paint = Createpaintwidget()

        # initiate 2D image for 2D display
        self.img = None

        self.list = QListWidget(
            self)  # a list that contains files to read or play with
        self.list.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.list.selectionModel().selectionChanged.connect(
            self.selectionChanged)  # connect it to sel change

        self.scrollArea = QScrollArea()
        self.scrollArea.setBackgroundRole(QPalette.Dark)
        self.scrollArea.setWidget(self.paint)
        self.paint.scrollArea = self.scrollArea

        self.table_widget = QWidget()
        table_widget_layout = QVBoxLayout()

        # Initialize tab screen
        self.tabs = QTabWidget(self)
        self.tab1 = QWidget()
        self.tab2 = QWidget()
        self.tab3 = QWidget()

        # Add tabs
        self.tabs.addTab(self.tab1, "Mask neuron")
        self.tabs.addTab(self.tab2, "Mask cell body")
        self.tabs.addTab(self.tab3, "Segment dendrites")

        # listen to tab changes
        self.tabs.currentChanged.connect(self._onTabChange)

        # Create first tab
        self.tab1.layout = QGridLayout()
        self.tab1.layout.setAlignment(Qt.AlignTop)
        self.tab1.layout.setHorizontalSpacing(3)
        self.tab1.layout.setVerticalSpacing(3)
        self.tab1.layout.setContentsMargins(0, 0, 0, 0)

        label1_tab1 = QLabel('Step 1:')
        self.tab1.layout.addWidget(label1_tab1, 0, 0)

        self.local_threshold = QPushButton("Local threshold")
        self.local_threshold.clicked.connect(self.run_threshold_neuron)
        self.tab1.layout.addWidget(self.local_threshold, 0, 1)
        self.global_threshold = QPushButton("Global threshold")
        self.global_threshold.clicked.connect(self.run_threshold_neuron)
        self.tab1.layout.addWidget(self.global_threshold, 0, 2)
        self.local_n_global_threshold = QPushButton(
            "Local AND Global threshold")
        self.local_n_global_threshold.clicked.connect(
            self.run_threshold_neuron)
        self.tab1.layout.addWidget(self.local_n_global_threshold, 0, 3)

        self.extra_value_for_threshold = QSpinBox()
        self.extra_value_for_threshold.setSingleStep(1)
        self.extra_value_for_threshold.setRange(0, 1_000_000)
        self.extra_value_for_threshold.setValue(6)
        self.tab1.layout.addWidget(self.extra_value_for_threshold, 0, 4)

        self.threshold_method = QComboBox()
        self.threshold_method.addItem('Mean')
        self.threshold_method.addItem('Median')
        self.tab1.layout.addWidget(self.threshold_method, 0, 5)

        label2_tab1 = QLabel('Step 2 (optional):')
        self.tab1.layout.addWidget(label2_tab1, 1, 0)

        self.remove_pixel_blobs_smaller_or_equal = QPushButton(
            "Remove pixel blobs smaller or equal to")
        self.remove_pixel_blobs_smaller_or_equal.clicked.connect(
            self.remove_blobs)
        self.tab1.layout.addWidget(self.remove_pixel_blobs_smaller_or_equal, 1,
                                   1)

        self.remove_blobs_size = QSpinBox()
        self.remove_blobs_size.setSingleStep(1)
        self.remove_blobs_size.setRange(0, 1_000_000)
        self.remove_blobs_size.setValue(1)
        self.tab1.layout.addWidget(self.remove_blobs_size, 1, 2)

        label3_tab1 = QLabel('Step 3: Save')
        self.tab1.layout.addWidget(label3_tab1, 2, 0)

        self.tab1.setLayout(self.tab1.layout)

        self.tab2.layout = QGridLayout()
        self.tab2.layout.setAlignment(Qt.AlignTop)
        self.tab2.layout.setHorizontalSpacing(3)
        self.tab2.layout.setVerticalSpacing(3)
        self.tab2.layout.setContentsMargins(0, 0, 0, 0)

        label1_tab2 = QLabel('Step 1:')
        self.tab2.layout.addWidget(label1_tab2, 0, 0)

        self.detect_cell_body = QPushButton("Detect cell body")
        self.detect_cell_body.clicked.connect(self.detect_neuronal_cell_body)
        self.tab2.layout.addWidget(self.detect_cell_body, 0, 1)

        self.extraCutOff_cell_body = QSpinBox()
        self.extraCutOff_cell_body.setSingleStep(1)
        self.extraCutOff_cell_body.setRange(0, 1_000_000)
        self.extraCutOff_cell_body.setValue(5)
        self.tab2.layout.addWidget(self.extraCutOff_cell_body, 0, 2)

        erosion_label = QLabel('erosion rounds')
        self.tab2.layout.addWidget(erosion_label, 0, 3)

        self.nb_erosion_cellbody = QSpinBox()
        self.nb_erosion_cellbody.setSingleStep(1)
        self.nb_erosion_cellbody.setRange(0, 1_000_000)
        self.nb_erosion_cellbody.setValue(2)
        self.tab2.layout.addWidget(self.nb_erosion_cellbody, 0, 4)

        min_object_size_label = QLabel('minimum object size')
        self.tab2.layout.addWidget(min_object_size_label, 0, 5)

        self.min_obj_size_px = QSpinBox()
        self.min_obj_size_px.setSingleStep(1)
        self.min_obj_size_px.setRange(0, 1_000_000)
        self.min_obj_size_px.setValue(600)
        self.tab2.layout.addWidget(self.min_obj_size_px, 0, 6)

        fill_label = QLabel('fill up to')
        self.tab2.layout.addWidget(fill_label, 0, 7)

        self.fill_holes_up_to = QSpinBox()
        self.fill_holes_up_to.setSingleStep(1)
        self.fill_holes_up_to.setRange(0, 1_000_000)
        self.fill_holes_up_to.setValue(600)
        self.tab2.layout.addWidget(self.fill_holes_up_to, 0, 8)

        nb_dilation_cell_body_label = QLabel('nb dilation cell body')
        self.tab2.layout.addWidget(nb_dilation_cell_body_label, 0, 9)

        self.nb_dilation_cellbody = QSpinBox()
        self.nb_dilation_cellbody.setSingleStep(1)
        self.nb_dilation_cellbody.setRange(0, 1_000_000)
        self.nb_dilation_cellbody.setValue(2)
        self.tab2.layout.addWidget(self.nb_dilation_cellbody, 0, 10)

        label2_tab2 = QLabel('Step 2: Save')
        self.tab2.layout.addWidget(label2_tab2, 6, 0)

        self.tab2.setLayout(self.tab2.layout)

        self.tab3.layout = QGridLayout()
        self.tab3.layout.setAlignment(Qt.AlignTop)
        self.tab3.layout.setHorizontalSpacing(3)
        self.tab3.layout.setVerticalSpacing(3)
        self.tab3.layout.setContentsMargins(0, 0, 0, 0)

        label1_tab3 = QLabel('Step 1:')
        self.tab3.layout.addWidget(label1_tab3, 0, 0)

        self.wshed = QPushButton("Watershed")
        self.wshed.clicked.connect(self.watershed_segment_the_neuron)
        self.tab3.layout.addWidget(self.wshed, 0, 1)

        self.whsed_big_blur = QDoubleSpinBox()
        self.whsed_big_blur.setSingleStep(0.1)
        self.whsed_big_blur.setRange(0, 100)
        self.whsed_big_blur.setValue(2.1)
        self.tab3.layout.addWidget(self.whsed_big_blur, 0, 2)

        self.whsed_small_blur = QDoubleSpinBox()
        self.whsed_small_blur.setSingleStep(0.1)
        self.whsed_small_blur.setRange(0, 100)
        self.whsed_small_blur.setValue(1.4)
        self.tab3.layout.addWidget(self.whsed_small_blur, 0, 3)

        self.wshed_rm_small_cells = QSpinBox()
        self.wshed_rm_small_cells.setSingleStep(1)
        self.wshed_rm_small_cells.setRange(0, 1_000_000)
        self.wshed_rm_small_cells.setValue(10)
        self.tab3.layout.addWidget(self.wshed_rm_small_cells, 0, 4)

        self.jSpinner11 = QSpinBox()
        self.jSpinner11.setSingleStep(1)
        self.jSpinner11.setRange(0, 1_000_000)
        self.jSpinner11.setValue(10)
        self.tab3.layout.addWidget(self.jSpinner11, 0, 5)

        label1_bis_tab3 = QLabel('Alternative Step 1:')
        self.tab3.layout.addWidget(label1_bis_tab3, 1, 0)

        self.skel = QPushButton("Skeletonize")
        self.skel.clicked.connect(self.skeletonize_mask)
        self.tab3.layout.addWidget(self.skel, 1, 1)

        label2_tab3 = QLabel('Step 2:')
        self.tab3.layout.addWidget(label2_tab3, 2, 0)

        self.apply_cell_body = QPushButton("Apply cell body")
        self.apply_cell_body.clicked.connect(
            self.apply_cell_body_to_skeletonized_mask)
        self.tab3.layout.addWidget(self.apply_cell_body, 2, 1)

        label3_tab3 = QLabel('Step 3 (Optional):')
        self.tab3.layout.addWidget(label3_tab3, 3, 0)

        self.prune = QPushButton("Prune")
        self.prune.clicked.connect(self.prune_dendrites)
        self.tab3.layout.addWidget(self.prune, 3, 1)

        self.prune_length = QSpinBox()
        self.prune_length.setSingleStep(1)
        self.prune_length.setRange(0, 1_000_000)
        self.prune_length.setValue(3)
        self.tab3.layout.addWidget(self.prune_length, 3, 2)

        label4_tab3 = QLabel('Step 4 (Optional):')
        self.tab3.layout.addWidget(label4_tab3, 4, 0)

        self.find_neurons = QPushButton("Find neurons")
        self.find_neurons.clicked.connect(self.find_neurons_in_mask)
        self.tab3.layout.addWidget(self.find_neurons, 4, 1)

        self.find_neurons_min_size = QSpinBox()
        self.find_neurons_min_size.setSingleStep(1)
        self.find_neurons_min_size.setRange(0, 1_000_000)
        self.find_neurons_min_size.setValue(45)
        self.tab3.layout.addWidget(self.find_neurons_min_size, 4, 2)

        self.prune_unconnected_segments = QPushButton(
            "Prune unconnected segments (run 'Find neurons' first)")
        self.prune_unconnected_segments.clicked.connect(
            self.prune_neuron_unconnected_segments)
        self.tab3.layout.addWidget(self.prune_unconnected_segments, 4, 3)

        label6_tab3 = QLabel('Step 5: Save')
        self.tab3.layout.addWidget(label6_tab3, 5, 0)

        label5_tab3 = QLabel('Step 6:')
        self.tab3.layout.addWidget(label5_tab3, 6, 0)

        self.create_n_save_bonds = QPushButton("Segment dendrites")
        self.create_n_save_bonds.clicked.connect(self.save_segmented_bonds)
        self.tab3.layout.addWidget(self.create_n_save_bonds, 6, 1)

        self.tab3.setLayout(self.tab3.layout)

        # Add tabs to widget
        table_widget_layout.addWidget(self.tabs)
        self.table_widget.setLayout(table_widget_layout)

        self.Stack = QStackedWidget(self)
        self.Stack.addWidget(self.scrollArea)

        # create a grid that will contain all the GUI interface
        self.grid = QGridLayout()
        self.grid.addWidget(self.Stack, 0, 0)
        self.grid.addWidget(self.list, 0, 1)
        # The first parameter of the rowStretch method is the row number, the second is the stretch factor. So you need two calls to rowStretch, like this: --> below the first row is occupying 80% and the second 20%
        self.grid.setRowStretch(0, 75)
        self.grid.setRowStretch(2, 25)

        # first col 75% second col 25% of total width
        self.grid.setColumnStretch(0, 75)
        self.grid.setColumnStretch(1, 25)

        # void QGridLayout::addLayout(QLayout * layout, int row, int column, int rowSpan, int columnSpan, Qt::Alignment alignment = 0)
        self.grid.addWidget(self.table_widget, 2, 0, 1,
                            2)  # spans over one row and 2 columns

        # BEGIN TOOLBAR
        # pen spin box and connect
        self.penSize = QSpinBox()
        self.penSize.setSingleStep(1)
        self.penSize.setRange(1, 256)
        self.penSize.setValue(3)
        self.penSize.valueChanged.connect(self.penSizechange)

        self.channels = QComboBox()
        self.channels.addItem("merge")
        self.channels.currentIndexChanged.connect(self.channelChange)

        tb_drawing_pane = QToolBar()

        save_button = QToolButton()
        save_button.setText("Save")
        save_button.clicked.connect(self.save_current_mask)
        tb_drawing_pane.addWidget(save_button)

        tb_drawing_pane.addWidget(QLabel("Channels"))
        tb_drawing_pane.addWidget(self.channels)

        # tb.addAction("Save")
        #
        tb_drawing_pane.addWidget(QLabel("Pen size"))
        tb_drawing_pane.addWidget(self.penSize)

        self.grid.addWidget(tb_drawing_pane, 1, 0)
        # END toolbar

        # toolbar for the list
        tb_list = QToolBar()

        del_button = QToolButton()
        del_button.setText("Delete selection from list")
        del_button.clicked.connect(self.delete_from_list)
        tb_list.addWidget(del_button)

        self.grid.addWidget(tb_list, 1, 1)

        # self.setCentralWidget(self.scrollArea)
        self.setCentralWidget(QFrame())
        self.centralWidget().setLayout(self.grid)

        # self.statusBar().showMessage('Ready')
        statusBar = self.statusBar(
        )  # sets an empty status bar --> then can add messages in it
        self.paint.statusBar = statusBar

        # add progress bar to status bar
        self.progress = QProgressBar(self)
        self.progress.setGeometry(200, 80, 250, 20)
        statusBar.addWidget(self.progress)

        # Set up menu bar
        self.mainMenu = self.menuBar()

        self.zoomInAct = QAction(
            "Zoom &In (25%)",
            self,  # shortcut="Ctrl++",
            enabled=True,
            triggered=self.zoomIn)
        self.zoomOutAct = QAction(
            "Zoom &Out (25%)",
            self,  # shortcut="Ctrl+-",
            enabled=True,
            triggered=self.zoomOut)
        self.normalSizeAct = QAction(
            "&Normal Size",
            self,  # shortcut="Ctrl+S",
            enabled=True,
            triggered=self.defaultSize)

        self.viewMenu = QMenu("&View", self)
        self.viewMenu.addAction(self.zoomInAct)
        self.viewMenu.addAction(self.zoomOutAct)
        self.viewMenu.addAction(self.normalSizeAct)

        self.menuBar().addMenu(self.viewMenu)

        self.setMenuBar(self.mainMenu)

        # set drawing window fullscreen
        fullScreenShortcut = QtWidgets.QShortcut(
            QtGui.QKeySequence(QtCore.Qt.Key_F), self)
        fullScreenShortcut.activated.connect(self.fullScreen)
        fullScreenShortcut.setContext(QtCore.Qt.ApplicationShortcut)

        escapeShortcut = QtWidgets.QShortcut(
            QtGui.QKeySequence(QtCore.Qt.Key_Escape), self)
        escapeShortcut.activated.connect(self.escape)
        escapeShortcut.setContext(QtCore.Qt.ApplicationShortcut)

        # Show/Hide the mask
        escapeShortcut = QtWidgets.QShortcut(
            QtGui.QKeySequence(QtCore.Qt.Key_H), self)
        escapeShortcut.activated.connect(self.showHideMask)
        escapeShortcut.setContext(QtCore.Qt.ApplicationShortcut)

        zoomPlus = QtWidgets.QShortcut("Ctrl+Shift+=", self)
        zoomPlus.activated.connect(self.zoomIn)
        zoomPlus.setContext(QtCore.Qt.ApplicationShortcut)

        zoomPlus2 = QtWidgets.QShortcut("Ctrl++", self)
        zoomPlus2.activated.connect(self.zoomIn)
        zoomPlus2.setContext(QtCore.Qt.ApplicationShortcut)

        zoomMinus = QtWidgets.QShortcut("Ctrl+Shift+-", self)
        zoomMinus.activated.connect(self.zoomOut)
        zoomMinus.setContext(QtCore.Qt.ApplicationShortcut)

        zoomMinus2 = QtWidgets.QShortcut("Ctrl+-", self)
        zoomMinus2.activated.connect(self.zoomOut)
        zoomMinus2.setContext(QtCore.Qt.ApplicationShortcut)

        spaceShortcut = QtWidgets.QShortcut(
            QtGui.QKeySequence(QtCore.Qt.Key_Space), self)
        spaceShortcut.activated.connect(self.nextFrame)
        spaceShortcut.setContext(QtCore.Qt.ApplicationShortcut)

        backspaceShortcut = QtWidgets.QShortcut(
            QtGui.QKeySequence(QtCore.Qt.Key_Backspace), self)
        backspaceShortcut.activated.connect(self.prevFrame)
        backspaceShortcut.setContext(QtCore.Qt.ApplicationShortcut)

        # connect enter keys to edit dendrites
        enterShortcut = QtWidgets.QShortcut(
            QtGui.QKeySequence(QtCore.Qt.Key_Return), self)
        enterShortcut.activated.connect(self.runSkel)
        enterShortcut.setContext(QtCore.Qt.ApplicationShortcut)
        enter2Shortcut = QtWidgets.QShortcut(
            QtGui.QKeySequence(QtCore.Qt.Key_Enter), self)
        enter2Shortcut.activated.connect(self.runSkel)
        enter2Shortcut.setContext(QtCore.Qt.ApplicationShortcut)

        #Qt.Key_Enter is the Enter located on the keypad:
        #Qt::Key_Return  0x01000004
        #Qt::Key_Enter   0x01000005  Typically located on the keypad.

        self.setAcceptDrops(True)  # KEEP IMPORTANT
示例#28
0
def getVLine():
    devideLine = QFrame()
    devideLine.setFrameShape(QFrame.VLine)
    devideLine.setMaximumWidth(1)
    return devideLine
示例#29
0
    def initUI(self):
        
        browseButton = QPushButton("Browse")
        browseButton.setAutoFillBackground(True)
        browseButton.setMaximumHeight(43)
        saveButton = QPushButton("Browse")
        sortButton = QPushButton("Sort")
        cancelButton = QPushButton("Cancel")
        prefButton = QPushButton("Advanced Options")
        textbox_in = QLineEdit()
        textbox_in.setTextMargins(5, 5, 6, 6)
        textbox_out = QLineEdit()
        textbox_out.setTextMargins(5, 5, 6, 6)
        cat1_num = QLineEdit()
        cat2_num = QLineEdit()
        cat3_num = QLineEdit()
        
        popSlider= QSlider(orientation = Qt.Horizontal)
        popSlider.setTickInterval(20)
        popSlider.setTickPosition(QSlider.TicksBelow)
        popReadout = QLabel('100')
        def updatePopulationSize(n): 
            popReadout.setText(str(n))
        popSlider.valueChanged[int].connect(updatePopulationSize)
        popSlider.setMaximum(500)
        popSlider.setMinimum(50)
        popSlider.setValue(100)
        
        rptSlider= QSlider(orientation = Qt.Horizontal)
        rptSlider.setTickInterval(10)
        rptSlider.setTickPosition(QSlider.TicksBelow)
        rptReadout = QLabel('50')
        def updateRpts(n): 
            rptReadout.setText(str(n))
        rptSlider.valueChanged[int].connect(updateRpts)
        rptSlider.setMaximum(200)
        rptSlider.setMinimum(1)
        rptSlider.setValue(50)
        
        iterSlider= QSlider(orientation = Qt.Horizontal)
        iterSlider.setTickInterval(30)
        iterSlider.setTickPosition(QSlider.TicksBelow)
        iterReadout = QLabel('50')
        def updateIterations(n): 
            iterReadout.setText(str(n))
        iterSlider.valueChanged[int].connect(updateIterations)
        iterSlider.setMaximum(500)
        iterSlider.setMinimum(10)
        iterSlider.setValue(50)
        
        # Set window background color
        self.setAutoFillBackground(True)
        p = self.palette()
        p.setColor(self.backgroundRole(), QColor(50, 40, 60))
                
        brush = QBrush(QColor(200, 200, 200))
        p.setBrush(QPalette.Active, QPalette.WindowText, brush)
        
        brush = QBrush(QColor(0, 100, 0))
        brush.setStyle(Qt.SolidPattern)
        p.setBrush(QPalette.Inactive, QPalette.Button, brush)
        self.setPalette(p)
        
        def selectFile():     
            textbox_in.setText(QFileDialog.getOpenFileName()[0])
            
        def saveFile():     
            textbox_out.setText(QFileDialog.getSaveFileName()[0])        
            
        def runSort():
            input_file = textbox_in.text()
            output_file = textbox_out.text()
            n1 = int(cat1_num.text())
            n2 = int(cat2_num.text())
            n3 = int(cat3_num.text())
            section_counts = [n1,n2,n3]
            
            f = open(input_file, "r")
            lines = f.readlines()
            if sum(section_counts) != len(lines[0].split(',')[5:]):
                print('category counts do not sum up to total options from input file')
                return
            paper_assign(str(input_file), str(output_file), section_counts,
                         population_size=int(popReadout.text()), 
                         num_iterations=int(iterReadout.text()),
                         repeat_all=int(rptReadout.text()))
                
        def showPrefs():
            prefFrame.setHidden(not prefFrame.isHidden())
            self.setFixedSize(self.sizeHint())

        browseButton.clicked.connect(selectFile)
        saveButton.clicked.connect(saveFile)
        sortButton.clicked.connect(runSort)
        prefButton.clicked.connect(showPrefs)
        hboxinst = QHBoxLayout()
        hboxinst.addStretch(2)
        hboxinst.addWidget(QLabel('Number of papers in each category (in order):'))
        hboxinst.addStretch(8)       

        hcatbox1 = QHBoxLayout()
        hcatbox1.addStretch(2)       
        hcatbox1.addWidget(QLabel('1st: '))
        hcatbox1.addWidget(cat1_num,2)
        hcatbox1.addStretch(8)       
        
        hcatbox2 = QHBoxLayout()
        hcatbox2.addStretch(2)       
        hcatbox2.addWidget(QLabel('2nd:'))
        hcatbox2.addWidget(cat2_num,2)
        hcatbox2.addStretch(8)       
        
        hcatbox3 = QHBoxLayout()
        hcatbox3.addStretch(2)       
        hcatbox3.addWidget(QLabel('3rd: '))
        hcatbox3.addWidget(cat3_num,2)
        hcatbox3.addStretch(8)       

        hbox = QHBoxLayout()
        hbox.addWidget(QLabel('Input file:'))
        hbox.addWidget(browseButton,1)
        hbox.addWidget(textbox_in, 10)
        
        hbox1 = QHBoxLayout()
        hbox1.addWidget(QLabel('Output file:'))
        hbox1.addWidget(saveButton,1)
        hbox1.addWidget(textbox_out, 10)
        hbox1.addWidget(sortButton, 2)
   
        hbox2 = QHBoxLayout()
        hbox2.addWidget(QLabel('Population size:'))
        hbox2.addWidget(popSlider)
        hbox2.addWidget(popReadout)
        
        hbox3 = QHBoxLayout()
        hbox3.addWidget(QLabel('Number of iterations:'))
        hbox3.addWidget(iterSlider)
        hbox3.addWidget(iterReadout)
        
        hbox4 = QHBoxLayout()
        hbox4.addWidget(QLabel('Number of repeats:'))
        hbox4.addWidget(rptSlider)
        hbox4.addWidget(rptReadout)
        
      
        vbox1 = QVBoxLayout()
        vbox1.addLayout(hboxinst)
        vbox1.addLayout(hcatbox1)
        vbox1.addLayout(hcatbox2)    
        vbox1.addLayout(hcatbox3)    
        vbox1.addLayout(hbox)    
        vbox1.addLayout(hbox1)   
        vbox1.addWidget(prefButton)
        
        vbox2 = QVBoxLayout()
        vbox2.addLayout(hbox2)  
        vbox2.addLayout(hbox3)  
        vbox2.addLayout(hbox4)  
        prefFrame = QFrame()
        prefFrame.setLayout(vbox2)
        
        vbox = QVBoxLayout()
        vbox.addLayout(vbox1)
        vbox.addWidget(prefFrame)

        prefFrame.setHidden(1)
        self.setLayout(vbox)
        self.setGeometry(300, 300, 300, 220)
        self.setWindowTitle('HKT Paper Sorting')
        self.setWindowIcon(QIcon('sort-hat.ico'))        
        self.show()
    def createDrinks(self):
        self.drinkContainer = QFrame(self)
        self.drinkContainer.setFixedSize(500, 700)

        vbox = QVBoxLayout()
        self.drinkGroup = QGroupBox("اختار مشروبك", self)
        self.drinkGroup.setFont(QFont("urdu Typesetting", 36, 900))
        drinkGrid = QGridLayout()
        self.lblDrink = QLabel("المشروب", self)
        self.lblDrinkPrice = QLabel("السعر(ج.م)", self)
        self.lblDrinkQuantity = QLabel("الكمية", self)
        drinkHeaders = [
            self.lblDrink, self.lblDrinkPrice, self.lblDrinkQuantity
        ]
        for h, head in enumerate(drinkHeaders):
            head.setFont(QFont("urdu Typesetting", 18, 900))
            head.setFixedSize(80, 40)
            head.setAlignment(Qt.AlignCenter)
            head.setStyleSheet(
                "background-color: grey; color: black; border: 1px solid black; border-radius:10px"
            )
            drinkGrid.addWidget(head, 0, h, 1, 1)

        self.chkCappuccino = QCheckBox("كابوتشـــــــــــينو", self)
        self.chkCappuccino.toggled.connect(lambda: self.selectedItem(
            self.chkCappuccino, self.priceCappuccino, self.QCappuccino))
        self.chkEspresso = QCheckBox("إسبريســـــــــو", self)
        self.chkEspresso.toggled.connect(lambda: self.selectedItem(
            self.chkEspresso, self.priceEspresso, self.QEspresso))
        self.chkTurkishCoffee = QCheckBox("قهـــــــوة تركـــي", self)
        self.chkTurkishCoffee.toggled.connect(
            lambda: self.selectedItem(self.chkTurkishCoffee, self.
                                      priceTurkishCoffee, self.QTurkishCoffee))
        self.chkBackTea = QCheckBox("شــــــــــاي أحمــر", self)
        self.chkBackTea.toggled.connect(lambda: self.selectedItem(
            self.chkBackTea, self.priceBlackTea, self.QBlackTea))
        self.chkGreenTea = QCheckBox("شـــــــــاي أخضـــر", self)
        self.chkGreenTea.toggled.connect(lambda: self.selectedItem(
            self.chkGreenTea, self.priceGreenTea, self.QGreenTea))
        self.chkOrangeJuice = QCheckBox("عصيــــــــر برتقـــال", self)
        self.chkOrangeJuice.toggled.connect(lambda: self.selectedItem(
            self.chkOrangeJuice, self.priceOrangeJuice, self.QOrangeJuice))
        self.chkLemonade = QCheckBox("عصيــــــــر ليمـــون", self)
        self.chkLemonade.toggled.connect(lambda: self.selectedItem(
            self.chkLemonade, self.priceLemonade, self.QLemonade))
        self.chGreenApple = QCheckBox("تفــــــــــاح أخضــــر", self)
        self.chGreenApple.toggled.connect(lambda: self.selectedItem(
            self.chGreenApple, self.priceGreenApple, self.QGreenApple))
        self.chkWaterBottle = QCheckBox("زجاجـــــــــة ميـــــاه", self)
        self.chkWaterBottle.toggled.connect(lambda: self.selectedItem(
            self.chkWaterBottle, self.priceWater, self.QWaterBottle))
        chkDrinks = [
            self.chkCappuccino, self.chkEspresso, self.chkTurkishCoffee,
            self.chkBackTea, self.chkGreenTea, self.chkOrangeJuice,
            self.chkLemonade, self.chGreenApple, self.chkWaterBottle
        ]
        chkFont = QFont("Traditional Arabic", 20)
        chkFont.setBold(True)
        # chkColor = QColor(30, 30, 200)
        chkStyle = "padding: 3px"
        for d, drink in enumerate(chkDrinks):
            drink.setFont(chkFont)
            drink.setStyleSheet(chkStyle)
            drinkGrid.addWidget(drink, d + 1, 0, 1, 1)

        self.priceCappuccino = QLabel("27.00", self)
        self.priceEspresso = QLabel("22.00", self)
        self.priceTurkishCoffee = QLabel("15.00", self)
        self.priceBlackTea = QLabel("10.00", self)
        self.priceGreenTea = QLabel("12.00", self)
        self.priceOrangeJuice = QLabel("18.00", self)
        self.priceLemonade = QLabel("18.00", self)
        self.priceGreenApple = QLabel("18.00", self)
        self.priceWater = QLabel("5.00", self)

        lblPrices = [
            self.priceCappuccino, self.priceEspresso, self.priceTurkishCoffee,
            self.priceBlackTea, self.priceGreenTea, self.priceOrangeJuice,
            self.priceLemonade, self.priceGreenApple, self.priceWater
        ]

        for p, price in enumerate(lblPrices):
            price.setFont(chkFont)
            price.setAlignment(Qt.AlignCenter)
            drinkGrid.addWidget(price, p + 1, 1, 1, 1)

        self.QCappuccino = QLineEdit("0", self)
        self.QEspresso = QLineEdit("0", self)
        self.QTurkishCoffee = QLineEdit("0", self)
        self.QBlackTea = QLineEdit("0", self)
        self.QGreenTea = QLineEdit("0", self)
        self.QOrangeJuice = QLineEdit("0", self)
        self.QLemonade = QLineEdit("0", self)
        self.QGreenApple = QLineEdit("0", self)
        self.QWaterBottle = QLineEdit("0", self)
        quantities = [
            self.QCappuccino, self.QEspresso, self.QTurkishCoffee,
            self.QBlackTea, self.QGreenTea, self.QOrangeJuice, self.QLemonade,
            self.QGreenApple, self.QWaterBottle
        ]
        for q, quantity in enumerate(quantities):
            quantity.setFixedSize(80, 40)
            quantity.setAlignment(Qt.AlignCenter)
            quantity.setFont(QFont("urdu Typesetting", 20))
            drinkGrid.addWidget(quantity, q + 1, 2, 1, 1)

        self.drinkGroup.setLayout(drinkGrid)
        vbox.addWidget(self.drinkGroup)
        self.resultGroup = QGroupBox("حساب الإجمالي", self)
        self.resultGroup.setFont(QFont("urdu Typesetting", 14, 900))
        resultGrid = QGridLayout()
        self.lblTotal = QLabel("الإجمالي", self)
        self.scrTotal = QLabel("0", self)
        self.lblDiscount = QLabel("خصم نقدي", self)
        self.scrDiscount = QLabel("0", self)
        self.lblVAT = QLabel("ضريبة ق.م", self)
        self.scrVAT = QLabel("0", self)
        self.lblNetValue = QLabel("الصافي", self)
        self.scrNetValue = QLabel("0", self)

        results = [[
            self.lblTotal, self.scrTotal, self.lblDiscount, self.scrDiscount
        ], [self.lblVAT, self.scrVAT, self.lblNetValue, self.scrNetValue]]
        for r, row in enumerate(results):
            for c, col in enumerate(row):
                col.setFont(QFont("urdu Typesetting", 14))
                col.setFixedSize(80, 40)
                resultGrid.addWidget(col, r, c, 1, 1)

        self.resultGroup.setLayout(resultGrid)
        vbox.addWidget(self.resultGroup)

        self.drinkContainer.setLayout(vbox)