Esempio n. 1
0
    def start(self):

        super().__init__()

        self.setWindowTitle("Enter your credentials")

        QBtn = QDialogButtonBox.StandardButton.Ok

        self.buttonBox = QDialogButtonBox(QBtn)
        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)

        self.layout = QFormLayout()
        self.layout.addRow('Username:'******'Password:'******'Hostname:', QLineEdit())
        self.layout.addRow('Database:', QLineEdit())

        self.layout.addWidget(self.buttonBox)
        self.setLayout(self.layout)

        self.exec()

        if QBtn == QDialogButtonBox.StandardButton.Ok:

            cred = {
                'user': self.layout.itemAt(1).widget().text(),
                'password': self.layout.itemAt(3).widget().text(),
                'host': self.layout.itemAt(5).widget().text(),
                'database': self.layout.itemAt(7).widget().text()
            }

            try:

                success = CONNECT(cred)
                env = dotenv.find_dotenv()
                dotenv.set_key(env, 'USER', cred['user'])
                dotenv.set_key(env, 'PASS', cred['password'])
                dotenv.set_key(env, 'HOST', cred['host'])
                dotenv.set_key(env, 'DATA', cred['database'])

                return success

            except (sql.errors.InterfaceError, ValueError):

                message = QMessageBox(self)
                message.setWindowTitle('Error')
                message.setText('The entered credentials are incorrect')
                message.setStandardButtons(QMessageBox.StandardButton.Ok)

                if message == QMessageBox.StandardButton.Ok:
                    self.start()
Esempio n. 2
0
    def __init__(self, parent=None):
        super(ConfigDialog, self).__init__(parent)
        self.classifyExercises = parent.classifyExercises
        self.setFixedSize(500, 400)
        self.setWindowTitle("Model Configurations")

        self.epochValue = QLabel()
        self.vbox = QVBoxLayout()
        self.label_maximum = QLabel()
        self.label_minimum = QLabel()
        self.slider_hbox = QHBoxLayout()
        self.slider_vbox = QVBoxLayout()
        self.batchSizeMenu = QComboBox()
        self.properties = QFormLayout()
        self.epochSlider = Slider(orientation=Qt.Orientations.Horizontal)

        self.trainButton = QPushButton('Train Model')
        self.resultButton = QPushButton('Show result image')
        self.progress = QProgressBar()

        self.batchSizeMenu.addItems(['2', '4', '8', '16', '32', '64', '128'])
        self.batchSizeMenu.setCurrentIndex(3)
        self.batchSizeMenu.setMaximumWidth(100)

        self.initSlider()

        self.properties.addRow('Batch Size', self.batchSizeMenu)

        self.resultButton.setEnabled(False)
        self.actionsLayout = QHBoxLayout()

        self.actionsLayout.addWidget(self.trainButton)
        self.actionsLayout.addWidget(self.resultButton)

        self.optionsLayout = QVBoxLayout()
        self.optionsLayout.addWidget(QLabel('Model properties'))
        self.optionsLayout.addLayout(self.vbox)
        self.optionsLayout.addLayout(self.properties)
        self.optionsLayout.addLayout(self.actionsLayout)
        self.progress.setAlignment(QtCore.Qt.Alignment.AlignCenter)
        self.optionsLayout.addWidget(self.progress)
        # self.options_layout.addWidget(self.label)
        # self.options_layout.addWidget(self.list_widget)

        self.setLayout(self.optionsLayout)

        self.trainThread = TrainThread(self.classifyExercises)
        self.connections()
        print("init config")
Esempio n. 3
0
 def __init__(self, parent=None):
     QWidget.__init__(self, parent)
     self.l = l = QFormLayout(self)
     self.username = u = QLineEdit(self)
     u.textChanged.connect(self.changed.emit)
     l.addRow(_('&Username:'******'Username for this account'))
     self.password = p = QLineEdit(self)
     l.addRow(_('&Password:'******'Password for this account'))
     p.textChanged.connect(self.changed.emit)
     p.setEchoMode(QLineEdit.EchoMode.Password)
     self.show_password = sp = QCheckBox(_('&Show password'))
     l.addWidget(sp)
     sp.toggled.connect(self.show_password_toggled)
     self.la = la = QLabel(_('&Notes:'))
     l.addRow(la)
     self.notes = n = QPlainTextEdit(self)
     la.setBuddy(n)
     n.textChanged.connect(self.changed.emit)
     l.addRow(n)
     self.autosubmit = asb = QCheckBox(
         _('&Auto login with these credentials'), self)
     l.addRow(asb)
     asb.stateChanged.connect(self.on_change)
     self.rb = b = QPushButton(_('&Delete this account'))
     b.clicked.connect(self.delete_requested.emit)
     l.addRow(b)
 def __init__(self, parent):
     super().__init__(parent)
     self.setWindowTitle('Cargar Fichero')
     self.dlg_v_layout = QVBoxLayout()
     form_layout = QFormLayout()
     self.load_file = QLineEdit()
     self.error_label = QLabel()
     form_layout.addRow('Ruta del archivo:', self.load_file)
     self.dlg_v_layout.addLayout(form_layout)
     self.dlg_v_layout.addWidget(self.error_label)
     buttons_h_layout = QHBoxLayout()
     button_cancel = QPushButton('Cancelar')
     self.button_ok = QPushButton('Aceptar')
     buttons_h_layout.addWidget(button_cancel)
     buttons_h_layout.addWidget(self.button_ok)
     self.dlg_v_layout.addLayout(buttons_h_layout)
     self.setLayout(self.dlg_v_layout)
     button_cancel.clicked.connect(self._clear)
     button_cancel.clicked.connect(self.close)
     self.button_ok.clicked.connect(self._load)
Esempio n. 5
0
    def lockPageUI(self):
        layout = QFormLayout()

        self.lockPage.facilNameInput = QLineEdit()
        layout.addRow("Name", self.lockPage.facilNameInput)

        self.lockPage.facilPasswordInput = QLineEdit()
        layout.addRow("Password", self.lockPage.facilPasswordInput)

        self.lockPage.loginButton = QPushButton("&Login")
        self.lockPage.loginButton.clicked.connect(self.attemptLockFacilLogin)
        layout.addRow(self.lockPage.loginButton)

        self.lockPage.setLayout(layout)
Esempio n. 6
0
class CreatePatientDialog(QDialog):
    def __init__(self, classification, patient, infoLabel, parent=None):
        super(CreatePatientDialog, self).__init__(parent)
        self.setWindowTitle('Create new patient')
        layout = QVBoxLayout()
        self.setLayout(layout)
        self.setMinimumWidth(200)

        self.patient = patient
        self.classifyExercises = classification
        self.infoLabel = infoLabel

        self.subjectEdit = QLineEdit()
        self.subjectEdit.setFixedHeight(30)
        self.subjectEdit.setText('Jozsika')
        self.subjectEdit.setStyleSheet(CustomQStyles.lineEditStyle)

        self.ageEdit = QLineEdit()
        self.ageEdit.setFixedHeight(30)
        self.ageEdit.setValidator(QIntValidator())
        self.ageEdit.setText('5')
        self.ageEdit.setStyleSheet(CustomQStyles.lineEditStyle)

        self.subjectButton = QPushButton('Add patient')
        self.subjectButton.setFixedHeight(30)
        self.subjectButton.setStyleSheet(CustomQStyles.outlineButtonStyle)
        self.subjectButton.clicked.connect(self.onSubjectSelected)
        self.subjectButton.setContentsMargins(5, 15, 5, 5)
        formContainer = QWidget()
        self.formLayout = QFormLayout()
        self.formLayout.addRow('Name', self.subjectEdit)
        self.formLayout.addRow('Age', self.ageEdit)
        self.formLayout.addWidget(self.subjectButton)
        self.formLayout.setFormAlignment(Qt.Alignment.AlignCenter)
        formContainer.setLayout(self.formLayout)
        formContainer.setStyleSheet(
            "background-color: white; border-radius: 7px;")
        layout.addWidget(formContainer)

    def onSubjectSelected(self):
        if self.classifyExercises is not None \
                and "" != self.subjectEdit.text() \
                and "" != self.ageEdit.text():
            self.subject = self.subjectEdit.text()
            self.classifyExercises.subject = self.subject
            self.classifyExercises.age = self.ageEdit.text()
            self.infoLabel.setText("Subject name set to " + self.subject +
                                   ", age " + self.classifyExercises.age)
            self.close()
Esempio n. 7
0
    def collapsePageUI(self):
        layout = QFormLayout()

        self.collapsePage.scoreBoard = QLabel()
        layout.addRow(self.collapsePage.scoreBoard)

        self.collapsePage.winnerDisplay = QLabel()
        layout.addRow(self.collapsePage.winnerDisplay)

        self.collapsePage.backButton = QPushButton("Back")
        self.collapsePage.backButton.clicked.connect(
            self.goTo_PlayerAdmissionsPage)
        layout.addRow(self.collapsePage.backButton)

        self.collapsePage.setLayout(layout)
Esempio n. 8
0
 def setup_ui(self):
     self.l = l = QFormLayout(self)
     l.setFieldGrowthPolicy(
         QFormLayout.FieldGrowthPolicy.ExpandingFieldsGrow)
     self.la = la = QLabel(self.msg)
     la.setMinimumWidth(450)
     la.setWordWrap(True)
     l.addRow(la)
     self.username = un = QLineEdit(self)
     l.addRow(_('&Username:'******'&Password:'******'&Show password'), self)
     l.addRow(c)
     c.toggled.connect(self.show_password_toggled)
     l.addRow(self.bb)
Esempio n. 9
0
    def loginPageUI(self):
        layout = QFormLayout()

        self.loginPage.nameInput = QLineEdit()
        layout.addRow("Name", self.loginPage.nameInput)

        self.loginPage.passwordInput = QLineEdit()
        layout.addRow("Password", self.loginPage.passwordInput)

        self.loginPage.loginButton = QPushButton("&Login")
        self.loginPage.loginButton.clicked.connect(self.attemptLogin)

        self.loginPage.abortLoginButton = QPushButton("&Back")
        self.loginPage.abortLoginButton.clicked.connect(
            self.goTo_PlayerAdmissionsPage)

        layout.addRow(self.loginPage.abortLoginButton,
                      self.loginPage.loginButton)
        self.loginPage.setLayout(layout)
    def __init__(
        self,
        parent: Optional[QWidget] = None,
        *args: Tuple[Any, Any],
        **kwargs: Tuple[Any, Any],
    ) -> None:
        """
        Grouped controls box for generating mazes
        """
        super(GenerateMazeGroupView, self).__init__(parent=parent,
                                                    *args,
                                                    **kwargs)
        self.setContentsMargins(0, 0, 0, 0)

        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)

        groupbox = QGroupBox("Generate Maze")
        layout.addWidget(groupbox)

        vbox = QFormLayout()
        groupbox.setLayout(vbox)

        self.__mazeSizePicker = XYPicker(
            minimum=XY(2, 2),
            maximum=XY(250, 250),
            initialValue=XY(2, 2),
            parent=self,
        )

        self.__simplyConnectedCheckbox = QCheckBox()
        self.__simplyConnectedCheckbox.setChecked(True)

        generateButton = QPushButton("Generate")
        generateButton.clicked.connect(
            self.__onGenerateButtonPressed)  # type: ignore

        vbox.addRow("Size", self.__mazeSizePicker)
        vbox.addRow("Simply Connected", self.__simplyConnectedCheckbox)
        vbox.addRow(generateButton)

        self.setLayout(layout)
