Ejemplo n.º 1
0
    def __init__(self, main_window_instance: MainWindow, *args, **kwargs):
        QWidget.__init__(self, None, Qt.WindowStaysOnTopHint, *args, **kwargs)
        self.main_window = main_window_instance
        self.layout = QGridLayout()
        self.resize(350, 180)
        self.setWindowTitle("Select Image Origin")

        self.headline = QLabel("From where do you want to load the image?",
                               self)
        self.headline.setSizePolicy(QSizePolicy.Expanding,
                                    QSizePolicy.Expanding)
        self.headline.setAlignment(Qt.AlignHCenter)
        self.layout.addWidget(self.headline, 0, 0)

        self.buttonlayout = QVBoxLayout()
        local_image_button = QCommandLinkButton("Use local image")
        local_image_button.clicked.connect(self.select_local_img)
        self.buttonlayout.addWidget(local_image_button)
        grab_image_button9 = QCommandLinkButton(
            "Grab 9 images from Google Images")
        grab_image_button9.clicked.connect(self.grab_img_9)
        self.buttonlayout.addWidget(grab_image_button9)
        grab_image_button5 = QCommandLinkButton(
            "Grab 5 images from Google Images")
        grab_image_button5.clicked.connect(self.grab_img_5)
        self.buttonlayout.addWidget(grab_image_button5)
        self.layout.addLayout(self.buttonlayout, 1, 0)
        self.setLayout(self.layout)

        self.GrabImagesThread = GrabImagesThread(self.main_window)
        self.GrabSelector = GrabSelector(self.main_window)
Ejemplo n.º 2
0
    def _start_video(self, super_layout):
        self.video_widget = QWidget()
        self.video_init_layout = QVBoxLayout()

        self.back_btn = QCommandLinkButton()
        self.back_btn.setIcon(QIcon("./assets/icons/back.png"))
        self.back_btn.setIconSize(QSize(30, 30))
        self.back_btn.setMaximumWidth(45)

        # Create Camera View
        self.cam_view = QLabel()

        self.video_init_layout.addWidget(self.back_btn)
        self.video_init_layout.addWidget(self.cam_view)
        self.video_init_layout.addWidget(self.cam_btn)

        self.video_widget.setLayout(self.video_init_layout)

        super_layout.addWidget(self.video_widget)
        super_layout.setCurrentWidget(self.video_widget)

        # create a timer
        self.timer = QTimer()

        # set timer timeout callback function
        self.timer.timeout.connect(self._video)

        if not self.timer.isActive():
            self.cam = cv2.VideoCapture(0)
            self.timer.start(1)
Ejemplo n.º 3
0
 def _createQCommandLinkButton(self, text, member, enabled=True):
     button = QCommandLinkButton(text)
     if member:
         button.clicked.connect(member)
     button.setEnabled(enabled)
     button.setFixedSize(120, 40)
     return button
Ejemplo n.º 4
0
    def _other_view(self):
        # For other screens aside Login Screen And Main View Screen
        self.stacked = QStackedWidget()
        self.main_grid_widget = QWidget()
        self.main_grid = QGridLayout()
        back_btn = QCommandLinkButton()
        back_btn.setIcon(QIcon("./assets/icons/back.png"))
        back_btn.setIconSize(QSize(30, 30))
        self.main_grid_widget.setLayout(self.main_grid)

        self.main_grid.addWidget(back_btn, 0, 0)
        self.main_grid.addWidget(self.stacked, 1, 0, 1, 0)

        back_btn.clicked.connect(self._handle_go_back)
        back_btn.setMaximumWidth(45)
Ejemplo n.º 5
0
 def __init__(self, parent, presenter, version_text, date_text = None):
     super(AboutView, self).__init__(parent)
     self.background_pixmap = QPixmap(':/images/First_use_Background.png')
     self.mantid_pixmap = QPixmap(':/images/mantid_smaller.png')
     self.lbl_version = QLabel()
     self.clb_release_notes = QCommandLinkButton()
     self.clb_sample_datasets = QCommandLinkButton()
     self.clb_mantid_introduction = QCommandLinkButton()
     self.clb_python_introduction = QCommandLinkButton()
     self.clb_python_in_mantid = QCommandLinkButton()
     self.clb_extending_mantid = QCommandLinkButton()
     self.cb_facility = QComboBox()
     self.cb_instrument = QComboBox()
     self.pb_manage_user_directories = QPushButton()
     self.chk_allow_usage_data = QCheckBox()
     self.lbl_privacy_policy = QLabel()
     self.chk_do_not_show_until_next_release = QCheckBox()
     self.pb_close = QPushButton()
     self.setupUI()
     self.customize_layout(version_text, date_text)
     self.presenter = presenter
