示例#1
0
    def __init__(self, *args, **kwargs):
        QDialog.__init__(self, *args, **kwargs)
        self.setLayout(QVBoxLayout())
        btn = QPushButton("Submit", self)
        btn.clicked.connect(self.submit)
        self.spinner = QtWaitingSpinner(self)

        self.layout().addWidget(btn)
        self.layout().addWidget(self.spinner)
示例#2
0
 def __init__(self, main_table):
     super().__init__()
     self.setWindowTitle("Client Connection")
     self.setWindowIcon(QIcon("src/icons/return.png"))
     self.setGeometry(650, 300, 250, 250)
     self.setFixedSize(self.size())
     self.spinner = QtWaitingSpinner()
     self.main_table = main_table
     self.ui()
     self.show()
示例#3
0
class Dialog(QDialog):
    def __init__(self, *args, **kwargs):
        QDialog.__init__(self, *args, **kwargs)
        self.setLayout(QVBoxLayout())
        btn = QPushButton("Submit", self)
        btn.clicked.connect(self.submit)
        self.spinner = QtWaitingSpinner(self)

        self.layout().addWidget(btn)
        self.layout().addWidget(self.spinner)

    def submit(self):
        self.spinner.start()
        runnable = RequestRunnable("https://api.github.com/some/endpoint",
                                   {'some': 'data'}, self)
        QThreadPool.globalInstance().start(runnable)

    @pyqtSlot(str)
    def setData(self, data):
        print(data)
        self.spinner.stop()
        self.adjustSize()
示例#4
0
    def initGUI(self):
        self.resize(483, 579)
        fg = self.frameGeometry()
        center = QDesktopWidget().availableGeometry().center()
        fg.moveCenter(center)
        self.move(fg.topLeft())
        self.setWindowTitle('CReF2')

        self.installBtn = QPushButton('Install', self)
        self.installBtn.move(202, 545)
        self.installBtn.clicked.connect(self.installBtnCB)

        self.logEditor = QTextEdit(self)
        self.logEditor.setReadOnly(True)
        self.logEditor.resize(463, 206)
        self.logEditor.move(10, 330)

        logo = QLabel(self)
        pm = QPixmap('logo.png')
        logo.setPixmap(pm)
        logo.move(10, 10)

        self.loading = QtWaitingSpinner(self, False, False)
        self.loading.setRoundness(70.0)
        self.loading.setMinimumTrailOpacity(15.0)
        self.loading.setTrailFadePercentage(70.0)
        self.loading.setNumberOfLines(30)
        self.loading.setLineLength(2)
        self.loading.setLineWidth(5)
        self.loading.setInnerRadius(10)
        self.loading.setRevolutionsPerSecond(1)
        self.loading.setColor(QColor(42, 161, 95))
        self.loading.move(self.width() / 2 - self.loading.width() / 2, 545)
        self.loading.setVisible(False)

        self.show()