Esempio n. 11
0
    def facilStartPageUI(self):
        layout = QFormLayout()

        self.facilStartPage.loginPlayersButton = QPushButton("Log In Players")
        self.facilStartPage.loginPlayersButton.clicked.connect(
            self.goTo_PlayerAdmissionsPage)
        layout.addRow(self.facilStartPage.loginPlayersButton)

        self.facilStartPage.questionBankButton = QPushButton("Question Bank")
        self.facilStartPage.questionBankButton.clicked.connect(
            self.goTo_QuestionBankPage)
        layout.addRow(self.facilStartPage.questionBankButton)

        self.facilStartPage.setLayout(layout)
Esempio n. 12
0
 def setupUI(self):
     """Setup the Add Contact dialog's GUI."""
     # Create line edits for data fields
     self.nameField = QLineEdit()
     self.nameField.setObjectName("Name")
     self.jobField = QLineEdit()
     self.jobField.setObjectName("Job")
     self.emailField = QLineEdit()
     self.emailField.setObjectName("Email")
     # Lay out the data fields
     layout = QFormLayout()
     layout.addrow("Name:", self.nameField)
     layout.addrow("Job:", self.jobField)
     layout.addrow("Email:", self.emailField)
     self.layout.addLayout(layout)
     # add standard buttons to the dialog and conntect them
     self.buttonsBox = QDialogButtonBox(self)
     self.buttonsBox.setOrientation(Qt.Horizontal)
     self.buttonsBox.setStandardButtons(
         QDialogButtonBox.Ok | QDialogButtonBox.Cancel
     )
     self.buttonsBox.accepted.connect(self.accept)
     self.buttonsBox.rejected.connect(self.reject)
     self.layout.addWidget(self.buttonsBox)
    def _create_metadata_display(self):
        self.hlayout_track_bpm = QHBoxLayout()
        self.form_layout_track = QFormLayout()
        self.form_layout_bpm = QFormLayout()

        self.display_title = QLineEdit()
        self.display_title.setFixedSize(200, 20)
        self.display_artist = QLineEdit()
        self.display_artist.setFixedSize(200, 20)
        self.display_album = QLineEdit()
        self.display_album.setFixedSize(200, 20)
        self.display_album_artist = QLineEdit()
        self.display_album_artist.setFixedSize(200, 20)
        self.display_genre = QLineEdit()
        self.display_genre.setFixedSize(200, 20)
        self.display_track = QLineEdit()
        self.display_track.setFixedSize(60, 20)
        self.display_release_date = QLineEdit()
        self.display_release_date.setFixedSize(200, 20)
        self.display_bpm = QLineEdit()
        self.display_bpm.setFixedSize(60, 20)
        self.display_publisher = QLineEdit()
        self.display_publisher.setFixedSize(200, 20)

        self.hlayout_track_bpm.addLayout(self.form_layout_track)
        self.form_layout_track.addRow('Pista:', self.display_track)
        self.hlayout_track_bpm.addLayout(self.form_layout_bpm)
        self.form_layout_bpm.addRow('BPM:', self.display_bpm)
        self.left_widget_top.setLayout(self.hlayout_track_bpm)

        self.form_layout = QFormLayout()
        self.form_layout.addRow('Titulo:', self.display_title)
        self.form_layout.addRow('Artista:', self.display_artist)
        self.form_layout.addRow('Album:', self.display_album)
        self.form_layout.addRow('Album artist:', self.display_album_artist)
        self.form_layout.addRow('Genero:', self.display_genre)
        self.form_layout.addRow('Fecha:', self.display_release_date)
        self.form_layout.addRow('Publicacion:', self.display_publisher)
        self.left_widget_bot.setLayout(self.form_layout)
Esempio n. 14
0
    def initUI(self):
        self.setWindowTitle("设置")
        logo = QLabel()
        logo.setPixmap(QPixmap(SRC_DIR + "logo2.gif"))
        logo.setStyleSheet("background-color:rgb(255,255,255);")
        logo.setAlignment(Qt.AlignmentFlag.AlignCenter)
        self.download_threads_lb = QLabel("同时下载文件数")
        self.download_threads_var = QLineEdit()
        self.download_threads_var.setPlaceholderText("范围:1-9")
        self.download_threads_var.setToolTip("范围:1-9")
        self.download_threads_var.setInputMask("D")
        self.max_size_lb = QLabel("分卷大小(MB)")
        self.max_size_var = QLineEdit()
        self.max_size_var.setPlaceholderText("普通用户最大100,vip用户根据具体情况设置")
        self.max_size_var.setToolTip("普通用户最大100,vip用户根据具体情况设置")
        self.max_size_var.setInputMask("D99")
        self.timeout_lb = QLabel("请求超时(秒)")
        self.timeout_var = QLineEdit()
        self.timeout_var.setPlaceholderText("范围:1-99")
        self.timeout_var.setToolTip("范围:1-99")
        self.timeout_var.setInputMask("D9")
        self.upload_delay_lb = QLabel("上传延时(秒)")
        self.upload_delay_var = QLineEdit()
        self.upload_delay_var.setPlaceholderText("范围:1-99")
        self.upload_delay_var.setToolTip("范围:1-99")
        self.upload_delay_var.setInputMask("D9")
        self.dl_path_lb = QLabel("下载保存路径")
        self.dl_path_var = MyLineEdit(self)
        self.dl_path_var.clicked.connect(self.set_download_path)
        self.time_fmt_box = QCheckBox("使用[年-月-日]时间格式")
        self.time_fmt_box.setToolTip("文件上传日期显示格式")
        self.to_tray_box = QCheckBox("关闭到系统托盘")
        self.to_tray_box.setToolTip("点击关闭软件按钮是最小化软件至系统托盘")
        self.watch_clipboard_box = QCheckBox("监听系统剪切板")
        self.watch_clipboard_box.setToolTip("检测到系统剪切板中有符合规范的蓝奏链接时自动唤起软件,并提取")
        self.debug_box = QCheckBox("开启调试日志")
        self.debug_box.setToolTip("记录软件 debug 信息至 debug-lanzou-gui.log 文件")
        self.set_pwd_box = QCheckBox("上传文件自动设置密码")
        self.set_pwd_var = AutoResizingTextEdit()
        self.set_pwd_var.setPlaceholderText(" 2-8 位数字或字母")
        self.set_pwd_var.setToolTip("2-8 位数字或字母")
        self.set_desc_box = QCheckBox("上传文件自动设置描述")
        self.set_desc_var = AutoResizingTextEdit()
        self.big_file_box = QCheckBox(f"允许上传超过 {self.max_size}MB 的大文件")
        self.big_file_box.setToolTip("开启大文件上传支持 (功能下线)")
        self.upgrade_box = QCheckBox("自动检测新版本")
        self.upgrade_box.setToolTip("在软件打开时自动检测是否有新的版本发布,如有则弹出更新信息")

        self.time_fmt_box.toggle()
        self.time_fmt_box.stateChanged.connect(self.change_time_fmt)
        self.to_tray_box.stateChanged.connect(self.change_to_tray)
        self.watch_clipboard_box.stateChanged.connect(self.change_watch_clipboard)
        self.debug_box.stateChanged.connect(self.change_debug)
        self.set_pwd_box.stateChanged.connect(self.change_set_pwd)
        self.set_pwd_var.editingFinished.connect(self.check_pwd)
        self.set_desc_box.stateChanged.connect(self.change_set_desc)
        self.big_file_box.stateChanged.connect(self.change_big_file)
        self.upgrade_box.stateChanged.connect(self.change_upgrade)

        buttonBox = QDialogButtonBox()
        buttonBox.setOrientation(Qt.Orientation.Horizontal)
        buttonBox.setStandardButtons(QDialogButtonBox.StandardButton.Reset | QDialogButtonBox.StandardButton.Save | QDialogButtonBox.StandardButton.Cancel)
        buttonBox.button(QDialogButtonBox.StandardButton.Reset).setText("重置")
        buttonBox.button(QDialogButtonBox.StandardButton.Save).setText("保存")
        buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setText("取消")
        buttonBox.button(QDialogButtonBox.StandardButton.Reset).clicked.connect(lambda: self.set_values(reset=True))
        buttonBox.button(QDialogButtonBox.StandardButton.Save).clicked.connect(self.slot_save)
        buttonBox.rejected.connect(self.reject)

        form = QFormLayout()
        form.setLabelAlignment(Qt.AlignmentFlag.AlignRight)
        form.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.AllNonFixedFieldsGrow)  # 覆盖MacOS的默认样式
        form.setSpacing(10)
        form.addRow(self.download_threads_lb, self.download_threads_var)
        form.addRow(self.timeout_lb, self.timeout_var)
        form.addRow(self.upload_delay_lb, self.upload_delay_var)
        form.addRow(self.max_size_lb, self.max_size_var)
        form.addRow(self.dl_path_lb, self.dl_path_var)

        vbox = QVBoxLayout()
        vbox.addWidget(logo)
        vbox.addStretch(1)
        vbox.addLayout(form)
        vbox.addStretch(1)
        hbox = QHBoxLayout()
        hbox.addWidget(self.time_fmt_box)
        hbox.addWidget(self.to_tray_box)
        hbox.addWidget(self.watch_clipboard_box)
        hbox.addWidget(self.debug_box)
        vbox.addLayout(hbox)
        vbox.addStretch(1)
        hbox_2 = QHBoxLayout()
        hbox_2.addWidget(self.set_pwd_box)
        hbox_2.addWidget(self.set_pwd_var)
        vbox.addLayout(hbox_2)
        vbox.addStretch(1)
        hbox_3 = QHBoxLayout()
        hbox_3.addWidget(self.set_desc_box)
        hbox_3.addWidget(self.set_desc_var)
        vbox.addLayout(hbox_3)
        hbox_4 = QHBoxLayout()
        hbox_4.addWidget(self.big_file_box)
        hbox_4.addWidget(self.upgrade_box)
        vbox.addStretch(1)
        vbox.addLayout(hbox_4)
        vbox.addStretch(2)
        vbox.addWidget(buttonBox)
        self.setLayout(vbox)
        self.setMinimumWidth(500)
