Exemple #1
0
    def __init__(self):
        super(Window, self).__init__()

        self.groupBox = QGroupBox(
            "What is your favorite programming Language ?")
        self.groupBox.setFont(QFont("Sanserif", 13))

        self.checkBox1 = QCheckBox("Python")
        self.checkBox1.setIcon(QIcon(""))
        self.checkBox1.setWhatsThis("This is a checkbox of Python")

        self.checkBox2 = QCheckBox("C++")
        self.checkBox2.setIcon(QIcon(""))
        self.checkBox1.setWhatsThis("This is a checkbox of C++")

        self.checkBox3 = QCheckBox("Java")
        self.checkBox3.setIcon(QIcon(""))
        self.checkBox1.setWhatsThis("This is a checkbox of Java")

        self.label = QLabel("You Have Selected FootBall")
        self.title = " "
        self.left = 100
        self.top = 200
        self.width = 400
        self.height = 300

        self.InitWindow()
    def createLayout(self):
        self.groupBox = QGroupBox("What Is Your Favorite Sport?")

        hboxlayout = QHBoxLayout()

        self.button = QPushButton("Football", self)
        self.button.setIcon(QtGui.QIcon("home.png"))
        self.button.setIconSize(QSize(40, 40))
        self.button.setToolTip("This Is Click Me Button")
        self.button.setMinimumHeight(40)
        hboxlayout.addWidget(self.button)

        self.button1 = QPushButton("Cricket", self)
        self.button1.setIcon(QtGui.QIcon("home.png"))
        self.button1.setIconSize(QSize(40, 40))
        self.button1.setMinimumHeight(40)
        self.button1.setToolTip("This Is Click Me Button")
        hboxlayout.addWidget(self.button1)

        self.button2 = QPushButton("Tennis", self)
        self.button2.setIcon(QtGui.QIcon("home.png"))
        self.button2.setIconSize(QSize(40, 40))
        self.button2.setMinimumHeight(40)
        self.button2.setToolTip("This Is Click Me Button")
        hboxlayout.addWidget(self.button2)

        self.groupBox.setLayout(hboxlayout)
    def setUpMainWindow(self):
        """Set up the GUI's main window."""
        search_line_edit = QLineEdit()
        search_line_edit.setPlaceholderText(
            "Enter text to search for a word below")

        list_of_words = self.loadWordsFromFile()

        list_view = QListView()
        # Create a model instance and pass the list of words to the model
        model = ListModel(list_view, list_of_words)
        list_view.setModel(model)

        # Create QCompleter object that shares the same model as the QListView
        completer = QCompleter(list_of_words)
        completer.setFilterMode(Qt.MatchFlag.MatchStartsWith)
        completer.setModel(model)
        search_line_edit.setCompleter(
            completer)  # Set the completer for the QLineEdit

        # Create a layout and organize all of the objects
        # into a QGroupBox
        main_v_box = QVBoxLayout()
        main_v_box.addWidget(search_line_edit)
        main_v_box.addWidget(list_view)

        word_group_box = QGroupBox("Keywords")
        word_group_box.setLayout(main_v_box)
        self.setCentralWidget(word_group_box)
    def __init__(self, parent, directory, is_checked):
        """Simple modal Preferences dialog"""
        super().__init__(parent)
        self.setWindowTitle("Preferences")
        self.setModal(True)

        image_dir_label = QLabel(
            f"<b>Images Location:</b> {directory.absolutePath()}")

        self.delete_images_checkbox = QCheckBox("Delete Original Images")
        self.delete_images_checkbox.setToolTip(
            """<p>If checked, images that are copied to the 
            <b>Images Location</b> are also deleted from their original location.</p>"""
        )
        self.delete_images_checkbox.setChecked(is_checked)

        handling_v_box = QVBoxLayout()
        handling_v_box.addWidget(self.delete_images_checkbox)

        handling_group_box = QGroupBox("Image Handling:")
        handling_group_box.setLayout(handling_v_box)

        self.button_box = QDialogButtonBox(
            QDialogButtonBox.StandardButton.Save
            | QDialogButtonBox.StandardButton.Cancel)
        self.button_box.accepted.connect(self.accept)
        self.button_box.rejected.connect(self.reject)

        # Add a layout to the dialog box
        dialog_v_box = QVBoxLayout()
        dialog_v_box.addWidget(image_dir_label)
        dialog_v_box.addWidget(handling_group_box)
        dialog_v_box.addStretch(1)
        dialog_v_box.addWidget(self.button_box)
        self.setLayout(dialog_v_box)
    def __init__(self, parent, selected_image):
        """Modeless dialog that displays file information for images"""
        super().__init__(parent)
        metadata = self.collectImageMetaData(selected_image)

        self.setWindowTitle(f"{metadata['file_name']} Info")

        # Create widgets for displaying information
        image_label = QLabel(f"<b>{metadata['base_name']}</b>")
        date_created = QLabel(
            f"Created: {metadata['date_created'].toString('MMMM d, yyyy h:mm:ss ap')}"
        )
        image_type = QLabel(f"Type: {metadata['extension']}")
        image_size = QLabel(f"Size: {metadata['size']:,} bytes")
        image_location = QLabel(f"Location: {metadata['file_path']}")
        date_modified = QLabel(
            f"""Modified: {metadata['last_modified'].toString('MMMM d, yyyy h:mm:ss ap')}"""
        )

        # Organize widgets that display metadata using containers/layouts
        general_v_box = QVBoxLayout()
        general_v_box.addWidget(image_type)
        general_v_box.addWidget(image_size)
        general_v_box.addWidget(image_location)

        general_group_box = QGroupBox("General:")
        general_group_box.setLayout(general_v_box)

        extra_v_box = QVBoxLayout()
        extra_v_box.addWidget(date_modified)

        extra_group_box = QGroupBox("Extra Info:")
        extra_group_box.setLayout(extra_v_box)

        self.button_box = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok)
        self.button_box.accepted.connect(self.accept)

        # Add a layout to the dialog box
        dialog_v_box = QVBoxLayout()
        dialog_v_box.addWidget(image_label)
        dialog_v_box.addWidget(date_created)
        dialog_v_box.addWidget(general_group_box)
        dialog_v_box.addWidget(extra_group_box)
        dialog_v_box.addStretch(1)
        dialog_v_box.addWidget(self.button_box)
        self.setLayout(dialog_v_box)
