Esempio n. 1
0
def MainGUI():
    # app = QApplication(sys.argv)
    app = QApplication([])
    win = QMainWindow()
    win.setGeometry(200, 200, 300, 450)
    win.setFixedSize(300, 450)
    win.setWindowTitle("FotoPDF")
    app.setWindowIcon(QIcon(resource_path('FotoPDF.png')))

    detail_widget = QTextEdit(win)
    detail_widget.setAlignment(Qt.AlignCenter)
    highlighter = Highlighter(detail_widget.document())
    detail_widget.setReadOnly(True)
    detail_widget.setText("Tip: it works with both a folder or any file in that folder.")
    detail_widget.setGeometry(0, 300, 300, 150)
    detail_widget.setStyleSheet("background-color: rgb{}; color: rgb(255,255,255);".format(str(MACOSDARK)))

    # Create widget to accept drag&drop
    header_widget = FileEdit(win, detail_widget)
    header_widget.setAlignment(Qt.AlignCenter)
    header_widget.setReadOnly(True)
    header_widget.setText("Drag folder here")
    header_widget.setGeometry(0, 0, 300, 300)
    font = header_widget.font()
    font.setPointSize(32)
    header_widget.setFont(font)
    header_widget.setStyleSheet(
        "background-color: rgb{}; color: rgb(255,255,255);border : 5px solid rgb{};".format(str(MACOSYELLOW),
                                                                                            str(MACOSDARK)))
    win.show()
    sys.exit(app.exec_())
Esempio n. 2
0
class QtPysideApp(QApplication):
    def __init__(self, renderer, title):
        QApplication.__init__(self, sys.argv)
        self.window = QMainWindow()
        self.window.setWindowTitle(title)
        self.window.resize(800,600)
        # Get OpenGL 4.1 context
        glformat = QGLFormat()
        glformat.setVersion(4, 1)
        glformat.setProfile(QGLFormat.CoreProfile)
        glformat.setDoubleBuffer(False)
        self.glwidget = MyGlWidget(renderer, glformat, self)
        self.window.setCentralWidget(self.glwidget)
        self.window.show()
        
    def __enter__(self):
        "setup for RAII using 'with' keyword"
        return self

    def __exit__(self, type_arg, value, traceback):
        "cleanup for RAII using 'with' keyword"
        self.glwidget.disposeGL()

    def run_loop(self):
        retval = self.exec_()
        sys.exit(retval)
Esempio n. 3
0
 def run(self):  # 2. Implement run()
     window = QMainWindow()
     version = self.build_settings["version"]
     window.setWindowTitle("HelloWorld v" + version)
     window.resize(250, 150)
     window.show()
     return self.app.exec_()  # 3. End run() with this line
Esempio n. 4
0
class WageStat(object):
    def __init__(self):
        self.window = QMainWindow()
        self.window.resize(600, 500)
        self.window.setWindowTitle('薪酬统筹')
        self.textEdit = QPlainTextEdit(self.window)
        self.textEdit.setPlaceholderText('请输入薪资表')
        self.textEdit.resize(400, 400)
        self.textEdit.move(100, 25)
        self.button = QPushButton('统计', self.window)
        self.button.move(250, 450)
        self.button.clicked.connect(self.__handler_click)

    def __handler_click(self):
        info = self.textEdit.toPlainText()
        info = info.split('\n')
        name = ''
        for data in info:
            num = re.search(r'\d{4,}', data)
            if num:
                if int(num.group()) <= 20000:
                    name += data[0:4] + '\n'
            else:
                print('匹配失败')
        QMessageBox.about(self.window, '统计结果', f'薪资低于2万人员名单\n{name}')
def run_interface():
    app = QApplication(sys.argv)
    window = QMainWindow()
    widget = DicomMoveWindow()
    window.setCentralWidget(widget)
    window.setWindowTitle("Dicom move")
    window.resize(600, widget.sizeHint().height())
    window.show()
    sys.exit(app.exec_())
Esempio n. 6
0
class GuiApplication(QApplication):
    def __init__(self):
        super().__init__()

        with open("styles/style.qss", "r") as stylesheet:
            self.setStyleSheet(stylesheet.read())

        self.main_window = QMainWindow()
        self.main_window.setWindowTitle("Gess!")

        # Controllers
        game_controller = GameController(self.main_window)

        self.main_window.show()
Esempio n. 7
0
class CSDN():
    def __init__(self):
        self.windows = QMainWindow()
        self.windows.resize(450, 300)
        self.windows.setWindowTitle("轻松获取csdn文章--by tansty")
        self.setup_ui()
        self.set_connect()

    def set_connect(self):
        #设置建立联系
        self.button.clicked.connect(self.spider_csdn)

    def setup_ui(self):
        #设置ui界面的建立
        self.button = QPushButton(self.windows)
        self.button.resize(100, 100)
        self.button.move(150, 150)
        self.button.setText("获取文章")
        self.text = QPlainTextEdit(self.windows)
        self.text.setPlaceholderText("请输入需要获取文章的链接")
        self.text.resize(450, 100)

    def spider_csdn(self):
        # 目标文章的链接
        title_url = self.text.toPlainText()
        MessageBox = QMessageBox(self.windows)
        if not title_url:
            MessageBox.critical(self.windows, "错误", "请输入网址")
            return
        head = {
            "User-Agent":
            "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36 Edg/84.0.522.52"
        }
        html = requests.get(url=title_url, headers=head).text
        page = parsel.Selector(html)
        #创建解释器
        title = page.css(".title-article::text").get()
        res = re.compile("[^\u4e00-\u9fa5^a-z^A-Z^0-9]")
        restr = ''
        res.sub(restr, title)
        content = page.css("article").get()
        content = re.sub("<a.*?a>", "", content)
        content = re.sub("<br>", "", content)
        texts = tomd.Tomd(content).markdown
        #转换为markdown 文件
        with open(title + ".md", mode="w", encoding="utf-8") as f:
            f.write("#" + title)
            f.write(texts)
            MessageBox.information(self.windows, "正确", "获取文章完成")
Esempio n. 8
0
class JosephusUIOnPyside2(QTUI):
    def __init__(self, title) -> None:
        self.window = QMainWindow()
        self.window.resize(500, 400)
        self.window.move(300, 310)
        self.window.setWindowTitle(title)

        self.textEdit = QPlainTextEdit(self.window)
        self.textEdit.setPlaceholderText("Please input people's items")
        self.textEdit.move(10, 25)
        self.textEdit.resize(300, 350)

        self.button = QPushButton('Generate survior', self.window)
        self.button.move(380, 80)
        self.button.clicked.connect(self.handle_button)

    def handle_button(self) -> None:
        people_info = self.textEdit.toPlainText()

        reader = []
        for row in people_info:
            data = row(read_files.str2list_row)
            reader.append(data)

        ring = Josephus.Ring(reader)
        ring.start = 0
        ring.step = 1

        res = ring.query_list_all()
        size_res = len(res)
        generator = ring.iter()

        survior = ''
        for i in range(size_res):
            some_one = next(generator)

            if some_one == None:
                break

            if i == size_res - 1:
                survior = 'Survivor\'s name is' + some_one.name + \
                    'age is' + some_one.age + 'gender is' + some_one.gender

            else:
                continue

        QmessageBox.about(self.window, 'Survior\'s items', survior)
Esempio n. 9
0
class Stats():
    def __init__(self):
        self.window = QMainWindow()
        self.window.resize(500, 400)
        self.window.move(300, 300)
        self.window.setWindowTitle('薪资统计')

        self.textEdit = QPlainTextEdit(self.window)
        self.textEdit.setPlaceholderText('请输入薪资表')
        self.textEdit.move(10, 25)
        self.textEdit.resize(300, 350)

        self.button = QPushButton('统计', self.window)
        self.button.move(380, 80)
        self.button.clicked.connect(self.handleCalc)
        pass

    def handleCalc(self):
        info = self.textEdit.toPlainText()

        salary_above_20k = ''
        salary_below_20k = ''

        for line in info.splitlines():
            if not line.strip():
                continue
                pass
            parts = line.split(' ')
            print(type(parts))

            parts = [p for p in parts if p]
            name, salary, age = parts
            if int(salary) >= 20000:
                salary_above_20k += name + '\n'
                pass
            else:
                salary_below_20k += name + '\n'
                pass
            pass
        QMessageBox.about(
            self.window, '统计结果', f'''薪资20000 以上的有:\n{salary_above_20k}
                        \n薪资20000 以下的有:\n{salary_below_20k}''')
        pass

    pass
