Esempio n. 1
0
def codeFile(qtbot, rgbValue, bits, decodedImage, txtFile, txtResult,
             filesize):
    window = Window()
    qtbot.addWidget(window)
    window.imagename.setText("18.jpg")
    index = window.RGBcomboBox.findText(rgbValue, Qt.MatchFixedString)
    window.RGBcomboBox.setCurrentIndex(index)
    index1 = window.bitsComboBox.findText(bits, Qt.MatchFixedString)
    window.bitsComboBox.setCurrentIndex(index1)
    window.decodedname.setText(decodedImage)
    window.radioButtonFile.setChecked(True)
    window.filePath.setText(txtFile)
    window.encodeFileName.setText(txtFile)
    qtbot.mouseClick(window.encode, Qt.LeftButton)
    #decoding
    window.imagename.setText(decodedImage)
    window.imagepath.setText(decodedImage)
    window.textLength.setValue(filesize)
    textLength = window.textLength.value()
    window.dradioButtonFile.setChecked(True)
    window.resultFileName.setText(txtResult)
    qtbot.mouseClick(window.decode, Qt.LeftButton)
    symbols = window.symbols.text()
    f = open(txtResult, "r")
    text = f.read()
    return text
Esempio n. 2
0
    def setUp(self):
        app = QApplication.instance()
        self.app = app or QApplication([])
        self.window = Window()

        # some useful shortcuts
        self.grid = self.window.main_grid
        self.gridvp = self.grid.viewport()
        self.tb = {
            k: self.window.toolbar.widgetForAction(obj) if isinstance(
                obj, QAction) else obj
            for k, obj in self.window.toolbar_controls.items()
        }

        self.window.show()
        # bring to foreground
        self.window.setWindowState((self.window.windowState()
                                    & ~Qt.WindowMinimized) | Qt.WindowActive)
        QTest.qWaitForWindowExposed(self.window)
Esempio n. 3
0
 def searchButton(self):
     global firmname
     if (self.lineEdit.text != ""):
         firmname = self.lineEdit.text()
     # for dir in dirs:
     #     file_name = dir.split('.')
     #     file_name=file_name[0].split('_')
     #     name.append(file_name)
     # namebool=False
     # for i in range(len(name)):
     #     if firmname in name[i]:
     #         name1=name[i][1]
     #         namebool=True
     # if namebool==False:
     #     name1=name[0][1]
     name1 = firmname
     print(name1)
     self.mainpage = QtWidgets.QMainWindow()
     self.ui = Window(name1)
     self.ui.show()
Esempio n. 4
0
    def test_inference(self):
        window = Window()
        window.image = Image.open("../test_data/graves_small.png")
        window.detect_fn = tf.saved_model.load("../ml/run9/saved_model")
        window.detect_gravestones()
        literal_pts = [(51.26742750406265, 142.48606532812119),
                       (51.26742750406265, 167.80804574489594),
                       (66.45438686013222, 167.80804574489594),
                       (66.45438686013222, 142.48606532812119),
                       (64.48887929320335, 77.39109113812447),
                       (64.48887929320335, 103.09586346149445),
                       (80.54988875985146, 103.09586346149445),
                       (80.54988875985146, 77.39109113812447),
                       (77.37902238965034, 14.716905392706394),
                       (77.37902238965034, 38.48378852009773),
                       (93.71639370918274, 38.48378852009773),
                       (93.71639370918274, 14.716905392706394)]

        # round because we are dealing with floats, 5 digits of precision is good enough
        # do it in code just to be surely consistent, this will never be the bottleneck if we are loading the
        # model in testing
        rounded_pts = {(round(pt[0], 5), round(pt[1], 5)) for pt in literal_pts}

        results = {(round(pt.x(), 5), round(pt.y(), 5))
                   for poly in window.viewer.selection_polygons for pt in poly.polygon_points}

        self.assertEqual(len(results), len(rounded_pts), "results had a different number of points than literal")

        for point in results:
            self.assertIn(point, rounded_pts)
            rounded_pts.remove(point)