Exemple #6
0
    def CreateGridLayout(self):
        self.horizontalGroupBox = QGroupBox("Grid")
        self.layout = QGridLayout()
        self.layout.setColumnStretch(2, 4)
        self.layout.setColumnStretch(1, 4)

        for label in "123456789":
            self.MakeButton(label)

        self.horizontalGroupBox.setLayout(self.layout)
    def __init__(self):
        super(MainWidget, self).__init__()
        self.resize(500, 600)
        self.setWindowTitle("喜马拉雅下载 by[Zero] " + __VERSION__)
        self.mainlayout = QVBoxLayout()
        self.setLayout(self.mainlayout)
        self.groupbox = QGroupBox("选择类型")
        self.groupbox.setFixedHeight(50)
        hlayout = QHBoxLayout(self.groupbox)
        self.signal_m4a = QRadioButton("单个下载")
        self.mut_m4a = QRadioButton("专辑下载")
        self.vip_signal_m4a = QRadioButton("VIP单个下载")
        self.vip_m4a = QRadioButton("VIP专辑下载")

        hlayout.addWidget(self.signal_m4a)
        hlayout.addWidget(self.mut_m4a)
        hlayout.addWidget(self.vip_signal_m4a)
        hlayout.addWidget(self.vip_m4a)
        self.mainlayout.addWidget(self.groupbox)

        frame01 = QFrame(self)
        child_layout = QVBoxLayout()
        print(self.width())
        label01 = QLabel("链   接", self)
        label02 = QLabel("下载目录", self)
        self.url_lineedit = QLineEdit(self)
        self.dir_lineedit = QLineEdit(self)
        hlayout01 = QHBoxLayout()
        hlayout01.addWidget(label01, 1)
        hlayout01.addWidget(self.url_lineedit, 9)
        hlayout02 = QHBoxLayout()
        hlayout02.addWidget(label02, 1)
        hlayout02.addWidget(self.dir_lineedit, 9)
        child_layout.addLayout(hlayout01)
        child_layout.addLayout(hlayout02)
        child_layout.setContentsMargins(
            5, 0, 5, 0)  #(int left, int top, int right, int bottom)
        frame01.setLayout(child_layout)
        self.download_progressbar = QProgressBar()
        self.download_progressbar.setAlignment(
            QtCore.Qt.Alignment.AlignCenter)  #文字居中
        self.download_progressbar.setValue(88)
        self.download_btn = QPushButton("开始下载")
        self.show_plaintextedit = QPlainTextEdit()
        self.show_plaintextedit.setMinimumHeight(400)
        self.mainlayout.addWidget(frame01)
        self.mainlayout.addWidget(self.download_progressbar)
        self.mainlayout.addWidget(self.download_btn)
        self.mainlayout.addWidget(self.show_plaintextedit)
        self.mainlayout.addStretch()
        ### 设置stylesheet
        self.download_btn.setStyleSheet(
            'QPushButton:pressed{ text-align: center;background-color:red;}')