Esempio n. 10
0
class Stats():
    def __init__(self):
        self.window = QMainWindow()
        self.window.resize(500, 400)
        self.window.move(300, 300)
        self.window.setWindowTitle('学生管理系统')

        self.label_account = QLabel(self.window)
        self.label_password = QLabel(self.window)
        self.label_account.setText("账号")
        self.label_password.setText("密码")

        self.textEdit = QPlainTextEdit(self.window)
        self.textEdit.setPlaceholderText("请输入薪资表")
        self.textEdit.move(10, 25)
        self.textEdit.resize(300, 350)

        self.button = QPushButton('统计', self.window)
        self.button.move(380, 80)

        self.button.clicked.connect(self.handleCalc)

    def handleCalc(self):
        info = self.textEdit.toPlainText()
        print(info)
        # 薪资20000 以上 和 以下 的人员名单
        salary_above_20k = ''
        salary_below_20k = ''
        for line in info.splitlines():
            print(line)
            if not line.strip():
                continue
            parts = line.split(' ')
            # 去掉列表中的空字符串内容
            parts = [p for p in parts if p]
            name, salary, age = parts
            if int(salary) >= 20000:
                salary_above_20k += name + '\n'
            else:
                salary_below_20k += name + '\n'

        QMessageBox.about(
            self.window, '统计结果', f'''薪资20000 以上的有:\n{salary_above_20k}
                    \n薪资20000 以下的有:\n{salary_below_20k}''')
Esempio n. 11
0
    def _open_item_tracker(self):
        # Importing this at root level seems to crash linux tests :(
        from PySide2.QtWebEngineWidgets import QWebEngineView

        tracker_window = QMainWindow()
        tracker_window.setWindowTitle("Item Tracker")
        tracker_window.resize(370, 380)

        web_view = QWebEngineView(tracker_window)
        tracker_window.setCentralWidget(web_view)

        self.web_view = web_view

        def update_window_icon():
            tracker_window.setWindowIcon(web_view.icon())

        web_view.iconChanged.connect(update_window_icon)
        web_view.load(QUrl("https://spaghettitoastbook.github.io/echoes/tracker/"))

        tracker_window.show()
        self._item_tracker_window = tracker_window
Esempio n. 12
0
class Stats():
    def __init__(self):
        # 主窗口
        self.window = QMainWindow()
        self.window.resize(500, 400)
        self.window.move(300, 300)
        self.window.setWindowTitle('薪资统计')
        # 纯文本框
        self.textEdit = QPlainTextEdit(self.window)
        self.textEdit.setPlaceholderText("请输入薪资表")
        self.textEdit.move(10, 25)
        self.textEdit.resize(300, 350)
        # 按钮
        self.button = QPushButton('统计', self.window)
        self.button.move(380, 80)
        # 按钮绑定响应函数
        self.button.clicked.connect(self.handleCalc)

    def handleCalc(self):
        # 获取纯文本框里的内容
        info = self.textEdit.toPlainText()

        # 薪资20000 以上 和 以下 的人员名单
        salary_above_20k = ''
        salary_below_20k = ''
        for line in info.splitlines():
            if not line.strip():
                continue
            parts = line.split(' ')
            # 去掉列表中的空字符串内容
            parts = [p for p in parts if p]
            name, salary, age = parts
            if int(salary) >= 20000:
                salary_above_20k += name + '\n'
            else:
                salary_below_20k += name + '\n'

        QMessageBox.about(
            self.window, '统计结果', f'''薪资20000 以上的有:\n{salary_above_20k}
                    \n薪资20000 以下的有:\n{salary_below_20k}''')
Esempio n. 13
0
 def viewImage(self):
     """
     display full size image in a new window
     Unused yet
     """
     parent = window
     newWin = QMainWindow(parent)
     newWin.setAttribute(Qt.WA_DeleteOnClose)
     newWin.setContextMenuPolicy(Qt.CustomContextMenu)
     label = imageLabel(parent=newWin)
     label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
     label.img = None
     newWin.setCentralWidget(label)
     sel = self.listWdg.selectedItems()
     item = sel[0]
     filename = item.data(Qt.UserRole)[0]
     newWin.setWindowTitle(filename)
     imImg = imImage.loadImageFromFile(filename,
                                       createsidecar=False,
                                       window=window)
     label.img = imImg
     newWin.showMaximized()
Esempio n. 14
0
    def run(self):  # 2. Implement run()
        window = QMainWindow()
        self.ui = Ui_MainWindow()

        self.ui.setupUi(window)
        version = self.build_settings['version']
        window.setWindowTitle("NosDamage v" + version)
        window.resize(250, 150)
        window.show()

        version_checker = VersionCheckerService(version)
        version_checker.needUpdate.connect(lambda need_update: (
            self.show_update_dialog() if need_update else None))
        version_checker.start()

        entities = ObservableList(ps.load_entities())

        self.editor_controller = EditorController(self.ui, entities)
        self.calculator_controller = CalculatorController(self.ui, entities)

        entities.add_observer(self.calculator_controller)

        return self.app.exec_()  # 3. End run() with this line