Ejemplo n.º 6
0
class COMPONENTS(QWidget):
    def __init__(self):
        super().__init__()
        self.APP_URL = "http://127.0.0.1:8000"
        # self.APP_URL = "https://face-recog-server.herokuapp.com"
        self.msg = QMessageBox()

        self.grid = QGridLayout()
        self.group_box = QGroupBox()

        # PROFILE PICTURE
        self.profile_pic = QLabel()
        self.profile_pic.setAlignment(Qt.AlignCenter)
        self.profile_pic.setMaximumSize(130, 130)
        self.profile_pic.setScaledContents(True)

        # PROFILE PICTURE LAYOUT
        self.pro_pic_view = QVBoxLayout()
        self.change_pro = QPushButton()
        self.change_pro.setIcon(QIcon("./assets/icons/capture.png"))

        self.pro_pic_view.addWidget(self.profile_pic)
        self.pro_pic_view.addWidget(self.change_pro)

        self.cam_btn = QPushButton("Capture")

        # FIRST NAME
        self.f_name = QLabel("First Name")
        self.f_name.setObjectName("Label")
        self.f_name_input = QLineEdit()

        # MIDDLE NAME
        self.m_name = QLabel("Middle Name")
        self.m_name.setObjectName("Label")
        self.m_name_input = QLineEdit()

        # LAST NAME
        self.l_name = QLabel("Last Name")
        self.l_name.setObjectName("Label")
        self.l_name_input = QLineEdit()

        # DATE OF BIRTH
        self.dob_label = QLabel("Date of Birth")
        self.dob_label.setObjectName("Label")
        self.dob_date_label = QLabel("Choose Date..")
        self.dob_date_label.setStyleSheet("font-weight: normal;")
        self.dob_date_choose = QPushButton()
        self.dob_date_choose.setIcon(QIcon("./assets/icons/calendar.png"))
        self.dob_date_choose.setIconSize(QSize(25, 25))
        self.dob_layout = QHBoxLayout()
        self.dob_date_choose.clicked.connect(self.calender_show)
        self.dob_layout.addWidget(self.dob_date_label)
        self.dob_layout.addWidget(self.dob_date_choose)

        # AGE
        self.age = QLabel("Age")
        self.age.setObjectName("Label")
        self.age_input = QLineEdit()
        self.age_input.setValidator(QIntValidator())
        self.age_input.setMaxLength(3)

        # GENDER
        self.gender = QLabel("Gender")
        self.gender.setObjectName("Label")
        self.gender_1 = QRadioButton("MALE")
        self.gender_2 = QRadioButton("FEMALE")
        self.gender_1.setChecked(True)
        self.gender_layout = QHBoxLayout()
        self.gender_layout.addWidget(self.gender_1)
        self.gender_layout.addWidget(self.gender_2)

        # NATIONAILTY
        self.nationality = QLabel("Nationality")
        self.nationality.setObjectName("Label")
        self.nationality_input = QLineEdit()

        # STATE OF ORIGIN
        self.state_origin = QLabel("State of Origin")
        self.state_origin.setObjectName("Label")
        self.state_origin_input = QLineEdit()

        # LGA OF ORIGIN
        self.lga_origin = QLabel("LGA")
        self.lga_origin.setObjectName("Label")
        self.lga_origin_input = QLineEdit()

        # MARITAL STATUS
        self.marital = QLabel("Marital Status")
        self.marital.setObjectName("Label")
        self.marital_select = QComboBox()
        self.marital_select.addItems(
            ["SINGLE", "SEPERATED", "DIVORCED", "MARRIED", "WIDOWED"])

        self.profession = QLabel("Profession")
        self.profession.setObjectName("Label")
        self.profession_input = QLineEdit()

        # JAMB NUMBER
        self.j_num = QLabel("JAMB No.")
        self.j_num.setObjectName("Label")
        self.j_num_input = QLineEdit()
        self.j_num_input.setMaxLength(10)

        # COLLEGE
        self.college = QLabel("College")
        self.college.setObjectName("Label")
        self.college_select = QComboBox()
        self.college_select.addItems([
            "CAERSE",
            "CASAP",
            "CAFST",
            "CCSS",
            "COED",
            "CEET",
            "CGSC",
            "COLMAS",
            "CNREM",
            "COLNAS",
            "COLPAS",
            "CVM",
        ])

        # DEPARTMENT
        self.dept = QLabel("Department")
        self.dept.setObjectName("Label")
        self.dept_select = QComboBox()
        self.dept_select.addItems([
            "AGRIBUSINESS MANAGEMENT",
            "AGRICULTURAL ECONOMICS",
            "AGRICULTURAL EXTENSION AND RURAL SOCIOLOGY",
        ])

        # LEVEL
        self.level = QLabel("Level")
        self.level.setObjectName("Label")
        self.level_select = QComboBox()
        self.level_select.addItems(["100L", "200L", "300L", "400L"])

        # MATRIC NUMBER
        self.m_num = QLabel("Matriculation No.")
        self.m_num.setObjectName("Label")
        self.m_num_input = QLineEdit()

        # HOME ADDRESS
        self.address = QLabel("Home Address")
        self.address.setObjectName("Label")
        self.address_input = QLineEdit()

        # CELL PHONE
        self.phone = QLabel("Cell Phone")
        self.phone.setObjectName("Label")
        self.phone_input = QLineEdit()
        # self.phone_input.setValidator(QIntValidator
        self.phone_input.setMaxLength(11)

        # EMAIL
        self.email = QLabel("Email")
        self.email.setObjectName("Label")
        self.email.setObjectName("Label")
        self.email_input = QLineEdit()

        # PARENT NAME
        self.p_name = QLabel("Parent's/Sponsor's Name")
        self.p_name.setObjectName("Label")
        self.p_name_input = QLineEdit()

        # PARENT EMAIL
        self.p_email = QLabel("Parent's/Sponsor's Email")
        self.p_email.setObjectName("Label")
        self.p_email_input = QLineEdit()

        # PARENT PHONE
        self.p_phone = QLabel("Parent's/Sponsor's Phone")
        self.p_phone.setObjectName("Label")
        self.p_phone_input = QLineEdit()
        self.p_phone_input.setMaxLength(11)

        # DATE OF REGISTRATION
        self.dor = QLabel("Date of Registration")
        self.dor.setObjectName("Label")
        self.dor_text = QLineEdit()
        date = QDate.currentDate().toString(Qt.ISODate)
        self.dor_text.setText(date)

        # Next
        self._next = QPushButton("Next")

        # Prev
        self._prev = QPushButton("Previous")

    def calender_show(self):

        self.initial_layout = QVBoxLayout()

        self.calender_view = QWidget()
        self.calender_view.setWindowTitle("Choose Date")

        self.calender = QCalendarWidget()
        self.calender.setGridVisible(True)

        self.flags = Qt.WindowFlags(Qt.WindowStaysOnTopHint)
        self.calender_view.setWindowFlags(self.flags)

        self.initial_layout.addWidget(self.calender)
        self.calender_view.setLayout(self.initial_layout)

        self.calender_view.show()
        self.calender_view.resize(350, 250)

        self.calender.clicked[QDate].connect(self.select_date)

    def select_date(self):
        self.dob_date_label.setText(self.calender.selectedDate().toString(
            Qt.ISODate))
        self.calender_view.hide()

    def _start_video(self, super_layout):
        self.video_widget = QWidget()
        self.video_init_layout = QVBoxLayout()

        self.back_btn = QCommandLinkButton()
        self.back_btn.setIcon(QIcon("./assets/icons/back.png"))
        self.back_btn.setIconSize(QSize(30, 30))
        self.back_btn.setMaximumWidth(45)

        # Create Camera View
        self.cam_view = QLabel()

        self.video_init_layout.addWidget(self.back_btn)
        self.video_init_layout.addWidget(self.cam_view)
        self.video_init_layout.addWidget(self.cam_btn)

        self.video_widget.setLayout(self.video_init_layout)

        super_layout.addWidget(self.video_widget)
        super_layout.setCurrentWidget(self.video_widget)

        # create a timer
        self.timer = QTimer()

        # set timer timeout callback function
        self.timer.timeout.connect(self._video)

        if not self.timer.isActive():
            self.cam = cv2.VideoCapture(0)
            self.timer.start(1)

    def _video(self):
        face_cascade = cv2.CascadeClassifier(
            "./assets/classifier/haarcascade_frontalface_alt2.xml")

        ret, self.image = self.cam.read()

        image_copy = self.image.copy()

        # Capture Image-by-Image
        gray = cv2.cvtColor(image_copy, cv2.COLOR_BGR2GRAY)
        faces = face_cascade.detectMultiScale(
            gray,
            scaleFactor=1.1,
            minNeighbors=5,
            minSize=(40, 40),
            flags=cv2.CASCADE_SCALE_IMAGE,
        )
        for (x, y, w, h) in faces:
            cv2.rectangle(image_copy, (x, y), (x + w, y + h), (255, 255, 255),
                          1)

        self.image_shown = cv2.cvtColor(image_copy, cv2.COLOR_BGR2RGB)

        # get image infos
        self.height, self.width, self.channel = self.image_shown.shape
        self.step = self.channel * self.width

        # create QImage from image
        self.qImg = QImage(
            self.image_shown.data,
            self.width,
            self.height,
            self.step,
            QImage.Format_RGB888,
        )

        # Set the data from qImg to cam_view
        self.cam_view.setPixmap(QPixmap.fromImage(self.qImg))

    def isConnected(self):
        try:
            r = requests.get(url=f"{self.APP_URL}")
            print(r.text)
            return True
        except requests.exceptions.ConnectionError as e:
            self.msg.setIconPixmap(QPixmap("./assets/icons/no_connection.png"))
            self.msg.setWindowTitle("Error!")
            self.msg.setWindowIcon(QIcon("./assets/icons/error.png"))
            self.msg.setText("Connect to the Internet to use app!")
            self.msg.show()
            self.msg.exec_()
            return False
        except requests.exceptions.Timeout as e:
            self.msg.setIconPixmap(
                QPixmap("./assets/icons/network_timeout.png"))
            self.msg.setWindowIcon(QIcon("./assets/icons/error.png"))
            self.msg.setWindowTitle("Information")
            self.msg.setWindowIcon(QIcon("./assets/icons/error.png"))
            self.msg.setText("Poor Network Connection!")
            self.msg.show()
            self.msg.exec_()
            return False
