Ejemplo n.º 1
0
 def closeEvent(self, event):
     database = QtSql.QSqlDatabase.addDatabase('QSQLITE')
     database.setDatabaseName('data.db')
     database.close()
     self._client.stop()
     asyncio.get_event_loop().stop()
     asyncio.get_event_loop().close()
     QApplication.instance().closingDown()
     os._exit(0)
Ejemplo n.º 2
0
def get_application():
    """Get the singleton QApplication"""
    from quamash import QApplication
    if not len(_application_):
        application = QApplication.instance()
        if not application:
            import sys
            application = QApplication(sys.argv)
        _application_.append(application)
    return _application_[0]
Ejemplo n.º 3
0
 def changeSkin(self):
     from PyQt5.Qt import QApplication
     if self.origan_skin:
         skin = "skin2.qss"
         self.origan_skin = False
     else:
         skin = "skin.qss"
         self.origan_skin = True
     QApplication.instance().setStyleSheet(
         utils.StyleReader.readQssFromFile(skin))
Ejemplo n.º 4
0
def get_application():
    """Get the singleton QApplication"""
    from quamash import QApplication
    if not len(_application_):
        application = QApplication.instance()
        if not application:
            import sys
            application = QApplication(sys.argv)
        application.setQuitOnLastWindowClosed(False)
        _application_.append(application)
    return _application_[0]
Ejemplo n.º 5
0
def get_application():
    """Get the singleton QApplication"""
    from quamash import QApplication
    if not len(_application_):
        application = QApplication.instance()
        if not application:
            import sys
            application = QApplication(sys.argv)
        application.setQuitOnLastWindowClosed(False)
        _application_.append(application)
    return _application_[0]
Ejemplo n.º 6
0
def get_application():
    """Get the singleton QApplication"""
    from quamash import QApplication
    if not len(_application_):
        application = QApplication.instance()
        if not application:
            import sys
            application = QApplication(sys.argv)
        _application_.append( application )
    return _application_[0]
Ejemplo n.º 7
0
 def exec_test():
     yield from asyncio.sleep(1)
     QTest.mouseClick(certification_dialog.radio_pubkey, Qt.LeftButton)
     QTest.keyClicks(certification_dialog.edit_pubkey, "FADxcH5LmXGmGFgdixSes6nWnC4Vb4pRUBYT81zQRhjn")
     QTest.mouseClick(certification_dialog.button_box.button(QDialogButtonBox.Ok), Qt.LeftButton)
     yield from asyncio.sleep(1)
     topWidgets = QApplication.topLevelWidgets()
     for w in topWidgets:
         if type(w) is QMessageBox:
             QTest.keyClick(w, Qt.Key_Enter)
Ejemplo n.º 8
0
 def exec_test():
     yield from asyncio.sleep(1)
     self.account.wallets[0].caches[self.community.currency].available_sources = yield from self.wallet.sources(self.community)
     QTest.mouseClick(transfer_dialog.radio_pubkey, Qt.LeftButton)
     QTest.keyClicks(transfer_dialog.edit_pubkey, "FADxcH5LmXGmGFgdixSes6nWnC4Vb4pRUBYT81zQRhjn")
     transfer_dialog.spinbox_amount.setValue(10)
     QTest.mouseClick(transfer_dialog.button_box.button(QDialogButtonBox.Ok), Qt.LeftButton)
     yield from asyncio.sleep(1)
     topWidgets = QApplication.topLevelWidgets()
     for w in topWidgets:
         if type(w) is QMessageBox:
             QTest.keyClick(w, Qt.Key_Enter)
Ejemplo n.º 9
0
def main():
    app = QApplication(sys.argv)
    loop = QEventLoop(app)
    # loop.set_debug(True)
    asyncio.set_event_loop(loop)  # NEW must set the event loop

    lobby = QuickLobby(loop)
    loop.add_signal_handler(signal.SIGINT, lobby.shutdown, None)

    for window in lobby.rootObjects():
        window.show()

    with loop:
        loop.run_forever()
Ejemplo n.º 10
0
 def iniWin(self):
     self.origan_skin = True
     self.initArrow()
     self.friends_data = {}
     self.rooms_data = {}
     self.templist = {}
     self.history_datalist = {}
     desktop = QApplication.desktop()
     x = (desktop.width() - self.frameSize().width()) - 20
     y = (desktop.height() - self.frameSize().height()) // 2 - 50
     self.move(x, y)
     self.setWindowFlag(QtCore.Qt.FramelessWindowHint)
     self.setDuration(1000)
     self.connectToListener()