Esempio n. 15
0
    def __init__(self, Script:QMainWindow):

        # Set window parameters
        Script.setWindowTitle("ASL Tools - Script")
        Script.setWindowFlag(Qt.Window)

        # Main frame
        frame = QWidget(Script)
        self.h_layout = QHBoxLayout(frame)

        # Menubar
        menubar = Script.menuBar()
        menu_file:QMenu = menubar.addMenu("Fichier")
        self.action_file_new = QAction("Nouveau", menubar)
        self.action_file_new.setIcon(QIcon(":/images/new-file.svg"))
        self.action_file_new.setShortcut("Ctrl+N")
        menu_file.addAction(self.action_file_new)
        self.action_file_open = QAction("Ouvrir", menubar)
        self.action_file_open.setIcon(QIcon(":/images/open-file.svg"))
        self.action_file_open.setShortcut("Ctrl+O")
        menu_file.addAction(self.action_file_open)
        self.action_file_save = QAction("Enregistrer", menubar)
        self.action_file_save.setIcon(QIcon(":/images/save.svg"))
        self.action_file_save.setShortcut("Ctrl+S")
        menu_file.addAction(self.action_file_save)
        self.action_file_saveas = QAction("Enregistrer sous", menubar)
        self.action_file_saveas.setIcon(QIcon(":/images/save-as.svg"))
        self.action_file_saveas.setShortcut("Ctrl+Shift+S")
        menu_file.addAction(self.action_file_saveas)
        menu_file.addSeparator()
        self.action_file_export = QAction("Exporter", menubar)
        self.action_file_export.setIcon(QIcon(":/images/export.svg"))
        menu_file.addAction(self.action_file_export)
        menu_file.addSeparator()
        self.action_file_quit = QAction("Quitter", menubar)
        self.action_file_quit.setIcon(QIcon(":/images/quit.svg"))
        menu_file.addAction(self.action_file_quit)
        menu_edit:QMenu = menubar.addMenu("Edition")
        self.action_edit_copy = QAction("Copier", menubar)
        self.action_edit_copy.setIcon(QIcon(":/images/copy.svg"))
        self.action_edit_copy.setShortcut("Alt+C")
        menu_edit.addAction(self.action_edit_copy)
        self.action_edit_paste = QAction("Coller", menubar)
        self.action_edit_paste.setIcon(QIcon(":/images/paste.svg"))
        self.action_edit_paste.setShortcut("Alt+V")
        menu_edit.addAction(self.action_edit_paste)

        # Spacer
        spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.h_layout.addItem(spacer)

        # Main grid
        self.grid_layout = QtWidgets.QGridLayout()
        # Filename
        self.label_file = QtWidgets.QLabel(frame)
        self.label_file.setAlignment(QtCore.Qt.AlignCenter)
        self.label_file.setObjectName("label_file")
        self.grid_layout.addWidget(self.label_file, 0, 0, 1, 2)
        # Action widgets
        self.h_layout_actions = QtWidgets.QHBoxLayout()
        self.btn_add = QtWidgets.QToolButton(frame)
        self.btn_add.setEnabled(True)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/images/add.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.btn_add.setIcon(icon)
        self.btn_add.setIconSize(QtCore.QSize(24, 24))
        self.btn_add.setAutoRaise(True)
        self.h_layout_actions.addWidget(self.btn_add)
        self.btn_remove = QtWidgets.QToolButton(frame)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/images/remove.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.btn_remove.setIcon(icon)
        self.btn_remove.setIconSize(QtCore.QSize(24, 24))
        self.btn_remove.setAutoRaise(True)
        self.h_layout_actions.addWidget(self.btn_remove)
        self.btn_move_up = QtWidgets.QToolButton(frame)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/images/arrow-up.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.btn_move_up.setIcon(icon)
        self.btn_move_up.setIconSize(QtCore.QSize(24, 24))
        self.btn_move_up.setAutoRaise(True)
        self.h_layout_actions.addWidget(self.btn_move_up)
        self.btn_move_down = QtWidgets.QToolButton(frame)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/images/arrow-down.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.btn_move_down.setIcon(icon)
        self.btn_move_down.setIconSize(QtCore.QSize(24, 24))
        self.btn_move_down.setAutoRaise(True)
        self.h_layout_actions.addWidget(self.btn_move_down)
        spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.h_layout_actions.addItem(spacer)
        self.grid_layout.addLayout(self.h_layout_actions, 1, 0, 1, 1)
        # List widget
        self.list = QtWidgets.QListWidget(frame)
        self.grid_layout.addWidget(self.list, 2, 0, 1, 1)

        # Grid
        self.grid_layout_form = QtWidgets.QGridLayout()
        # Compliance
        self.label_compliance = QtWidgets.QLabel(frame)
        self.grid_layout_form.addWidget(self.label_compliance, 0, 0, 1, 1)
        self.compliance = QtWidgets.QSpinBox(frame)
        self.compliance.setMaximum(500)
        self.grid_layout_form.addWidget(self.compliance, 0, 1, 1, 1)
        # Resistance
        self.label_resistance = QtWidgets.QLabel(frame)
        self.grid_layout_form.addWidget(self.label_resistance, 1, 0, 1, 1)
        self.resistance = QtWidgets.QSpinBox(frame)
        self.resistance.setMaximum(500)
        self.grid_layout_form.addWidget(self.resistance, 1, 1, 1, 1)
        # Respiratory rate
        self.label_respi_rate = QtWidgets.QLabel(frame)
        self.grid_layout_form.addWidget(self.label_respi_rate, 2, 0, 1, 1)
        self.respi_rate = QtWidgets.QSpinBox(frame)
        self.respi_rate.setMaximum(500)
        self.grid_layout_form.addWidget(self.respi_rate, 2, 1, 1, 1)
        # Spacer
        spacerItem1 = QtWidgets.QSpacerItem(20, 30, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred)
        self.grid_layout_form.addItem(spacerItem1, 4, 0, 1, 1)
        # Pmus insp
        self.label_i_pmus = QtWidgets.QLabel(frame)
        self.grid_layout_form.addWidget(self.label_i_pmus, 5, 0, 1, 1)
        self.i_pmus = QtWidgets.QSpinBox(frame)
        self.i_pmus.setMaximum(100)
        self.grid_layout_form.addWidget(self.i_pmus, 5, 1, 1, 1)
        # Pmus insp inc
        self.label_i_pmus_inc = QtWidgets.QLabel(frame)
        self.grid_layout_form.addWidget(self.label_i_pmus_inc, 6, 0, 1, 1)
        self.i_pmus_inc = QtWidgets.QSpinBox(frame)
        self.i_pmus_inc.setMaximum(100)
        self.grid_layout_form.addWidget(self.i_pmus_inc, 6, 1, 1, 1)
        # Pmus insp hold
        self.label_i_pmus_hld = QtWidgets.QLabel(frame)
        self.grid_layout_form.addWidget(self.label_i_pmus_hld, 7, 0, 1, 1)
        self.i_pmus_hld = QtWidgets.QSpinBox(frame)
        self.i_pmus_hld.setMaximum(100)
        self.grid_layout_form.addWidget(self.i_pmus_hld, 7, 1, 1, 1)
        # Pmus insp rel
        self.label_i_pmus_rel = QtWidgets.QLabel(frame)
        self.grid_layout_form.addWidget(self.label_i_pmus_rel, 8, 0, 1, 1)
        self.i_pmus_rel = QtWidgets.QSpinBox(frame)
        self.i_pmus_rel.setMaximum(100)
        self.grid_layout_form.addWidget(self.i_pmus_rel, 8, 1, 1, 1)
        # Spacer
        spacerItem4 = QtWidgets.QSpacerItem(20, 30, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred)
        self.grid_layout_form.addItem(spacerItem4, 9, 0, 1, 1)
        # Pmus exp
        self.label_e_pmus = QtWidgets.QLabel(frame)
        self.grid_layout_form.addWidget(self.label_e_pmus, 10, 0, 1, 1)
        self.e_pmus = QtWidgets.QSpinBox(frame)
        self.e_pmus.setMaximum(100)
        self.grid_layout_form.addWidget(self.e_pmus, 10, 1, 1, 1)
        # Pmus exp inc
        self.label_e_pmus_inc = QtWidgets.QLabel(frame)
        self.grid_layout_form.addWidget(self.label_e_pmus_inc, 11, 0, 1, 1)
        self.e_pmus_inc = QtWidgets.QSpinBox(frame)
        self.e_pmus_inc.setMaximum(100)
        self.grid_layout_form.addWidget(self.e_pmus_inc, 11, 1, 1, 1)
        # Pmus exp hold
        self.label_e_pmus_hld = QtWidgets.QLabel(frame)
        self.grid_layout_form.addWidget(self.label_e_pmus_hld, 12, 0, 1, 1)
        self.e_pmus_hld = QtWidgets.QSpinBox(frame)
        self.e_pmus_hld.setMaximum(100)
        self.grid_layout_form.addWidget(self.e_pmus_hld, 12, 1, 1, 1)
        # Pmus exp rel
        self.label_e_pmus_rel = QtWidgets.QLabel(frame)
        self.grid_layout_form.addWidget(self.label_e_pmus_rel, 13, 0, 1, 1)
        self.e_pmus_rel = QtWidgets.QSpinBox(frame)
        self.e_pmus_rel.setMaximum(100)
        self.grid_layout_form.addWidget(self.e_pmus_rel, 13, 1, 1, 1)
        # Spacer
        spacerItem3 = QtWidgets.QSpacerItem(20, 30, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred)
        self.grid_layout_form.addItem(spacerItem3, 14, 0, 1, 1)
        # CRF
        self.label_crf = QtWidgets.QLabel(frame)
        self.grid_layout_form.addWidget(self.label_crf, 15, 0, 1, 1)
        self.crf = QtWidgets.QDoubleSpinBox(frame)
        self.crf.setDecimals(1)
        self.crf.setSingleStep(0.1)
        self.grid_layout_form.addWidget(self.crf, 15, 1, 1, 1)
        # Spacer
        spacerItem2 = QtWidgets.QSpacerItem(20, 30, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred)
        self.grid_layout_form.addItem(spacerItem2, 16, 0, 1, 1)
        # Repetions
        self.label_repetitions = QtWidgets.QLabel(frame)
        self.grid_layout_form.addWidget(self.label_repetitions, 17, 0, 1, 1)
        self.repetitions = QtWidgets.QSpinBox(frame)
        self.repetitions.setMaximum(9999)
        self.grid_layout_form.addWidget(self.repetitions, 17, 1, 1, 1)
        self.label_repetitions_total = QtWidgets.QLabel(frame)
        self.label_repetitions_total.setMinimumWidth(30)
        self.grid_layout_form.addWidget(self.label_repetitions_total, 17, 2, 1, 1)
        # Spacer
        spacerItem2 = QtWidgets.QSpacerItem(20, 30, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
        self.grid_layout_form.addItem(spacerItem2, 18, 0, 1, 1)
        # Set form layout in the main grid
        self.grid_layout.addLayout(self.grid_layout_form, 2, 1, 1, 1)
        # Progress bar
        self.progress = QProgressBar(frame)
        self.progress.setMaximumHeight(10)
        self.progress.setTextVisible(False)
        self.grid_layout.addWidget(self.progress, 3, 0, 1, 2)
        # Spacer
        spacer = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
        self.grid_layout.addItem(spacer, 4, 0, 1, 2)

        self.h_layout.addLayout(self.grid_layout)
        spacer = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.h_layout.addItem(spacer)

        # Set size and position
        w, h = self.h_layout.sizeHint().toTuple()
        w_s, h_s = QApplication.primaryScreen().size().toTuple()
        x = round(w_s/2 - w/2)
        y = round(h_s/2 - h/2)
        Script.setCentralWidget(frame)
        Script.resize(w, h)
        Script.move(x, y)

        self.retranslateUi(Script)
        QtCore.QMetaObject.connectSlotsByName(Script)
        Script.setTabOrder(self.btn_add, self.btn_remove)
        Script.setTabOrder(self.btn_remove, self.btn_move_up)
        Script.setTabOrder(self.btn_move_up, self.btn_move_down)
        Script.setTabOrder(self.btn_move_down, self.list)
        Script.setTabOrder(self.list, self.compliance)
        Script.setTabOrder(self.compliance, self.resistance)
        Script.setTabOrder(self.resistance, self.respi_rate)
        Script.setTabOrder(self.respi_rate, self.i_pmus)
        Script.setTabOrder(self.i_pmus, self.i_pmus_inc)
        Script.setTabOrder(self.i_pmus_inc, self.i_pmus_hld)
        Script.setTabOrder(self.i_pmus_hld, self.i_pmus_rel)
        Script.setTabOrder(self.i_pmus_rel, self.e_pmus)
        Script.setTabOrder(self.e_pmus, self.e_pmus_inc)
        Script.setTabOrder(self.e_pmus_inc, self.e_pmus_hld)
        Script.setTabOrder(self.e_pmus_hld, self.e_pmus_rel)
        Script.setTabOrder(self.e_pmus_rel, self.crf)
        Script.setTabOrder(self.crf, self.repetitions)
Esempio n. 16
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Author  : 影子
# @Time    : 2020-10-25 18:25
# @Software: PyCharm
# @File    : PySide2_01.py
# 用户输入一段文本包含:员工姓名,薪资,年龄。把薪资在 2万 以上、以下的人员名单分别打印出来
import os
from PySide2.QtWidgets import QApplication, QMainWindow, QPushButton, QPlainTextEdit

# 增加环境变量
# https://blog.csdn.net/liuzhuchen/article/details/101348454?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-5.add_param_isCf&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-5.add_param_isCf
# envpath = r'D:\ProgramData\Anaconda3\Lib\site-packages\PySide2\plugins\platforms'
# os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = envpath

app = QApplication([])  # 初始化操作提供整个图形界面程序的底层管理功能:初始化、程序入口参数的处理,用户事件等
window = QMainWindow()
window.resize(500, 400)
window.move(300, 310)
window.setWindowTitle("薪资统计")

textEdit = QPlainTextEdit(window)
textEdit.setPlaceholderText("请输入薪资表")
textEdit.move(10, 25)
textEdit.resize(300, 350)
button = QPushButton("统计", window)
button.move(380, 80)
window.show()
app.exec_()
Esempio n. 17
0
import sys
from PySide2.QtWidgets import QApplication, QMainWindow

aplicacao = QApplication(sys.argv)

janela = QMainWindow()
# setGeometry(esquerda, topo, largura, altura)
janela.setGeometry(100, 50, 300, 200)
janela.setWindowTitle("Primeira Janela")
janela.show()

aplicacao.exec_()
sys.exit()
Esempio n. 18
0
class Ui_Application(object):
    # ---------------------------------------------------------------------------------------------------------------- #
    def buySellStocks(self):
        self.inputWindow = inputDialog()
        portfolioName = self.inputWindow.gettext("Enter portfolio to update: ")
        if portfolioName is not None:
            stockTicker = self.inputWindow.gettext(
                "Enter the stock name to trade: ")
            if stockTicker is not None:
                tickerPrice = Main.getStockPrice(portfolioName, stockTicker)
                stockAmount = self.inputWindow.getint(
                    f"The price of this stock is: ${tickerPrice}\nEnter how many shares to buy/sell: "
                )
                if stockAmount is not None:
                    Main.buySellStocks(portfolioName, stockTicker, stockAmount,
                                       tickerPrice)

    # ---------------------------------------------------------------------------------------------------------------- #
    def createPortfolioWindow(self):
        self.inputWindow = inputDialog()
        portfolioName = self.inputWindow.gettext()
        if portfolioName is not None:
            createPortfolio(portfolioName)
            return portfolioName

    # ---------------------------------------------------------------------------------------------------------------- #
    def viewPortfolioWindow(self):
        self.inputWindow = inputDialog()
        portfolioName = self.inputWindow.gettext()
        if portfolioName is not None:
            self.viewPortfolioWindow = QMainWindow()
            self.viewPortfolioWindow.resize(1000, 500)
            self.viewPortfolioWindow.setWindowTitle("View Portfolio")
            label = QtWidgets.QLabel(self.viewPortfolioWindow)
            label.move(50, 50)
            label.setText(Main.getPortfolioInfo(portfolioName))
            label.setStyleSheet("QLabel {font: 22pt Courier}")
            label.adjustSize()
            self.viewPortfolioWindow.show()

    # ---------------------------------------------------------------------------------------------------------------- #
    def detailedStockInfo(self):
        self.inputWindow = inputDialog()
        stockTickers = self.inputWindow.gettext("Enter stock name: ")
        if stockTickers is not None:
            self.detailedStockInfo = QMainWindow()
            self.detailedStockInfo.resize(1000, 1000)
            self.detailedStockInfo.setWindowTitle("Detailed Stock Info")
            label = QtWidgets.QLabel(self.detailedStockInfo)
            label.move(50, 50)
            label.setText(Main.getAllStockData(stockTickers))
            label.setStyleSheet("QLabel {font: 22pt Courier}")
            label.adjustSize()
            self.detailedStockInfo.show()

    # ---------------------------------------------------------------------------------------------------------------- #
    def plotStockHistory(self):
        self.inputWindow = inputDialog()
        tickerChoice = self.inputWindow.gettext("Enter stock to view: ")
        if tickerChoice is not None:
            numberOfDays = self.inputWindow.getint(
                "Enter number of days to view: ")
            if numberOfDays is not None:
                chartChoice = self.inputWindow.getItem("Choose chart type: ")
                print(chartChoice)
                self.wid = QtWidgets.QWidget()
                self.wid.setWindowTitle(f"{tickerChoice} Stock History")
                self.wid.resize(1000, 500)
                grid = QtWidgets.QGridLayout(self.wid)
                fig, ax = plt.subplots()
                data = GrabDataFromAPI.grabStockHistory(
                    tickerChoice, numberOfDays)
                fig.patch.set_facecolor('silver')
                ax.set_facecolor('grey')
                if chartChoice != 'Candlestick':
                    x = [
                        dates.datestr2num(data[i][0])
                        for i in range(numberOfDays)
                    ]
                    y = [float(data[i][4]) for i in range(numberOfDays)]
                    ax.xaxis.set_major_formatter(
                        dates.DateFormatter('%m/%d/%Y'))
                    ax.xaxis.set_major_locator(ticker.MaxNLocator(10))
                    ax.set_xlabel('Date')
                    ax.set_ylabel('Price in USD')
                    ax.set_title(tickerChoice + ' Closing Price History')
                    ax.grid(True)
                    ax.plot(x, y, color='cyan')
                else:
                    ohlc_data = []  # Open High Low Close Data
                    for row in data:
                        ohlc_data.append(
                            (dates.datestr2num(row[0]), np.float64(row[1]),
                             np.float64(row[2]), np.float64(row[3]),
                             np.float64(row[4])))

                    candlestick_ohlc(ax,
                                     ohlc_data,
                                     width=float(0.5),
                                     colorup='cyan',
                                     colordown='orange',
                                     alpha=0.8)
                    ax.xaxis.set_major_formatter(
                        dates.DateFormatter('%m/%d/%Y'))
                    ax.xaxis.set_major_locator(ticker.MaxNLocator(10))
                    plt.xticks(rotation=30)
                    plt.grid()
                    plt.xlabel('Date')
                    plt.ylabel('Price in USD')
                    plt.title(tickerChoice + ' Candlestick Chart')
                    plt.tight_layout()
                canvas = FigureCanvas(fig)
                grid.addWidget(canvas, 0, 0)
                self.wid.show()

    # ------------------------------------------------------------------------------------------------------------ #
    def setupUi(self, Application):
        Application.setObjectName("Application")
        Application.resize(1000, 1000)

        self.gridLayout = QtWidgets.QGridLayout(Application)
        self.gridLayout.setObjectName("gridLayout")

        # Top Label
        self.label = QtWidgets.QLabel(Application)
        self.label.setAlignment(QtCore.Qt.AlignCenter)
        self.label.setObjectName("label")
        self.label.setStyleSheet(
            "QLabel {font: 30pt Elephant; color: #e8fcca}")
        self.gridLayout.addWidget(self.label, 0, 0, 1, 1)

        # First Button
        self.pushButton = QtWidgets.QPushButton(Application)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.pushButton.sizePolicy().hasHeightForWidth())
        self.pushButton.setSizePolicy(sizePolicy)
        self.pushButton.setObjectName("pushButton")
        self.pushButton.setStyleSheet('QPushButton {font: 25pt Elephant}')
        self.gridLayout.addWidget(self.pushButton, 2, 0, 1, 1)

        # Second Button
        self.pushButton_2 = QtWidgets.QPushButton(Application)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.pushButton_2.sizePolicy().hasHeightForWidth())
        self.pushButton_2.setSizePolicy(sizePolicy)
        self.pushButton_2.setObjectName("pushButton_2")
        self.pushButton_2.setStyleSheet('QPushButton {font: 25pt Elephant}')
        self.gridLayout.addWidget(self.pushButton_2, 3, 0, 1, 1)

        # Third Button
        self.pushButton_3 = QtWidgets.QPushButton(Application)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.pushButton_3.sizePolicy().hasHeightForWidth())
        self.pushButton_3.setSizePolicy(sizePolicy)
        self.pushButton_3.setObjectName("pushButton_3")
        self.pushButton_3.setStyleSheet('QPushButton {font: 25pt Elephant}')
        self.gridLayout.addWidget(self.pushButton_3, 4, 0, 1, 1)

        # Fourth Button
        self.pushButton_4 = QtWidgets.QPushButton(Application)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.pushButton_4.sizePolicy().hasHeightForWidth())
        self.pushButton_4.setSizePolicy(sizePolicy)
        self.pushButton_4.setObjectName("pushButton_4")
        self.pushButton_4.setStyleSheet('QPushButton {font: 25pt Elephant}')
        self.gridLayout.addWidget(self.pushButton_4, 5, 0, 1, 1)

        # Fifth Button
        self.pushButton_5 = QtWidgets.QPushButton(Application)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.pushButton_5.sizePolicy().hasHeightForWidth())
        self.pushButton_5.setSizePolicy(sizePolicy)
        self.pushButton_5.setObjectName("pushButton_5")
        self.pushButton_5.setStyleSheet('QPushButton {font: 25pt Elephant}')
        self.gridLayout.addWidget(self.pushButton_5, 6, 0, 1, 1)

        # Lines
        self.line = QtWidgets.QFrame(Application)
        self.line.setFrameShape(QtWidgets.QFrame.HLine)
        self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line.setObjectName("line")
        self.gridLayout.addWidget(self.line, 1, 0, 1, 1)

        self.line_2 = QtWidgets.QFrame(Application)
        self.line_2.setFrameShape(QtWidgets.QFrame.HLine)
        self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_2.setObjectName("line")
        self.gridLayout.addWidget(self.line_2, 7, 0, 1, 1)

        self.retranslateUi(Application)
        QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL("clicked()"),
                               self.buySellStocks)
        QtCore.QObject.connect(self.pushButton_2, QtCore.SIGNAL("clicked()"),
                               self.viewPortfolioWindow)
        QtCore.QObject.connect(self.pushButton_3, QtCore.SIGNAL("clicked()"),
                               self.createPortfolioWindow)
        QtCore.QObject.connect(self.pushButton_4, QtCore.SIGNAL("clicked()"),
                               self.plotStockHistory)
        QtCore.QObject.connect(self.pushButton_5, QtCore.SIGNAL("clicked()"),
                               self.detailedStockInfo)

        QtCore.QMetaObject.connectSlotsByName(Application)

    # ------------------------------------------------------------------------------------------------------------ #
    def retranslateUi(self, Application):
        Application.setWindowTitle(
            QtWidgets.QApplication.translate(
                "Application", "Virtual Stock Market Application", None, -1))
        self.pushButton.setText(
            QtWidgets.QApplication.translate("Application", "Buy/Sell Stocks",
                                             None, -1))
        self.pushButton_3.setText(
            QtWidgets.QApplication.translate("Application", "Create Portfolio",
                                             None, -1))
        self.label.setText(
            QtWidgets.QApplication.translate(
                "Application", "Virtual Stock Market Application", None, -1))
        self.pushButton_4.setText(
            QtWidgets.QApplication.translate("Application",
                                             "Plot Stock History", None, -1))
        self.pushButton_2.setText(
            QtWidgets.QApplication.translate("Application", "View Portfolio",
                                             None, -1))
        self.pushButton_5.setText(
            QtWidgets.QApplication.translate("Application",
                                             "View Detailed Stock Data", None,
                                             -1))