Esempio n. 15
0
    def initUI(self):
        self.setWindowTitle("登录蓝奏云")
        self.setWindowIcon(QIcon(SRC_DIR + "login.ico"))
        logo = QLabel()
        logo.setPixmap(QPixmap(SRC_DIR + "logo3.gif"))
        logo.setStyleSheet("background-color:rgb(0,153,255);")
        logo.setAlignment(Qt.AlignmentFlag.AlignCenter)

        self.tabs = QTabWidget()
        self.auto_tab = QWidget()
        self.hand_tab = QWidget()

        # Add tabs
        self.tabs.addTab(self.auto_tab,"自动获取Cookie")
        self.tabs.addTab(self.hand_tab,"手动输入Cookie")
        self.auto_get_cookie_ok = AutoResizingTextEdit("🔶点击👇自动获取浏览器登录信息👇")
        self.auto_get_cookie_ok.setReadOnly(True)
        self.auto_get_cookie_btn = QPushButton("自动读取浏览器登录信息")
        auto_cookie_notice = '支持浏览器:Chrome, Chromium, Opera, Edge, Firefox'
        self.auto_get_cookie_btn.setToolTip(auto_cookie_notice)
        self.auto_get_cookie_btn.clicked.connect(self.call_auto_get_cookie)
        self.auto_get_cookie_btn.setStyleSheet("QPushButton {min-width: 210px;max-width: 210px;}")

        self.name_lb = QLabel("&U 用户")
        self.name_lb.setAlignment(Qt.AlignmentFlag.AlignCenter)
        self.name_ed = QLineEdit()
        self.name_lb.setBuddy(self.name_ed)

        self.pwd_lb = QLabel("&P 密码")
        self.pwd_lb.setAlignment(Qt.AlignmentFlag.AlignCenter)
        self.pwd_ed = QLineEdit()
        self.pwd_ed.setEchoMode(QLineEdit.EchoMode.Password)
        self.pwd_lb.setBuddy(self.pwd_ed)

        self.cookie_lb = QLabel("&Cookie")
        self.cookie_ed = QTextEdit()
        notice = "由于滑动验证的存在,需要输入cookie,cookie请使用浏览器获取\n" + \
            "cookie会保存在本地,下次使用。其格式如下:\n ylogin=value1; phpdisk_info=value2"
        self.cookie_ed.setPlaceholderText(notice)
        self.cookie_lb.setBuddy(self.cookie_ed)

        self.show_input_cookie_btn = QPushButton("显示Cookie输入框")
        self.show_input_cookie_btn.setToolTip(notice)
        self.show_input_cookie_btn.setStyleSheet("QPushButton {min-width: 110px;max-width: 110px;}")
        self.show_input_cookie_btn.clicked.connect(self.change_show_input_cookie)
        self.ok_btn = QPushButton("登录")
        self.ok_btn.clicked.connect(self.change_ok_btn)
        self.cancel_btn = QPushButton("取消")
        self.cancel_btn.clicked.connect(self.change_cancel_btn)
        lb_line_1 = QLabel()
        lb_line_1.setText('<html><hr />切换用户</html>')
        lb_line_2 = QLabel()
        lb_line_2.setText('<html><hr /></html>')

        self.form = QFormLayout()
        self.form.setLabelAlignment(Qt.AlignmentFlag.AlignRight)
        self.form.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.AllNonFixedFieldsGrow)  # 覆盖MacOS的默认样式
        self.form.addRow(self.name_lb, self.name_ed)
        self.form.addRow(self.pwd_lb, self.pwd_ed)
        if is_windows:
            def set_assister_path():
                """设置辅助登录程序路径"""
                assister_path = QFileDialog.getOpenFileName(self, "选择辅助登录程序路径",
                                                            self._cwd, "EXE Files (*.exe)")
                if not assister_path[0]:
                    return None
                assister_path = os.path.normpath(assister_path[0])  # windows backslash
                if assister_path == self._cookie_assister:
                    return None
                self.assister_ed.setText(assister_path)
                self._cookie_assister = assister_path

            self.assister_lb = QLabel("登录辅助程序")
            self.assister_lb.setAlignment(Qt.AlignmentFlag.AlignCenter)
            self.assister_ed = MyLineEdit(self)
            self.assister_ed.setText(self._cookie_assister)
            self.assister_ed.clicked.connect(set_assister_path)
            self.assister_lb.setBuddy(self.assister_ed)
            self.form.addRow(self.assister_lb, self.assister_ed)

        hbox = QHBoxLayout()
        hbox.addWidget(self.show_input_cookie_btn)
        hbox.addStretch(1)
        hbox.addWidget(self.ok_btn)
        hbox.addWidget(self.cancel_btn)

        user_box = QHBoxLayout()
        self.user_num = 0
        self.user_btns = {}
        for user in self._config.users_name:
            user = str(user)  # TODO: 可能需要删掉
            self.user_btns[user] = QDoublePushButton(user)
            self.user_btns[user].setStyleSheet("QPushButton {border:none;}")
            if user == self._config.name:
                self.user_btns[user].setStyleSheet("QPushButton {background-color:rgb(0,153,2);}")
                self.tabs.setCurrentIndex(1)
            self.user_btns[user].setToolTip(f"点击选中,双击切换至用户:{user}")
            self.user_btns[user].doubleClicked.connect(self.choose_user)
            self.user_btns[user].clicked.connect(self.delete_chose_user)
            user_box.addWidget(self.user_btns[user])
            self.user_num += 1
            user_box.addStretch(1)

        self.layout = QVBoxLayout(self)
        self.layout.addWidget(logo)
        vbox = QVBoxLayout()
        if self._config.name:
            vbox.addWidget(lb_line_1)
            user_box.setAlignment(Qt.AlignmentFlag.AlignCenter)
            vbox.addLayout(user_box)
            vbox.addWidget(lb_line_2)
            if self.user_num > 1:
                self.del_user_btn = QPushButton("删除账户")
                self.del_user_btn.setIcon(QIcon(SRC_DIR + "delete.ico"))
                self.del_user_btn.setStyleSheet("QPushButton {min-width: 180px;max-width: 180px;}")
                self.del_user_btn.clicked.connect(self.call_del_chose_user)
                vbox.addWidget(self.del_user_btn)
            else:
                self.del_user_btn = None
            vbox.addStretch(1)

        vbox.addLayout(self.form)
        vbox.addStretch(1)
        vbox.addLayout(hbox)
        vbox.setAlignment(Qt.AlignmentFlag.AlignCenter)

        self.hand_tab.setLayout(vbox)
        auto_cookie_vbox = QVBoxLayout()
        auto_cookie_vbox.addWidget(self.auto_get_cookie_ok)
        auto_cookie_vbox.addWidget(self.auto_get_cookie_btn)
        auto_cookie_vbox.setAlignment(Qt.AlignmentFlag.AlignCenter)
        self.auto_tab.setLayout(auto_cookie_vbox)
        self.layout.addWidget(self.tabs)
        self.setLayout(self.layout)
        self.update_selection(self._config.name)
Esempio n. 16
0
    def initUI(self):
        self.setWindowTitle("关于 lanzou-gui")
        about = f'本项目使用PyQt6实现图形界面,可以完成蓝奏云的大部分功能<br/> \
    得益于 <a href="{self._api_url}">API</a> 的功能,可以间接突破单文件最大 100MB 的限制,同时增加了批量上传/下载的功能<br/> \
Python 依赖见<a href="{self._github }/blob/master/requirements.txt">requirements.txt</a>,\
<a href="{self._github}/releases">releases</a> 有打包好了的 Windows 可执行程序,但可能不是最新的'

        project_url = f'<a href="{self._home_page}">主页</a> | <a href="{self._github}">repo</a> | \
                        <a href="{self._gitee}">mirror repo</a>'

        self.logo = QLabel()  # logo
        self.logo.setPixmap(QPixmap(SRC_DIR + "logo2.gif"))
        self.logo.setStyleSheet("background-color:rgb(255,255,255);")
        self.logo.setAlignment(Qt.AlignmentFlag.AlignCenter)
        self.lb_qt_ver = QLabel("依赖")  # QT 版本
        self.lb_qt_text = QLabel(
            f"QT: {QT_VERSION_STR}, PyQt: {PYQT_VERSION_STR}")  # QT 版本
        self.lb_name = QLabel("版本")  # 版本
        self.lb_name_text = QPushButton("")  # 版本
        self.lb_name_text.setToolTip("点击检查更新")
        ver_style = "QPushButton {border:none; background:transparent;font-weight:bold;color:blue;}"
        self.lb_name_text.setStyleSheet(ver_style)
        self.lb_name_text.clicked.connect(
            lambda: self.check_update.emit(self._ver, True))
        self.lb_about = QLabel("关于")  # about
        self.lb_about_text = QLabel()
        self.lb_about_text.setText(about)
        self.lb_about_text.setOpenExternalLinks(True)
        self.lb_author = QLabel("作者")  # author
        self.lb_author_mail = QLabel(
            "<a href='mailto:[email protected]'>rachpt</a>")
        self.lb_author_mail.setOpenExternalLinks(True)
        self.lb_update = QLabel("项目")  # 更新
        self.lb_update_url = QLabel(project_url)
        self.lb_update_url.setOpenExternalLinks(True)
        self.buttonBox = QDialogButtonBox()
        self.buttonBox.setOrientation(Qt.Orientation.Horizontal)
        self.buttonBox.setStandardButtons(
            QDialogButtonBox.StandardButton.Close)
        self.buttonBox.button(
            QDialogButtonBox.StandardButton.Close).setText("关闭")
        self.buttonBox.rejected.connect(self.reject)
        self.buttonBox.setStyleSheet(btn_style)

        self.recommend = QLabel(
            "<br />大文件推荐使用 <a href='https://github.com/Aruelius/cloud189'>cloud189-cli</a>"
        )
        self.recommend.setOpenExternalLinks(True)

        self.line = QLine(QPoint(), QPoint(550, 0))
        self.lb_line = QLabel('<html><hr /></html>')

        vbox = QVBoxLayout()
        vbox.addWidget(self.logo)
        vbox.addStretch(1)
        self.form = QFormLayout()
        self.form.setLabelAlignment(Qt.AlignmentFlag.AlignRight)
        self.form.setFormAlignment(Qt.AlignmentFlag.AlignLeft)
        self.form.setHorizontalSpacing(40)
        self.form.setVerticalSpacing(15)
        self.form.addRow(self.lb_qt_ver, self.lb_qt_text)
        self.form.addRow(self.lb_name, self.lb_name_text)
        self.form.addRow(self.lb_update, self.lb_update_url)
        self.form.addRow(self.lb_author, self.lb_author_mail)
        self.form.addRow(self.lb_about, self.lb_about_text)
        self.form.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.
                                       AllNonFixedFieldsGrow)  # 覆盖MacOS的默认样式
        vbox.addLayout(self.form)
        vbox.addStretch(1)
        vbox.addWidget(self.recommend)
        vbox.addWidget(self.lb_line)
        donate = QLabel()
        donate.setText("<b>捐助我</b>&nbsp;如果你愿意")
        donate.setAlignment(Qt.AlignmentFlag.AlignCenter)
        hbox = QHBoxLayout()
        hbox.addStretch(2)
        for it in ["wechat", "alipay", "qqpay"]:
            lb = QLabel()
            lb.setPixmap(QPixmap(SRC_DIR + f"{it}.jpg"))
            hbox.addWidget(lb)
        hbox.addStretch(1)
        hbox.addWidget(self.buttonBox)
        vbox.addWidget(donate)
        vbox.addLayout(hbox)
        self.setLayout(vbox)
        self.setMinimumWidth(720)