Ejemplo n.º 11
0
def main():
    logging.basicConfig(level=logging.INFO)
    app = QApplication([])
    loop = QEventLoop(app)
    asyncio.set_event_loop(loop)
    atexit.register(loop.close)

    win = MainWindow(app, None)

    container = QtWidgets.QWidget(win)
    layout = QtWidgets.QGridLayout()
    container.setLayout(layout)

    scanner = ScanWidget()
    scanner.setFocusPolicy(QtCore.Qt.StrongFocus)
    layout.addWidget(scanner, 0, 0, -1, 1)

    spinbox = ScientificSpinBox()
    spinbox.setFocusPolicy(QtCore.Qt.StrongFocus)
    spinbox.setStyleSheet("QDoubleSpinBox {color:blue}")
    spinbox.setMinimumSize(110, 0)
    layout.addWidget(spinbox, 0, 1)
    scanner.startChanged.connect(spinbox.setValue)
    spinbox.valueChanged.connect(scanner.setStart)
    scanner.setStart(-100)

    spinbox = QtWidgets.QSpinBox()
    spinbox.setFocusPolicy(QtCore.Qt.StrongFocus)
    spinbox.setMinimum(1)
    spinbox.setMaximum((1 << 31) - 1)
    layout.addWidget(spinbox, 1, 1)
    scanner.numChanged.connect(spinbox.setValue)
    spinbox.valueChanged.connect(scanner.setNum)
    scanner.setNum(11)

    spinbox = ScientificSpinBox()
    spinbox.setFocusPolicy(QtCore.Qt.StrongFocus)
    spinbox.setStyleSheet("QDoubleSpinBox {color:red}")
    layout.addWidget(spinbox, 2, 1)
    scanner.stopChanged.connect(spinbox.setValue)
    spinbox.valueChanged.connect(scanner.setStop)
    scanner.setStop(200)

    win.setCentralWidget(container)
    win.show()
    loop.run_until_complete(win.exit_request.wait())
Ejemplo n.º 12
0
 def load(cls):
     app = QApplication.instance()
     theme = LocalStorage.themeGet()
     skin_qss = '{qss_path}/theme/{theme}/skin.qss'.format(
         qss_path=Config().qss_path, theme=theme)
     style_qss = '{qss_path}/theme/{theme}/style.qss'.format(
         qss_path=Config().qss_path, theme=theme)
     qss_string = ''
     # 0).资源文件
     skin_rc = importlib.import_module(
         'resources.qss.theme.{theme}.skin_rc'.format(theme=theme))
     style_rc = importlib.import_module(
         'resources.qss.theme.{theme}.style_rc'.format(theme=theme))
     skin_rc.qInitResources()
     style_rc.qInitResources()
     # 1).自带皮肤
     app.setStyle('Fusion')
     # 2).调色板
     palette_module = importlib.import_module(
         'resources.qss.theme.{theme}.palette'.format(theme=theme))
     cls.palette = getattr(palette_module, 'Palette')
     cls.palette.render(app)
     # 3).通用样式表
     with open(COMMON_STYLE) as stylesheet:
         qss_string += stylesheet.read()
     # 4).皮肤样式表
     with open(skin_qss) as stylesheet:
         qss_string += stylesheet.read()
     # 5).界面样式表
     with open(style_qss, encoding='utf-8') as stylesheet:
         qss_string += stylesheet.read()
     # 6).设置样式
     app.setStyleSheet(qss_string)
     # 7).抗锯齿
     font = app.font()
     font.setStyleStrategy(QFont.PreferAntialias)
     app.setFont(font)
Ejemplo n.º 13
0
def application():
    from quamash import QApplication
    return QApplication([])
Ejemplo n.º 14
0
    import sys
    import qdarkstyle
    import cgitb
    from quamash import QEventLoop, QApplication
    import asyncio

    #修改logging.config源码以utf-8读取文件
    logging.config.fileConfig("logger/logging.conf")
    # 输出日志到控制台和文件,获取的是root对应的logger
    #logger = logging.getLogger()

    # import os
    # curPath = os.path.abspath(os.path.dirname(__file__))
    # rootPath = curPath[:curPath.rfind("Toolbox") + len("Toolbox")]  # Toolbox,也就是项目的根路径
    # os.chdir(rootPath)

    cgitb.enable(logdir=r'logger/cgitb', format='text')
    app = QApplication(sys.argv)
    style.setScrollBarStyle(app)
    #app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
    # 将Qt事件循环写到asyncio事件循环里。
    # QEventLoop不是Qt原生事件循环,
    # 是被asyncio重写的事件循环。
    loop = QEventLoop(app)
    asyncio.set_event_loop(loop)
    with loop:
        Form = MainWindow()
        Form.resize(1200, 800)
        #Form.resize(800, 600)
        Form.show()
        loop.run_forever()
Ejemplo n.º 15
0
                "select * from {tableName} limit {offset},{pageSize}".format(
                    **queryParam))
            header = [item[0] for item in cursor.description]
            datas = cursor.fetchall()

        table.setColumnCount(len(header))
        # 注意必须在初始化行列之后进行,否则,没有效果
        table.setHorizontalHeaderLabels(header)

        table.setRowCount(len(datas))
        for i, row in enumerate(datas):
            for j, data in enumerate(row, start=0):

                item = QTableWidgetItem(str(data))
                table.setItem(i, j, item)


if __name__ == '__main__':
    import os

    os.chdir("../..")
    print(os.getcwd())
    app = QApplication(sys.argv)
    # 创建窗口
    example = DbTableWidget()
    example.resize(1000, 800)
    # 显示窗口
    example.show()
    example.loadTable()
    sys.exit(app.exec_())