Esempio n. 19
0
class MainWindow(BaseQtView):

    def __init__(self, title: str = "", volume_widget: Optional[QWidget] = None, slice_widget: Optional[QWidget] = None):
        self.title = title
        self.volume_widget = volume_widget if volume_widget else QWidget()
        self.slice_widget = slice_widget if slice_widget else QWidget()

        self._init()

    def _init(self):
        print("Building...")

        self.win = QMainWindow()
        self._default_window_title = self.title

        widget = QWidget()
        self.win.setCentralWidget(widget)

        main_layout = QHBoxLayout()
        widget.setLayout(main_layout)

        main_layout.addWidget(self.slice_widget)
        main_layout.addWidget(self.volume_widget)

        side_layout = QVBoxLayout()
        main_layout.addLayout(side_layout)

        load_image_button = QPushButton("Load Section")
        side_layout.addWidget(load_image_button)
        load_image_button.clicked.connect(self.show_load_image_dialog)

        # Atlas BUttons
        button_hbox = QHBoxLayout()
        side_layout.addLayout(button_hbox)

        atlas_buttons = QButtonGroup(self.win)
        atlas_buttons.setExclusive(True)
        atlas_buttons.buttonToggled.connect(self.atlas_button_toggled)

        for resolution in [100, 25, 10]:
            atlas_button = QPushButton(f"{resolution}um")
            atlas_button.setCheckable(True)
            button_hbox.addWidget(atlas_button)
            atlas_buttons.addButton(atlas_button)

            # The 10um atlas takes way too long to download at the moment.
            # It needs some kind of progress bar or async download feature to be useful.
            # The disabled button here shows it as an option for the future, but keeps it from being used.
            if resolution == 10:
                atlas_button.setDisabled(True)

        self.title_reset_timer = Timer(interval=2, connect=lambda e: self._show_default_window_title(), iterations=1,
                                       start=False)
        self._show_default_window_title()

        self.statusbar = self.win.statusBar()

        self.image_coord_label = QLabel(text="Image Coords")
        self.statusbar.addPermanentWidget(self.image_coord_label)

        self.win.show()

    @property
    def qt_widget(self) -> QWidget:
        return self.win

    def on_image_coordinate_highlighted(self, image_coords, atlas_coords):
        i, j = image_coords
        x, y, z = atlas_coords
        self.image_coord_label.setText(f"(i={i}, j={j})      (x={x:.1f}, y={y:.1f}, z={z:.1f})")

    def on_error_raised(self, msg: str):
        self.show_temp_title(msg)

    def atlas_button_toggled(self, button: QPushButton, is_checked: bool):
        if not is_checked:  # Don't do anything for the button being unselected.
            return

        resolution_label = button.text()
        resolution = int("".join(filter(str.isdigit, resolution_label)))
        self.load_atlas(resolution=resolution)

    # Command Routing
    def show_load_image_dialog(self):
        filename, filetype = QFileDialog.getOpenFileName(
            parent=self.win,
            caption="Load Image",
            dir="../data/RA_10X_scans/MEA",
            filter="OME-TIFF (*.ome.tiff)"
        )
        if not filename:
            return
        self.load_section(filename=filename)

    def load_atlas(self, resolution: int):
        raise NotImplementedError("Connect to LoadAtlasCommand before using.")

    def load_section(self, filename: str):
        raise NotImplementedError("Connect to a LoadImageCommand before using.")

    # View Code
    def _show_default_window_title(self):
        self.win.setWindowTitle(self._default_window_title)

    def show_temp_title(self, title: str) -> None:
        self.win.setWindowTitle(title)
        self.title_reset_timer.stop()
        self.title_reset_timer.start(iterations=1)
