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


Python QTabManager.setText方法代码示例

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


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

示例1: qtitem

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

#.........这里部分代码省略.........
		desc:
			Puts the splitter in split view.
		"""

        self.splitter.setSizes([self.splitter.width() / 2, self.splitter.width() / 2])
        self.button_view.set_view_icon(u"split")

    def update(self):

        """
		desc:
			Updates both the script and the controls.
		"""

        self.update_script()
        self.edit_widget()

    def update_script(self):

        """
		desc:
			Regenerates the script and updates the script widget.
		"""

        # Normally, the script starts with a 'define' line and is indented by
        # a tab. We want to undo this, and present only unindented content.
        import textwrap

        script = self.to_string()
        script = script[script.find(u"\t") :]
        script = textwrap.dedent(script)
        if self._script_widget.text() != script:
            self.main_window.set_unsaved()
            self._script_widget.setText(script)
            self.extension_manager.fire(u"change_item", name=self.name)

    def edit_widget(self, *deprecated, **_deprecated):

        """
		desc:
			This function updates the controls based on the item state.
		"""

        self.auto_edit_widget()
        self.header.refresh()

    def apply_edit_changes(self, *deprecated, **_deprecated):

        """
		desc:
			Applies changes to the graphical controls.
		"""

        self.auto_apply_edit_changes()
        self.update_script()
        return True

    def apply_script_changes(self, *deprecated, **_deprecated):

        """
		desc:
			Applies changes to the script, by re-parsing the item from string.
		"""

        old_script = self.to_string()
        new_script = self._script_widget.text()
开发者ID:JdenHartog,项目名称:OpenSesame,代码行数:70,代码来源:qtitem.py

示例2: inline_script

# 需要导入模块: from QProgEdit import QTabManager [as 别名]
# 或者: from QProgEdit.QTabManager import setText [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

示例3: qtitem

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

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

		"""
		desc:
			Puts the splitter in split view.
		"""

		self.splitter.setSizes([self.splitter.width()/2,
			self.splitter.width()/2])
		self.button_view.set_view_icon(u'split')

	def update(self):

		"""
		desc:
			Updates both the script and the controls.
		"""

		self.update_script()
		self.edit_widget()

	def update_script(self):

		"""
		desc:
			Regenerates the script and updates the script widget.
		"""

		# Normally, the script starts with a 'define' line and is indented by
		# a tab. We want to undo this, and present only unindented content.
		import textwrap
		script = self.to_string()
		script = script[script.find(u'\t'):]
		script = textwrap.dedent(script)
		self._script_widget.setText(script)

	def edit_widget(self, *deprecated, **_deprecated):

		"""
		desc:
			This function updates the controls based on the item state.
		"""

		debug.msg()
		self.auto_edit_widget()
		self.header.refresh()

	def apply_edit_changes(self, *deprecated, **_deprecated):

		"""
		desc:
			Applies changes to the graphical controls.
		"""

		debug.msg()
		self.auto_apply_edit_changes()
		self.update_script()
		self.main_window.set_unsaved(True)
		return True

	def apply_script_changes(self, *deprecated, **_deprecated):

		"""
		desc:
			Applies changes to the script, by re-parsing the item from string.
		"""
开发者ID:bwarna,项目名称:OpenSesame,代码行数:69,代码来源:qtitem.py

示例4: qtitem

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

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

		if not stretch:
			debug.msg(u"passing the stretch argument is deprecated", \
				reason=u"deprecation")
		self.user_hint_widget.clear()
		self.header.restore_name(False)
		self.header.refresh()
		self._edit_widget.__edit_item__ = self.name
		if not self.sanity_check():
			self.open_script_tab()
			return
		self.auto_edit_widget()
		self.user_hint_widget.refresh()
		return self._edit_widget

	def apply_name_change(self, rebuild=True):

		"""
		Apply an item name change

		Keywords arguments:
		rebuild -- a deprecated argument (default=True)
		"""

		debug.msg()

		# Sanitize the name, check if it is new and valid, and if so, rename
		new_name = self.experiment.sanitize(self.header.edit_name.text(), \
			strict=True, allow_vars=False)
		if new_name.lower() != self.name.lower():
			valid = self.experiment.check_name(new_name)
			if valid != True:
				self.experiment.notify(valid)
				self.header.edit_name.setText(self.name)
				return
		old_name = self.name
		self.name = new_name
		self._edit_widget.__edit_item__	= new_name
		self.experiment.main_window.dispatch.event_name_change.emit(old_name, \
			new_name)

	def apply_edit_changes(self, rebuild=True):

		"""
		Applies the GUI controls.

		Keywords arguments:
		rebuild	--	Specifies whether the overview area (item list) should be
					rebuild. (default=True)
		"""

		debug.msg(self.name)
		if self.experiment.main_window.lock_refresh:
			debug.msg(u"skipping, because refresh in progress")
			return False
		self.auto_apply_edit_changes()
		self.set(u"description", \
			self.experiment.sanitize(unicode( \
				self.header.edit_desc.text()).strip()))
		if self.description == u"":
			self.description = u"No description"
		self.header.label_desc.setText(self.description)
		self.experiment.main_window.dispatch.event_simple_change.emit(self.name)
		return True

	def close_edit_tab(self, index=None):
开发者ID:EoinTravers,项目名称:OpenSesame,代码行数:70,代码来源:qtitem.py

示例5: qtitem

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

#.........这里部分代码省略.........
			self.splitter.width()/2])
		self.button_view.set_view_icon(u'split')

	def update(self):

		"""
		desc:
			Updates both the script and the controls.
		"""

		# Items are updated when their tab is shown, so we don't need to update
		# them if they aren't shown.
		if self.tabwidget.current_item() != self.name:
			return False
		self.update_script()
		self.edit_widget()
		return True

	def update_script(self):

		"""
		desc:
			Regenerates the script and updates the script widget.
		"""

		# Normally, the script starts with a 'define' line and is indented by
		# a tab. We want to undo this, and present only unindented content.
		import textwrap
		script = self.to_string()
		script = script[script.find(u'\t'):]
		script = textwrap.dedent(script)
		if self._script_widget.text() != script:
			self.main_window.set_unsaved()
			self._script_widget.setText(script)
			self.extension_manager.fire(u'change_item', name=self.name)

	def edit_widget(self, *deprecated, **_deprecated):

		"""
		desc:
			This function updates the controls based on the item state.
		"""

		self.auto_edit_widget()
		self.header.refresh()

	def apply_edit_changes(self, *deprecated, **_deprecated):

		"""
		desc:
			Applies changes to the graphical controls.
		"""

		self.auto_apply_edit_changes()
		self.update_script()
		return True

	def apply_script_changes(self, *deprecated, **_deprecated):

		"""
		desc:
			Applies changes to the script.
		"""

		if not self.validate_script():
			return
开发者ID:dev-jam,项目名称:OpenSesame,代码行数:70,代码来源:qtitem.py


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