Ejemplo n.º 7
0
    def setupTab1(self, tab1):
        """Basic widgets for preview panel"""
        scrollContainer = QVBoxLayout()
        scrollArea = QScrollArea()
        scrollArea.setWidgetResizable(True)
        mainWidget = QWidget()
        layout = QVBoxLayout()
        mainWidget.setLayout(layout)
        mainWidget.setMinimumSize(QSize(420, 800))
        scrollArea.setWidget(mainWidget)
        scrollContainer.addWidget(scrollArea)
        tab1.setLayout(scrollContainer)

        # Label TextBox
        group1 = QGroupBox("Text")
        group1.setCheckable(True)
        group1layout = QHBoxLayout()
        group1.setLayout(group1layout)
        layout.addWidget(group1)
        layoutCol1 = QFormLayout()
        layoutCol2 = QFormLayout()
        group1layout.addLayout(layoutCol1)
        group1layout.addLayout(layoutCol2)

        label1 = QLabel(self.tr("User Name(&Id):"))
        text1 = QLineEdit("default")
        label1.setBuddy(text1)
        label2 = QLabel(self.tr("data 1:"))
        text2 = QLineEdit()
        text2.setPlaceholderText(self.tr("input"))
        lebel3 = QLabel(self.tr("<b>Pasword</b>:"))
        text3 = QLineEdit("******")
        text3.setEchoMode(QLineEdit.Password)
        label4 = QLabel(self.tr("link label:"))
        label5 = QLabel(
            self.
            tr("<a href='https://github.com/hustlei/'>github.com/hustlei</a>"))
        label5.setOpenExternalLinks(True)
        label6 = QLabel(self.tr("icon label:"))
        label7 = QLabel("icon")
        label7.setPixmap(QPixmap(":appres.img/book_address.png"))
        layoutCol1.addRow(label1, text1)
        layoutCol1.addRow(label2, text2)
        layoutCol1.addRow(lebel3, text3)
        layoutCol1.addRow(label4, label5)
        layoutCol1.addRow(label6, label7)

        text4 = QLineEdit()
        text4.setInputMask("0000-00-00")
        text5 = QLineEdit()
        text5.setInputMask("HH:HH:HH:HH:HH:HH;_")
        text6 = QLineEdit()
        text6.setInputMask("XXXXXX")
        text7 = QLineEdit()
        validator1 = QDoubleValidator()
        validator1.setRange(0, 100)
        validator1.setDecimals(2)
        text7.setValidator(validator1)
        text8 = QLineEdit()
        validator2 = QRegExpValidator()
        reg = QRegExp("[a-zA-Z0-9]+$")
        validator2.setRegExp(reg)
        text8.setValidator(validator2)
        layoutCol2.addRow(self.tr("Date Mask:"), text4)
        layoutCol2.addRow(self.tr("Mac Mask"), text5)
        layoutCol2.addRow(self.tr("String Mask"), text6)
        layoutCol2.addRow(self.tr("Double Validate:"), text7)
        layoutCol2.addRow(self.tr("Regexp Validate:"), text8)

        text9 = QLineEdit()
        text9.setPlaceholderText("input email")
        text9.setToolTip("please input a email address.")
        model = QStandardItemModel(0, 1, self)
        completer = QCompleter(model, self)
        text9.setCompleter(completer)

        def textch(texts):
            if "@" in texts:
                return
            strList = [
                "@163.com", "@qq.com", "@gmail.com", "@hotmail.com", "@126.com"
            ]
            model.removeRows(0, model.rowCount())
            for i in strList:
                model.insertRow(0)
                model.setData(model.index(0, 0), texts + i)

        text9.textChanged.connect(textch)
        text10 = QLineEdit("ReadOnly")
        text10.setReadOnly(True)
        layoutCol1.addRow(self.tr("auto complete:"), text9)
        layoutCol2.addRow("Readonly:", text10)

        # Button
        group2 = QGroupBox("Button")
        group2.setCheckable(True)
        group2layout = QVBoxLayout()
        group2.setLayout(group2layout)
        layout.addWidget(group2)
        layoutRow1 = QHBoxLayout()
        layoutRow2 = QHBoxLayout()
        group2layout.addLayout(layoutRow1)
        group2layout.addLayout(layoutRow2)

        btn1 = QPushButton("Button")
        btn2 = QPushButton("IconBtn")
        btn2.setIcon(QIcon(":appres.img/yes.png"))
        btn3 = QPushButton("Disabled")
        btn3.setEnabled(False)
        btn4 = QPushButton("Default")
        btn4.setDefault(True)

        btn5 = QPushButton("Switch")
        btn5.setCheckable(True)
        btn6 = QToolButton()
        # btn6.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        btn6.setText("ToolButton")
        btn6.setPopupMode(QToolButton.MenuButtonPopup)
        m = QMenu()
        m.addAction("action1")
        m.addAction("action2")
        m.addAction("action3")
        btn6.setMenu(m)
        btn7 = QCommandLinkButton("LinkBtn")
        layoutRow1.addWidget(btn1)
        layoutRow1.addWidget(btn2)
        layoutRow1.addWidget(btn3)
        layoutRow1.addWidget(btn4)
        layoutRow2.addWidget(btn5)
        layoutRow2.addWidget(btn6)
        layoutRow2.addWidget(btn7)

        # Checkable Item
        group3 = QGroupBox("Checkable")
        group3Layout = QVBoxLayout()
        layoutRow1 = QHBoxLayout()
        layoutRow2 = QHBoxLayout()
        group3Layout.addLayout(layoutRow1)
        group3Layout.addLayout(layoutRow2)
        group3.setLayout(group3Layout)
        layout.addWidget(group3)

        group3.setCheckable(True)
        ch1 = QRadioButton("Radio")
        ch2 = QRadioButton("Iconradio")
        ch2.setIcon(QIcon(":appres.img/Flag_blueHS.png"))
        ch3 = QRadioButton("Iconradio")
        ch3.setIcon(QIcon(":appres.img/Flag_greenHS.png"))
        ch4 = QRadioButton("Disable")
        ch4.setEnabled(False)
        ch5 = QCheckBox("CheckBox")
        ch6 = QCheckBox("CheckBox")
        ch6.setIcon(QIcon(":appres.img/Flag_blueHS.png"))
        ch7 = QCheckBox("TriState")
        ch7.setTristate(True)
        ch7.setCheckState(Qt.PartiallyChecked)
        ch8 = QCheckBox("Disable")
        ch8.setEnabled(False)
        layoutRow1.addWidget(ch1)
        layoutRow1.addWidget(ch2)
        layoutRow1.addWidget(ch3)
        layoutRow1.addWidget(ch4)
        layoutRow2.addWidget(ch5)
        layoutRow2.addWidget(ch6)
        layoutRow2.addWidget(ch7)
        layoutRow2.addWidget(ch8)

        # Selecting Input
        group4 = QGroupBox("Selectable")
        group4.setCheckable(True)
        group4Layout = QVBoxLayout()
        layoutRow1 = QHBoxLayout()
        group4Layout.addLayout(layoutRow1)
        group4.setLayout(group4Layout)
        layout.addWidget(group4)

        s1 = QSpinBox()
        s1.setValue(50)
        s2 = QDoubleSpinBox()
        s2.setRange(0, 1)
        s2.setValue(0.5)
        s3 = QComboBox()
        s3.addItems(["aaa", "bbb", "ccc"])
        s3.setEditable(True)
        s3.setCurrentIndex(2)
        s4 = QComboBox()
        s4.addItems(["aaa", "bbb", "ccc"])
        layoutRow1.addWidget(s1)
        layoutRow1.addWidget(s2)
        layoutRow1.addWidget(s3)
        layoutRow1.addWidget(s4)

        # TextEdit
        group5 = QGroupBox("TextEdit")
        group5.setCheckable(True)
        group5Layout = QVBoxLayout()
        group5.setLayout(group5Layout)
        layout.addWidget(group5)

        group5Layout.addWidget(
            QTextEdit(
                self.
                tr("If you do not leave me, I will be by your side until the end."
                   )))

        layout.addStretch(1)