Esempio n. 20
0
        sock.settimeout(int(time))  # 限制重连时间
        sock.connect((ip, int(port)))  # 对对应主机的对应端口发起连接
        result = f'{port}端口开放'
        sock.close()  # 关闭连接
    except Exception as e:
        result = f'{port}端口关闭'
    win.append(result)
    #QMessageBox.about(window,'扫描结果',result)


app = QApplication([])

window = QMainWindow()
window.resize(500, 270)
window.move(300, 300)
window.setWindowTitle('端口扫描')

textEdit1 = QPlainTextEdit(window)
#textEdit1.setPlaceholderText("输入IP")
textEdit1.move(10, 50)
textEdit1.resize(200, 40)

textEdit2 = QPlainTextEdit(window)
#textEdit2.setPlaceholderText("输入端口")
textEdit2.move(10, 130)
textEdit2.resize(200, 40)

textEdit3 = QPlainTextEdit(window)
#textEdit3.setPlaceholderText("超时(毫秒)")
textEdit3.move(10, 210)
textEdit3.resize(200, 40)
Esempio n. 21
0
from board_widget import BoardWidget
from top_widget import TopWidget


class Center(QWidget):
    def __init__(self, parent=None):
        super(Center, self).__init__(parent)
        layout = QVBoxLayout()

        p = self.palette()
        p.setColor(QPalette.Background, QColor(192, 192, 192))
        self.setPalette(p)
        self.setAutoFillBackground(True)

        self.board = BoardWidget(16, 30, 99, parent=self)
        self.top = TopWidget(99, parent=self)

        layout.addWidget(self.top)
        layout.addWidget(self.board)

        self.setLayout(layout)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    window = QMainWindow()
    window.setCentralWidget(Center(parent=window))
    window.setWindowTitle('Definitely not minesweeper')
    window.show()
    sys.exit(app.exec_())