Esempio n. 5
0
class TestInterface(unittest.TestCase):
    def setUp(self):
        self.win = Window()

    def testInit(self):
        self.assertIsInstance(self.win, (Window, PyQt5.QtWidgets.QMainWindow))
        self.assertTrue(self.win.partie.play)
        self.assertIsNone(self.win.posFrom)
        self.assertIsNone(self.win.posTo)

    def testTourHumain(self):
        self.win.posFrom = (5, 5)
        self.win.posTo = (4, 4)
        self.win.unTourHuman()
        self.assertIsNone(self.win.posFrom)
        self.assertIsNone(self.win.posTo)

    def testTourAi(self):
        self.win.partie.playerVSia(side=0)
        self.win.posFrom = (5, 5)
        self.win.posTo = (4, 4)
        self.win.unTourAi()
        self.assertIsNone(self.win.posFrom)
        self.assertIsNone(self.win.posTo)
Esempio n. 6
0
def codeText(qtbot, text, rgbValue, bits, decodedImage):
    window = Window()
    qtbot.addWidget(window)
    window.imagename.setText("18.jpg")
    window.textEdit.setText(text)
    text = window.textEdit.toPlainText()
    index = window.RGBcomboBox.findText(rgbValue, Qt.MatchFixedString)
    window.RGBcomboBox.setCurrentIndex(index)
    index1 = window.bitsComboBox.findText(bits, Qt.MatchFixedString)
    window.bitsComboBox.setCurrentIndex(index1)
    window.decodedname.setText(decodedImage)
    qtbot.mouseClick(window.encode, Qt.LeftButton)
    #decoding
    window.imagename.setText(decodedImage)
    window.imagepath.setText(decodedImage)
    window.textLength.setValue(len(text))
    textLength = window.textLength.value()
    qtbot.mouseClick(window.decode, Qt.LeftButton)
    decodedText = window.result.toPlainText()
    return decodedText
Esempio n. 7
0
        super(Login, self).__init__(parent)
        self.textName = QtGui.QLineEdit(self)
        self.textPass = QtGui.QLineEdit(self)
        self.buttonLogin = QtGui.QPushButton('Login', self)
        self.buttonLogin.clicked.connect(self.handleLogin)
        layout = QtGui.QVBoxLayout(self)
        layout.addWidget(self.textName)
        layout.addWidget(self.textPass)
        layout.addWidget(self.buttonLogin)

    def handleLogin(self):
        if (self.textName.text() == 'foo' and self.textPass.text() == 'bar'):
            self.accept()
        else:
            QtGui.QMessageBox.warning(self, 'Error', 'Bad user or password')


if __name__ == '__main__':

    import sys

    db_name = 'zzp_project'
    db = DatabaseClass(db_name)
    app = QtGui.QApplication(sys.argv)
    login = Login()

    if login.exec_() == QtGui.QDialog.Accepted:
        ex = Window()
        ex.show()
        x = app.exec_()
        sys.exit(x)
Esempio n. 8
0
from main import Window