Ejemplo n.º 8
0
 def add_button( self, layout: QGridLayout, sample_dir, action, icon ):
     act = (action or "") + sample_dir
     
     button = QCommandLinkButton()
     button.setText( file_helper.get_filename_without_extension( sample_dir ) )
     button.setStatusTip( act )
     if not action:
         button.setEnabled( False )
     button.setToolTip( button.statusTip() )
     button.setAutoDefault( False )
     button.clicked[bool].connect( self.__on_button_clicked )
     button.setIcon( icon.icon() )
     self.__controls.append( button )
     i = layout.count()
     x = i % 3
     y = i // 3
     layout.addWidget( button, y, x )
Ejemplo n.º 9
0
    def __init__(self, files, tab, delete, parent, test=False):
        """
        Keyword arguments:
        files  -- list with dicts containing file names
        tab -- instanseof AudioVideoTab, ImageTab or DocumentTab
               indicating currently active tab
        delete -- boolean that shows if files must removed after conversion
        parent -- parent widget

        files:
        Each dict have only one key and one corresponding value.
        Key is a file to be converted and it's value is the name of the new
        file that will be converted.

        Example list:
        [{"/foo/bar.png" : "/foo/bar.bmp"}, {"/f/bar2.png" : "/f/bar2.bmp"}]
        """
        super(Progress, self).__init__(parent)
        self.parent = parent

        self.files = files
        self.num_total_files = len(self.files)
        self.tab = tab
        self.delete = delete
        if not test:
            self._type = tab.name
        self.ok = 0
        self.error = 0
        self.running = True

        self.nowQL = QLabel(self.tr('In progress: '))
        self.nowQPBar = QProgressBar()
        self.nowQPBar.setValue(0)
        self.shutdownQCB = QCheckBox(self.tr('Shutdown after conversion'))
        self.cancelQPB = QPushButton(self.tr('Cancel'))

        detailsQPB = QCommandLinkButton(self.tr('Details'))
        detailsQPB.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        detailsQPB.setCheckable(True)
        detailsQPB.setMaximumWidth(113)
        line = QFrame()
        line.setFrameShape(QFrame.HLine)
        line.setFrameShadow(QFrame.Sunken)
        self.outputQTE = QTextEdit()
        self.outputQTE.setReadOnly(True)
        self.frame = QFrame()
        frame_layout = utils.add_to_layout('h', self.outputQTE)
        self.frame.setLayout(frame_layout)
        self.frame.hide()

        hlayout1 = utils.add_to_layout('h', None, self.nowQL, None)
        hlayout2 = utils.add_to_layout('h', detailsQPB, line)
        hlayout3 = utils.add_to_layout('h', self.frame)
        hlayout4 = utils.add_to_layout('h', None, self.cancelQPB)
        vlayout = utils.add_to_layout(
                'v', hlayout1, self.nowQPBar, hlayout2, hlayout3,
                self.shutdownQCB, hlayout4
                )
        self.setLayout(vlayout)

        detailsQPB.toggled.connect(self.resize_dialog)
        detailsQPB.toggled.connect(self.frame.setVisible)
        self.cancelQPB.clicked.connect(self.reject)
        self.file_converted_signal.connect(self.next_file)
        self.update_text_edit_signal.connect(self.update_text_edit)

        self.resize(484, 190)
        self.setWindowTitle('FF Multi Converter - ' + self.tr('Conversion'))

        if not test:
            self.get_data() # should be first and not in QTimer.singleShot()
            QTimer.singleShot(0, self.manage_conversions)