Esempio n. 22
0
                    if point in centers:
                        self._board[point].color = Qt.red

                self._application.processEvents()

    def _toogleCenter(self, cell):
        cell.isCenter = not cell.isCenter
        cell.color = self.CELL_CENTER_COLOR if cell.isCenter else self.CELL_SIMPLE_COLOR

    def _clearBoard(self):
        for cell in self._board.values():
            if not cell.isCenter:
                cell.color = self.CELL_SIMPLE_COLOR


if __name__ == '__main__':
    application = QApplication(sys.argv)

    mainWindow = QMainWindow()
    mainWindow.setWindowTitle('Partition')

    boardWidget = BoardWidget(WINDOW_SIZE, 5, application,
                              mainWindow.statusBar())

    settingsWidget = SettingsWidget(boardWidget)

    mainWindow.setCentralWidget(
        PartitionCentralWidget(boardWidget, settingsWidget))
    mainWindow.show()

    sys.exit(application.exec_())
Esempio n. 23
0
import sys
import time

from PySide2.QtCore import QUrl
from PySide2.QtWidgets import QApplication
from PySide2.QtWidgets import QMainWindow, QPushButton
from PySide2.QtWebEngineWidgets import QWebEngineView
from Util import MyTabWidget
from Util import WebEngineView

if __name__ == "__main__":
    # 启动应用
    app = QApplication(sys.argv)

    # 生成窗口并配置
    mainWindow = QMainWindow()
    mainWindow.resize(640, 480)
    mainWindow.setWindowTitle('测试应用')

    # 生成并配置tab组件
    tabWidget = MyTabWidget()
    webView = WebEngineView(tabWidget)
    webView.load(QUrl("http://www.ifeng.com"))
    tabWidget.create_Tab([webView])

    mainWindow.setCentralWidget(tabWidget)
    mainWindow.showMaximized()

    # 退出应用
    sys.exit(app.exec_())
