def updateMapCompleters(self):
"""Update the auto completers for maps."""
for i in range(self.max_no_sets):
completer = PyQt5.QtWidgets.QCompleter(
scctool.settings.maps, self.le_map[i])
completer.setCaseSensitivity(PyQt5.QtCore.Qt.CaseInsensitive)
completer.setCompletionMode(
PyQt5.QtWidgets.QCompleter.InlineCompletion)
completer.setWrapAround(True)
self.le_map[i].setCompleter(completer)
python类QtCore()的实例源码
def __init__(self, controller, app, translator):
"""Init the main window."""
try:
super(MainWindow, self).__init__()
self.trigger = True
self.controller = controller
self.translator = translator
self.createFormMatchDataBox()
self.createTabs()
self.createHorizontalGroupBox()
self.createBackgroundTasksBox()
self.createMenuBar()
mainLayout = PyQt5.QtWidgets.QVBoxLayout()
mainLayout.addWidget(self.tabs, 0)
mainLayout.addWidget(self.fromMatchDataBox, 1)
mainLayout.addWidget(self.backgroundTasksBox, 0)
mainLayout.addWidget(self.horizontalGroupBox, 0)
self.setWindowTitle(
"StarCraft Casting Tool v{}".format(scctool.__version__))
self.window = PyQt5.QtWidgets.QWidget()
self.window.setLayout(mainLayout)
self.setCentralWidget(self.window)
# self.size
self.statusBar()
self.progressBar = BusyProgressBar()
# self.progressBar.setMaximumHeight(20)
self.progressBar.setMaximumWidth(160)
self.progressBar.setMinimumWidth(160)
self.progressBar.setVisible(False)
self.progressBar.setText(_("FTP Transfer in progress..."))
self.statusBar().addPermanentWidget(self.progressBar)
self.app = app
self.controller.setView(self)
self.controller.refreshButtonStatus()
self.processEvents()
self.settings = PyQt5.QtCore.QSettings(
"team pheeniX", "StarCraft Casting Tool")
self.restoreGeometry(self.settings.value(
"geometry", self.saveGeometry()))
self.restoreState(self.settings.value(
"windowState", self.saveState()))
self.mysubwindow1 = None
self.mysubwindow2 = None
self.mysubwindow3 = None
self.mysubwindow4 = None
self.show()
except Exception as e:
module_logger.exception("message")
def changeLanguage(self, language):
"""Change the language."""
try:
lang = gettext.translation(
'messages', localedir='locales', languages=[language])
lang.install()
except:
lang = gettext.NullTranslations()
self.app.removeTranslator(self.translator)
self.translator = PyQt5.QtCore.QTranslator(self.app)
self.translator.load(PyQt5.QtCore.QLocale(language),
"qtbase", "_", scctool.settings.getAbsPath('locales'), ".qm")
self.app.installTranslator(self.translator)
scctool.settings.config.parser.set("SCT", "language", language)
self.restart()
def __init__(self, package):
UIParser.__init__(self, QtCore, QtGui, QtWidgets, LoaderCreatorPolicy(package))
def list_molecules(self):
result = [];
try:
if (not os.path.exists(self.moleculeConfigFile)):
raise RuntimeError("Could not load molecules from the file: "+self.moleculeConfigFile);
parser = configparser.ConfigParser();
parser.read(self.moleculeConfigFile);
result = parser.sections();
except Exception as e:
self.noMoleculesWarningMsg = str(e);
timer = PyQt5.QtCore.QTimer(self);
timer.timeout.connect(self.noMoleculesWarning);
timer.setSingleShot(True)
timer.start(0);
return result
def __init__(self, package):
UIParser.__init__(self, QtCore, QtGui, QtWidgets, LoaderCreatorPolicy(package))
def __init__(self,hardcore,scratchdir):
super().__init__();
self.hardcore = hardcore;
self.scratchdir = scratchdir
self.ui = Ui_MainWindow()
self.ui.setupUi(self);
self.moleculeConfigFile = "conf/molecules.conf";
_translate = PyQt5.QtCore.QCoreApplication.translate
self.ui.moleculesBox.clear();
self.ui.moleculesBox.addItems(self.list_molecules());
self.ui.moleculesBox.model().sort(0);
self.ui.moleculesBox.model().insertRow(0);
self.ui.moleculesBox.setItemText(0,"Load...");
self.ui.moleculesBox.setCurrentIndex(0);
self.ui.mybutn.clicked.connect(self.Go);
self.ui.saveTrace.triggered.connect(self.saveTrace);
self.ui.actionPrecalculate.triggered.connect(self.precalculate);
self.ui.actionClose_figures.triggered.connect(self.close_figs);
self.ui.actionExit.triggered.connect(self.quit_program);
self.ui.actionHelp.triggered.connect(self.help);
self.ui.actionAbout.triggered.connect(self.about);
self.ui.moleculesBox.activated.connect(self.moleculeSelected);
self.ui.alpha_par.textChanged.connect(self.calculateDalpha);
self.ui.alpha_perp.textChanged.connect(self.calculateDalpha);
self.ui.Aconst.textChanged.connect(self.update_num_states);
self.ui.Bconst.textChanged.connect(self.update_num_states);
self.ui.Bconst.textChanged.connect(self.update_timestep);
self.ui.Temperature.textChanged.connect(self.update_num_states);
self.ui.abundanceEven.textChanged.connect(self.update_num_states);
self.ui.abundanceOdd.textChanged.connect(self.update_num_states);
self.ui.percentile.textChanged.connect(self.update_num_states);
self.ui.forceDT.clicked.connect(self.force_timestep_click);
self.ui.Jmax.textChanged.connect(self.update_timestep);
self.ui.cos2d.clicked.connect(self.update_timestep);
if (not propagation.can_propagate_using_ODE):
self.ui.doODE.setEnabled(False);
self.ui.doMatrix.setChecked(True);
self.ui.doODE.clicked.connect(self.doODE_click);
self.ui.doMatrix.clicked.connect(self.doMatrix_click);
self.ensemble = [];
self.show();
def _wrapinstance(func, ptr, base=None):
"""Enable implicit cast of pointer to most suitable class
This behaviour is available in sip per default.
Based on http://nathanhorne.com/pyqtpyside-wrap-instance
Usage:
This mechanism kicks in under these circumstances.
1. Qt.py is using PySide 1 or 2.
2. A `base` argument is not provided.
See :func:`QtCompat.wrapInstance()`
Arguments:
func (function): Original function
ptr (long): Pointer to QObject in memory
base (QObject, optional): Base class to wrap with. Defaults to QObject,
which should handle anything.
"""
assert isinstance(ptr, long), "Argument 'ptr' must be of type <long>"
assert (base is None) or issubclass(base, Qt.QtCore.QObject), (
"Argument 'base' must be of type <QObject>")
if base is None:
q_object = func(long(ptr), Qt.QtCore.QObject)
meta_object = q_object.metaObject()
class_name = meta_object.className()
super_class_name = meta_object.superClass().className()
if hasattr(Qt.QtWidgets, class_name):
base = getattr(Qt.QtWidgets, class_name)
elif hasattr(Qt.QtWidgets, super_class_name):
base = getattr(Qt.QtWidgets, super_class_name)
else:
base = Qt.QtCore.QObject
return func(long(ptr), base)