start = Window()
Esempio n. 9
0
class SpreadsheetAppTestCase(unittest.TestCase):
    def setUp(self):
        app = QApplication.instance()
        self.app = app or QApplication([])
        self.window = Window()

        # some useful shortcuts
        self.grid = self.window.main_grid
        self.gridvp = self.grid.viewport()
        self.tb = {
            k: self.window.toolbar.widgetForAction(obj) if isinstance(
                obj, QAction) else obj
            for k, obj in self.window.toolbar_controls.items()
        }

        self.window.show()
        # bring to foreground
        self.window.setWindowState((self.window.windowState()
                                    & ~Qt.WindowMinimized) | Qt.WindowActive)
        QTest.qWaitForWindowExposed(self.window)

    def tearDown(self):
        # self.app.exec_()
        pass

    def cell_pos(self, row, col):
        """center x,y position of row, col"""
        grid = self.grid
        return QPoint(
            grid.columnViewportPosition(col) + grid.columnWidth(col) // 2,
            grid.rowViewportPosition(row) + grid.rowHeight(row) // 2,
        )

    def test_filldown(self):
        gridvp = self.grid.viewport()

        # date diff filldown
        QTest.mouseClick(gridvp, Qt.LeftButton, Qt.NoModifier,
                         self.cell_pos(0, 0))
        QTest.keyClicks(gridvp.focusWidget(), "2020-1-1\r")
        QTest.keyClicks(gridvp.focusWidget(), "2020-2-1\r")
        QTest.mouseClick(gridvp, Qt.LeftButton, Qt.NoModifier,
                         self.cell_pos(0, 0))
        QTest.mouseClick(gridvp, Qt.LeftButton, Qt.ShiftModifier,
                         self.cell_pos(5, 0))
        QTest.keyClick(gridvp, "d", Qt.ControlModifier)
        output = [self.grid.data[(r, 0)].value for r in range(0, 6)]
        expected = [
            datetime.date(2020, 1, 1),
            datetime.date(2020, 2, 1),
            datetime.date(2020, 3, 1),
            datetime.date(2020, 4, 1),
            datetime.date(2020, 5, 1),
            datetime.date(2020, 6, 1),
        ]
        self.assertListEqual(output, expected)

        # formula fill down
        QTest.mouseClick(gridvp, Qt.LeftButton, Qt.NoModifier,
                         self.cell_pos(0, 1))
        QTest.keyClicks(gridvp.focusWidget(), "5\r")
        QTest.keyClicks(gridvp.focusWidget(), "2*r[-1]c+3\r")
        QTest.mouseClick(gridvp, Qt.LeftButton, Qt.NoModifier,
                         self.cell_pos(1, 1))
        QTest.mouseClick(gridvp, Qt.LeftButton, Qt.ShiftModifier,
                         self.cell_pos(5, 1))
        QTest.keyClick(gridvp, "d", Qt.ControlModifier)
        output = [self.grid.data[(r, 1)].value for r in range(0, 6)]
        expected = [5, 13, 29, 61, 125, 253]
        self.assertListEqual(output, expected)

    def cell_typer(self, delay, row, col, text):
        """Enters text into cell with delay."""
        QTest.mouseClick(self.gridvp, Qt.LeftButton, Qt.NoModifier,
                         self.cell_pos(row, col))
        for ch in text:
            QTest.keyClicks(self.gridvp.focusWidget(), ch, Qt.NoModifier, -1)
            QTest.qWait(int(gauss(delay, 3)))

    def widget_typer(self, delay, widget, text):
        """Enters text into widget with delay."""
        for ch in text:
            QTest.keyClicks(widget, ch, Qt.NoModifier, -1)
            QTest.qWait(int(gauss(delay, 3)))

    def hover_click(self, delay, widget):
        QTest.mouseMove(widget)
        QTest.qWait(int(gauss(delay, 3)))
        QTest.mouseClick(widget, Qt.LeftButton)
        QTest.qWait(int(gauss(delay, 3)))

    def grid_select_range(self, rs, cs, rf, cf):
        QTest.mouseClick(self.gridvp, Qt.LeftButton, Qt.NoModifier,
                         self.cell_pos(rs, cs))
        QTest.mouseClick(self.gridvp, Qt.LeftButton, Qt.ShiftModifier,
                         self.cell_pos(rf, cf))

    @unittest.skip("For demo generation only")
    def test_demo(self):
        QTest.qWait(5000)

        delay = 50

        cell_typer = partial(self.cell_typer, delay)
        widget_typer = partial(self.widget_typer, delay)
        hover_click = partial(self.hover_click, 1000)

        QTest.keyClicks(
            self.window.text_editor,
            ("from random import uniform, gauss\r"
             "import pandas as pd\r"),
            Qt.NoModifier,
            delay,
        )

        hover_click(self.tb["button_calculate"])

        rs = 2
        rc = count(rs)
        cell_typer(next(rc), 0, '"Date"\r')
        cell_typer(next(rc), 0, "2020-1-1\r")
        cell_typer(next(rc), 0, "2020-2-1\r")

        rc = count(rs)
        cell_typer(next(rc), 1, '"Uniform"\r')
        cell_typer(next(rc), 1, "uniform(0,1)\r")

        rc = count(rs)
        cell_typer(next(rc), 2, '"Gauss"\r')
        cell_typer(next(rc), 2, "gauss(0,1)\r")

        # fill down
        self.grid_select_range(rs + 1, 0, rs + 9, 2)
        QTest.keyClick(self.gridvp, "d", Qt.ControlModifier, delay)

        # format
        self.grid_select_range(rs + 1, 1, rs + 9, 2)
        widget_typer(self.tb["textfield_format"], ".4f\r")

        # add pandas objects
        cell_typer(
            0,
            4,
            f'pd.DataFrame(r{rs+2}c1:r{rs+10}c3, columns=r{rs+1}c1:r{rs+1}c3[0]).set_index("Date")\r',
        )
        cell_typer(1, 4, f"r[-1]c.plot()\r")
        hover_click(self.tb["button_resize_all"])

        # invalidate
        self.grid_select_range(rs + 1, 1, rs + 9, 2)
        for _ in range(3):
            hover_click(self.tb["button_invalidate"])

        # type something into console
        widget_typer(self.window.console_panel.input, "dir()\r")

        # add some code
        QTest.keyClicks(
            self.window.text_editor,
            ("\r\r"
             "def tick():\r"
             "\tfor r in range(3, 12):\r"
             "\t\tfor c in range(1, 3):\r"
             "\t\t\tGRID.data[(r, c)].func.invalidate()\r"
             "\tGRID.calculate()\r"
             "\r\r"),
            Qt.NoModifier,
            delay,
        )
        hover_click(self.tb["button_calculate"])

        # test in console
        widget_typer(self.window.console_panel.input, "tick()\r")
        widget_typer(self.window.console_panel.input, "tick()\r")

        # add timer
        # add some code
        QTest.keyClicks(
            self.window.text_editor,
            ("# start a timer\r"
             "from PyQt5.QtCore import QTimer\r"
             "timer = QTimer()\r"
             "timer.timeout.connect(tick)\r"
             "timer.start(1000)\r"),
            Qt.NoModifier,
            delay,
        )
        hover_click(self.tb["button_calculate"])