Exemple #8
0
 def setupStatisticsTab(self):
     """ Create statistics container """
     self.statisticsContainer = QWidget()
     self.statisticsContainerLayout = QVBoxLayout(self.statisticsContainer)
     self.statisticsContainer.setLayout(self.statisticsContainerLayout)
     """ Create work time groupbox """
     self.statisticsWorkTimeGroupBox = QGroupBox("Work Time")
     self.statisticsWorkTimeGroupBoxLayout = QHBoxLayout()
     self.statisticsWorkTimeGroupBox.setLayout(
         self.statisticsWorkTimeGroupBoxLayout)
     self.statisticsWorkTimeDisplay = QLCDNumber(8)
     self.statisticsWorkTimeDisplay.display("00:00:00")
     self.statisticsWorkTimeGroupBoxLayout.addWidget(
         self.statisticsWorkTimeDisplay)
     """ Create rest time groupbox """
     self.statisticsRestTimeGroupBox = QGroupBox("Rest Time")
     self.statisticsRestTimeGroupBoxLayout = QHBoxLayout()
     self.statisticsRestTimeGroupBox.setLayout(
         self.statisticsRestTimeGroupBoxLayout)
     self.statisticsRestTimeDisplay = QLCDNumber(8)
     self.statisticsRestTimeDisplay.display("00:00:00")
     self.statisticsRestTimeGroupBoxLayout.addWidget(
         self.statisticsRestTimeDisplay)
     """ Create total time groupbox """
     self.statisticsTotalTimeGroupBox = QGroupBox("Total Time")
     self.statisticsTotalTimeGroupBoxLayout = QHBoxLayout()
     self.statisticsTotalTimeGroupBox.setLayout(
         self.statisticsTotalTimeGroupBoxLayout)
     self.statisticsTotalTimeDisplay = QLCDNumber(8)
     self.statisticsTotalTimeDisplay.display("00:00:00")
     self.statisticsTotalTimeGroupBoxLayout.addWidget(
         self.statisticsTotalTimeDisplay)
     """ Add widgets to container """
     self.statisticsContainerLayout.addWidget(
         self.statisticsTotalTimeGroupBox)
     self.statisticsContainerLayout.addWidget(
         self.statisticsWorkTimeGroupBox)
     self.statisticsContainerLayout.addWidget(
         self.statisticsRestTimeGroupBox)
     return self.statisticsContainer
Exemple #9
0
 def show_setting(self, conf: dict, layout: QGridLayout):
     groups = list()
     x = 0
     y = 0
     shape = 3
     for key in conf.keys():
         if type(conf[key]) == bool or type(conf[key]) == str:
             continue
         conf_title = conf[key]["title"]
         conf_enabled = conf[key]["enabled"]
         conf_times = conf[key]["times"]
         group = QGroupBox(conf_title)
         group.setStyleSheet("QGroupBox{border-radius:5px;}")
         group.setToolTip(conf_title + "  的设置")
         enabled = QCheckBox("启用")
         enabled.setObjectName(key)
         enabled.setToolTip("单击切换开关状态")
         enabled.setChecked(conf_enabled)
         enabled.setStyleSheet(
             "QCheckBox::indicator{width:10px;height:10px;border:none;border-radius:5px;background:#9BE3DE;}QCheckBox::indicator:unchecked{background:#BEEBE9;}QCheckBox::indicator:unchecked:hover{background:#9AD3BC;}QCheckBox::indicator:checked{background:#95E1D3;}QCheckBox::indicator:checked:hover{background:#98DED9;}"
         )
         times = QHBoxLayout()
         times_label = QLabel("次数:")
         times_label.setStyleSheet(
             "QLabel{background:transparent;border:none;border-radius:5px;}"
         )
         times_input = EnhancedEdit()
         times_input.setObjectName(key)
         times_input.setText(str(conf_times))
         times_input.setToolTip("仅限正整数")
         times_input.setValidator(
             QRegularExpressionValidator(
                 QRegularExpression("^[1-9][0-9]{1,8}$")))
         times_input.setStyleSheet(
             "QLineEdit{border:1px solid #F3EAC2;border-radius:5px;background:transparent;}QLineEdit:hover{border:1px solid #F5B461;}"
         )
         times.addWidget(times_label)
         times.addWidget(times_input)
         group_layout = QVBoxLayout()
         group_layout.addWidget(enabled)
         group_layout.addLayout(times)
         group.setLayout(group_layout)
         group.setObjectName(key)
         groups.append(group)
     for group in groups:
         if y >= shape:
             x = x + 1
             y = 0
         layout.addWidget(group, x, y)
         y = y + 1
     self.logger.debug("最后的元素位置:(%d,%d)" % (x, y))
     return (x, y)
    def setupUi(self, TrainPanel):
        self.parent = TrainPanel
        self.mainLayout = QHBoxLayout(TrainPanel)

        self.bigFont = QLabel().font()
        self.bigFont.setPointSize(13)

        self.actionsLayout = QHBoxLayout(TrainPanel)
        # self.checkRecording = QCheckBox(TrainPanel)
        self.calibrateButton = QPushButton("Calibrate", parent=TrainPanel)
        self.calibrateButton.setFont(self.bigFont)
        self.calibrateButton.setStyleSheet(CustomQStyles.buttonStyle)
        self.calibrateButton.setMinimumHeight(50)
        self.calibrateButton.setMaximumWidth(170)
        self.calibrateButton.setMinimumWidth(120)

        self.sessionButton = QPushButton("Session", parent=TrainPanel)
        self.sessionButton.setFont(self.bigFont)
        self.sessionButton.setStyleSheet(CustomQStyles.outlineButtonStyle)
        self.sessionButton.setMinimumHeight(50)
        self.sessionButton.setMaximumWidth(170)
        self.sessionButton.setMinimumWidth(120)

        self.listFiles = QListWidget(TrainPanel)
        self.listFiles.setFont(self.bigFont)
        self.label = QLabel('or select', parent=TrainPanel)
        self.subjectLayout = QVBoxLayout(TrainPanel)
        print("init")

        self.box1 = QGroupBox(parent=TrainPanel)
        self.box2 = QGroupBox(parent=TrainPanel)
        self.wizard = CalibrateWizard(parent=TrainPanel)

        self.setPatientsBox(TrainPanel)  # right panel
        self.setActionsBox(TrainPanel)  # left panel

        self.mainLayout.addWidget(self.box1, stretch=2)
        self.mainLayout.addWidget(self.box2, stretch=3)
    def CreateHorizontalLayout(self):
        self.horizontalGroupBox = QGroupBox("What is your favorite color?")
        layout = QHBoxLayout()

        buttonBlue = QPushButton('Blue', self)
        buttonBlue.clicked.connect(lambda: self.on_click(buttonBlue))
        layout.addWidget(buttonBlue)

        buttonRed = QPushButton('Red', self)
        buttonRed.clicked.connect(lambda: self.on_click(buttonRed))
        layout.addWidget(buttonRed)

        buttonGreen = QPushButton('Green', self)
        buttonGreen.clicked.connect(lambda: self.on_click(buttonGreen))
        layout.addWidget(buttonGreen)

        self.horizontalGroupBox.setLayout(layout)