Esempio n. 17
0
class AboutDialog(QDialog):
    check_update = pyqtSignal(str, bool)

    def __init__(self, parent=None):
        super(AboutDialog, self).__init__(parent)
        self._ver = ''
        self._github = 'https://github.com/rachpt/lanzou-gui'
        self._api_url = 'https://github.com/zaxtyson/LanZouCloud-API'
        self._gitee = 'https://gitee.com/rachpt/lanzou-gui'
        self._home_page = 'https://rachpt.cn/lanzou-gui/'
        self.initUI()
        self.setStyleSheet(others_style)

    def set_values(self, version):
        self._ver = version
        self.lb_name_text.setText(f"v{version}  (点击检查更新)")  # 更新版本

    def show_update(self, ver, msg):
        self.lb_new_ver = QLabel("新版")  # 检测新版
        self.lb_new_ver_msg = QLabel()
        self.lb_new_ver_msg.setOpenExternalLinks(True)
        self.lb_new_ver_msg.setWordWrap(True)
        if ver != '0':
            self.lb_name_text.setText(f"{self._ver}  ➡  {ver}")
        self.lb_new_ver_msg.setText(msg)
        self.lb_new_ver_msg.setMinimumWidth(700)
        if self.form.rowCount() < 5:
            self.form.insertRow(1, self.lb_new_ver, self.lb_new_ver_msg)

    def initUI(self):
        self.setWindowTitle("关于 lanzou-gui")
        about = f'本项目使用PyQt6实现图形界面,可以完成蓝奏云的大部分功能<br/> \
    得益于 <a href="{self._api_url}">API</a> 的功能,可以间接突破单文件最大 100MB 的限制,同时增加了批量上传/下载的功能<br/> \
Python 依赖见<a href="{self._github }/blob/master/requirements.txt">requirements.txt</a>,\
<a href="{self._github}/releases">releases</a> 有打包好了的 Windows 可执行程序,但可能不是最新的'

        project_url = f'<a href="{self._home_page}">主页</a> | <a href="{self._github}">repo</a> | \
                        <a href="{self._gitee}">mirror repo</a>'

        self.logo = QLabel()  # logo
        self.logo.setPixmap(QPixmap(SRC_DIR + "logo2.gif"))
        self.logo.setStyleSheet("background-color:rgb(255,255,255);")
        self.logo.setAlignment(Qt.AlignmentFlag.AlignCenter)
        self.lb_qt_ver = QLabel("依赖")  # QT 版本
        self.lb_qt_text = QLabel(
            f"QT: {QT_VERSION_STR}, PyQt: {PYQT_VERSION_STR}")  # QT 版本
        self.lb_name = QLabel("版本")  # 版本
        self.lb_name_text = QPushButton("")  # 版本
        self.lb_name_text.setToolTip("点击检查更新")
        ver_style = "QPushButton {border:none; background:transparent;font-weight:bold;color:blue;}"
        self.lb_name_text.setStyleSheet(ver_style)
        self.lb_name_text.clicked.connect(
            lambda: self.check_update.emit(self._ver, True))
        self.lb_about = QLabel("关于")  # about
        self.lb_about_text = QLabel()
        self.lb_about_text.setText(about)
        self.lb_about_text.setOpenExternalLinks(True)
        self.lb_author = QLabel("作者")  # author
        self.lb_author_mail = QLabel(
            "<a href='mailto:[email protected]'>rachpt</a>")
        self.lb_author_mail.setOpenExternalLinks(True)
        self.lb_update = QLabel("项目")  # 更新
        self.lb_update_url = QLabel(project_url)
        self.lb_update_url.setOpenExternalLinks(True)
        self.buttonBox = QDialogButtonBox()
        self.buttonBox.setOrientation(Qt.Orientation.Horizontal)
        self.buttonBox.setStandardButtons(
            QDialogButtonBox.StandardButton.Close)
        self.buttonBox.button(
            QDialogButtonBox.StandardButton.Close).setText("关闭")
        self.buttonBox.rejected.connect(self.reject)
        self.buttonBox.setStyleSheet(btn_style)

        self.recommend = QLabel(
            "<br />大文件推荐使用 <a href='https://github.com/Aruelius/cloud189'>cloud189-cli</a>"
        )
        self.recommend.setOpenExternalLinks(True)

        self.line = QLine(QPoint(), QPoint(550, 0))
        self.lb_line = QLabel('<html><hr /></html>')

        vbox = QVBoxLayout()
        vbox.addWidget(self.logo)
        vbox.addStretch(1)
        self.form = QFormLayout()
        self.form.setLabelAlignment(Qt.AlignmentFlag.AlignRight)
        self.form.setFormAlignment(Qt.AlignmentFlag.AlignLeft)
        self.form.setHorizontalSpacing(40)
        self.form.setVerticalSpacing(15)
        self.form.addRow(self.lb_qt_ver, self.lb_qt_text)
        self.form.addRow(self.lb_name, self.lb_name_text)
        self.form.addRow(self.lb_update, self.lb_update_url)
        self.form.addRow(self.lb_author, self.lb_author_mail)
        self.form.addRow(self.lb_about, self.lb_about_text)
        self.form.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.
                                       AllNonFixedFieldsGrow)  # 覆盖MacOS的默认样式
        vbox.addLayout(self.form)
        vbox.addStretch(1)
        vbox.addWidget(self.recommend)
        vbox.addWidget(self.lb_line)
        donate = QLabel()
        donate.setText("<b>捐助我</b>&nbsp;如果你愿意")
        donate.setAlignment(Qt.AlignmentFlag.AlignCenter)
        hbox = QHBoxLayout()
        hbox.addStretch(2)
        for it in ["wechat", "alipay", "qqpay"]:
            lb = QLabel()
            lb.setPixmap(QPixmap(SRC_DIR + f"{it}.jpg"))
            hbox.addWidget(lb)
        hbox.addStretch(1)
        hbox.addWidget(self.buttonBox)
        vbox.addWidget(donate)
        vbox.addLayout(hbox)
        self.setLayout(vbox)
        self.setMinimumWidth(720)

    def paintEvent(self, event):
        QDialog.paintEvent(self, event)
        if not self.line.isNull():
            painter = QPainter(self)
            pen = QPen(Qt.GlobalColor.red, 3)
            painter.setPen(pen)
            painter.drawLine(self.line)
Esempio n. 18
0
    def accountCreationPageUI(self):
        layout = QFormLayout()

        self.accountCreationPage.nameInput = QLineEdit()
        layout.addRow("Name", self.accountCreationPage.nameInput)

        self.accountCreationPage.phoneNumberInput = QLineEdit()
        layout.addRow("Phone Number",
                      self.accountCreationPage.phoneNumberInput)

        self.accountCreationPage.passwordInput = QLineEdit()
        layout.addRow("New Password", self.accountCreationPage.passwordInput)

        self.accountCreationPage.passwordConfirmInput = QLineEdit()
        layout.addRow("Confirm New Password",
                      self.accountCreationPage.passwordConfirmInput)

        self.accountCreationPage.createAccountButton = QPushButton(
            "&Create Account")
        self.accountCreationPage.createAccountButton.clicked.connect(
            self.createAccount)

        self.accountCreationPage.finishCreatingAccountsButton = QPushButton(
            "&Done")
        self.accountCreationPage.finishCreatingAccountsButton.clicked.connect(
            self.goTo_PlayerAdmissionsPage)

        layout.addRow(self.accountCreationPage.finishCreatingAccountsButton,
                      self.accountCreationPage.createAccountButton)
        self.accountCreationPage.setLayout(layout)