示例#5
0
class ConnectingUpdating(QWidget):
    def __init__(self, main_table):
        super().__init__()
        self.setWindowTitle("Client Connection")
        self.setWindowIcon(QIcon("src/icons/return.png"))
        self.setGeometry(650, 300, 250, 250)
        self.setFixedSize(self.size())
        self.spinner = QtWaitingSpinner()
        self.main_table = main_table
        self.ui()
        self.show()

    def ui(self):
        self.widgets()
        self.layouts()

    def widgets(self):
        self.ipAddressInputField = QLineEdit()
        self.ipAddressInputField.setText("192.168.1.11")

        self.ipAddressInputField.setStyleSheet(
            'QLineEdit{border-color: #A3C1DA; font-size: 15pt; font: Liberation Mono}'
        )
        self.portInputField = QLineEdit()
        self.portInputField.setText("9999")
        self.portInputField.setStyleSheet(
            'QLineEdit{border-color: #A3C1DA; font-size: 15pt; font: Liberation Mono}'
        )
        self.submitBtn = QPushButton("Submit")
        self.submitBtn.setStyleSheet(
            'QPushButton{background-color:#9bc9ff;border-style:solid;border-width:2px;border-radius:10px;border-color:beige;font:14px;padding:6px;min-width:6em;font-family:Liberation Mono;}'
        )

        self.submitBtn.clicked.connect(self.submit)

    def layouts(self):
        self.mainLayout = QVBoxLayout()
        self.bottomLayout = QFormLayout()
        self.topFrameLayout = QFrame()
        self.topFrameLayout.setStyleSheet(style.sell_product_top_frame())
        self.bottomFrameLayout = QFrame()
        self.bottomFrameLayout.setStyleSheet(style.sell_product_bottom_frame())
        # Add widgets
        self.bottomLayout.addRow(QLabel("IP: "), self.ipAddressInputField)
        self.bottomLayout.addRow(QLabel("Port: "), self.portInputField)
        self.bottomLayout.addRow(QLabel(""), self.submitBtn)
        self.bottomFrameLayout.setLayout(self.bottomLayout)
        self.mainLayout.addWidget(self.bottomFrameLayout)
        self.mainLayout.addWidget(self.spinner)
        self.setLayout(self.mainLayout)

    def submit(self):
        if self.portInputField.text() == "" or self.ipAddressInputField.text(
        ) == "":
            QMessageBox.warning(self, "Warning!", "Fields can not be empty!")
        else:
            self.spinner.start()
            runnable = RequestRunnable(self)

            QThreadPool.globalInstance().start(runnable)

    @pyqtSlot(str)
    def setData(self, data):
        # print(data)
        self.spinner.stop()
        self.adjustSize()
        QMessageBox.information(self, "Success!", "Updated succesfully!")
        self.main_table.update_to_DB.setIcon(QIcon('src/icons/update.png'))
        self.main_table.update_to_DB.setText("Updated")
        with open('database_backup/state.txt', 'w') as f:
            f.write('some')
        self.close()

    @pyqtSlot(str)
    def setData_two(self, data):
        # print(data)
        self.spinner.stop()
        self.adjustSize()
        QMessageBox.warning(self, "Warning!", "Server isnt working!")
        self.close()
示例#6
0
class GUI(QWidget):
    def __init__(self):
        super().__init__()
        exec('sudo echo')
        self.initGUI()
        self.fsize = 0
        self.tsize = 0

    def addLog(self, msg, overwrite):
        if overwrite:
            t = self.logEditor.toPlainText()
            t = t[:t.rfind(' ')] + ' ' + msg
            self.logEditor.setPlainText(t)
        else:
            self.logEditor.append(msg)
        self.logEditor.verticalScrollBar().setValue(
            self.logEditor.verticalScrollBar().maximum())

    def stop(self):
        self.loading.stop()
        self.loading.setVisible(False)

    def installBtnCB(self):
        self.install = InstallationThread()
        self.install.start()
        self.install.logSignal.connect(self.addLog)
        self.install.stopSignal.connect(self.stop)
        self.installBtn.setVisible(False)
        self.loading.setVisible(True)
        self.loading.start()

    def initGUI(self):
        self.resize(483, 579)
        fg = self.frameGeometry()
        center = QDesktopWidget().availableGeometry().center()
        fg.moveCenter(center)
        self.move(fg.topLeft())
        self.setWindowTitle('CReF2')

        self.installBtn = QPushButton('Install', self)
        self.installBtn.move(202, 545)
        self.installBtn.clicked.connect(self.installBtnCB)

        self.logEditor = QTextEdit(self)
        self.logEditor.setReadOnly(True)
        self.logEditor.resize(463, 206)
        self.logEditor.move(10, 330)

        logo = QLabel(self)
        pm = QPixmap('logo.png')
        logo.setPixmap(pm)
        logo.move(10, 10)

        self.loading = QtWaitingSpinner(self, False, False)
        self.loading.setRoundness(70.0)
        self.loading.setMinimumTrailOpacity(15.0)
        self.loading.setTrailFadePercentage(70.0)
        self.loading.setNumberOfLines(30)
        self.loading.setLineLength(2)
        self.loading.setLineWidth(5)
        self.loading.setInnerRadius(10)
        self.loading.setRevolutionsPerSecond(1)
        self.loading.setColor(QColor(42, 161, 95))
        self.loading.move(self.width() / 2 - self.loading.width() / 2, 545)
        self.loading.setVisible(False)

        self.show()