当前位置: 首页>>代码示例>>Python>>正文


Python QTabManager.isModified方法代码示例

本文整理汇总了Python中QProgEdit.QTabManager.isModified方法的典型用法代码示例。如果您正苦于以下问题:Python QTabManager.isModified方法的具体用法?Python QTabManager.isModified怎么用?Python QTabManager.isModified使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QProgEdit.QTabManager的用法示例。


在下文中一共展示了QTabManager.isModified方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: inline_script

# 需要导入模块: from QProgEdit import QTabManager [as 别名]
# 或者: from QProgEdit.QTabManager import isModified [as 别名]
class inline_script(libopensesame.inline_script.inline_script, qtitem.qtitem):

	"""The inline_script GUI controls"""

	def __init__(self, name, experiment, string=None):

		"""
		Constructor.

		Arguments:
		name 		--	The item name.
		experiment	--	The experiment object.

		Keywords arguments:
		string		--	A definition string. (default=None)
		"""

		libopensesame.inline_script.inline_script.__init__(self, name, \
			experiment, string)
		qtitem.qtitem.__init__(self)
		self.lock = False
		self._var_info = None

	def apply_edit_changes(self, **args):

		"""
		Applies the controls.

		Keywords arguments:
		args	--	A dictionary to accept unused keyword arguments.
		"""

		qtitem.qtitem.apply_edit_changes(self, False)
		sp = self.qprogedit.text(index=0)
		sr = self.qprogedit.text(index=1)
		self.set(u'_prepare', sp)
		self.set(u'_run', sr)
		self.lock = True
		self._var_info = None
		self.experiment.main_window.refresh(self.name)
		self.lock = False

	def init_edit_widget(self):

		"""Constructs the GUI controls."""
		
		from QProgEdit import QTabManager
		qtitem.qtitem.init_edit_widget(self, False)
		self.qprogedit = QTabManager(handler=self.apply_edit_changes, \
			defaultLang=u'Python', cfg=cfg)
		self.qprogedit.addTab(u'Prepare')
		self.qprogedit.addTab(u'Run')
		# Switch to the run phase, unless there is only content for the prepare
		# phase.
		if self._run == u'' and self._prepare != u'':
			self.qprogedit.setCurrentIndex(0)
		else:
			self.qprogedit.setCurrentIndex(1)
		self.edit_vbox.addWidget(self.qprogedit)

	def edit_widget(self):

		"""
		Updates the GUI controls.

		Returns:
		The control QWidget.
		"""

		qtitem.qtitem.edit_widget(self, False)
		if not self.lock:
			self.qprogedit.setText(self._prepare, index=0)
			self.qprogedit.setText(self._run, index=1)
		return self._edit_widget

	def get_ready(self):

		"""Applies pending script changes."""

		if self.qprogedit.isModified():
			debug.msg(u'applying pending script changes')
			self.apply_edit_changes(catch=False)
			return True
		return qtitem.qtitem.get_ready(self)
开发者ID:EoinTravers,项目名称:OpenSesame,代码行数:86,代码来源:inline_script.py

示例2: qtitem

# 需要导入模块: from QProgEdit import QTabManager [as 别名]
# 或者: from QProgEdit.QTabManager import isModified [as 别名]

#.........这里部分代码省略.........
		return l

	def variable_vars(self, exclude=[]):

		"""
		Determines if one of the variables of the current item is defined in
		terms of another variable

		Keywords arguments:
		exclude -- a list of variables that should not be checked

		Returns:
		True if there are variably defined variables, False otherwise
		"""

		for var in self.variables:
			if var not in exclude:
				val = self.variables[var]
				if isinstance(val, basestring) and u'[' in val:
					return True
		return False

	def get_ready(self):

		"""
		This function should be overridden to do any last-minute stuff that
		and item should do before an experiment is actually run, such as
		applying pending script changes.

		Returns:
		True if some action has been taken, False if nothing was done
		"""

		if self.script_qprogedit.isModified():
			debug.msg(u'applying pending script changes')
			self.apply_script_changes(catch=False)
			return True
		return False		
		
	def auto_edit_widget(self):

		"""Update the GUI controls based on the auto-widgets"""

		debug.msg()
		for var, edit in self.auto_line_edit.iteritems():
			edit.editingFinished.disconnect()
			if self.has(var):
				try:
					edit.setText(self.unistr(self.get(var, _eval=False)))
				except Exception as e:
					self.experiment.notify(_(u"Failed to set control '%s': %s") \
						% (var, e))
			else:
				edit.setText(u"")
			edit.editingFinished.connect(self.apply_edit_changes)

		for var, combobox in self.auto_combobox.iteritems():
			combobox.currentIndexChanged.disconnect()
			if self.has(var):
				try:
					combobox.setCurrentIndex(combobox.findText( \
						self.unistr(self.get(var, _eval=False))))
				except Exception as e:
					self.experiment.notify(_(u"Failed to set control '%s': %s") \
						% (var, e))
			combobox.currentIndexChanged.connect(self.apply_edit_changes)
开发者ID:EoinTravers,项目名称:OpenSesame,代码行数:70,代码来源:qtitem.py


注:本文中的QProgEdit.QTabManager.isModified方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。