def get_qapplication_instance(): """ Returns the QApplication instance. Creates one if it doesn't exist. """ app = QtGui.QApplication.instance() if app is None: app = QtGui.QApplication(sys.argv) check_class(app, QtGui.QApplication) return app
def main(): import platform if sys.platform == "linux2": QtGui.QApplication.addLibraryPath( '/usr/lib/%s-linux-gnu/qt5/plugins/' % platform.machine()) app = QtGui.QApplication(sys.argv) window = ThFrame() window.setGeometry(100, 100, 800, 600) window.setWindowTitle('ThFrame') window.show() sys.exit(app.exec_())
self.accept() # 关闭对话框并返回1 def login(loginoptions): """返回True或False""" dialog = LoginDialog(loginoptions) if dialog.exec_(): return True, (unicode(dialog.login_name.text()), unicode(dialog.login_password.text())) else: return False, (u'', u'') if __name__ == '__main__': import sys app = QtGui.QApplication(sys.argv) styleoptions = { 'title': u'登录', 'windowicon': os.sep.join( [os.path.dirname(__file__), 'utildialogskin', 'images', 'bg.jpg']), 'minsize': (400, 300), 'size': (400, 300), 'logo_title': u'智能光纤云终端管理平台', 'logo_img_url': os.sep.join( [os.path.dirname(__file__), 'utildialogskin', 'images', 'bg.jpg']) } print login(styleoptions)