Exemple #12
0
    def __init__(self):
        super(Window, self).__init__()

        self.groupBox = QGroupBox(
            "What is your favorite programming Language ?")
        self.groupBox.setFont(QFont("Sanserif", 13))

        self.lineEdit = QLineEdit()

        self.label = QLabel("You input string is :")
        self.title = " "
        self.left = 100
        self.top = 200
        self.width = 400
        self.height = 300

        self.InitWindow()
    def __init__(self):
        super(Window, self).__init__()

        self.groupBox = QGroupBox("What is your favorite sport ?")
        self.radiobtn3 = QRadioButton("BasketBall")
        self.radiobtn3.setIcon(QIcon(""))
        self.radiobtn2 = QRadioButton("Swimming")
        self.radiobtn2.setIcon(QIcon(""))
        self.radiobtn1 = QRadioButton("FootBall")
        self.radiobtn1.setIcon(QIcon(""))

        self.label = QLabel("You Have Selected FootBall")
        self.title = " "
        self.left = 100
        self.top = 200
        self.width = 400
        self.height = 300

        self.InitWindow()
    def createLayout(self):
        self.groupBox = QGroupBox(
            "What is your favorite programming language?")

        gridLayout = QGridLayout()

        button1 = QPushButton("Python", self)
        gridLayout.addWidget(button1, 0, 0)

        button2 = QPushButton("C++", self)
        gridLayout.addWidget(button2, 0, 1)

        button3 = QPushButton("Java", self)
        gridLayout.addWidget(button3, 1, 0)

        button4 = QPushButton("C#", self)
        gridLayout.addWidget(button4, 1, 1)

        self.groupBox.setLayout(gridLayout)
    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)
Exemple #16
0
    def __init__(self, task: DownloadTask):
        super().__init__()
        self.task = task
        constant.download_task_widget_map[task.chapterInfo.url] = self
        self.setMinimumHeight(40)
        self.setMaximumHeight(40)
        self.groupBox = QGroupBox(self)

        self.title = QLabel(self.groupBox)
        self.title.setText(task.comicInfo.title + task.chapterInfo.title)
        self.title.setGeometry(10, 5, 300, 20)
        # 下载进度
        self.schedule = QLabel(self.groupBox)
        self.schedule.setText(
            f"总页数:{len(self.task.imageInfos)}  已下载:{len(self.task.success)}  下载失败:{len(self.task.error)}")
        self.schedule.setGeometry(310, 5, 200, 20)
        # 进度条
        self.pbar = QProgressBar(self.groupBox)
        self.pbar.setGeometry(10, 25, 600, 10)
        self.pbar.setMinimum(0)
        self.pbar.setMaximum(len(task.imageInfos))
        self.pbar.setValue(0)
        self.update_task_signa.connect(self.update_task_thread)
        # 状态
        self.status = QLabel(self.groupBox)
        self.status.setGeometry(620, 12, 70, 20)
        self.status.setText("等待下载")
        # 按钮
        self.button = ButtonQLabel(self.groupBox)
        self.button.setGeometry(700, 12, 100, 20)
        self.button.setText("暂停")
        self.button.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.PointingHandCursor))
        button_font = QtGui.QFont()
        button_font.setUnderline(True)
        self.button.setFont(button_font)
        self.button.onclick(self.button_click)
