class DialogLogin(QDialog, Ui_DialogLogin): """ Class documentation goes here. """ def __init__(self, parent=None): """ Constructors @param parent reference to the parent widget @type QWidget """ QDialog.__init__(self, parent) self.setupUi(self) self.lineEdit_password.setEchoMode(QLineEdit.Password) self.main_window = None @pyqtSignature("") def on_pushButton_login_clicked(self): """ Slot documentation goes here. """ username = unicode(self.lineEdit_user.text()) password = unicode(self.lineEdit_password.text()) # 创建SQL客户端。保证全局可用。 global sql_client sql_client = globalvar._init(username, password) if sql_client.check_user(): print "登陆成功" from main import MainWindow self.main_window = MainWindow() self.main_window.show() else: print "用户名或密码错误!"
class MainWindowTest(unittest.TestCase): def setUp(self): self.form = MainWindow() def test_scrape_process(self): urls = [ 'http://www.pythonic.me', 'http://www.onet.pl', 'http://www.wp.pl', 'http://www.allegro.pl', 'http://www.wykop.pl' ] urls_number = len(urls) self.form.show() QTest.qWaitForWindowShown(self.form) self.form.load_urls(urls) self.assertIn('urls in queue', self.form.statusBar().currentMessage()) self.assertEqual(urls_number, len(self.form.scraper_dialog.urls)) QTest.mouseClick(self.form.open_scraper_button, Qt.LeftButton) QTest.qWaitForWindowShown(self.form.scraper_dialog) QTest.mouseClick(self.form.scraper_dialog.start_button, Qt.LeftButton) while self.form.scraper_dialog.scraper_thread.isRunning(): QApplication.processEvents() self.assertIn( 'keep-alive', self.form.scraper_dialog.result_plain_text_edit.toPlainText())
def main(): app = QtGui.QApplication(sys.argv) mainWindow = MainWindow() mainWindow.show() return app.exec_()
def main(): app = QtGui.QApplication(sys.argv) ex = MainWindow() ex.show() sys.exit(app.exec_()) return
class StartWindow(QtWidgets.QDialog): def __init__(self, parent=None): super(StartWindow, self).__init__() self.ui = startWnd.Ui_StartForm() self.ui.setupUi(self) self.mw = MainWindow() self.mw.set_start_wnd(self) self.ui.pbStart.clicked.connect(self.on_start) self.ui.pbExit.clicked.connect(self.on_close_clicked) def on_close_clicked(self): QtWidgets.QApplication.quit() def on_start(self): diff = int count = int try: diff = int(self.ui.edDiff.text()) except: QtWidgets.QMessageBox.warning( self, 'Error', 'Неверные символы в поле сложность! Необходимо число!', QtWidgets.QMessageBox.Yes) self.ui.edDiff.setText("1") return try: count = int(self.ui.edCount.text()) except: QtWidgets.QMessageBox.warning( self, 'Error', 'Неверные символы в поле ходов! Необходимо число!', QtWidgets.QMessageBox.Yes) self.ui.edCount.setText("1") return if diff < 1: QtWidgets.QMessageBox.warning( self, 'Error', 'Сложность должны быть больше единицы', QtWidgets.QMessageBox.Yes) return if count < 1: QtWidgets.QMessageBox.warning( self, 'Error', 'Количество ходов должно быть больше единицы', QtWidgets.QMessageBox.Yes) return self.mw.checker.set_params(diff, count) self.mw.start_test() self.hide() self.mw.show()
class StartWindow(QtWidgets.QDialog): def __init__(self, parent=None): super(StartWindow, self).__init__() self.ui = startWnd.Ui_StartForm() self.ui.setupUi(self) self.mw = MainWindow() self.mw.set_start_wnd(self) self.ui.pbStart.clicked.connect(self.on_start) self.ui.pbExit.clicked.connect(self.on_close_clicked) def on_close_clicked(self): QtWidgets.QApplication.quit() def on_start(self): diff = int count = int try: diff = int( self.ui.edDiff.text() ) except: QtWidgets.QMessageBox.warning(self, 'Error', 'Неверные символы в поле сложность! Необходимо число!', QtWidgets.QMessageBox.Yes) self.ui.edDiff.setText("1") return try: count = int( self.ui.edCount.text() ) except: QtWidgets.QMessageBox.warning(self, 'Error', 'Неверные символы в поле ходов! Необходимо число!', QtWidgets.QMessageBox.Yes) self.ui.edCount.setText("1") return if diff < 1: QtWidgets.QMessageBox.warning(self, 'Error', 'Сложность должны быть больше единицы', QtWidgets.QMessageBox.Yes) return if count < 1: QtWidgets.QMessageBox.warning(self, 'Error', 'Количество ходов должно быть больше единицы', QtWidgets.QMessageBox.Yes) return self.mw.checker.set_params(diff, count) self.mw.start_test() self.hide() self.mw.show()
class WelcomWindow(QMainWindow, Ui_WelcomWindow): panel = None def __init__(self, parent=None): """ Constructor @param parent reference to the parent widget @type QWidget """ super(WelcomWindow, self).__init__(parent) self.setupUi(self) @pyqtSlot() def on_pushButton_clicked(self): self.panel = MainWindow() self.panel.show() self.close() return
class Login(QMainWindow, Ui_Login): def __init__(self, parent=None): super(Login, self).__init__(parent) self.setupUi(self) self.pwd_lineEdit.setEchoMode(QtGui.QLineEdit.Password) self.login_pushButton.clicked.connect(self.doLogin) self.exit_pushButton.clicked.connect(self.doExit) def doExit(self): print("called doExit") self.close() def doLogin(self): print("called doLogin") usr=unicode(self.usr_lineEdit.text()) pwd=unicode(self.pwd_lineEdit.text()) user=User.get_by(username=usr) if user: if user.password==pwd: self.showMain() else: loginMsgBox = QMessageBox() loginMsgBox.setText(u"密码错误." ) loginMsgBox.exec_() else: loginMsgBox = QMessageBox() loginMsgBox.setText(u"用户不存在." ) loginMsgBox.exec_() def showMain(self): self.main = MainWindow() #self.main.showFullScreen() self.main.show() self.close()
def test_connecting_disconnecting_from_gui(qtbot): mainWin = MainWindow() mainWin.show() qtbot.addWidget(mainWin) qtbot.wait(2000) if_select = mainWin.interfaceSelection qtbot.mouseClick(if_select, Qt.LeftButton) qtbot.wait(100) # check if we see the simulator running and can potentially connect to it assert (if_select.findText("cb_sim", Qt.MatchContains) != -1) num_connections = 10 while num_connections > 0: if_select.setCurrentIndex( if_select.findText("cb_sim", Qt.MatchContains)) qtbot.wait(500) assert (mainWin.nodeIdLineEdit.text() == "cb_sim") if_select.setCurrentIndex(if_select.findText("None", Qt.MatchContains)) qtbot.wait(1000) assert (if_select.findText("cb_sim", Qt.MatchContains) != -1) num_connections -= 1
#!/usr/bin/python import sys from PySide import QtGui from main import MainWindow if __name__ == "__main__": app = QtGui.QApplication(sys.argv) myapp = MainWindow() myapp.show() sys.exit(app.exec_())
# -*- coding: utf-8 -*- import sys import atexit from PyQt4 import QtGui from PyQt4.QtSql import QSqlDatabase from main import MainWindow @atexit.register def appExit(): pass def createConnection(): db=QSqlDatabase.addDatabase("QSQLITE") db.setDatabaseName("sqlite.db3") return db.open() createConnection() app = QtGui.QApplication(sys.argv) app.addLibraryPath("qt4_plugins") main_window = MainWindow() main_window.showMaximized() main_window.show() sys.exit(app.exec_())
def main(argv): path = None first_arg = None second_arg = None config = None apath = None print("QT VERSION %s" % QT_VERSION_STR ) try: first_arg = argv[1] second_arg = argv[2] except IndexError: pass if first_arg is not None: if first_arg == "-c": config = True if second_arg is not None: path = second_arg else: path = first_arg try: #app = QApplication(argv) app = MyApp(argv) QCoreApplication.setOrganizationDomain('www.trickplay.com'); QCoreApplication.setOrganizationName('Trickplay'); QCoreApplication.setApplicationName('Trickplay Debugger'); QCoreApplication.setApplicationVersion('0.0.1'); s = QProcessEnvironment.systemEnvironment().toStringList() for item in s: k , v = str( item ).split( "=" , 1 ) if k == 'PWD': apath = v apath = os.path.join(apath, os.path.dirname(str(argv[0]))) main = MainWindow(app, apath) main.config = config main.show() main.raise_() wizard = Wizard() app.main = main path = wizard.start(path) if path: settings = QSettings() settings.setValue('path', path) app.setActiveWindow(main) main.start(path, wizard.filesToOpen()) main.show() sys.exit(app.exec_()) # TODO, better way of doing this for 'clean' exit... except KeyboardInterrupt: exit("Exited")
from PySide2.QtWidgets import QApplication from main import MainWindow if __name__ == '__main__': import sys app = QApplication(sys.argv) win = MainWindow() win.show() app.exec_()
def Run(): main = MainWindow() main.show() gtk.main()
import sys from PyQt5.QtWidgets import QApplication from main import MainWindow app = QApplication(sys.argv) Rocpy = MainWindow() Rocpy.show() sys.exit(app.exec_())
self.messageLabel.setGeometry(QRect(70, 15, 360, 50)) self.messageLabel.setWordWrap(True) self.messageLabel.setScaledContents(True) self.messageLabel.setStyleSheet( 'QLabel{background-color:rgb(255,0,79);color:white;font:9pt;padding-left:5px;padding-right:5px;}' ) # border-radius:5px # height = self.messageLabel.fontMetrics().boundingRect(self.messageLabel.text()).height() self.messageLabel.hide() def initSpinner(self): self.spinner = QtWaitingSpinner(self, centerOnParent=True, disableParentWhenSpinning=True) self.spinner.setNumberOfLines(15) # self.spinner.setColor(QColor(81, 4, 71)) self.spinner.setInnerRadius(20) # 设置内圆大小 self.spinner.setLineLength(15) # 设置线长 self.spinner.setLineWidth(5) # 设置线宽 self.spinner.setTrailFadePercentage(80) if __name__ == '__main__': app = QtWidgets.QApplication(sys.argv) loginDialog = LoginDialog() if loginDialog.exec_() == QDialog.Accepted: mainWindow = MainWindow() mainWindow.setWindowTitle('{},欢迎您进入余票查询'.format(loginDialog.userName)) mainWindow.show() sys.exit(app.exec_())
#!/usr/bin/env python3 # # run.py # Runs a skeleton program that contains a main window and customized menu bar. # Using Python 3.6 and PySide2 v.5.12 # # Copyright (C) 2019 Robert Parker # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. import sys from PySide2.QtWidgets import QApplication from main import MainWindow if __name__ == '__main__': app = QApplication(sys.argv) ex = MainWindow() ex.show() sys.exit(app.exec_())
import sys from PyQt5.QtWidgets import QApplication, QMainWindow #import test # module test.py from main import MainWindow if __name__ == '__main__': app = QApplication(sys.argv) myMainWindow = MainWindow() #myUi = test.Ui_MainWindow() #myUi.setupUi(myMainWindow) myMainWindow.show() sys.exit(app.exec_())
def main(argv): path = None first_arg = None second_arg = None config = None apath = None print("QT VERSION %s" % QT_VERSION_STR) try: first_arg = argv[1] second_arg = argv[2] except IndexError: pass if first_arg is not None: if first_arg == "-c": config = True if second_arg is not None: path = second_arg else: path = first_arg try: #app = QApplication(argv) app = MyApp(argv) QCoreApplication.setOrganizationDomain('www.trickplay.com') QCoreApplication.setOrganizationName('Trickplay') QCoreApplication.setApplicationName('Trickplay Debugger') QCoreApplication.setApplicationVersion('0.0.1') s = QProcessEnvironment.systemEnvironment().toStringList() for item in s: k, v = str(item).split("=", 1) if k == 'PWD': apath = v apath = os.path.join(apath, os.path.dirname(str(argv[0]))) main = MainWindow(app, apath) main.config = config main.show() main.raise_() wizard = Wizard() app.main = main path = wizard.start(path) if path: settings = QSettings() settings.setValue('path', path) app.setActiveWindow(main) main.start(path, wizard.filesToOpen()) main.show() sys.exit(app.exec_()) # TODO, better way of doing this for 'clean' exit... except KeyboardInterrupt: exit("Exited")
#!/usr/bin/python import sys from PyQt4 import QtCore, QtGui from main import MainWindow app = QtGui.QApplication(sys.argv) win = MainWindow() win.show() app.exec_()
# -*- coding: utf-8 -*- import sys import atexit from PyQt4 import QtGui from PyQt4.QtSql import QSqlDatabase from main import MainWindow @atexit.register def appExit(): pass def createConnection(): db = QSqlDatabase.addDatabase("QSQLITE") db.setDatabaseName("sqlite.db3") return db.open() createConnection() app = QtGui.QApplication(sys.argv) app.addLibraryPath("qt4_plugins") main_window = MainWindow() main_window.showMaximized() main_window.show() sys.exit(app.exec_())
def main(): import sys app = QtGui.QApplication(sys.argv) ui = MainWindow() ui.show() sys.exit(app.exec_())
def main(): app = QApplication(sys.argv) app.setStyle(QStyleFactory.create('Fusion')) mainWindow = MainWindow() mainWindow.show() sys.exit(app.exec_())
class Login(QMainWindow): def __init__(self, servers_up): super(Login, self).__init__() self.setWindowFlags(Qt.FramelessWindowHint) self.servers_up = servers_up loadUi('ui/loginui.ui', self) palette = QPalette() palette.setBrush(QPalette.Background, QBrush(QPixmap("images/blast.png"))) self.setPalette(palette) self.close_button.clicked.connect(self.close_window) self.min_button.clicked.connect(self.min_window) self.user_field.setPlaceholderText("Username") self.pass_field.setPlaceholderText("Password") self.pass_field.setEchoMode(QLineEdit.Password) self.pass_field.returnPressed.connect(self.login) self.submit_login.clicked.connect(self.login) self.error_label.setAlignment(Qt.AlignCenter) self.error_label.hide() config = configparser.ConfigParser() config.read('config.ini') api_endpoint = config["API_SERVER"]["address"] # Check servers if not self.servers_up: self.error_label.setText( 'Can\'t connect to the Blastboard servers.') self.error_label.show() self.user_field.setDisabled(True) self.pass_field.setDisabled(True) self.submit_login.setDisabled(True) @pyqtSlot() def min_window(self): self.window().showMinimized() @pyqtSlot() def close_window(self): self.window().close() @pyqtSlot() def login(self): username = self.user_field.text() password = self.pass_field.text() login_endpoint = self.api_endpoint + "/Login" login_request = requests.post(login_endpoint, data={ 'username': username, 'password': password }) login_response = json.loads(login_request.text) if login_response: login_status = login_response["status"] login_message = login_response["message"] if login_status == 200: self.close() self.main_window = MainWindow() self.main_window.show() elif login_status == 100: self.error_label.setText('Incorrect username or password') self.error_label.show() else: self.error_label.show() else: self.error_label.setText('Please try again.') self.error_label.show()