Exemplo n.º 1
0
	def init_edit_widget(self):
	
		"""Construct the GUI controls"""
		
		libqtopensesame.qtitem.qtitem.init_edit_widget(self, False)
		
		tabwidget_script = QtGui.QTabWidget(self._edit_widget)
		py_ver = "Python %d.%d.%d" % (sys.version_info[0], sys.version_info[1], sys.version_info[2])
		
		self.textedit_prepare = inline_editor(self.experiment, notification=py_ver, syntax="python")
		self.textedit_prepare.apply.clicked.connect(self.apply_edit_changes)
		QtCore.QObject.connect(self.textedit_prepare.edit, QtCore.SIGNAL("focusLost"), self.apply_edit_changes)		
				
		hbox = QtGui.QHBoxLayout()
		hbox.addStretch()
		hbox.setContentsMargins(0, 0, 0, 0)
		hbox_widget = QtGui.QWidget()
		hbox_widget.setLayout(hbox)		
					
		vbox = QtGui.QVBoxLayout()		
		vbox.addWidget(self.textedit_prepare)
		vbox.addWidget(hbox_widget)
		
		widget = QtGui.QWidget()
		widget.setLayout(vbox)
		
		tabwidget_script.addTab(widget, self.experiment.icon("inline_script"), "Prepare phase")
								
		self.textedit_run = inline_editor(self.experiment, notification=py_ver, syntax="python")
		self.textedit_run.apply.clicked.connect(self.apply_edit_changes)
		QtCore.QObject.connect(self.textedit_run.edit, QtCore.SIGNAL("focusLost"), self.apply_edit_changes)				
		
		hbox = QtGui.QHBoxLayout()
		hbox.addStretch()
		hbox.setContentsMargins(0, 0, 0, 0)
		hbox_widget = QtGui.QWidget()
		hbox_widget.setLayout(hbox)			
		
		vbox = QtGui.QVBoxLayout()				
		vbox.addWidget(self.textedit_run)		
		vbox.addWidget(hbox_widget)		
		
		widget = QtGui.QWidget()
		widget.setLayout(vbox)
		
		tabwidget_script.addTab(widget, self.experiment.icon("inline_script"), "Run phase")			
		
		# Switch to the run script by default, unless there is only content for
		# the prepare script.
		if self._run == "" and self._prepare != "":
			tabwidget_script.setCurrentIndex(0)		
		else:
			tabwidget_script.setCurrentIndex(1)
		
		self.edit_vbox.addWidget(tabwidget_script)
Exemplo n.º 2
0
	def add_editor_control(self, var, label, syntax = False, tooltip = None, default = None):
	
		"""
		Adds a texteditor
		"""
	
		label = QtGui.QLabel(label)
	
		editor = inline_editor.inline_editor(self.experiment)
		editor.apply.clicked.connect(self.apply_edit_changes)
		if syntax:
			syntax_highlighter.syntax_highlighter(editor.edit.document(), syntax_highlighter.python_keywords)
		
		if var != None:
			self.auto_editor[var] = editor
		
		self.edit_vbox.addWidget(label)			
		self.edit_vbox.addWidget(editor)	
Exemplo n.º 3
0
    def init_edit_widget(self):
        """
		This function creates the controls for the edit
		widget.
		"""

        # Lock the widget until we're doing creating it
        self.lock = True

        # Pass the word on to the parent
        qtplugin.qtplugin.init_edit_widget(self, False)

        # Content editor
        self.editor_msg = inline_editor.inline_editor(self.experiment)
        self.editor_msg.apply.clicked.connect(self.apply_edit_changes)
        self.edit_vbox.addWidget(self.editor_msg)

        # Unlock
        self.lock = True
Exemplo n.º 4
0
	def init_edit_widget(self):
	
		"""
		This function creates the controls for the edit
		widget.
		"""
		
		# Lock the widget until we're doing creating it
		self.lock = True
		
		# Pass the word on to the parent		
		qtplugin.qtplugin.init_edit_widget(self, False)			

		# Content editor
		self.editor_msg = inline_editor.inline_editor(self.experiment)
		self.editor_msg.apply.clicked.connect(self.apply_edit_changes)		
		self.edit_vbox.addWidget(self.editor_msg)		
				
		# Unlock
		self.lock = True		
Exemplo n.º 5
0
	def __init__(self, parent=None):
	
		"""
		Constructor
		
		Keywords arguments:
		parent -- the parent QWidget
		"""
	
		self.main_window = parent
		QtGui.QWidget.__init__(self)		

		# Set the header, with the icon, label and script button
		self.header_widget = general_header_widget(self.main_window.experiment)
		button_help = QtGui.QPushButton(self.main_window.experiment.icon("help"), "")
		button_help.setIconSize(QtCore.QSize(16, 16))
		button_help.clicked.connect(self.open_help_tab)
		button_help.setToolTip("Tell me more about OpenSesame!")
		header_hbox = QtGui.QHBoxLayout()
		header_hbox.addWidget(self.main_window.experiment.label_image("experiment_large"))
		header_hbox.addWidget(self.header_widget)
		header_hbox.addStretch()
		header_hbox.addWidget(button_help)
		header_hbox.setContentsMargins(0, 0, 0, 16)
		header_widget = QtGui.QWidget()
		header_widget.setLayout(header_hbox)

		# The rest of the controls from the UI file
		w = QtGui.QWidget()
		self.ui = general_widget_ui.Ui_Form()
		self.ui.setupUi(w)

		# The foeground and background widgets get a special treatment		
		self.ui.edit_foreground = color_edit.color_edit(self.main_window.experiment)
		self.ui.edit_background = color_edit.color_edit(self.main_window.experiment)
		self.ui.edit_foreground.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
		self.ui.edit_background.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
		self.ui.layout_general_properties.addWidget(self.ui.edit_foreground, 3, 5)
		self.ui.layout_general_properties.addWidget(self.ui.edit_background, 4, 5)
		QtCore.QObject.connect(self.ui.edit_foreground, QtCore.SIGNAL("set_color"), self.apply_changes)
		QtCore.QObject.connect(self.ui.edit_background, QtCore.SIGNAL("set_color"), self.apply_changes)
		
		# Connect the rest
		self.ui.combobox_start.currentIndexChanged.connect(self.apply_changes)
		self.ui.spinbox_width.editingFinished.connect(self.apply_changes)
		self.ui.spinbox_height.editingFinished.connect(self.apply_changes)
		self.ui.spinbox_compensation.editingFinished.connect(self.apply_changes)
		self.ui.group_script.toggled.connect(self.toggle_script_editor)
		self.ui.group_backend_settings.toggled.connect(self.toggle_backend_settings)
		self.ui.label_opensesame.setText(unicode(self.ui.label_opensesame.text()).replace("[version]", misc.version).replace("[codename]", misc.codename))

		# Set the backend combobox
		for backend in openexp.backend_info.backend_list:
			desc = openexp.backend_info.backend_list[backend]["description"]
			self.ui.combobox_backend.addItem("%s -- %s" % (backend, desc))
		self.ui.combobox_backend.currentIndexChanged.connect(self.apply_changes)
		
		# Script editor
		self.edit_script = inline_editor(self.main_window.experiment, syntax="opensesame")
		self.edit_script.apply.clicked.connect(self.apply_script)		
		self.ui.layout_script.addWidget(self.edit_script)
		
		vbox = QtGui.QVBoxLayout()
		vbox.addWidget(header_widget)
		vbox.addWidget(w)

		self.setLayout(vbox)
		self.general_tab = True

		self.toggle_script_editor()
		self.toggle_backend_settings()