Ejemplo n.º 10
0
    def __init__(self):
        super(main_win, self).__init__()

        self.setWindowTitle('uploader')
        self.setFont(QFont('微软雅黑'))
        # self.setFixedSize(1200,800)
        # self.setWindowFlag(Qt.FramelessWindowHint)

        globallayout = QVBoxLayout()
        toplayout = QHBoxLayout()
        middelelayout = QHBoxLayout()
        bottomlayout = QVBoxLayout()

        self.config = configparser.ConfigParser()
        self.config.read(r'main-setting.ini')

        ################# toplayout #################
        self.btn_user_info = QPushButton('用户信息')
        self.btn_remote = QPushButton('远程同步')
        self.btn_setting = QPushButton('设置')
        self.btn_upload = QPushButton('上传')
        self.btn_default = QPushButton('默认')
        # QCommandLinkButton
        self.btn_command = QCommandLinkButton()
        self.btn_minimize = QPushButton()
        self.btn_close = QPushButton()

        self.btn_user_info.setObjectName('user_info')
        self.btn_minimize.setObjectName('minimize')
        self.btn_close.setObjectName('close')

        toplayout.addWidget(self.btn_user_info)
        toplayout.addWidget(self.btn_remote)
        toplayout.addWidget(self.btn_setting)
        toplayout.addWidget(self.btn_upload)
        toplayout.addWidget(self.btn_default)
        toplayout.addWidget(self.btn_command)
        toplayout.addWidget(self.btn_minimize)
        toplayout.addWidget(self.btn_close)

        self.btn_user_info.pressed.connect(self.m_user_info)
        self.btn_remote.pressed.connect(self.m_remote)
        self.btn_setting.pressed.connect(self.m_setting)
        self.btn_upload.pressed.connect(self.m_upload)
        self.btn_default.pressed.connect(self.m_default)
        # self.btn_command.pressed.connect()
        self.btn_minimize.pressed.connect(self.m_minimize)
        self.btn_close.pressed.connect(self.m_close)

        ################## middellayout #################
        self.db = QSqlDatabase.addDatabase('QSQLITE')
        self.db.setDatabaseName('data.db')

        self.local = QSqlDatabase.addDatabase('QSQLITE')
        self.local.setDatabaseName('local.db')

        middle_inside = QGridLayout()
        self.tableview = QTableView()

        self.lab_title = QLabel('标题')
        self.line_title = QLineEdit()
        self.line_title.setWindowOpacity(0.5)
        self.lab_video_info = QLabel('视频描述')
        # self.text_video_info_en=QTextBrowser()
        self.text_video_info_ch = QTextBrowser()
        self.lab_labels = QLabel('视频标签')
        self.line_label1 = QLineEdit()
        self.line_label2 = QLineEdit()
        self.line_label3 = QLineEdit()
        self.line_label4 = QLineEdit()
        self.line_label5 = QLineEdit()
        self.lab_header_choice = QLabel('片头选择')
        self.com_header_choice = QComboBox()
        self.lab_logo_choice = QLabel('logo选择')
        self.com_logo_choice = QComboBox()
        self.btn_save = QPushButton('保存编辑')
        self.btn_clear = QPushButton('清空编辑')
        self.btn_bilibili = QCheckBox('哔哩哔哩')
        self.btn_dayuhao = QCheckBox('大鱼号')
        self.btn_baijiahao = QCheckBox('百家号')
        self.btn_qiehao = QCheckBox('企鹅号')
        self.btn_other = QCheckBox('未完待续')
        self.btn_submit = QPushButton('上传')

        self.line_title.setObjectName('line_title')
        self.text_video_info_ch.setObjectName('video_info_ch')
        self.line_label1.setProperty('line', 'label')
        self.line_label2.setProperty('line', 'label')
        self.line_label3.setProperty('line', 'label')
        self.line_label4.setProperty('line', 'label')
        self.line_label5.setProperty('line', 'label')
        self.com_header_choice.setProperty('com', 'option')
        self.com_logo_choice.setProperty('com', 'option')
        self.btn_save.setProperty('btn', 'submit')
        self.btn_clear.setProperty('btn', 'submit')
        # self.btn_bilibili.setProperty('btn','upload')
        # self.btn_dayuhao.setProperty('btn','upload')
        # self.btn_baijiahao.setProperty('btn','upload')
        # self.btn_qiehao.setProperty('btn','upload')
        # self.btn_other.setProperty('btn','upload')

        middle_inside.addWidget(self.lab_title, 0, 0, 1, 1)
        middle_inside.addWidget(self.line_title, 1, 0, 1, 1)
        middle_inside.addWidget(self.lab_video_info, 2, 0, 1, 1)
        # middle_inside.addWidget(self.text_video_info_en,3,0,3,1)
        middle_inside.addWidget(self.text_video_info_ch, 6, 0, 3, 1)
        middle_inside.addWidget(self.lab_labels, 0, 1, 1, 1)
        middle_inside.addWidget(self.line_label1, 1, 1, 1, 1)
        middle_inside.addWidget(self.line_label2, 2, 1, 1, 1)
        middle_inside.addWidget(self.line_label3, 3, 1, 1, 1)
        middle_inside.addWidget(self.line_label4, 4, 1, 1, 1)
        middle_inside.addWidget(self.line_label5, 5, 1, 1, 1)
        middle_inside.addWidget(self.btn_save, 6, 1, 1, 1)
        middle_inside.addWidget(self.btn_clear, 7, 1, 1, 1)

        middelelayout.addWidget(self.tableview)
        middelelayout.addLayout(middle_inside)

        self.tabmodel = QSqlTableModel()
        self.tabmodel.setTable('temp_video_list')
        self.tabmodel.setEditStrategy(QSqlTableModel.OnManualSubmit)
        # self.tabmodel.setFilter()
        self.tabmodel.select()
        self.tabmodel.setHeaderData(0, Qt.Horizontal, 'title')
        self.tabmodel.setHeaderData(1, Qt.Horizontal, 'length')
        self.tabmodel.setHeaderData(2, Qt.Horizontal, 'url')
        self.tabmodel.setHeaderData(3, Qt.Horizontal, 'views')
        self.tabmodel.setHeaderData(4, Qt.Horizontal, 'loaded')
        self.tableview.setModel(self.tabmodel)

        self.btn_save.pressed.connect(self.m_save)
        self.btn_clear.pressed.connect(self.m_clear)
        # self.item_video=QStandardItem()
        self.tableview.setSelectionBehavior(QAbstractItemView.SelectRows)
        # self.tableview.setSelectionModel(QAbstractItemView.SingleSelection)

        # open video file
        # signals inherit from QAbstractItemView
        self.tableview.doubleClicked.connect(self.m_doubleclick)
        # self.tableview.clicked
        self.tableview.activated.connect(self.m_active)
        # self.tableview.pressed

        #######bottomlayout#######
        self.lab_local_info = QLabel('执行信息')
        self.textbrowser = QTextBrowser()
        # self.textbrowser

        self.textbrowser.setAlignment(Qt.AlignBottom)
        self.textbrowser.setObjectName('textbrowser')

        bottomlayout.addWidget(self.lab_local_info)
        bottomlayout.addWidget(self.textbrowser)

        # 界面全局
        globallayout.addLayout(toplayout)
        globallayout.addLayout(middelelayout)
        globallayout.addLayout(bottomlayout)

        self.setLayout(globallayout)
    def lay_out(self):
        self.setWindowTitle(ls.strings.PARAMETERS_BUTTON)
        self.layout = QVBoxLayout()

        # -----------  Callback functions  ----------
        def valider_callback():
            p = prenom.text()
            n = nom.text()
            if not p or not n:
                return
            err = self.registre.ajouter_membre(p, n)
            if type(err) == str:
                dialog(err, ls.strings.ERROR)
                return
            for _ in range(liste_membres.count()):
                liste_membres.takeItem(0)

            for m in self.registre.membres:
                liste_membres.addItem(m.id)
            self.update_registre()

        def retirer_membre_callback():
            if liste_membres.currentItem() is None:
                return
            identification = liste_membres.currentItem().text()
            m = self.registre.find_membre_by_id(identification)
            self.registre.supprimer_membre(m)
            for _ in range(liste_membres.count()):
                liste_membres.takeItem(0)
            for m in self.registre.membres:
                liste_membres.addItem(m.id)
            self.update_registre()

        def cat_list_connect(x, y):
            if x is not None:
                for cat in cert_lists:
                    cert_lists[cat].hide()
                cert_lists[x.text()].show()
                cert_label.setText(ls.strings.X_CAT_CERTIFICATES(x.text()))
            else:
                cat_input.setCurrentIndex(-1)

        def cat_input_connect(x):
            l = cat_list.findItems(x, Qt.MatchExactly)
            if l:
                cat_list.setCurrentItem(l[0])
                for cat in cert_lists:
                    cert_lists[cat].hide()
                cert_lists[x].show()

        def valider_cert_callback():
            cat = cat_input.currentText()
            nom = nom_input.text()
            if not cat or not nom:
                dialog(ls.strings.PLEASE_ENTER_CERTIFICATE_NAME_AND_CATEGORY)
                return
            err = self.registre.ajouter_certificat(nom, cat)
            if err is not None:
                dialog(err, ls.strings.ERROR)
                return
            if cat not in cert_lists:
                cert_lists[cat] = ResizableListWidget()
                b_left_layout.addWidget(cert_lists[cat])
                cert_lists[cat].hide()
            else:
                for _ in range(cert_lists[cat].count()):
                    cert_lists[cat].takeItem(0)
            for _ in range(cat_list.count()):
                cat_list.takeItem(0)
                cat_input.removeItem(0)
            for categ in self.registre.categories:
                cat_list.addItem(categ)
                cat_input.addItem(categ)
            if cat in self.registre.categories:
                for c in self.registre.get_certificats(cat):
                    cert_lists[cat].addItem(c.nom)

            cat_list.setCurrentItem(
                cat_list.findItems(cat, Qt.MatchExactly)[0])
            cat_input.setCurrentText(cat)

            cert_lists[cat].show()
            self.update_registre()

        def supprimer_certificat(nom, cat):
            c_row = cert_lists[cat].row(cert_lists[cat].currentItem())
            cert_lists[cat].takeItem(c_row)
            self.registre.supprimer_certificat(
                self.registre.find_certificat_by_name(nom))

        def suppr_cert_callback():
            cat = cat_list.currentItem()
            nom = cert_lists[cat.text()].currentItem()
            if nom is None or cat is None:
                return
            nom = nom.text()
            cat = cat.text()

            supprimer_certificat(nom, cat)
            self.update_registre()

        def suppr_cat_callback():
            if confirm(ls.strings.DELETE_CATEGORY_Q):
                if cat_list.currentItem() is None:
                    return
                cat = cat_list.currentItem().text()
                for nom in [c.nom for c in self.registre.get_certificats(cat)]:
                    supprimer_certificat(nom, cat)
                cat_row = cat_list.row(cat_list.currentItem())
                cat_list.takeItem(cat_row)
                self.registre.supprimer_categorie(cat)
                cert_lists[cat].hide()
                self.update_registre()

        def avance_callback():
            if self.avance.text() == ls.strings.ADVANCED:
                self.avance.setText(ls.strings.HIDE)
                self.avance_w.show()
            else:
                self.avance.setText(ls.strings.ADVANCED)
                self.avance_w.hide()

        def change_school_callback():
            self.hide()
            NewSchoolWindow(self).show()

        def supprimer_registre_callback():
            if cloud_support.supprimer_registre(self.school_name):
                self.parentWidget().school_name = ""
                self.school_name = ""
                self.registre.clear()
            self.hide_widgets()

        def change_language_callback():
            ls.select_language(ls.strings.code)
            self.lay_out()
            self.parentWidget().lay_out()

        # --------------------------------------------------

        # header : create/load/delete online register buttons
        f = 20  # font size
        header = QWidget()
        header_layout = QHBoxLayout()
        header_layout.setContentsMargins(16, 0, 16, 0)
        self.school_name_w = QLabel(self.school_name)
        self.school_name_w.setFont(QFont("unknown", f))
        self.school_name_w.setMaximumHeight(60)
        self.avance = QCommandLinkButton(ls.strings.ADVANCED)
        self.avance.setMaximumWidth(100)
        self.avance_w = QWidget()
        if self.school_name != "": self.avance_w.hide()
        avance_layout = QHBoxLayout()
        avance_layout.setContentsMargins(0, 0, 0, 0)
        self.avance_w.setLayout(avance_layout)
        self.change_school = QPushButton(ls.strings.CREATE_LOAD_REGISTER)
        self.supprimer_registre = QPushButton(ls.strings.DELETE_REGISTER)
        self.supprimer_registre.setMaximumWidth(300)
        avance_layout.addWidget(self.change_school)
        avance_layout.addWidget(self.supprimer_registre)
        header_layout.addWidget(self.school_name_w)
        header_layout.addWidget(self.avance)
        header_layout.addWidget(self.avance_w)
        header.setLayout(header_layout)
        self.layout.addWidget(header)

        self.avance.clicked.connect(avance_callback)
        self.change_school.clicked.connect(change_school_callback)
        self.supprimer_registre.clicked.connect(supprimer_registre_callback)

        # top widget : member list management
        self.gestion_membres = QWidget()
        self.gestion_membres.setMaximumHeight(300)
        membres_layout = QHBoxLayout()
        t_left_w = QWidget()
        t_right_w = QWidget()
        t_left_layout = QVBoxLayout()
        t_right_layout = QVBoxLayout()
        t_left_w.setLayout(t_left_layout)
        t_right_w.setLayout(t_right_layout)
        liste_membres_label = QLabel(ls.strings.MEMBER_LIST)
        ajouter_membre = QLabel(ls.strings.ADD_MEMBER)
        prenom = MyLineEdit(placeholder=ls.strings.FIRST_NAME)
        nom = MyLineEdit(placeholder=ls.strings.LAST_NAME)
        prenom.setFont(QFont("unknown", 15))
        nom.setFont(QFont("unknown", 15))
        liste_membres = ResizableListWidget()
        for m in self.registre.membres:
            liste_membres.addItem(m.id)
        valider = ResizableButton(ls.strings.VALIDATE)
        retirer_membre = ResizableButton(ls.strings.REMOVE_MEMBER)
        t_left_layout.addWidget(liste_membres_label)
        t_left_layout.addWidget(liste_membres)
        t_left_layout.addWidget(retirer_membre)
        t_right_layout.addWidget(ajouter_membre)
        t_right_layout.addWidget(prenom)
        t_right_layout.addWidget(nom)
        t_right_layout.addWidget(valider)
        membres_layout.addWidget(t_left_w)
        membres_layout.addWidget(t_right_w)
        self.gestion_membres.setLayout(membres_layout)

        # bottom widget : gestion des certificats
        self.gestion_certificats = QWidget()
        certificats_layout = QHBoxLayout()
        b_left_w = QWidget()
        b_right_w = QWidget()
        b_left_layout = QVBoxLayout()
        b_right_layout = QVBoxLayout()
        b_left_w.setLayout(b_left_layout)
        b_right_w.setLayout(b_right_layout)
        cat_label = QLabel(ls.strings.CATEGORIES)
        cat_list = ResizableListWidget()
        cat_list.addItems(self.registre.categories)
        cert_label = QLabel(ls.strings.CERTIFICATES)
        ajouter_certificat = QLabel(ls.strings.ADD_CERTIFICATE)
        cat_input = MyComboBox(placeholder=ls.strings.CATEGORY)
        cat_input.setFont(QFont("unknown", 15))
        cat_input.addItems(self.registre.categories)
        valider_cert = ResizableButton(ls.strings.VALIDATE)
        nom_input = MyLineEdit(placeholder=ls.strings.CERTIFICATE_NAME)
        nom_input.setFont(QFont("unknown", 15))
        supprs_w = QWidget()
        supprs_layout = QHBoxLayout()
        suppr_cert = ResizableButton(ls.strings.DELETE_CERTIFICATE)
        suppr_cat = ResizableButton(ls.strings.DELETE_CATEGORY)
        supprs_w.setLayout(supprs_layout)
        self.gestion_certificats.setLayout(certificats_layout)
        b_left_layout.addWidget(cat_label)
        b_left_layout.addWidget(cat_list)
        b_left_layout.addWidget(cert_label)
        cert_lists = {}
        for cat in self.registre.categories:
            cert_lists[cat] = ResizableListWidget()
            for cert in self.registre.get_certificats(cat):
                cert_lists[cat].addItem(cert.nom)
            b_left_layout.addWidget(cert_lists[cat])
            cert_lists[cat].hide()
        b_right_layout.addWidget(ajouter_certificat)
        b_right_layout.addWidget(cat_input)
        b_right_layout.addWidget(nom_input)
        b_right_layout.addWidget(valider_cert)
        supprs_layout.addWidget(suppr_cert)
        supprs_layout.addWidget(suppr_cat)
        b_right_layout.addWidget(supprs_w)
        certificats_layout.addWidget(b_left_w)
        certificats_layout.addWidget(b_right_w)

        # footer
        self.footer = QWidget()
        footer_layout = QHBoxLayout()
        change_language = QPushButton(ls.strings.LANGUAGE + ls.strings.name)
        change_language.setMaximumWidth(change_language.sizeHint().width())
        self.thread_progress = QLabel(ls.strings.SAVED)
        self.thread_progress.setAlignment(Qt.AlignRight)
        self.thread_progress.setStyleSheet("color:grey")
        footer_layout.addWidget(change_language)
        footer_layout.addWidget(self.thread_progress)
        self.footer.setLayout(footer_layout)

        self.layout.addWidget(self.gestion_membres)
        self.layout.addWidget(self.gestion_certificats)
        self.layout.addWidget(self.footer)
        main_widget = QWidget()
        main_widget.setLayout(self.layout)
        self.setCentralWidget(main_widget)
        self.hide_widgets()

        # connecting slots
        valider.clicked.connect(valider_callback)
        retirer_membre.clicked.connect(retirer_membre_callback)
        cat_list.currentItemChanged.connect(cat_list_connect)
        cat_input.currentTextChanged.connect(cat_input_connect)
        valider_cert.clicked.connect(valider_cert_callback)
        suppr_cert.clicked.connect(suppr_cert_callback)
        suppr_cat.clicked.connect(suppr_cat_callback)
        change_language.clicked.connect(change_language_callback)

        cat_list.setCurrentRow(0, QItemSelectionModel.Select)
