本文整理汇总了Python中PyQt4.QtCore.pyqtRestoreInputHook方法的典型用法代码示例。如果您正苦于以下问题:Python QtCore.pyqtRestoreInputHook方法的具体用法?Python QtCore.pyqtRestoreInputHook怎么用?Python QtCore.pyqtRestoreInputHook使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore
的用法示例。
在下文中一共展示了QtCore.pyqtRestoreInputHook方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fit_component
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import pyqtRestoreInputHook [as 别名]
def fit_component(self,component):
'''Fit the component and save values'''
from astropy.modeling import fitting
# Generate Fit line
fit_line = AbsLine(component.init_wrest,
linelist=self.llist[self.llist['List']])
fit_line.analy['vlim'] = component.vlim
fit_line.analy['spec'] = self.spec
fit_line.attrib['z'] = component.zcomp
fit_line.measure_aodm()
# Guesses
fmin = np.argmin(self.spec.flux[fit_line.analy['pix']])
zguess = self.spec.dispersion[fit_line.analy['pix'][fmin]]/component.init_wrest - 1.
bguess = (component.vlim[1]-component.vlim[0])/2.
Nguess = fit_line.attrib['logN']
# Voigt model
fitvoigt = xsv.single_voigt_model(logN=Nguess,b=bguess.value,
z=zguess, wrest=component.init_wrest.value,
gamma=fit_line.data['gamma'].value,
f=fit_line.data['f'], fwhm=self.fwhm)
# Restrict z range
try:
fitvoigt.z.min = component.zcomp+component.vlim[0].value/3e5/(1+component.zcomp)
except TypeError:
QtCore.pyqtRemoveInputHook()
xdb.set_trace()
QtCore.pyqtRestoreInputHook()
fitvoigt.z.max = component.zcomp+component.vlim[1].value/3e5/(1+component.zcomp)
#QtCore.pyqtRemoveInputHook()
#xdb.set_trace()
#QtCore.pyqtRestoreInputHook()
# Fit
fitter = fitting.LevMarLSQFitter()
parm = fitter(fitvoigt,self.spec.dispersion[fit_line.analy['pix']],
self.spec.flux[fit_line.analy['pix']].value)
# Save and sync
component.attrib['N'] = parm.logN.value
component.attrib['z'] = parm.z.value
component.attrib['b'] = parm.b.value * u.km/u.s
component.sync_lines()
示例2: enable_qt4
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import pyqtRestoreInputHook [as 别名]
def enable_qt4(self, app=False):
"""Enable event loop integration with PyQt4.
Parameters
----------
app : bool
Create a running application object or not.
Notes
-----
This methods sets the PyOS_InputHook for PyQt4, which allows
the PyQt4 to integrate with terminal based applications like
IPython.
If ``app`` is True, we create an :class:`QApplication` as follows::
from PyQt4 import QtCore
app = QtGui.QApplication(sys.argv)
But, we first check to see if an application has already been
created. If so, we simply return that instance.
"""
from PyQt4 import QtCore
# PyQt4 has had this since 4.3.1. In version 4.2, PyOS_InputHook
# was set when QtCore was imported, but if it ever got removed,
# you couldn't reset it. For earlier versions we can
# probably implement a ctypes version.
try:
QtCore.pyqtRestoreInputHook()
except AttributeError:
pass
self._current_gui = GUI_QT4
if app:
from PyQt4 import QtGui
app = QtCore.QCoreApplication.instance()
if app is None:
app = QtGui.QApplication(sys.argv)
self._apps[GUI_QT4] = app
return app
示例3: out_qtrace
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import pyqtRestoreInputHook [as 别名]
def out_qtrace():
from PyQt4 import QtCore
QtCore.pyqtRestoreInputHook()
#if __name__ == "__main__":