Exemple #17
0
    def setUpMainWindow(self):
        """Create and arrange widgets in the main window."""
        # Create the container widget for each of the pages
        # in the tab widget
        self.customer_tab = QWidget()
        self.orders_tab = QWidget()
        self.category_tab = QWidget()
        self.products_tab = QWidget()

        # Add or insert the tabs into the tab widget
        self.tabs = QTabWidget()
        self.tabs.setDocumentMode(True)
        self.tabs.addTab(self.customer_tab, "Customers")
        self.tabs.addTab(self.orders_tab, "Orders")
        self.tabs.addTab(self.category_tab, "Categories")
        self.tabs.addTab(self.products_tab, "Products")
        if self.admin_or_not == 1:
            self.staff_tab = QWidget()
            self.tabs.insertTab(0, self.staff_tab, "Staff")
            self.createStaffTab()
            self.tabs.setCurrentIndex(1)  # Set tab to Customers tab
        self.tabs.currentChanged.connect(self.updateWidgetsAndStates)

        # Call the methods to construct each page
        self.createCustomersTab()
        self.createOrdersTab()
        self.createCategoriesTab()
        self.createProductsTab()

        # Create the widgets in the sidebar for filtering table content
        self.table_name_label = QLabel("<b>Customers</b>")
        self.table_name_label.setAlignment(Qt.AlignmentFlag.AlignCenter)

        self.filter_pattern_line = QLineEdit()
        self.filter_pattern_line.setClearButtonEnabled(True)
        self.filter_pattern_line.textChanged.connect(self.filterRegExpChanged)

        self.filter_regex_combo = QComboBox()
        filter_options = ["Default", "Wildcard", "Fixed String"]
        self.filter_regex_combo.addItems(filter_options)
        self.filter_regex_combo.currentIndexChanged.connect(
            self.filterRegExpChanged)

        self.filter_field_combo = QComboBox()
        self.updateWidgetsAndStates(
            1)  # Initialize the values in filter_field_combo
        self.filter_field_combo.currentIndexChanged.connect(
            self.selectTableColumn)

        filter_case_sensitivity_cb = QCheckBox("Filter with Case Sensitivity")
        filter_case_sensitivity_cb.toggled.connect(self.toggleCaseSensitivity)
        filter_case_sensitivity_cb.toggle()

        # Layout for the sidebar
        filter_v_box = QVBoxLayout()
        filter_v_box.addWidget(self.table_name_label)
        filter_v_box.addWidget(QLabel("Filter Pattern"))
        filter_v_box.addWidget(self.filter_pattern_line)
        filter_v_box.addWidget(QLabel("Filter filter"))
        filter_v_box.addWidget(self.filter_regex_combo)
        filter_v_box.addWidget(QLabel("Select Table Column"))
        filter_v_box.addWidget(self.filter_field_combo)
        filter_v_box.addWidget(filter_case_sensitivity_cb)
        filter_v_box.addStretch(2)

        self.filter_group = QGroupBox("Filtering")
        self.filter_group.setMaximumWidth(260)
        self.filter_group.setLayout(filter_v_box)

        # Arrange the containers in the main window
        main_h_box = QHBoxLayout()
        main_h_box.addWidget(self.tabs)
        main_h_box.addWidget(self.filter_group)

        main_container = QWidget()
        main_container.setLayout(main_h_box)
        self.setCentralWidget(main_container)

        # Create status bar
        self.setStatusBar(QStatusBar())
Exemple #18
0
 def __init__(self, parent: QWidget):
     super().__init__()
     self.logger = logging.getLogger(__name__)
     with open(file="config.json", mode="r",
               encoding="utf-8") as conf_reader:
         self.conf = json.loads(conf_reader.read())
     self.logger.debug("初始化设置界面。设置内容:%s" % self.conf)
     layout = QGridLayout()
     self.setLayout(layout)
     self.setModal(True)
     self.setParent(parent)
     self.resize(400, 300)
     title = QLabel("设置")
     title.setStyleSheet(
         "QLabel{border:none;border-radius:5px;background:transparent;color:#9AD3BC;font-size:20px;}"
     )
     title.setAlignment(Qt.Alignment.AlignCenter)
     layout.addWidget(title, 0, 1, Qt.Alignment.AlignCenter)
     control_close = QPushButton()
     control_close.setStyleSheet(
         "QPushButton{background:#FFE3ED;border-radius:5px;border:none;}QPushButton:hover{background:#EC524B;}"
     )
     control_close.setToolTip("关闭")
     control_close.setFixedHeight(20)
     control_close.clicked.connect(self.close_callback)
     layout.addWidget(control_close, 0, 0)
     debug_check = QCheckBox("调试模式")
     debug_check.setChecked(self.conf["debug"])
     debug_check.setToolTip("单击切换开关状态")
     debug_check.setStyleSheet(
         "QCheckBox::indicator{width:10px;height:10px;border:none;border-radius:5px;background:#9BE3DE;}QCheckBox::indicator:unchecked{background:#BEEBE9;}QCheckBox::indicator:unchecked:hover{background:#9AD3BC;}QCheckBox::indicator:checked{background:#95E1D3;}QCheckBox::indicator:checked:hover{background:#98DED9;}"
     )
     self.content = QGridLayout()
     (x, y) = self.show_setting(conf=self.conf,
                                layout=self.content)  # 返回content的最后一个元素的x,y
     proxy = QGroupBox()
     proxy.setObjectName("proxy")
     proxy_layout = QVBoxLayout()
     proxy_label = QLabel("代理地址:")
     proxy_label.setStyleSheet(
         "QLabel{background:transparent;border:none;}")
     proxy_input = EnhancedEdit()
     proxy_input.setText(self.conf["proxy"])
     proxy_input.setToolTip("格式为协议://IP:端口,留空保持直连")
     proxy_input.setStyleSheet(
         "QLineEdit{border:1px solid #F3EAC2;border-radius:5px;background:transparent;}QLineEdit:hover{border:1px solid #F5B461;}"
     )
     proxy_layout.addWidget(proxy_label)
     proxy_layout.addWidget(proxy_input)
     proxy.setLayout(proxy_layout)
     proxy.setStyleSheet("QGroupBox{border-radius:5px;}")
     proxy.setToolTip("代理设置")
     if y + 1 >= 3:
         y_ = 0
         x_ = x + 1
     else:
         y_ = y + 1
         x_ = x
     self.content.addWidget(proxy, x_, y_)
     self.content.addWidget(debug_check)
     layout.addLayout(self.content, 1, 1)
