# Qt4 plugins are bundled as data files (see hooks/hook-PyQt4*), # within a "qt4_plugins" directory. # We add a runtime hook to tell Qt4 where to find them. import os d = "qt4_plugins" if "_MEIPASS2" in os.environ: d = os.path.join(os.environ["_MEIPASS2"], d) else: d = os.path.join(os.path.dirname(sys.argv[0]), d) # We cannot use QT_PLUGIN_PATH here, because it would not work when # PyQt4 is compiled with a different CRT from Python (eg: it happens # with Riverbank's GPL package). from PyQt4.QtCore import QCoreApplication QCoreApplication.addLibraryPath(os.path.abspath(d))
# -*- coding: utf-8 -*- from PyQt4.QtSql import * from PyQt4.QtGui import * from PyQt4.QtCore import * import sys from PyQt4.QtCore import QCoreApplication QCoreApplication.addLibraryPath("./plugins") QTextCodec.setCodecForTr(QTextCodec.codecForName("utf8")) def openDatabase(): db = QSqlDatabase.addDatabase("QODBC3") connectionString = "DRIVER={SQL Server};SERVER=172.16.200.3;UID=sa;PWD=gxqsj@12345=;DATABASE=GXSJ_EHR_2;" db.setDatabaseName(connectionString) db.open() if (db.isOpen()): print u"连接成功!" return db else: print u"连接失败" def loadData(): db = openDatabase() model = QSqlTableModel() model.setTable("BM_GWLB2") model.setFilter("GRADE = 1") parentBM = []
# -*- coding: utf-8 -*- from PyQt4.QtSql import * from PyQt4.QtGui import * from PyQt4.QtCore import * import sys from PyQt4.QtCore import Qt, QCoreApplication from test import * QCoreApplication.addLibraryPath("./plugins"); QTextCodec.setCodecForTr(QTextCodec.codecForName("utf8")) def openDatabase(): db = QSqlDatabase.addDatabase("QODBC3") connectionString = "DRIVER={SQL Server};SERVER=172.16.200.3;UID=sa;PWD=gxqsj@12345=;DATABASE=GXSJ_EHR_2;" db.setDatabaseName(connectionString) db.open() if(db.isOpen()): print u"连接成功!" return db else: print u"连接失败" def smModel(): db = openDatabase() model = QSqlTableModel() model.setTable("BM_GWLB2") model.setFilter("GRADE = 1") parentBM = [] parentItem = []
command_line_args = parser.parse_args() sys.path.insert(0, command_line_args.directory) from PyQt4 import QtGui # noqa import mantid # noqa from ErrorReporter import resources # noqa from mantid.kernel import UsageService # noqa from ErrorReporter.error_report_presenter import ErrorReporterPresenter # noqa from ErrorReporter.errorreport import CrashReportPage # noqa # Set path to look for package qt libraries if command_line_args.qtdir is not None: from PyQt4.QtCore import QCoreApplication QCoreApplication.addLibraryPath(command_line_args.qtdir) def main(): if not UsageService.isEnabled(): return int(command_line_args.exit_code) app = QtGui.QApplication(sys.argv) form = CrashReportPage(show_continue_terminate=False) presenter = ErrorReporterPresenter(form, command_line_args.exit_code) presenter.show_view() app.exec_() return int(command_line_args.exit_code) if __name__ == '__main__': # if we're running file directly and not importing it sys.exit(main()) # run the main function
# Qt4 plugins are bundled as data files (see hooks/hook-PyQt4*), # within a "qt4_plugins" directory. # We add a runtime hook to tell Qt4 where to find them. import os d = "qt4_plugins" if "_MEIPASS2" in os.environ: d = os.path.join(os.environ["_MEIPASS2"], d) else: d = os.path.join(os.path.dirname(sys.argv[0]), d) # We cannot use QT_PLUGIN_PATH here, because it would not work when # PyQt4 is compiled with a different CRT from Python (eg: it happens # with Riverbank's GPL package). from PyQt4.QtCore import QCoreApplication QCoreApplication.addLibraryPath(os.path.abspath(d))
command_line_args = parser.parse_args() sys.path.insert(0, command_line_args.directory) from PyQt4 import QtGui # noqa import mantid # noqa from ErrorReporter import resources # noqa from ErrorReporter.error_report_presenter import ErrorReporterPresenter # noqa from ErrorReporter.errorreport import CrashReportPage # noqa # Set path to look for package qt libraries if command_line_args.qtdir is not None: from PyQt4.QtCore import QCoreApplication QCoreApplication.addLibraryPath( command_line_args.qtdir ) def main(): if mantid.config['usagereports.enabled'] != '1': return int(command_line_args.exit_code) app = QtGui.QApplication(sys.argv) form = CrashReportPage(show_continue_terminate=False) presenter = ErrorReporterPresenter(form, command_line_args.exit_code) presenter.show_view() app.exec_() return int(command_line_args.exit_code) if __name__ == '__main__': # if we're running file directly and not importing it