Esempio n. 24
0
    def __init__(self, BigScript: QMainWindow):

        # Set Window parameters
        BigScript.setWindowTitle("ASL Tools - Big Script")
        BigScript.setWindowFlag(Qt.Window)

        # Main frame
        frame = QWidget(BigScript)
        self.h_layout = QHBoxLayout(frame)

        # Menubar
        menubar = BigScript.menuBar()
        menu_file: QMenu = menubar.addMenu("Fichier")
        self.action_file_new = QAction("Nouveau", menubar)
        self.action_file_new.setIcon(QIcon(":/images/new-file.svg"))
        self.action_file_new.setShortcut("Ctrl+N")
        menu_file.addAction(self.action_file_new)
        self.action_file_save = QAction("Enregistrer", menubar)
        self.action_file_save.setIcon(QIcon(":/images/save.svg"))
        self.action_file_save.setShortcut("Ctrl+S")
        menu_file.addAction(self.action_file_save)
        self.action_file_saveas = QAction("Enregistrer sous", menubar)
        self.action_file_saveas.setIcon(QIcon(":/images/save-as.svg"))
        self.action_file_saveas.setShortcut("Ctrl+Shift+S")
        menu_file.addAction(self.action_file_saveas)
        menu_file.addSeparator()
        self.action_file_export = QAction("Exporter", menubar)
        self.action_file_export.setIcon(QIcon(":/images/export.svg"))
        menu_file.addAction(self.action_file_export)
        menu_file.addSeparator()
        self.action_file_quit = QAction("Quitter", menubar)
        self.action_file_quit.setIcon(QIcon(":/images/quit.svg"))
        menu_file.addAction(self.action_file_quit)

        # Spacer
        spacerItem = QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding,
                                 QtWidgets.QSizePolicy.Minimum)
        self.h_layout.addItem(spacerItem)

        # Grid layout
        self.gridLayout = QtWidgets.QGridLayout()
        self.gridLayout.setSpacing(15)
        # File
        self.label_file = QtWidgets.QLabel(frame)
        self.label_file.setTextFormat(QtCore.Qt.PlainText)
        self.label_file.setAlignment(QtCore.Qt.AlignCenter)
        self.label_file.setObjectName("label_file")
        self.gridLayout.addWidget(self.label_file, 0, 0, 1, 4)
        # Header
        self.label_from = QLabel(frame)
        self.gridLayout.addWidget(self.label_from, 1, 1, 1, 1)
        self.label_to = QLabel(frame)
        self.gridLayout.addWidget(self.label_to, 1, 2, 1, 1)
        self.label_step = QLabel(frame)
        self.gridLayout.addWidget(self.label_step, 1, 3, 1, 1)
        # Resistance
        self.label_r = QLabel(frame)
        self.gridLayout.addWidget(self.label_r, 2, 0, 1, 1)
        self.r_from = QtWidgets.QSpinBox(frame)
        self.r_from.setObjectName("grid-spin")
        self.r_from.setMinimum(0)
        self.r_from.setMaximum(200)
        self.gridLayout.addWidget(self.r_from, 2, 1, 1, 1)
        self.r_to = QtWidgets.QSpinBox(frame)
        self.r_to.setObjectName("grid-spin")
        self.r_to.setMinimum(0)
        self.r_to.setMaximum(200)
        self.gridLayout.addWidget(self.r_to, 2, 2, 1, 1)
        self.r_step = QtWidgets.QSpinBox(frame)
        self.r_step.setObjectName("grid-spin")
        self.r_step.setMinimum(1)
        self.gridLayout.addWidget(self.r_step, 2, 3, 1, 1)
        # Compliance
        self.label_c = QLabel(frame)
        self.gridLayout.addWidget(self.label_c, 3, 0, 1, 1)
        self.c_from = QtWidgets.QSpinBox(frame)
        self.c_from.setObjectName("grid-spin")
        self.c_from.setMinimum(0)
        self.c_from.setMaximum(200)
        self.gridLayout.addWidget(self.c_from, 3, 1, 1, 1)
        self.c_to = QtWidgets.QSpinBox(frame)
        self.c_to.setObjectName("grid-spin")
        self.c_to.setMinimum(0)
        self.c_to.setMaximum(200)
        self.gridLayout.addWidget(self.c_to, 3, 2, 1, 1)
        self.c_step = QtWidgets.QSpinBox(frame)
        self.c_step.setObjectName("grid-spin")
        self.c_step.setMinimum(1)
        self.gridLayout.addWidget(self.c_step, 3, 3, 1, 1)
        # Breath rate
        self.label_br = QLabel(frame)
        self.gridLayout.addWidget(self.label_br, 4, 0, 1, 1)
        self.br_from = QtWidgets.QSpinBox(frame)
        self.br_from.setObjectName("grid-spin")
        self.br_from.setMinimum(1)
        self.br_from.setMaximum(100)
        self.gridLayout.addWidget(self.br_from, 4, 1, 1, 1)
        self.br_to = QtWidgets.QSpinBox(frame)
        self.br_to.setObjectName("grid-spin")
        self.br_to.setMinimum(1)
        self.br_to.setMaximum(100)
        self.gridLayout.addWidget(self.br_to, 4, 2, 1, 1)
        self.br_step = QtWidgets.QSpinBox(frame)
        self.br_step.setObjectName("grid-spin")
        self.br_step.setMinimum(1)
        self.gridLayout.addWidget(self.br_step, 4, 3, 1, 1)
        # Pmus
        self.label_i_pmus = QLabel(frame)
        self.gridLayout.addWidget(self.label_i_pmus, 5, 0, 1, 1)
        self.i_pmus_from = QtWidgets.QSpinBox(frame)
        self.i_pmus_from.setObjectName("grid-spin")
        self.i_pmus_from.setMinimum(0)
        self.i_pmus_from.setMaximum(100)
        self.gridLayout.addWidget(self.i_pmus_from, 5, 1, 1, 1)
        self.i_pmus_to = QtWidgets.QSpinBox(frame)
        self.i_pmus_to.setObjectName("grid-spin")
        self.i_pmus_to.setMinimum(0)
        self.i_pmus_to.setMaximum(100)
        self.gridLayout.addWidget(self.i_pmus_to, 5, 2, 1, 1)
        self.i_pmus_step = QtWidgets.QSpinBox(frame)
        self.i_pmus_step.setObjectName("grid-spin")
        self.i_pmus_step.setMinimum(1)
        self.gridLayout.addWidget(self.i_pmus_step, 5, 3, 1, 1)
        # Pmus increase
        self.label_i_pmus_inc = QLabel(frame)
        self.gridLayout.addWidget(self.label_i_pmus_inc, 6, 0, 1, 1)
        self.i_pmus_inc_from = QtWidgets.QSpinBox(frame)
        self.i_pmus_inc_from.setObjectName("grid-spin")
        self.i_pmus_inc_from.setMinimum(0)
        self.i_pmus_inc_from.setMaximum(100)
        self.gridLayout.addWidget(self.i_pmus_inc_from, 6, 1, 1, 1)
        self.i_pmus_inc_to = QtWidgets.QSpinBox(frame)
        self.i_pmus_inc_to.setObjectName("grid-spin")
        self.i_pmus_inc_to.setMinimum(0)
        self.i_pmus_inc_to.setMaximum(100)
        self.gridLayout.addWidget(self.i_pmus_inc_to, 6, 2, 1, 1)
        self.i_pmus_inc_step = QtWidgets.QSpinBox(frame)
        self.i_pmus_inc_step.setObjectName("grid-spin")
        self.i_pmus_inc_step.setMinimum(1)
        self.gridLayout.addWidget(self.i_pmus_inc_step, 6, 3, 1, 1)
        # Pmus hold
        self.label_i_pmus_hld = QLabel(frame)
        self.gridLayout.addWidget(self.label_i_pmus_hld, 7, 0, 1, 1)
        self.i_pmus_hld_from = QtWidgets.QSpinBox(frame)
        self.i_pmus_hld_from.setObjectName("grid-spin")
        self.i_pmus_hld_from.setMinimum(0)
        self.i_pmus_hld_from.setMaximum(100)
        self.gridLayout.addWidget(self.i_pmus_hld_from, 7, 1, 1, 1)
        self.i_pmus_hld_to = QtWidgets.QSpinBox(frame)
        self.i_pmus_hld_to.setObjectName("grid-spin")
        self.i_pmus_hld_to.setMinimum(0)
        self.i_pmus_hld_to.setMaximum(100)
        self.gridLayout.addWidget(self.i_pmus_hld_to, 7, 2, 1, 1)
        self.i_pmus_hld_step = QtWidgets.QSpinBox(frame)
        self.i_pmus_hld_step.setObjectName("grid-spin")
        self.i_pmus_hld_step.setMinimum(1)
        self.gridLayout.addWidget(self.i_pmus_hld_step, 7, 3, 1, 1)
        # Pmus hold
        self.label_i_pmus_rel = QLabel(frame)
        self.gridLayout.addWidget(self.label_i_pmus_rel, 8, 0, 1, 1)
        self.i_pmus_rel_from = QtWidgets.QSpinBox(frame)
        self.i_pmus_rel_from.setObjectName("grid-spin")
        self.i_pmus_rel_from.setMinimum(0)
        self.i_pmus_rel_from.setMaximum(100)
        self.gridLayout.addWidget(self.i_pmus_rel_from, 8, 1, 1, 1)
        self.i_pmus_rel_to = QtWidgets.QSpinBox(frame)
        self.i_pmus_rel_to.setObjectName("grid-spin")
        self.i_pmus_rel_to.setMinimum(0)
        self.i_pmus_rel_to.setMaximum(100)
        self.gridLayout.addWidget(self.i_pmus_rel_to, 8, 2, 1, 1)
        self.i_pmus_rel_step = QtWidgets.QSpinBox(frame)
        self.i_pmus_rel_step.setObjectName("grid-spin")
        self.i_pmus_rel_step.setMinimum(1)
        self.gridLayout.addWidget(self.i_pmus_rel_step, 8, 3, 1, 1)
        # Repetitions
        self.label_n_cycles = QLabel(frame)
        self.gridLayout.addWidget(self.label_n_cycles, 9, 0, 1, 1)
        self.n_cycles = QtWidgets.QSpinBox(frame)
        self.n_cycles.setObjectName("grid-spin")
        self.n_cycles.setMinimum(0)
        self.n_cycles.setMaximum(100)
        self.gridLayout.addWidget(self.n_cycles, 9, 1, 1, 1)
        # Informations
        separator = QtWidgets.QFrame(frame)
        separator.setFrameShape(QtWidgets.QFrame.HLine)
        separator.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.gridLayout.addWidget(separator, 10, 0, 1, 4)
        self.label_tot_simus = QLabel(frame)
        self.gridLayout.addWidget(self.label_tot_simus, 11, 0, 1, 1)
        self.tot_simus = QLabel(frame)
        self.gridLayout.addWidget(self.tot_simus, 11, 1, 1, 1)
        self.label_tot_time = QLabel(frame)
        self.gridLayout.addWidget(self.label_tot_time, 12, 0, 1, 3)
        self.tot_time = QLabel(frame)
        self.gridLayout.addWidget(self.tot_time, 12, 1, 1, 3)
        # Progress
        self.progress = QProgressBar(frame)
        self.progress.setMaximumHeight(10)
        self.progress.setTextVisible(False)
        self.gridLayout.addWidget(self.progress, 13, 0, 1, 4)
        # Spacer
        spacerItem = QSpacerItem(40, 20, QtWidgets.QSizePolicy.Minimum,
                                 QtWidgets.QSizePolicy.Expanding)
        self.gridLayout.addItem(spacerItem, 14, 0, 1, 4)

        self.h_layout.addLayout(self.gridLayout)
        spacerItem5 = QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding,
                                  QtWidgets.QSizePolicy.Minimum)
        self.h_layout.addItem(spacerItem5)

        # Set size and position
        w, h = self.h_layout.sizeHint().toTuple()
        w_s, h_s = QApplication.primaryScreen().size().toTuple()
        x = round(w_s / 2 - w / 2)
        y = round(h_s / 2 - h / 2)
        BigScript.setCentralWidget(frame)
        BigScript.resize(w, h)
        BigScript.move(x, y)

        self.retranslateUi(BigScript)
        QtCore.QMetaObject.connectSlotsByName(BigScript)
Esempio n. 25
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2021/11/4 20:32
# @Author : HuYouLiang
# @File : TestQt.py
# @Purpose :

from PySide2.QtWidgets import QApplication, QMainWindow, QPushButton, QMessageBox
import PySide2.QtCore


def handleclick():
    print("button is clicked")
    QMessageBox.information(window, "hint", "button is clicked",
                            QMessageBox.Ok)


app = QApplication([])

window = QMainWindow()
window.resize(500, 400)
window.move(300, 310)
window.setWindowTitle("Test Qt")

button = QPushButton(window)
button.resize(80, 20)
button.setText("Test Button")
button.clicked.connect(handleclick)