Exemple #19
0
 def setupTimerTab(self):
     settings = QSettings()
     self.timerContainer = QWidget(self)
     self.timerContainerLayout = QVBoxLayout(self.timerContainer)
     self.timerContainer.setLayout(self.timerContainerLayout)
     """ Create work groupbox"""
     self.workGroupBox = QGroupBox("Work")
     self.workGroupBoxLayout = QHBoxLayout(self.workGroupBox)
     self.workGroupBox.setLayout(self.workGroupBoxLayout)
     self.workHoursSpinBox = QSpinBox(
         minimum=0,
         maximum=24,
         value=int(settings.value(workHoursKey, 0)),
         suffix="h",
         sizePolicy=self.size_policy,
     )
     self.workMinutesSpinBox = QSpinBox(
         minimum=0,
         maximum=60,
         value=int(settings.value(workMinutesKey, 25)),
         suffix="m",
         sizePolicy=self.size_policy,
     )
     self.workSecondsSpinBox = QSpinBox(
         minimum=0,
         maximum=60,
         value=int(settings.value(workSecondsKey, 0)),
         suffix="s",
         sizePolicy=self.size_policy,
     )
     """ Create rest groupbox"""
     self.restGroupBox = QGroupBox("Rest")
     self.restGroupBoxLayout = QHBoxLayout(self.restGroupBox)
     self.restGroupBox.setLayout(self.restGroupBoxLayout)
     self.restHoursSpinBox = QSpinBox(
         minimum=0,
         maximum=24,
         value=int(settings.value(restHoursKey, 0)),
         suffix="h",
         sizePolicy=self.size_policy,
     )
     self.restMinutesSpinBox = QSpinBox(
         minimum=0,
         maximum=60,
         value=int(settings.value(restMinutesKey, 5)),
         suffix="m",
         sizePolicy=self.size_policy,
     )
     self.restSecondsSpinBox = QSpinBox(
         minimum=0,
         maximum=60,
         value=int(settings.value(restSecondsKey, 0)),
         suffix="s",
         sizePolicy=self.size_policy,
     )
     self.restGroupBoxLayout.addWidget(self.restHoursSpinBox)
     self.restGroupBoxLayout.addWidget(self.restMinutesSpinBox)
     self.restGroupBoxLayout.addWidget(self.restSecondsSpinBox)
     """ Create other groupbox"""
     self.otherGroupBox = QGroupBox("Other")
     self.otherGroupBoxLayout = QHBoxLayout(self.otherGroupBox)
     self.otherGroupBox.setLayout(self.otherGroupBoxLayout)
     self.repetitionsLabel = QLabel("Repetitions")
     self.repetitionsSpinBox = QSpinBox(
         minimum=0,
         maximum=10000,
         value=0,
         sizePolicy=self.size_policy,
         specialValueText="∞",
     )
     self.modeLabel = QLabel("Mode")
     self.modeComboBox = QComboBox(sizePolicy=self.size_policy)
     self.modeComboBox.addItems(["work", "rest"])
     self.otherGroupBoxLayout.addWidget(self.repetitionsLabel)
     self.otherGroupBoxLayout.addWidget(self.repetitionsSpinBox)
     self.otherGroupBoxLayout.addWidget(self.modeLabel)
     self.otherGroupBoxLayout.addWidget(self.modeComboBox)
     """ Create timer groupbox"""
     self.lcdDisplayGroupBox = QGroupBox("Time")
     self.lcdDisplayGroupBoxLayout = QHBoxLayout(self.lcdDisplayGroupBox)
     self.lcdDisplayGroupBox.setLayout(self.lcdDisplayGroupBoxLayout)
     self.timeDisplay = QLCDNumber(8, sizePolicy=self.size_policy)
     self.timeDisplay.setFixedHeight(100)
     self.timeDisplay.display("00:00:00")
     self.lcdDisplayGroupBoxLayout.addWidget(self.timeDisplay)
     """ Create pause, start and reset buttons"""
     self.buttonContainer = QWidget()
     self.buttonContainerLayout = QHBoxLayout(self.buttonContainer)
     self.buttonContainer.setLayout(self.buttonContainerLayout)
     self.startButton = self.makeButton("start", disabled=False)
     self.resetButton = self.makeButton("reset")
     self.pauseButton = self.makeButton("pause")
     """ Add widgets to container """
     self.workGroupBoxLayout.addWidget(self.workHoursSpinBox)
     self.workGroupBoxLayout.addWidget(self.workMinutesSpinBox)
     self.workGroupBoxLayout.addWidget(self.workSecondsSpinBox)
     self.timerContainerLayout.addWidget(self.workGroupBox)
     self.timerContainerLayout.addWidget(self.restGroupBox)
     self.timerContainerLayout.addWidget(self.otherGroupBox)
     self.timerContainerLayout.addWidget(self.lcdDisplayGroupBox)
     self.buttonContainerLayout.addWidget(self.pauseButton)
     self.buttonContainerLayout.addWidget(self.startButton)
     self.buttonContainerLayout.addWidget(self.resetButton)
     self.timerContainerLayout.addWidget(self.buttonContainer)
     return self.timerContainer