Esempio n. 19
0
class ConfigDialog(QDialog):
    def __init__(self, parent=None):
        super(ConfigDialog, self).__init__(parent)
        self.classifyExercises = parent.classifyExercises
        self.setFixedSize(500, 400)
        self.setWindowTitle("Model Configurations")

        self.epochValue = QLabel()
        self.vbox = QVBoxLayout()
        self.label_maximum = QLabel()
        self.label_minimum = QLabel()
        self.slider_hbox = QHBoxLayout()
        self.slider_vbox = QVBoxLayout()
        self.batchSizeMenu = QComboBox()
        self.properties = QFormLayout()
        self.epochSlider = Slider(orientation=Qt.Orientations.Horizontal)

        self.trainButton = QPushButton('Train Model')
        self.resultButton = QPushButton('Show result image')
        self.progress = QProgressBar()

        self.batchSizeMenu.addItems(['2', '4', '8', '16', '32', '64', '128'])
        self.batchSizeMenu.setCurrentIndex(3)
        self.batchSizeMenu.setMaximumWidth(100)

        self.initSlider()

        self.properties.addRow('Batch Size', self.batchSizeMenu)

        self.resultButton.setEnabled(False)
        self.actionsLayout = QHBoxLayout()

        self.actionsLayout.addWidget(self.trainButton)
        self.actionsLayout.addWidget(self.resultButton)

        self.optionsLayout = QVBoxLayout()
        self.optionsLayout.addWidget(QLabel('Model properties'))
        self.optionsLayout.addLayout(self.vbox)
        self.optionsLayout.addLayout(self.properties)
        self.optionsLayout.addLayout(self.actionsLayout)
        self.progress.setAlignment(QtCore.Qt.Alignment.AlignCenter)
        self.optionsLayout.addWidget(self.progress)
        # self.options_layout.addWidget(self.label)
        # self.options_layout.addWidget(self.list_widget)

        self.setLayout(self.optionsLayout)

        self.trainThread = TrainThread(self.classifyExercises)
        self.connections()
        print("init config")

    def initSlider(self):
        self.epochValue.setAlignment(QtCore.Qt.Alignment.AlignHCenter)

        self.epochSlider.setMinimum(2)
        self.epochSlider.setMaximum(10)
        self.epochSlider.setTickInterval(1)
        # self.epochSlider.setInterval(1)
        # self.epochSlider.setValue(8)  # no idea why, but 8 is the middle somehow
        self.epochSlider.setSliderPosition(6)
        self.epochSlider.setTickPosition(QSlider.TickPosition.TicksBelow)

        self.label_minimum.setNum(self.epochSlider.minimum().real * 50)
        self.label_minimum.setAlignment(QtCore.Qt.Alignment.AlignLeft)
        self.label_maximum.setNum(self.epochSlider.maximum().real * 50)

        self.label_maximum.setAlignment(QtCore.Qt.Alignment.AlignRight)

        self.epochSlider.minimumChanged.connect(self.label_minimum.setNum)
        self.epochSlider.maximumChanged.connect(self.label_maximum.setNum)

        self.slider_hbox.addWidget(self.label_minimum,
                                   QtCore.Qt.Alignment.AlignLeft)
        self.slider_hbox.addWidget(self.epochValue)
        self.slider_hbox.addWidget(self.label_maximum,
                                   QtCore.Qt.Alignment.AlignRight)

        self.slider_vbox.addWidget(self.epochSlider)
        self.slider_vbox.addLayout(self.slider_hbox)
        # self.slider_vbox.addStretch()

        self.vbox.addLayout(self.slider_vbox)

    def connections(self):
        self.batchSizeMenu.currentIndexChanged.connect(
            self.onBatchSizeSelected)
        self.resultButton.clicked.connect(self.onResultClicked)
        self.trainButton.clicked.connect(self.onTrainClicked)
        self.epochSlider.valueChanged.connect(self.updateEpochValue)
        self.trainThread.taskFinished.connect(self.onFinished)

    def updateEpochValue(self, num):
        print(num)
        epochs = num * 50
        self.epochValue.setNum(epochs)
        self.classifyExercises.epochs = epochs

    def onBatchSizeSelected(self, ind):
        self.classifyExercises.training_batch_size = int(
            self.batchSizeMenu.currentText())

    def onResultClicked(self):
        print("open image")
        self.classifyExercises.DisplayResults()

    def onTrainClicked(self):
        if self.classifyExercises.subject is not None:
            if self.classifyExercises.DataAvailable():
                if self.resultButton.isEnabled:
                    self.resultButton.setEnabled(False)

                self.trainThread.start()
                self.progress.setRange(0, 0)
            else:
                CustomMessage.showDialog(
                    "Message", "Calibrate for patient to obtain data.",
                    QMessageBox.StandardButtons.Ok)

        else:
            CustomMessage.showDialog(
                "Message", "You must either select or enter a subject name.",
                QMessageBox.StandardButtons.Ok)
            print("Subject is none!")

    def onFinished(self):
        # Stop the progress
        self.progress.setRange(0, 1)
        self.progress.setValue(1)
        CustomMessage.showDialog("Message", "Training model finished!",
                                 QMessageBox.StandardButtons.Ok)
        self.resultButton.setEnabled(True)
class View(QMainWindow):
    def __init__(self):
        super().__init__()

        self.setWindowTitle('Editor de Tags')
        self.setFixedSize(700, 480)

        self._central_widget = QWidget(self)
        self.setCentralWidget(self._central_widget)

        self.left_widget = QWidget(self._central_widget)
        self.left_widget.setGeometry(0, 80, 300, 380)
        self.right_widget = QWidget(self._central_widget)
        self.right_widget.setGeometry(305, 50, 400, 480)

        self.left_widget_top = QWidget(self.left_widget)
        self.left_widget_top.setGeometry(21, 10, 300, 50)
        self.left_widget_bot = QWidget(self.left_widget)
        self.left_widget_bot.setGeometry(0, 40, 300, 300)

        self._create_file_path_display()
        self._create_metadata_display()
        self._create_buttons()
        self._create_tool_bar()
        self._create_status_bar()

    #crear el visor de archivos y los metadatos
    def _create_file_path_display(self):
        self.file_path_display = QLineEdit(parent=self._central_widget)
        self.file_path_display.setGeometry(0, 0, 700, 60)
        self.file_path_display.setAlignment(Qt.AlignmentFlag.AlignCenter)
        self.file_path_display.setReadOnly(True)

    def _create_metadata_display(self):
        self.hlayout_track_bpm = QHBoxLayout()
        self.form_layout_track = QFormLayout()
        self.form_layout_bpm = QFormLayout()

        self.display_title = QLineEdit()
        self.display_title.setFixedSize(200, 20)
        self.display_artist = QLineEdit()
        self.display_artist.setFixedSize(200, 20)
        self.display_album = QLineEdit()
        self.display_album.setFixedSize(200, 20)
        self.display_album_artist = QLineEdit()
        self.display_album_artist.setFixedSize(200, 20)
        self.display_genre = QLineEdit()
        self.display_genre.setFixedSize(200, 20)
        self.display_track = QLineEdit()
        self.display_track.setFixedSize(60, 20)
        self.display_release_date = QLineEdit()
        self.display_release_date.setFixedSize(200, 20)
        self.display_bpm = QLineEdit()
        self.display_bpm.setFixedSize(60, 20)
        self.display_publisher = QLineEdit()
        self.display_publisher.setFixedSize(200, 20)

        self.hlayout_track_bpm.addLayout(self.form_layout_track)
        self.form_layout_track.addRow('Pista:', self.display_track)
        self.hlayout_track_bpm.addLayout(self.form_layout_bpm)
        self.form_layout_bpm.addRow('BPM:', self.display_bpm)
        self.left_widget_top.setLayout(self.hlayout_track_bpm)

        self.form_layout = QFormLayout()
        self.form_layout.addRow('Titulo:', self.display_title)
        self.form_layout.addRow('Artista:', self.display_artist)
        self.form_layout.addRow('Album:', self.display_album)
        self.form_layout.addRow('Album artist:', self.display_album_artist)
        self.form_layout.addRow('Genero:', self.display_genre)
        self.form_layout.addRow('Fecha:', self.display_release_date)
        self.form_layout.addRow('Publicacion:', self.display_publisher)
        self.left_widget_bot.setLayout(self.form_layout)

    #crear barra de tareas y botones

    def _create_buttons(self):
        self.close_button = QPushButton('Cerrar', parent=self.right_widget)
        self.close_button.setGeometry(220, 350, 70, 30)
        self.save_button = QPushButton('Guardar', parent=self.right_widget)
        self.save_button.setGeometry(300, 350, 70, 30)

    def _create_tool_bar(self):
        self.tools = QToolBar()
        self.addToolBar(self.tools)

    def _create_status_bar(self):
        status = QStatusBar()
        status.showMessage("Activo")
        self.setStatusBar(status)

    #crear el texto del display

    def set_display_text(self, file_path, title, artist, album, album_artist,
                         genre, track, release_date, bpm, publisher):
        self.file_path_display.setText(file_path)
        self.display_title.setText(title)
        self.display_artist.setText(artist)
        self.display_album.setText(album)
        self.display_album_artist.setText(album_artist)
        self.display_genre.setText(str(genre))
        self.display_track.setText(str(track))
        self.display_release_date.setText(str(release_date))
        self.display_bpm.setText(str(bpm))
        self.display_publisher.setText(publisher)

    def display_text(self):
        return self.display_title.text(), self.display_artist.text(
        ), self.display_album.text(), self.display_album_artist.text(
        ), self.display_genre.text(), self.display_track.text(
        ), self.display_release_date.text(), self.display_bpm.text(
        ), self.display_publisher.text()
    def __init__(self):
        """ Dialog to manage the settings of the application """
        super().__init__()
        self.setWindowTitle("Settings")
        self.setFixedSize(310, 250)

        # Create the general settings widgets for managing the text color,
        # text alignment, and author of the app's content
        # NOTE: Altering the default CSS attributes, such as the color, of a
        # widget can change its appearance. Hence, the button may appear
        # rectangular depending upon your platform
        self.text_color_button = QPushButton()
        self.text_color_button.setStyleSheet(
            "background-color: #000000")  # Black
        self.text_color_button.clicked.connect(self.selectTextColor)

        self.align_left = QRadioButton(text="Left")  # Default
        self.align_left.setChecked(True)
        self.align_center = QRadioButton(text="Center")
        self.align_center.setChecked(False)
        self.align_right = QRadioButton(text="Right")
        self.align_right.setChecked(False)

        # Layout and container for alignment radio buttons
        align_v_box = QVBoxLayout()
        align_v_box.setContentsMargins(0, 5, 0, 0)
        align_v_box.addWidget(self.align_left)
        align_v_box.addWidget(self.align_center)
        align_v_box.addWidget(self.align_right)

        align_frame = QFrame()
        align_frame.setFrameShape(QFrame.Shape.NoFrame)
        align_frame.setLayout(align_v_box)

        self.author_name = QLineEdit()
        self.author_name.setMinimumWidth(160)

        self.button_box = QDialogButtonBox(
            QDialogButtonBox.StandardButtons.Ok
            | QDialogButtonBox.StandardButtons.Cancel)
        self.button_box.accepted.connect(self.accept)
        self.button_box.rejected.connect(self.reject)

        dialog_layout = QFormLayout()
        dialog_layout.addRow("<b>Text Color:</b>", self.text_color_button)
        dialog_layout.addRow(HorizontalSeparator())
        dialog_layout.addRow("<b>Text Alignment:</b>", align_frame)
        dialog_layout.addRow(HorizontalSeparator())
        dialog_layout.addRow("<b>Author:</b>", self.author_name)
        dialog_layout.addWidget(self.button_box)
        self.setLayout(dialog_layout)