window.show()
app.exec_()
Esempio n. 26
0
def playDiaporama(diaporamaGenerator, parent=None):
    """
    Open a new window and play a slide show.
    @param diaporamaGenerator: generator for file names
    @type  diaporamaGenerator: iterator object
    @param parent:
    @type parent:
    """
    global isSuspended
    isSuspended = False

    # init diaporama window
    newWin = QMainWindow(parent)
    newWin.setAttribute(Qt.WA_DeleteOnClose)
    newWin.setContextMenuPolicy(Qt.CustomContextMenu)
    newWin.setWindowTitle(parent.tr('Slide show'))
    label = imageLabel(mainForm=parent)
    label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
    label.img = None
    newWin.setCentralWidget(label)
    newWin.showFullScreen()
    # Pause key shortcut
    actionEsc = QAction('Pause', None)
    actionEsc.setShortcut(QKeySequence(Qt.Key_Escape))
    newWin.addAction(actionEsc)

    # context menu event handler
    def contextMenuHandler(action):
        global isSuspended
        if action.text() == 'Pause':
            isSuspended = True
            # quit full screen mode
            newWin.showMaximized()
        elif action.text() == 'Full Screen':
            if action.isChecked():
                newWin.showFullScreen()
            else:
                newWin.showMaximized()
        elif action.text() == 'Resume':
            newWin.close()
            isSuspended = False
            playDiaporama(diaporamaGenerator, parent=window)
        # rating : the tag is written into the .mie file; the file is
        # created if needed.
        elif action.text() in ['0', '1', '2', '3', '4', '5']:
            with exiftool.ExifTool() as e:
                e.writeXMPTag(name, 'XMP:rating', int(action.text()))

    # connect shortkey action
    actionEsc.triggered.connect(
        lambda checked=False, name=actionEsc: contextMenuHandler(
            name))  # named arg checked is sent

    # context menu
    def contextMenu(position):
        menu = QMenu()
        actionEsc.setEnabled(not isSuspended)
        action2 = QAction('Full Screen', None)
        action2.setCheckable(True)
        action2.setChecked(newWin.windowState() & Qt.WindowFullScreen)
        action3 = QAction('Resume', None)
        action3.setEnabled(isSuspended)
        for action in [actionEsc, action2, action3]:
            menu.addAction(action)
            action.triggered.connect(
                lambda checked=False, name=action: contextMenuHandler(
                    name))  # named arg checked is sent
        subMenuRating = menu.addMenu('Rating')
        for i in range(6):
            action = QAction(str(i), None)
            subMenuRating.addAction(action)
            action.triggered.connect(
                lambda checked=False, name=action: contextMenuHandler(
                    name))  # named arg checked is sent
        menu.exec_(position)

    # connect contextMenuRequested
    newWin.customContextMenuRequested.connect(contextMenu)
    newWin.setToolTip("Esc to exit full screen mode")
    newWin.setWhatsThis(""" <b>Slide Show</b><br>
        The slide show cycles through the starting directory and its subfolders to display images.
        Photos rated 0 or 1 star are not shown (by default, all photos are rated 5 stars).<br>
        Hit the Esc key to <b>exit full screen mode and pause.</b><br> Use the Context Menu for <b>rating and resuming.</b>
        The rating is saved in the .mie sidecar and the image file is not modified.
        """)  # end of setWhatsThis
    # play diaporama
    window.modeDiaporama = True
    while True:
        if isSuspended:
            newWin.setWindowTitle(newWin.windowTitle() + ' Paused')
            break
        try:
            if not newWin.isVisible():
                break
            name = next(diaporamaGenerator)
            # search rating in metadata
            rating = 5  # default
            with exiftool.ExifTool() as e:
                try:
                    rt = e.readXMPTag(
                        name,
                        'XMP:rating')  # raise ValueError if sidecar not found
                    r = search("\d", rt)
                    if r is not None:
                        rating = int(r.group(0))
                except ValueError:
                    rating = 5
            # don't display image with low rating
            if rating < 2:
                app.processEvents()
            imImg = imImage.loadImageFromFile(name,
                                              createsidecar=False,
                                              cmsConfigure=True,
                                              window=window)
            # zoom might be modified by the mouse wheel : remember
            if label.img is not None:
                imImg.Zoom_coeff = label.img.Zoom_coeff
            coeff = imImg.resize_coeff(label)
            imImg.yOffset -= (imImg.height() * coeff - label.height()) / 2.0
            imImg.xOffset -= (imImg.width() * coeff - label.width()) / 2.0
            app.processEvents()
            if isSuspended:
                newWin.setWindowTitle(newWin.windowTitle() + ' Paused')
                break
            newWin.setWindowTitle(
                parent.tr('Slide show') + ' ' + name + ' ' +
                ' '.join(['*'] * imImg.meta.rating))
            gc.collect()
            label.img = imImg
            label.repaint()
            app.processEvents()
            gc.collect()
            sleep(2)
            app.processEvents()
        except StopIteration:
            newWin.close()
            window.diaporamaGenerator = None
            break
        except ValueError:
            continue
        except RuntimeError:
            window.diaporamaGenerator = None
            break
        except:
            window.diaporamaGenerator = None
            window.modeDiaporama = False
            raise
        app.processEvents()
    window.modeDiaporama = False
Esempio n. 27
0
        else:
            lbl.setText('')
            sim.cleanup()
            t.stop()
            benc_timer.stop()

    action.changed.connect(_handle_sim_action)
    toolbar = QToolBar()

    lbl = QLabel()

    benc_timer = QTimer(w)

    def _on_bench():
        global ticks
        lbl.setText(f'Frequency: {ticks} Hz')
        ticks = 0

    benc_timer.timeout.connect(_on_bench)

    toolbar.addAction(action)
    toolbar.addSeparator()
    toolbar.addWidget(lbl)
    w.addToolBar(toolbar)

    w.setCentralWidget(ed)

    w.setWindowTitle(make_title())
    w.show()
    app.exec_()
                if index_coluna != 0:
                    if coluna == "": coluna = "3"
                    if index_coluna % 2 == 0:
                        somatorio += 5 - int(coluna)
                    else:
                        somatorio += int(coluna) - 1
    res = (somatorio / num_entrevistados) * 2.5
    return int(round(res, 0))


aplicacao = QApplication(sys.argv)

janela = QMainWindow()
# setGeometry(esquerda, topo, largura, altura)
janela.setGeometry(100, 50, 300, 250)
janela.setWindowTitle("Calculo de usabilidade")

label = QLabel(
    "Informe a nota que você acredita que \no teste de usabilidade irá resultar: ",
    janela)
label.move(20, 20)
label.resize(200, 40)

label_slider_0 = QLabel("0", janela)
label_slider_0.move(20, 60)
label_slider_0.resize(20, 20)

label_slider_100 = QLabel("100", janela)
label_slider_100.move(260, 60)
label_slider_100.resize(20, 20)
Esempio n. 29
0
    for data in info:
        wage = re.search(r"\d{4,}", data)
        if wage:
            if int(wage.group()) <= 20000:
                name_list += data[0:4] + '\n'
        else:
            print('格式有误')
    QMessageBox.about(window, '统计结果', '薪资20000以下的有\n' f'{name_list}')


if __name__ == '__main__':
    app = QApplication(sys.argv)

    window = QMainWindow()
    window.resize(600, 500)
    window.setWindowTitle('薪资统筹')

    # 输入面板
    textEdit = QPlainTextEdit(window)
    textEdit.setPlaceholderText('请输入薪资表')
    textEdit.move(100, 50)
    textEdit.resize(400, 300)

    # 按钮
    button = QPushButton('统计', window)
    button.move(250, 400)
    button.clicked.connect(handler_click)

    # 显示和退出
    window.show()
    sys.exit(app.exec_())
Esempio n. 30
0
from PySide2.QtWidgets import QApplication, QMainWindow, QPushButton, QPlainTextEdit

app = QApplication([])

window = QMainWindow()
window.resize(500, 400)
window.move(300, 310)  # 显示在显示器的什么位置 300 从左到右 310 从上到下
window.setWindowTitle('薪资统计')

textEdit = QPlainTextEdit(window)
textEdit.setPlaceholderText("请输入薪资表")
textEdit.move(10, 25)
textEdit.resize(300, 350)

button = QPushButton('统计', window)
button.move(380, 80)

window.show()

app.exec_()