Esempio n. 10
0
 def setUp(self):
     self.win = Window()
Esempio n. 11
0
class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.setFixedSize(600, 350)  #设置窗口长宽
        #        Form.resize(500, 277)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        Form.setFont(font)
        Form.setStyleSheet("")
        #输入框
        self.lineEdit = QtWidgets.QLineEdit(Form)
        self.lineEdit.setGeometry(QtCore.QRect(130, 210, 300, 40))
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                           QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.lineEdit.sizePolicy().hasHeightForWidth())
        self.lineEdit.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        self.lineEdit.setFont(font)
        self.lineEdit.setText("")
        self.lineEdit.setReadOnly(False)
        self.lineEdit.setObjectName("lineEdit")
        #查找界面按钮

        self.pushButton = Pushbtn_diy(Form)
        self.pushButton.setGeometry(QtCore.QRect(440, 210, 61, 40))
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        self.pushButton.setFont(font)
        self.pushButton.setStyleSheet(
            "background-color: rgb(7,188,252);border-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(255, 255, 255, 255));border-radius: 4px;"
        )
        self.pushButton.setObjectName("pushButton")
        #快速锁定财富洼地, 你的价值投资军火库
        self.label = QtWidgets.QLabel(Form)
        self.label.setGeometry(QtCore.QRect(90, 130, 500, 40))

        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        font.setPointSize(12)
        self.label.setFont(font)
        self.label.setObjectName("label")

        #一眼看懂公司财报
        self.label_2 = QtWidgets.QLabel(Form)
        self.label_2.setGeometry(QtCore.QRect(150, 80, 400, 43))
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        font.setPointSize(18)
        font.setBold(True)
        font.setWeight(75)
        self.label_2.setFont(font)
        self.label_2.setObjectName("label_2")

        #查找界面背景
        self.graphicsView = QtWidgets.QGraphicsView(Form)
        self.graphicsView.setGeometry(QtCore.QRect(0, 0, 600, 350))
        self.graphicsView.setStyleSheet(
            "background-image: url(img/start.png);")
        self.graphicsView.setObjectName("graphicsView")
        #输入公司名/股票代码
        self.label_3 = QtWidgets.QLabel(Form)
        self.label_3.setGeometry(QtCore.QRect(133, 219, 200, 20))
        self.label_3.setStyleSheet("color: rgb(202, 202, 202);")
        self.label_3.setObjectName("label_3")
        #退出按钮
        self.pushButton_2 = QtWidgets.QPushButton(Form)
        self.pushButton_2.setGeometry(QtCore.QRect(560, 0, 40, 40))
        # self.pushButton_2.setStyleSheet("background-image: url(:/image/exit.png);")
        self.pushButton_2.setFlat(True)
        self.pushButton_2.setIcon(QIcon("img\close.png"))
        self.pushButton_2.setText("")
        self.pushButton_2.setObjectName("pushButton_2")
        self.pushButton_2.clicked.connect(QCoreApplication.instance().quit)

        self.pushButton.clicked.connect(self.searchButton)
        self.graphicsView.raise_()
        self.pushButton.raise_()
        self.lineEdit.raise_()
        self.lineEdit.textChanged.connect(self.masklabel3)
        self.label.raise_()
        self.label_2.raise_()
        self.label_3.raise_()
        self.pushButton_2.raise_()

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

    '''查找界面设置模块'''

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowFlags(Qt.FramelessWindowHint)
        Form.setWindowTitle(_translate("Form", "小财报"))
        self.pushButton.setText(_translate("Form", "搜索"))
        self.label.setText(_translate("Form", "快速锁定财富洼地, 你的价值投资军火库"))
        self.label_2.setText(_translate("Form", "一眼看懂公司财报"))
        self.label_3.setText(_translate("Form", "输入公司名/股票代码"))

    def masklabel3(self, Form):
        self.label_3.setText(None)

    def searchButton(self):
        global firmname
        if (self.lineEdit.text != ""):
            firmname = self.lineEdit.text()
        # for dir in dirs:
        #     file_name = dir.split('.')
        #     file_name=file_name[0].split('_')
        #     name.append(file_name)
        # namebool=False
        # for i in range(len(name)):
        #     if firmname in name[i]:
        #         name1=name[i][1]
        #         namebool=True
        # if namebool==False:
        #     name1=name[0][1]
        name1 = firmname
        print(name1)
        self.mainpage = QtWidgets.QMainWindow()
        self.ui = Window(name1)
        self.ui.show()
Esempio n. 12
0
import os
os.environ["PATH"] += os.pathsep if os.environ["PATH"][-1] != os.pathsep else ""
os.environ["PATH"] += os.pathsep.join([os.getcwd()])

import sys, qdarkstyle
from fbs_runtime.application_context.PyQt5 import ApplicationContext

from main import Window

if __name__ == "__main__":
	app = ApplicationContext()
	# app.app.setStyle("fusion")
	# app.app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
	# app.PyQt5.QtWidgets.QStyleFactory.keys()

	window = Window(app)
	window.show()

	sys.exit(app.app.exec_())