Esempio n. 22
0
    def playerAdmissionsPageUI(self):
        layout = QFormLayout()

        self.playerAdmissionsPage.createAnAccountButton = QPushButton(
            "&Create New Account!")
        self.playerAdmissionsPage.createAnAccountButton.clicked.connect(
            self.goTo_AccountCreationPage)
        layout.addRow(self.playerAdmissionsPage.createAnAccountButton)

        self.playerAdmissionsPage.proceedToLoginButton = QPushButton("&Login")
        self.playerAdmissionsPage.proceedToLoginButton.clicked.connect(
            self.goTo_LoginPage)
        layout.addRow(self.playerAdmissionsPage.proceedToLoginButton)

        self.playerAdmissionsPage.readyList = QListWidget()
        layout.addRow(self.playerAdmissionsPage.readyList)

        self.playerAdmissionsPage.removePlayerButton = QPushButton(
            "&Remove Selected Players")
        self.playerAdmissionsPage.removePlayerButton.clicked.connect(
            self.removePlayerFromPlayerAdmissionsPageList)
        layout.addRow(self.playerAdmissionsPage.removePlayerButton)

        self.playerAdmissionsPage.startGameButton = QPushButton("&Start Game!")
        self.playerAdmissionsPage.startGameButton.clicked.connect(
            self.startNewGame)
        layout.addRow(self.playerAdmissionsPage.startGameButton)

        self.playerAdmissionsPage.proceedToFacilAuthPageButton = QPushButton(
            "&Faciliator Page")
        self.playerAdmissionsPage.proceedToFacilAuthPageButton.clicked.connect(
            self.goTo_FacilAuthPage)
        layout.addRow(self.playerAdmissionsPage.proceedToFacilAuthPageButton)

        self.playerAdmissionsPage.setLayout(layout)
Esempio n. 23
0
    def initUI(self):
        self.setWindowIcon(QIcon(SRC_DIR + "share.ico"))
        self.setWindowTitle("文件信息")
        self.buttonBox = QDialogButtonBox()
        self.buttonBox.setOrientation(Qt.Orientation.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.StandardButton.Close)
        self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setText("关闭")
        self.buttonBox.rejected.connect(self.reject)
        self.buttonBox.rejected.connect(self.clean)
        self.buttonBox.rejected.connect(self.closed.emit)

        self.logo = QLabel()
        self.logo.setPixmap(QPixmap(SRC_DIR + "q9.gif"))
        self.logo.setAlignment(Qt.AlignmentFlag.AlignCenter)
        self.logo.setStyleSheet("background-color:rgb(255,204,51);")

        self.lb_name = QLabel()
        self.lb_name.setText("文件名:")
        self.tx_name = AutoResizingTextEdit()
        self.tx_name.setReadOnly(True)
        self.tx_name.setMinimumLines(1)

        self.lb_size = QLabel()
        self.lb_size.setText("文件大小:")
        self.tx_size = QLabel()

        self.lb_time = QLabel()
        self.lb_time.setText("上传时间:")
        self.tx_time = QLabel()

        self.lb_dl_count = QLabel()
        self.lb_dl_count.setText("下载次数:")
        self.tx_dl_count = QLabel()

        self.lb_share_url = QLabel()
        self.lb_share_url.setText("分享链接:")
        self.tx_share_url = QLineEdit()
        self.tx_share_url.setReadOnly(True)

        self.lb_pwd = QLabel()
        self.lb_pwd.setText("提取码:")
        self.tx_pwd = QLineEdit()
        self.tx_pwd.setReadOnly(True)

        self.lb_short = QLabel()
        self.lb_short.setText("短链接:")
        self.tx_short = AutoResizingTextEdit(self)
        self.tx_short.setPlaceholderText("单击获取")
        self.tx_short.clicked.connect(self.call_get_short_url)
        self.tx_short.setReadOnly(True)
        self.tx_short.setMinimumLines(1)

        self.lb_desc = QLabel()
        self.lb_desc.setText("文件描述:")
        self.tx_desc = AutoResizingTextEdit()
        self.tx_desc.setReadOnly(True)
        self.tx_desc.setMinimumLines(1)

        self.lb_dl_link = QLabel()
        self.lb_dl_link.setText("下载直链:")
        self.tx_dl_link = AutoResizingTextEdit(self)
        self.tx_dl_link.setPlaceholderText("单击获取")
        self.tx_dl_link.clicked.connect(self.call_get_dl_link)
        self.tx_dl_link.setReadOnly(True)
        self.tx_dl_link.setMinimumLines(1)

        vbox = QVBoxLayout()
        vbox.addWidget(self.logo)
        vbox.addStretch(1)
        form = QFormLayout()
        form.setLabelAlignment(Qt.AlignmentFlag.AlignRight)
        form.addRow(self.lb_name, self.tx_name)
        form.addRow(self.lb_size, self.tx_size)
        form.addRow(self.lb_time, self.tx_time)
        form.addRow(self.lb_dl_count, self.tx_dl_count)
        form.addRow(self.lb_share_url, self.tx_share_url)
        form.addRow(self.lb_pwd, self.tx_pwd)
        form.addRow(self.lb_short, self.tx_short)
        form.addRow(self.lb_desc, self.tx_desc)
        form.addRow(self.lb_dl_link, self.tx_dl_link)
        form.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.AllNonFixedFieldsGrow)  # 覆盖MacOS的默认样式
        vbox.addLayout(form)
        vbox.addStretch(1)
        vbox.addWidget(self.buttonBox)

        self.setLayout(vbox)
        self.setMinimumWidth(500)
Esempio n. 24
0
    def __init__(
        self,
        onPlayButtonPressed: Callable[[], None],
        onPauseButtonPressed: Callable[[], None],
        onStepButtonPressed: Callable[[], None],
        onRestartButtonPressed: Callable[[], None],
        onSpeedControlValueChanged: Callable[[int], None],
        onOpenLogButtonPressed: Callable[[], None],
        onAgentVarsButtonPressed: Callable[[], None],
        onSolveButtonPressed: Callable[[MazeSolverSpecification], None],
        mazeSize: XY,
        parent: Optional[QWidget] = None,
        *args: Tuple[Any, Any],
        **kwargs: Tuple[Any, Any],
    ) -> None:
        """
        Grouped controls box for controls for solving mazes
        """
        self.__onSolveButtonPressed = onSolveButtonPressed

        self.__mazeSize = mazeSize
        self.__maximumXY = XY(
            self.__mazeSize.x - 1,
            self.__mazeSize.y - 1,
        )

        super().__init__(parent=parent, *args, **kwargs)
        self.setContentsMargins(0, 0, 0, 0)

        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)

        groupbox = QGroupBox("Solve Maze")
        layout.addWidget(groupbox)

        vbox = QFormLayout()
        groupbox.setLayout(vbox)

        self.__startPosition = XYPicker(
            minimum=XY(0, 0),
            maximum=self.__maximumXY,
            initialValue=XY(0, 0),
            parent=self,
            label="•",
        )

        self.__endPosition = XYPicker(
            minimum=XY(0, 0),
            maximum=self.__maximumXY,
            initialValue=self.__maximumXY,
            parent=self,
            label="•",
        )

        self.__solverTypePicker = QComboBox(self)
        self.__solverTypePicker.addItem("Wall Follower", WallFollower)
        self.__solverTypePicker.addItem("Pledge Solver", PledgeSolver)
        self.__solverTypePicker.addItem("Random Mouse", RandomMouse)

        solveButton = QPushButton("Solve")
        solveButton.clicked.connect(  # type: ignore
            lambda: self.__onSolveButtonPressed(
                MazeSolverSpecification(
                    startPosition=self.__startPosition.getValues(),
                    endPosition=self.__endPosition.getValues(),
                    solverType=self.__solverTypePicker.currentData(),
                ),
            )
        )

        self.__solverControlsDropdown = SolverControlsView(
            onPlayButtonPressed=onPlayButtonPressed,
            onPauseButtonPressed=onPauseButtonPressed,
            onStepButtonPressed=onStepButtonPressed,
            onRestartButtonPressed=onRestartButtonPressed,
            onSpeedControlValueChanged=onSpeedControlValueChanged,
            onOpenLogButtonPressed=onOpenLogButtonPressed,
            onAgentVarsButtonPressed=onAgentVarsButtonPressed,
            parent=self,
        )
        #  connect enable/disable signal to child view
        self.setMazeSolverControlsEnabled.connect(
            self.__solverControlsDropdown.setMazeSolverControlsEnabled
        )

        vbox.addRow("Start Position", self.__startPosition)
        vbox.addRow("End Position", self.__endPosition)
        vbox.addRow("Solver Type", self.__solverTypePicker)
        vbox.addRow(solveButton)
        vbox.addRow(self.__solverControlsDropdown)

        self.setLayout(layout)