Exemple #20
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)
Exemple #21
0
    def __init__(self, comic_info: ComicInfo, down_v_box_layout: QVBoxLayout):
        super().__init__()
        self.comic_info = comic_info
        self.down_v_box_layout = down_v_box_layout
        self.img_label = QLabel(self)
        self.img_label.setScaledContents(True)
        img = QImage.fromData(comic_info.cover)
        w, h = image_resize(comic_info.cover, width=200)
        self.img_label.resize(QtCore.QSize(w, h))
        self.img_label.setGeometry(10, 10, w, h)
        self.img_label.setPixmap(QPixmap.fromImage(img))
        # self.img_label.setPixmap(QtGui.QPixmap("/Users/bo/my/tmp/老夫子2/第1卷/1.jpg"))

        self.title = QLabel(self)
        self.title.setGeometry(220, 10, 100, 40)
        title_font = QtGui.QFont()
        title_font.setPointSize(16)
        title_font.setBold(True)
        title_font.setUnderline(True)
        self.title.setFont(title_font)
        self.title.setText(comic_info.title)
        self.title.setWordWrap(True)

        info_font = QtGui.QFont()
        info_font.setPointSize(14)
        # 作者
        self.author = QLabel(self)
        self.author.setText("作者 : " + comic_info.author)
        self.author.setGeometry(220, 50, 150, 40)
        self.author.setWordWrap(True)
        self.author.setFont(info_font)
        # 状态
        self.status = QLabel(self)
        self.status.setText("更新状态 : " + comic_info.status)
        self.status.setGeometry(220, 90, 150, 40)
        self.status.setFont(info_font)

        # 热度
        self.heat = QLabel(self)
        self.heat.setText("热度 : " + str(comic_info.heat))
        self.heat.setGeometry(220, 130, 150, 40)
        self.heat.setFont(info_font)

        # 类型
        self.tip = QLabel(self)
        self.tip.setText("类型 : " + comic_info.tip)
        self.tip.setGeometry(220, 170, 150, 40)
        self.tip.setWordWrap(True)
        self.tip.setFont(info_font)

        # web
        self.domain = QLabel(self)
        self.domain.setText(f"查看原网页 : {comic_info.domain}")
        self.domain.setText(f'查看原网页 : <a href="{comic_info.url}">{comic_info.domain}</a>')
        self.domain.setGeometry(220, 210, 150, 40)
        self.domain.setOpenExternalLinks(True)
        self.domain.setFont(info_font)

        # 描述
        self.describe = QLabel(self)
        self.describe.setText("  " + comic_info.describe)
        self.describe.setGeometry(10, 320, 350, 330)
        self.describe.setWordWrap(True)
        # 对齐方式
        self.describe.setAlignment(
            QtCore.Qt.AlignmentFlag.AlignLeading | QtCore.Qt.AlignmentFlag.AlignLeft | QtCore.Qt.AlignmentFlag.AlignTop)

        # 章节列表,创建一个区域

        self.searchHBoxLayout = QHBoxLayout()
        # self.searchHBoxLayout.addSpacing()
        self.searchGroupBox = QGroupBox()
        self.searchGroupBox.setLayout(self.searchHBoxLayout)

        self.searchScroll = QScrollArea(self)
        self.searchScroll.setGeometry(370, 10, 574, 590)
        self.searchScroll.setWidget(self.searchGroupBox)
        self.searchScroll.setWidgetResizable(True)

        # 全选
        self.check_all = QCheckBox(self)
        self.check_all.setText("全选")
        self.check_all.setGeometry(700, 610, 100, 20)
        self.check_all.stateChanged.connect(self.check_all_fun)

        # 下载
        self.down_button = QPushButton(self)
        self.down_button.setText("下载")
        self.down_button.setGeometry(780, 605, 50, 30)

        self.down_button.clicked.connect(self.download_button_click)

        self.load_chapter_list_signa.connect(self.load_chapter)
        self.load_download_task_signa.connect(self.download_callback)

        # 调用对应的service的接口,获取章节列表
        constant.SERVICE.chapter(comic_info, self.load_chapter_list_signa.emit)