Ejemplo n.º 12
0
    def create_ui(self):
        # 1.文字标签
        # QLabel(显示的文字, 父标签/放到哪个窗口上)
        label1 = QLabel('用户名:', self)
        # 一般不常用的移动坐标
        label1.move(50, 10)

        # 2.按钮
        btn1 = QPushButton('登录', self)
        btn1.move(50, 50)
        # css语法:选择器{属性1:属性值1; 属性2:属性值2;..}
        # color - 字体颜色,对应的值:颜色单词, rbg(255, 0, 0)
        #
        btn1.setStyleSheet('QPushButton{}')
        btn2 = QRadioButton('男', self)
        btn2.move(50, 100)
        btn3 = QCheckBox('篮球', self)
        btn3.move(50, 150)
        btn4 = QCommandLinkButton('hello', 'hellowword', self)
        btn4.move(50, 200)

        b1 = QDialogButtonBox.StandardButton.Ok
        b2 = QDialogButtonBox.StandardButton.Cancel
        btn5 = QDialogButtonBox(b2, self)
        btn5.move(50, 300)

        # 3.输入框
        input1 = QLineEdit(self)
        input1.move(150, 10)
        input2 = QLineEdit('admin', self)
        input2.move(150, 50)
        input1.setText('张三')
        # 富文本
        input3 = QTextEdit('张三', self)
        input3.move(50, 300)
        # 设置成只读
        input3.setReadOnly(True)
        # 只能显示纯文本
        input4 = QPlainTextEdit(self)
        input4.move(300, 10)
        # 输入数值
        input5 = QSpinBox(self)
        input5.move(100, 100)
        input5.setMinimum(10)
        input5.setMaximum(20)
        input5.setValue(15)
        print(input5.value())  # 获取当前值
        # 输入小数
        input6 = QDoubleSpinBox(self)
        input6.move(100, 150)
        # 下拉菜单
        input7 = QComboBox(self)
        input7.addItems(['item1', 'item2'])
        input7.move(150, 200)
        print(input7.currentText())  # 获取当前选中的选项,适用input8
        input8 = QFontComboBox(self)
        input8.move(350, 300)
        input8.setCurrentIndex(2)
        print(input8.currentText())
        label1.setFont(input8.currentFont())
        # 日期选择
        input9 = QDateEdit(date.today(), self)
        input9.move(300, 400)
        # 选择颜色
        input10 = QColorDialog(self)
        input10.move(400, 400)
        # input10.show()

        input11 = QDial(self)
        input11.move(300, 200)

        input12 = QSlider(self)
        input12.move(430, 350)
        input12.setMaximum(100)
        input12.setMinimum(-100)
        input12.setValue(20)
        input12.setOrientation(Qt.Horizontal)  # 设置为水平方向