Esempio n. 25
0
class LoginDialog(QDialog):
    """登录对话框"""

    clicked_ok = pyqtSignal()

    def __init__(self, config):
        super().__init__()
        self._cwd = os.getcwd()
        self._config = config
        self._cookie_assister = 'login_assister.exe'
        self._user = ""
        self._pwd = ""
        self._cookie = {}
        self._del_user = ""
        self.initUI()
        self.setStyleSheet(dialog_qss_style)
        self.setMinimumWidth(560)
        self.name_ed.setFocus()
        # 信号
        self.name_ed.textChanged.connect(self.set_user)
        self.pwd_ed.textChanged.connect(self.set_pwd)
        self.cookie_ed.textChanged.connect(self.set_cookie)

    def update_selection(self, user):
        """显示已经保存的登录用户信息"""
        user_info = self._config.get_user_info(user)
        if user_info:
            self._user = user_info[0]
            self._pwd = user_info[1]
            self._cookie = user_info[2]
        # 更新控件显示内容
        self.name_ed.setText(self._user)
        self.pwd_ed.setText(self._pwd)
        try: text = ";".join([f'{k}={v}' for k, v in self._cookie.items()])
        except: text = ''
        self.cookie_ed.setPlainText(text)

    def initUI(self):
        self.setWindowTitle("登录蓝奏云")
        self.setWindowIcon(QIcon(SRC_DIR + "login.ico"))
        logo = QLabel()
        logo.setPixmap(QPixmap(SRC_DIR + "logo3.gif"))
        logo.setStyleSheet("background-color:rgb(0,153,255);")
        logo.setAlignment(Qt.AlignmentFlag.AlignCenter)

        self.tabs = QTabWidget()
        self.auto_tab = QWidget()
        self.hand_tab = QWidget()

        # Add tabs
        self.tabs.addTab(self.auto_tab,"自动获取Cookie")
        self.tabs.addTab(self.hand_tab,"手动输入Cookie")
        self.auto_get_cookie_ok = AutoResizingTextEdit("🔶点击👇自动获取浏览器登录信息👇")
        self.auto_get_cookie_ok.setReadOnly(True)
        self.auto_get_cookie_btn = QPushButton("自动读取浏览器登录信息")
        auto_cookie_notice = '支持浏览器:Chrome, Chromium, Opera, Edge, Firefox'
        self.auto_get_cookie_btn.setToolTip(auto_cookie_notice)
        self.auto_get_cookie_btn.clicked.connect(self.call_auto_get_cookie)
        self.auto_get_cookie_btn.setStyleSheet("QPushButton {min-width: 210px;max-width: 210px;}")

        self.name_lb = QLabel("&U 用户")
        self.name_lb.setAlignment(Qt.AlignmentFlag.AlignCenter)
        self.name_ed = QLineEdit()
        self.name_lb.setBuddy(self.name_ed)

        self.pwd_lb = QLabel("&P 密码")
        self.pwd_lb.setAlignment(Qt.AlignmentFlag.AlignCenter)
        self.pwd_ed = QLineEdit()
        self.pwd_ed.setEchoMode(QLineEdit.EchoMode.Password)
        self.pwd_lb.setBuddy(self.pwd_ed)

        self.cookie_lb = QLabel("&Cookie")
        self.cookie_ed = QTextEdit()
        notice = "由于滑动验证的存在,需要输入cookie,cookie请使用浏览器获取\n" + \
            "cookie会保存在本地,下次使用。其格式如下:\n ylogin=value1; phpdisk_info=value2"
        self.cookie_ed.setPlaceholderText(notice)
        self.cookie_lb.setBuddy(self.cookie_ed)

        self.show_input_cookie_btn = QPushButton("显示Cookie输入框")
        self.show_input_cookie_btn.setToolTip(notice)
        self.show_input_cookie_btn.setStyleSheet("QPushButton {min-width: 110px;max-width: 110px;}")
        self.show_input_cookie_btn.clicked.connect(self.change_show_input_cookie)
        self.ok_btn = QPushButton("登录")
        self.ok_btn.clicked.connect(self.change_ok_btn)
        self.cancel_btn = QPushButton("取消")
        self.cancel_btn.clicked.connect(self.change_cancel_btn)
        lb_line_1 = QLabel()
        lb_line_1.setText('<html><hr />切换用户</html>')
        lb_line_2 = QLabel()
        lb_line_2.setText('<html><hr /></html>')

        self.form = QFormLayout()
        self.form.setLabelAlignment(Qt.AlignmentFlag.AlignRight)
        self.form.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.AllNonFixedFieldsGrow)  # 覆盖MacOS的默认样式
        self.form.addRow(self.name_lb, self.name_ed)
        self.form.addRow(self.pwd_lb, self.pwd_ed)
        if is_windows:
            def set_assister_path():
                """设置辅助登录程序路径"""
                assister_path = QFileDialog.getOpenFileName(self, "选择辅助登录程序路径",
                                                            self._cwd, "EXE Files (*.exe)")
                if not assister_path[0]:
                    return None
                assister_path = os.path.normpath(assister_path[0])  # windows backslash
                if assister_path == self._cookie_assister:
                    return None
                self.assister_ed.setText(assister_path)
                self._cookie_assister = assister_path

            self.assister_lb = QLabel("登录辅助程序")
            self.assister_lb.setAlignment(Qt.AlignmentFlag.AlignCenter)
            self.assister_ed = MyLineEdit(self)
            self.assister_ed.setText(self._cookie_assister)
            self.assister_ed.clicked.connect(set_assister_path)
            self.assister_lb.setBuddy(self.assister_ed)
            self.form.addRow(self.assister_lb, self.assister_ed)

        hbox = QHBoxLayout()
        hbox.addWidget(self.show_input_cookie_btn)
        hbox.addStretch(1)
        hbox.addWidget(self.ok_btn)
        hbox.addWidget(self.cancel_btn)

        user_box = QHBoxLayout()
        self.user_num = 0
        self.user_btns = {}
        for user in self._config.users_name:
            user = str(user)  # TODO: 可能需要删掉
            self.user_btns[user] = QDoublePushButton(user)
            self.user_btns[user].setStyleSheet("QPushButton {border:none;}")
            if user == self._config.name:
                self.user_btns[user].setStyleSheet("QPushButton {background-color:rgb(0,153,2);}")
                self.tabs.setCurrentIndex(1)
            self.user_btns[user].setToolTip(f"点击选中,双击切换至用户:{user}")
            self.user_btns[user].doubleClicked.connect(self.choose_user)
            self.user_btns[user].clicked.connect(self.delete_chose_user)
            user_box.addWidget(self.user_btns[user])
            self.user_num += 1
            user_box.addStretch(1)

        self.layout = QVBoxLayout(self)
        self.layout.addWidget(logo)
        vbox = QVBoxLayout()
        if self._config.name:
            vbox.addWidget(lb_line_1)
            user_box.setAlignment(Qt.AlignmentFlag.AlignCenter)
            vbox.addLayout(user_box)
            vbox.addWidget(lb_line_2)
            if self.user_num > 1:
                self.del_user_btn = QPushButton("删除账户")
                self.del_user_btn.setIcon(QIcon(SRC_DIR + "delete.ico"))
                self.del_user_btn.setStyleSheet("QPushButton {min-width: 180px;max-width: 180px;}")
                self.del_user_btn.clicked.connect(self.call_del_chose_user)
                vbox.addWidget(self.del_user_btn)
            else:
                self.del_user_btn = None
            vbox.addStretch(1)

        vbox.addLayout(self.form)
        vbox.addStretch(1)
        vbox.addLayout(hbox)
        vbox.setAlignment(Qt.AlignmentFlag.AlignCenter)

        self.hand_tab.setLayout(vbox)
        auto_cookie_vbox = QVBoxLayout()
        auto_cookie_vbox.addWidget(self.auto_get_cookie_ok)
        auto_cookie_vbox.addWidget(self.auto_get_cookie_btn)
        auto_cookie_vbox.setAlignment(Qt.AlignmentFlag.AlignCenter)
        self.auto_tab.setLayout(auto_cookie_vbox)
        self.layout.addWidget(self.tabs)
        self.setLayout(self.layout)
        self.update_selection(self._config.name)

    def call_del_chose_user(self):
        if self._del_user:
            if self._del_user != self._config.name:
                self.user_num -= 1
                self._config.del_user(self._del_user)
                self.user_btns[self._del_user].close()
                self._del_user = ""
                if self.user_num <= 1:
                    self.del_user_btn.close()
                    self.del_user_btn = None
                return
            else:
                title = '不能删除'
                msg = '不能删除当前登录账户,请先切换用户!'
        else:
            title = '请选择账户'
            msg = '请单击选择需要删除的账户\n\n注意不能删除当前账户(绿色)'
        message_box = QMessageBox(self)
        message_box.setIcon(QMessageBox.Icon.Critical)
        message_box.setStyleSheet(btn_style)
        message_box.setWindowTitle(title)
        message_box.setText(msg)
        message_box.setStandardButtons(QMessageBox.StandardButton.Close)
        buttonC = message_box.button(QMessageBox.StandardButton.Close)
        buttonC.setText('关闭')
        message_box.exec()

    def delete_chose_user(self):
        """更改单击选中需要删除的用户"""
        user = str(self.sender().text())
        self._del_user = user
        if self.del_user_btn:
            self.del_user_btn.setText(f"删除 <{user}>")

    def choose_user(self):
        """切换用户"""
        user = self.sender().text()
        if user != self._config.name:
            self.ok_btn.setText("切换用户")
        else:
            self.ok_btn.setText("登录")
        self.update_selection(user)

    def change_show_input_cookie(self):
        row_c = 4 if is_windows else 3
        if self.form.rowCount() < row_c:
            self.org_height = self.height()
            self.form.addRow(self.cookie_lb, self.cookie_ed)
            self.show_input_cookie_btn.setText("隐藏Cookie输入框")
            self.change_height = None
            self.adjustSize()
        else:
            if not self.change_height:
                self.change_height = self.height()
            if self.cookie_ed.isVisible():
                self.cookie_lb.setVisible(False)
                self.cookie_ed.setVisible(False)
                self.show_input_cookie_btn.setText("显示Cookie输入框")
                start_height, end_height = self.change_height, self.org_height
            else:
                self.cookie_lb.setVisible(True)
                self.cookie_ed.setVisible(True)
                self.show_input_cookie_btn.setText("隐藏Cookie输入框")
                start_height, end_height = self.org_height, self.change_height
            gm = self.geometry()
            x, y = gm.x(), gm.y()
            wd = self.width()
            self.animation = QPropertyAnimation(self, b'geometry')
            self.animation.setDuration(400)
            self.animation.setStartValue(QRect(x, y, wd, start_height))
            self.animation.setEndValue(QRect(x, y, wd, end_height))
            self.animation.start()

    def set_user(self, user):
        self._user = user
        if not user:
            return None
        if user not in self._config.users_name:
            self.ok_btn.setText("添加用户")
            self.cookie_ed.setPlainText("")
        elif user != self._config.name:
            self.update_selection(user)
            self.ok_btn.setText("切换用户")
        else:
            self.update_selection(user)
            self.ok_btn.setText("登录")

    def set_pwd(self, pwd):
        if self._user in self._config.users_name:
            user_info = self._config.get_user_info(self._user)
            if pwd and pwd != user_info[1]:  # 改变密码,cookie作废
                self.cookie_ed.setPlainText("")
                self._cookie = None
            if not pwd:  # 输入空密码,表示删除对pwd的存储,并使用以前的cookie
                self._cookie = user_info[2]
                try: text = ";".join([f'{k}={v}' for k, v in self._cookie.items()])
                except: text = ''
                self.cookie_ed.setPlainText(text)
        self._pwd = pwd

    def set_cookie(self):
        cookies = self.cookie_ed.toPlainText()
        if cookies:
            try:
                self._cookie = {kv.split("=")[0].strip(" "): kv.split("=")[1].strip(" ") for kv in cookies.split(";") if kv.strip(" ") }
            except: self._cookie = None

    def change_cancel_btn(self):
        self.update_selection(self._config.name)
        self.close()

    def change_ok_btn(self):
        if self._user and self._pwd:
            if self._user not in self._config.users_name:
                self._cookie = None
        if self._cookie:
            up_info = {"name": self._user, "pwd": self._pwd, "cookie": self._cookie, "work_id": -1}
            if self.ok_btn.text() == "切换用户":
                self._config.change_user(self._user)
            else:
                self._config.set_infos(up_info)
            self.clicked_ok.emit()
            self.close()
        elif USE_WEB_ENG:
            self.web = LoginWindow(self._user, self._pwd)
            self.web.cookie.connect(self.get_cookie_by_web)
            self.web.setWindowModality(Qt.WindowModality.ApplicationModal)
            self.web.exec()
        elif os.path.isfile(self._cookie_assister):
            try:
                result = os.popen(f'{self._cookie_assister} {self._user} {self._pwd}')
                cookie = result.read()
                try:
                    self._cookie = {kv.split("=")[0].strip(" "): kv.split("=")[1].strip(" ") for kv in cookie.split(";")}
                except: self._cookie = None
                if not self._cookie:
                    return None
                up_info = {"name": self._user, "pwd": self._pwd, "cookie": self._cookie, "work_id": -1}
                self._config.set_infos(up_info)
                self.clicked_ok.emit()
                self.close()
            except: pass
        else:
            title = '请使用 Cookie 登录或是选择 登录辅助程序'
            msg = '没有输入 Cookie,或者没有找到登录辅助程序!\n\n' + \
                  '推荐使用浏览器获取 cookie 填入 cookie 输入框\n\n' + \
                  '如果不嫌文件体积大,请下载登录辅助程序:\n' + \
                  'https://github.com/rachpt/lanzou-gui/releases'
            message_box = QMessageBox(self)
            message_box.setIcon(QMessageBox.Icon.Critical)
            message_box.setStyleSheet(btn_style)
            message_box.setWindowTitle(title)
            message_box.setText(msg)
            message_box.setStandardButtons(QMessageBox.StandardButton.Close)
            buttonC = message_box.button(QMessageBox.StandardButton.Close)
            buttonC.setText('关闭')
            message_box.exec()

    def get_cookie_by_web(self, cookie):
        """使用辅助登录程序槽函数"""
        self._cookie = cookie
        self._close_dialog()

    def call_auto_get_cookie(self):
        """自动读取浏览器cookie槽函数"""
        try:
            self._cookie = get_cookie_from_browser()
        except Exception as e:
            logger.error(f"Browser_cookie3 Error: {e}")
            self.auto_get_cookie_ok.setPlainText(f"❌获取失败,错误信息\n{e}")
        else:
            if self._cookie:
                self._user = self._pwd = ''
                self.auto_get_cookie_ok.setPlainText("✅获取成功即将登录……")
                QTimer.singleShot(2000, self._close_dialog)
            else:
                self.auto_get_cookie_ok.setPlainText("❌获取失败\n请提前使用支持的浏览器登录蓝奏云,读取前完全退出浏览器!\n支持的浏览器与顺序:\nchrome, chromium, opera, edge, firefox")

    def _close_dialog(self):
        """关闭对话框"""
        up_info = {"name": self._user, "pwd": self._pwd, "cookie": self._cookie}
        self._config.set_infos(up_info)
        self.clicked_ok.emit()
        self.close()