Exemple #22
0
    def __init__(self, main_window: QWidget):
        super().__init__()
        self.search_callback = None
        # 主题空间 子组件都放这个Widget里
        self.centralWidget = QtWidgets.QWidget(main_window)
        self.centralWidget.setObjectName("centralWidget")
        # 搜索框
        self.souInput = QtWidgets.QLineEdit(self.centralWidget)
        self.souInput.setGeometry(QtCore.QRect(40, 30, 800, 30))
        font = QtGui.QFont()
        font.setPointSize(22)
        font.setKerning(True)
        font.setStyleStrategy(QtGui.QFont.StyleStrategy.PreferDefault)
        self.souInput.setFont(font)
        self.souInput.setObjectName("souInput")
        self.souInput.setText("龙珠")

        self.modBox = CheckableComboBox(self.centralWidget)
        self.modBox.setGeometry(QtCore.QRect(850, 30, 120, 30))
        for k in constant.mod_dist.keys():
            if k in constant.mod_list:
                self.modBox.addItem(QtCore.Qt.CheckState.Checked, k)
            else:
                self.modBox.addItem(QtCore.Qt.CheckState.Unchecked, k)

        # QTabWidget tab页签
        self.tabWidget = QtWidgets.QTabWidget(self.centralWidget)
        self.tabWidget.setGeometry(QtCore.QRect(40, 70, 944, 668))
        self.tabWidget.setTabsClosable(True)
        self.tabWidget.setObjectName("tabWidget")
        # 下载页面
        self.down_tab = QtWidgets.QWidget()
        self.down_tab.setStatusTip("")
        self.down_tab.setAutoFillBackground(False)
        self.down_tab.setObjectName("down_tab")
        self.tabWidget.addTab(self.down_tab, "下载列表")
        # 书架页面
        self.bookshelf_tab = QtWidgets.QWidget()
        self.bookshelf_tab.setObjectName("bookshelf_tab")
        self.tabWidget.addTab(self.bookshelf_tab, "书架")
        # 搜索结果页面
        self.search_tab = QtWidgets.QWidget()
        self.search_tab.setObjectName("search_tab")
        self.tabWidget.addTab(self.search_tab, "搜索结果")
        # None 空按钮,tab签右侧按钮,设置到前面
        tbr = self.tabWidget.tabBar().tabButton(0, QTabBar.ButtonPosition.RightSide)
        self.tabWidget.tabBar().setTabButton(0, QTabBar.ButtonPosition.LeftSide, tbr)
        self.tabWidget.tabBar().setTabButton(1, QTabBar.ButtonPosition.LeftSide, tbr)
        self.tabWidget.tabBar().setTabButton(2, QTabBar.ButtonPosition.LeftSide, tbr)
        # 启用关闭页签的功能
        self.tabWidget.tabCloseRequested.connect(self.tab_close)
        # 默认打开到书架
        self.tabWidget.setCurrentIndex(1)
        # 主体的centralWidget 放到主窗口中
        main_window.setCentralWidget(self.centralWidget)
        # 书架页
        self.bookshelfVBoxLayout = QVBoxLayout()
        self.bookshelfGroupBox = QGroupBox()
        self.bookshelfScroll = QScrollArea()
        self.bookshelfLayout = QVBoxLayout(self.bookshelf_tab)
        self.bookshelfVBoxLayout.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)

        self.bookshelfGroupBox.setLayout(self.bookshelfVBoxLayout)
        self.bookshelfScroll.setWidget(self.bookshelfGroupBox)
        self.bookshelfScroll.setWidgetResizable(True)
        self.bookshelfLayout.addWidget(self.bookshelfScroll)
        # 搜索页
        self.searchVBoxLayout = QVBoxLayout()
        self.searchGroupBox = QGroupBox()
        self.searchScroll = QScrollArea()
        self.searchLayout = QVBoxLayout(self.search_tab)
        self.searchVBoxLayout.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)

        self.searchGroupBox.setLayout(self.searchVBoxLayout)
        self.searchScroll.setWidget(self.searchGroupBox)
        self.searchScroll.setWidgetResizable(True)
        self.searchLayout.addWidget(self.searchScroll)
        # 下载页
        self.downVBoxLayout = QVBoxLayout()
        self.downGroupBox = QGroupBox()
        self.downScroll = QScrollArea()
        self.downLayout = QVBoxLayout(self.down_tab)
        self.downVBoxLayout.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)

        self.downGroupBox.setLayout(self.downVBoxLayout)
        self.downScroll.setWidget(self.downGroupBox)
        self.downScroll.setWidgetResizable(True)
        self.downLayout.addWidget(self.downScroll)
        down_button_layout = QHBoxLayout()
        self.downLayout.addLayout(down_button_layout)
        down_button_layout.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight)
        all_start = QPushButton()
        all_start.setText("全部开始")
        all_stop = QPushButton()
        all_stop.setText("全部停止")
        clear_done = QPushButton()
        clear_done.setText("清理已完成")

        down_button_layout.addWidget(all_start)
        down_button_layout.addWidget(all_stop)
        down_button_layout.addWidget(clear_done)

        self.souInput.returnPressed.connect(self.input_return_pressed)  # 回车搜索

        self.load_comic_list_signa.connect(self.search_load_comic_list)  # 更新ui的插槽

        self.bookshelf_load_comic_list()
        self.download_callback()