Ejemplo n.º 13
0
 def activate_cmd(self, cmd_btn: QtWidgets.QCommandLinkButton) -> None:
     cmd_btn.setEnabled(True)
     for btn in self.cmd_btns:
         btn.setChecked(False)
     cmd_btn.setChecked(True)
Ejemplo n.º 14
0
cameraEntity.setPosition(QVector3D(0.0, 0.0, 20.0))
cameraEntity.setUpVector(QVector3D(0.0, 1.0, 0.0))
cameraEntity.setViewCenter(QVector3D(0.0, 0.0, 0.0))

# For camera controls.
camController = QFirstPersonCameraController(rootEntity)
camController.setCamera(cameraEntity)

# Scene modifier.
modifier = SceneModifier(rootEntity)

# Set root object of the scene.
view.setRootEntity(rootEntity)

# Create control widgets.
info = QCommandLinkButton(text="Qt3D ready-made meshes")
info.setDescription("Qt3D provides several ready-made meshes, like torus, "
                    "cylinder, cone, cube, plane and sphere.")
info.setIconSize(QSize(0, 0))

torusCB = QCheckBox(checked=True, text="Torus")
coneCB = QCheckBox(checked=True, text="Cone")
cylinderCB = QCheckBox(checked=True, text="Cylinder")
cuboidCB = QCheckBox(checked=True, text="Cuboid")
planeCB = QCheckBox(checked=True, text="Plane")
sphereCB = QCheckBox(checked=True, text="Sphere")

vLayout.addWidget(info)
vLayout.addWidget(torusCB)
vLayout.addWidget(coneCB)
vLayout.addWidget(cylinderCB)