Esempio n. 26
0
    def questionPlayPageUI(self):
        layout = QFormLayout()

        self.questionPlayPage.titleDisplay = QLabel()
        layout.addRow(self.questionPlayPage.titleDisplay)

        self.questionPlayPage.contentDisplay = QLabel()
        layout.addRow(self.questionPlayPage.contentDisplay)

        self.questionPlayPage.choiceList = QListWidget()
        self.questionPlayPage.playerScores = QLabel()
        layout.addRow(self.questionPlayPage.choiceList,
                      self.questionPlayPage.playerScores)

        self.questionPlayPage.chooseButton = QPushButton("&Submit")
        self.questionPlayPage.chooseButton.clicked.connect(
            self.submitPlayQuestion)
        layout.addRow(self.questionPlayPage.chooseButton)

        self.questionPlayPage.collapseButton = QPushButton("Collapse!")
        self.questionPlayPage.collapseButton.clicked.connect(
            self.goTo_CollapsePage)
        self.questionPlayPage.abortButton = QPushButton("Abort")
        self.questionPlayPage.abortButton.clicked.connect(
            self.abortGameInProgress)
        layout.addRow(self.questionPlayPage.collapseButton,
                      self.questionPlayPage.abortButton)

        self.questionPlayPage.setLayout(layout)
Esempio n. 27
0
    def enterQuestionCodePageUI(self):
        layout = QFormLayout()

        self.enterQuestionCodePage.currPlayerTurnDisplay = QLabel()
        layout.addRow(self.enterQuestionCodePage.currPlayerTurnDisplay)

        enterColorLayout = QFormLayout()
        enterColorButtonGroup = QButtonGroup(self.enterQuestionCodePage)
        self.enterQuestionCodePage.yellowRadio = QRadioButton()
        self.enterQuestionCodePage.blueRadio = QRadioButton()
        self.enterQuestionCodePage.redRadio = QRadioButton()
        self.enterQuestionCodePage.yellowRadio.toggled.connect(
            self.enterColorRadioToggle)
        self.enterQuestionCodePage.blueRadio.toggled.connect(
            self.enterColorRadioToggle)
        self.enterQuestionCodePage.redRadio.toggled.connect(
            self.enterColorRadioToggle)
        enterColorButtonGroup.addButton(self.enterQuestionCodePage.yellowRadio)
        enterColorButtonGroup.addButton(self.enterQuestionCodePage.blueRadio)
        enterColorButtonGroup.addButton(self.enterQuestionCodePage.redRadio)
        enterColorLayout.addRow("Yellow",
                                self.enterQuestionCodePage.yellowRadio)
        enterColorLayout.addRow("Blue", self.enterQuestionCodePage.blueRadio)
        enterColorLayout.addRow("Red", self.enterQuestionCodePage.redRadio)

        combLayout = QHBoxLayout()
        combLayout.addLayout(enterColorLayout)
        layout.addRow(combLayout)

        self.enterQuestionCodePage.submitQuestionCodeButton = QPushButton(
            "&Submit Code!")
        self.enterQuestionCodePage.submitQuestionCodeButton.clicked.connect(
            self.submitQuestionCode)
        layout.addRow(self.enterQuestionCodePage.submitQuestionCodeButton)

        self.enterQuestionCodePage.setLayout(layout)
import sys
from PyQt6.QtWidgets import QApplication, QFormLayout, QLineEdit, QWidget

app = QApplication(sys.argv)
window = QWidget()
window.setWindowTitle('Horizontal Layout')
layout = QFormLayout()
layout.addRow("Name:", QLineEdit())
layout.addRow("Age:", QLineEdit())
layout.addRow("Job:", QLineEdit())
window.setLayout(layout)
window.show()
sys.exit(app.exec())
Esempio n. 29
0
    def questionBankPageUI(self):
        layout = QFormLayout()

        subLayout = QHBoxLayout()
        self.questionBankPage.questionList = QListWidget()
        self.questionBankPage.questionList.currentRowChanged.connect(
            self.displayQuestionOnQuestionBankPage)
        self.questionBankPage.questionTextDisplay = QLabel()
        self.questionBankPage.questionTextDisplay.setFixedSize(500, 100)
        self.questionBankPage.questionAnswersList = QListWidget()
        self.questionBankPage.definedCorrectAnswerDisplay = QLabel()
        self.questionBankPage.definedCorrectAnswerDisplay.setFixedSize(50, 10)
        self.questionBankPage.questionCodeParserDisplay = QLabel()
        self.questionBankPage.questionCodeParserDisplay.setFixedSize(100, 50)
        subLayout.addWidget(self.questionBankPage.questionList)
        subLayout.addWidget(self.questionBankPage.questionTextDisplay)
        subLayout.addWidget(self.questionBankPage.questionAnswersList)
        subLayout.addWidget(self.questionBankPage.definedCorrectAnswerDisplay)
        subLayout.addWidget(self.questionBankPage.questionCodeParserDisplay)
        layout.addRow(subLayout)

        self.questionBankPage.newQuestionTitle = QLineEdit()
        self.questionBankPage.newQuestionContent = QPlainTextEdit()
        layout.addRow(self.questionBankPage.newQuestionTitle,
                      self.questionBankPage.newQuestionContent)

        self.questionBankPage.newQuestionAnswerInput = QLineEdit()
        self.questionBankPage.newQuestionAnswerList = QListWidget()
        layout.addRow(self.questionBankPage.newQuestionAnswerInput,
                      self.questionBankPage.newQuestionAnswerList)

        colorLayout = QFormLayout()
        colorButtonGroup = QButtonGroup(self.questionBankPage)
        self.questionBankPage.yellowRadio = QRadioButton()
        self.questionBankPage.blueRadio = QRadioButton()
        self.questionBankPage.redRadio = QRadioButton()
        self.questionBankPage.yellowRadio.toggled.connect(
            self.colorRadioToggle)
        self.questionBankPage.blueRadio.toggled.connect(self.colorRadioToggle)
        self.questionBankPage.redRadio.toggled.connect(self.colorRadioToggle)
        colorButtonGroup.addButton(self.questionBankPage.yellowRadio)
        colorButtonGroup.addButton(self.questionBankPage.blueRadio)
        colorButtonGroup.addButton(self.questionBankPage.redRadio)
        colorLayout.addRow("Yellow", self.questionBankPage.yellowRadio)
        colorLayout.addRow("Blue", self.questionBankPage.blueRadio)
        colorLayout.addRow("Red", self.questionBankPage.redRadio)

        combLayout = QHBoxLayout()
        combLayout.addLayout(colorLayout)
        layout.addRow(combLayout)

        self.questionBankPage.definedNewCorrectAnswerDisplay = QLabel()
        layout.addRow(self.questionBankPage.definedNewCorrectAnswerDisplay)

        self.questionBankPage.defineCorrectAnswerButton = QPushButton(
            "&Define Correct Answer")
        self.questionBankPage.defineCorrectAnswerButton.clicked.connect(
            self.defineCorrectAnswer)
        self.questionBankPage.submitNewAnswerButton = QPushButton(
            "Submit &Answer")
        self.questionBankPage.submitNewAnswerButton.clicked.connect(
            self.submitNewAnswer)
        layout.addRow(self.questionBankPage.defineCorrectAnswerButton,
                      self.questionBankPage.submitNewAnswerButton)

        self.questionBankPage.submitNewQuestionButton = QPushButton(
            "Submit New &Question")
        self.questionBankPage.submitNewQuestionButton.clicked.connect(
            self.submitNewQuestion)
        layout.addRow(self.questionBankPage.submitNewQuestionButton)

        self.questionBankPage.backButton = QPushButton("&Back")
        self.questionBankPage.backButton.clicked.connect(
            self.goTo_FacilStartPage)
        self.questionBankPage.refreshButton = QPushButton("&Refresh")
        self.questionBankPage.refreshButton.clicked.connect(
            self.goTo_QuestionBankPage)
        layout.addRow(self.questionBankPage.backButton,
                      self.questionBankPage.refreshButton)

        self.questionBankPage.setLayout(layout)