Exemple #1
0
    def toggle_onetabmode(self):
        """Toggles onetabmode"""

        config.set_config(u"onetabmode", \
         self.main_window.ui.action_onetabmode.isChecked())
        if config.get_config(u"onetabmode"):
            self.close_other()
        self.setTabsClosable(not config.get_config(u"onetabmode"))
        self.main_window.ui.action_close_other_tabs.setEnabled(not \
         config.get_config(u"onetabmode"))
Exemple #2
0
	def toggle_onetabmode(self):

		"""Toggles onetabmode"""

		config.set_config(u"onetabmode", \
			self.main_window.ui.action_onetabmode.isChecked())
		if config.get_config(u"onetabmode"):
			self.close_other()
		self.setTabsClosable(not config.get_config(u"onetabmode"))
		self.main_window.ui.action_close_other_tabs.setEnabled(not \
			config.get_config(u"onetabmode"))
Exemple #3
0
	def get_logfile(self, quick=False, subject_nr=0):
		
		"""
		Gets the logfile for the current session, either by falling back to a 
		default value ('quickrun.csv') or through a pop-up dialogue.
		
		Keyword arguments:
		quick		--	Indicates whether we are quickrunning the experiment.
						(default=False)
		subject_nr	--	Indicates the subject number, which is used to
						suggest a logfile. (default=0)
					
		Returns:
		A pathname for the logfile or None if no logfile was chosen (i.e. the
		dialogue was cancelled).
		"""
		
		if quick:
			logfile = os.path.join(config.get_config( \
				u'default_logfile_folder'), config.get_config( \
				u'quick_run_logfile'))
		else:
			# Suggested filename
			suggested_path = os.path.join(config.get_config( \
				u'default_logfile_folder'), u'subject-%d.csv' % subject_nr)
			# Get the data file
			csv_filter = u'Comma-separated values (*.csv)'
			logfile = unicode(QtGui.QFileDialog.getSaveFileName( \
				self.main_window.ui.centralwidget, \
				_(u"Choose location for logfile (press 'escape' for default location)"), \
				suggested_path, filter=csv_filter))
			# An empty string indicates that the dialogue was cancelled, in
			# which case we fall back to a default location.
			if logfile == u'':
				logfile = os.path.join(config.get_config( \
						'default_logfile_folder'), u'defaultlog.csv')
			# If a logfile was provided, but it did not have a proper extension,
			# we add a `.csv` extension.
			else:
				if os.path.splitext(logfile)[1].lower() not in \
					self.valid_logfile_extensions:
					logfile += self.default_logfile_extension		
		# If the logfile is not writable, inform the user and cancel.
		try:
			open(logfile, u'w').close()
		except:
			self.main_window.experiment.notify( \
				_(u"The logfile '%s' is not writable. Please choose another location for the logfile.") \
				% logfile)
			return None
		# Remember the logfile folder for the next run
		# Remember the location of the logfile
		config.set_config('default_logfile_folder', os.path.dirname(logfile))
		return logfile
Exemple #4
0
    def toggle_onetabmode(self):
        """Toggles onetabmode"""

        config.set_config(u"onetabmode",
                          self.main_window.ui.action_onetabmode.isChecked())
        if config.get_config(u"onetabmode"):
            self.close_other()
            self.tabBar().setVisible(False)
        else:
            self.tabBar().setVisible(True)
        self.setTabsClosable(not config.get_config(u"onetabmode"))
        self.main_window.ui.action_close_all_tabs.setEnabled(
            not config.get_config(u"onetabmode"))
        self.main_window.ui.action_close_current_tab.setEnabled(
            not config.get_config(u"onetabmode"))
        self.main_window.ui.action_close_other_tabs.setEnabled(
            not config.get_config(u"onetabmode"))
Exemple #5
0
	def toggle_onetabmode(self):

		"""Toggles onetabmode"""

		config.set_config(u"onetabmode",
			self.main_window.ui.action_onetabmode.isChecked())
		if config.get_config(u"onetabmode"):
			self.close_other()
			self.tabBar().setVisible(False)
		else:
			self.tabBar().setVisible(True)
		self.setTabsClosable(not config.get_config(u"onetabmode"))
		self.main_window.ui.action_close_all_tabs.setEnabled(
			not config.get_config(u"onetabmode"))
		self.main_window.ui.action_close_current_tab.setEnabled(
			not config.get_config(u"onetabmode"))
		self.main_window.ui.action_close_other_tabs.setEnabled(
			not config.get_config(u"onetabmode"))
	def apply(self):

		"""Apply the controls"""

		if self.lock:
			return
		self.lock = True
		debug.msg()

		self.experiment.auto_response = \
			self.ui.checkbox_autoresponse.isChecked()
		self.main_window.ui.action_enable_auto_response.setChecked(
			self.ui.checkbox_autoresponse.isChecked())

		if self.ui.checkbox_toolbar_text.isChecked():
			self.main_window.ui.toolbar_main.setToolButtonStyle(
				QtCore.Qt.ToolButtonTextUnderIcon)
		else:
			self.main_window.ui.toolbar_main.setToolButtonStyle(
				QtCore.Qt.ToolButtonIconOnly)

		old_size = config.get_config(u'toolbar_size')
		if self.ui.checkbox_small_toolbar.isChecked():
			new_size = 16
		else:
			new_size = 32
		if old_size != new_size:
			config.set_config(u"toolbar_size", new_size)
			self.theme.set_toolbar_size(config.get_config("toolbar_size"))

		from libqtopensesame import runners
		for runner in runners.runner_list:
			if runner in self.ui.combobox_runner.currentText():
				config.set_config(u'runner', runner)

		config.set_config(u'theme',
			unicode(self.ui.combobox_theme.currentText()))

		config.set_config(u'style',
			unicode(self.ui.combobox_style.currentText()))
		self.main_window.save_state()

		self.lock = False
Exemple #7
0
    def apply(self):
        """Apply the controls"""

        if self.lock:
            return
        self.lock = True
        debug.msg()

        self.experiment.auto_response = \
         self.ui.checkbox_autoresponse.isChecked()
        self.main_window.ui.action_enable_auto_response.setChecked(
            self.ui.checkbox_autoresponse.isChecked())

        if self.ui.checkbox_toolbar_text.isChecked():
            self.main_window.ui.toolbar_main.setToolButtonStyle(
                QtCore.Qt.ToolButtonTextUnderIcon)
        else:
            self.main_window.ui.toolbar_main.setToolButtonStyle(
                QtCore.Qt.ToolButtonIconOnly)

        old_size = config.get_config(u'toolbar_size')
        if self.ui.checkbox_small_toolbar.isChecked():
            new_size = 16
        else:
            new_size = 32
        if old_size != new_size:
            config.set_config(u"toolbar_size", new_size)
            self.theme.set_toolbar_size(config.get_config("toolbar_size"))

        from libqtopensesame import runners
        for runner in runners.runner_list:
            if runner in self.ui.combobox_runner.currentText():
                config.set_config(u'runner', runner)

        config.set_config(u'theme',
                          unicode(self.ui.combobox_theme.currentText()))

        config.set_config(u'style',
                          unicode(self.ui.combobox_style.currentText()))
        self.main_window.save_state()

        self.lock = False
	def apply(self):

		"""Apply the controls"""

		if self.lock:
			return
		self.lock = True
		debug.msg()

		config.set_config(u'immediate_rename', \
			self.ui.checkbox_immediately_rename.isChecked())
		self.main_window.experiment.auto_response = \
			self.ui.checkbox_autoresponse.isChecked()
		self.main_window.ui.action_enable_auto_response.setChecked( \
			self.ui.checkbox_autoresponse.isChecked())

		if self.ui.checkbox_toolbar_text.isChecked():
			self.main_window.ui.toolbar_main.setToolButtonStyle( \
				QtCore.Qt.ToolButtonTextUnderIcon)
		else:
			self.main_window.ui.toolbar_main.setToolButtonStyle( \
				QtCore.Qt.ToolButtonIconOnly)
		
		old_size = config.get_config(u'toolbar_size')
		if self.ui.checkbox_small_toolbar.isChecked():
			new_size = 16
		else:
			new_size = 32
		if old_size != new_size:
			config.set_config(u"toolbar_size", new_size)
			self.main_window.theme.set_toolbar_size(config.get_config( \
				"toolbar_size"))		

		if self.ui.checkbox_enable_autosave.isChecked():
			config.set_config(u'autosave_interval', 60000 * \
				self.ui.spinbox_autosave_interval.value())
		else:
			config.set_config(u'autosave_interval', 0)	
		config.set_config(u'autosave_max_age', \
			self.ui.spinbox_autosave_max_age.value())
		self.main_window.start_autosave_timer()

		config.set_config(u'auto_update_check', \
			self.ui.checkbox_auto_update_check.isChecked())
		
		from libqtopensesame import runners
		for runner in runners.runner_list:
			if runner in self.ui.combobox_runner.currentText():
				config.set_config(u'runner', runner)

		config.set_config(u'theme', unicode( \
			self.ui.combobox_theme.currentText()))

		# Create a semicolon-separated list of disabled plugins
		l = []
		for plugin in plugins.list_plugins(filter_disabled=False):
			if not self.checkbox_plugins[plugin].isChecked():
				l.append(plugin)
		config.set_config(u"disabled_plugins", ";".join(l))

		config.set_config(u'style', unicode( \
			self.ui.combobox_style.currentText()))
		self.main_window.save_state()

		self.lock = False
Exemple #9
0
    def get_logfile(self, quick=False, subject_nr=0):

        """
		Gets the logfile for the current session, either by falling back to a
		default value ('quickrun.csv') or through a pop-up dialogue.

		Keyword arguments:
		quick		--	Indicates whether we are quickrunning the experiment.
						(default=False)
		subject_nr	--	Indicates the subject number, which is used to
						suggest a logfile. (default=0)

		Returns:
		A pathname for the logfile or None if no logfile was chosen (i.e. the
		dialogue was cancelled).
		"""

        remember_logfile = True
        if quick:
            logfile = os.path.join(
                config.get_config(u"default_logfile_folder"), config.get_config(u"quick_run_logfile")
            )
            try:
                open(logfile, u"w").close()
            except:
                import tempfile
                from libopensesame import misc

                debug.msg(u"Failed to open %s" % logfile)
                logfile = os.path.join(
                    tempfile.gettempdir().decode(misc.filesystem_encoding()),
                    tempfile.gettempprefix().decode(misc.filesystem_encoding()) + u"quickrun.csv",
                )
                debug.msg(u"Using temporary file %s" % logfile)
                remember_logfile = False
        else:
            # Suggested filename
            suggested_path = os.path.join(config.get_config(u"default_logfile_folder"), u"subject-%d.csv" % subject_nr)
            # Get the data file
            csv_filter = u"Comma-separated values (*.csv)"
            logfile = unicode(
                QtGui.QFileDialog.getSaveFileName(
                    self.main_window.ui.centralwidget,
                    _(u"Choose location for logfile (press 'escape' for default location)"),
                    suggested_path,
                    filter=csv_filter,
                )
            )
            # An empty string indicates that the dialogue was cancelled, in
            # which case we fall back to a default location.
            if logfile == u"":
                logfile = os.path.join(config.get_config("default_logfile_folder"), u"defaultlog.csv")
                # If a logfile was provided, but it did not have a proper extension,
                # we add a `.csv` extension.
            else:
                if os.path.splitext(logfile)[1].lower() not in self.valid_logfile_extensions:
                    logfile += self.default_logfile_extension
                    # If the logfile is not writable, inform the user and cancel.
        try:
            open(logfile, u"w").close()
        except:
            self.main_window.experiment.notify(
                _(u"The logfile '%s' is not writable. Please choose another location for the logfile.") % logfile
            )
            return None
        if remember_logfile:
            # Remember the logfile folder for the next run
            config.set_config("default_logfile_folder", os.path.dirname(logfile))
        return logfile
Exemple #10
0
	def apply(self):

		"""Apply the controls"""

		if self.lock:
			return
		self.lock = True
		debug.msg()

		self.main_window.immediate_rename = self.ui.checkbox_immediately_rename.isChecked()
		self.main_window.show_startup_tip = self.ui.checkbox_show_random_tips.isChecked()
		self.main_window.experiment.auto_response = self.ui.checkbox_autoresponse.isChecked()
		self.main_window.ui.action_enable_auto_response.setChecked(self.ui.checkbox_autoresponse.isChecked())

		if self.ui.checkbox_toolbar_text.isChecked():
			self.main_window.ui.toolbar_main.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
		else:
			self.main_window.ui.toolbar_main.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
		
		if self.ui.checkbox_small_toolbar.isChecked():
			config.set_config("toolbar_size", 16)
		else:
			config.set_config("toolbar_size", 32)
		self.main_window.theme.set_toolbar_size(config.get_config( \
			"toolbar_size"))		

		if self.ui.checkbox_enable_autosave.isChecked():
			self.main_window.autosave_interval = 60000 * self.ui.spinbox_autosave_interval.value()
		else:
			self.main_window.autosave_interval = 0						
		self.main_window.autosave_max_age = self.ui.spinbox_autosave_max_age.value()
		self.main_window.start_autosave_timer()

		self.main_window.auto_check_update = self.ui.checkbox_auto_update_check.isChecked()
		self.main_window.opensesamerun = self.ui.checkbox_opensesamerun.isChecked()

		self.ui.edit_opensesamerun_exec.setEnabled(self.ui.checkbox_opensesamerun.isChecked() and not self.ui.checkbox_auto_opensesamerun_exec.isChecked())
		self.ui.label_opensesamerun_exec.setEnabled(self.ui.checkbox_opensesamerun.isChecked() and not self.ui.checkbox_auto_opensesamerun_exec.isChecked())

		if self.ui.checkbox_auto_opensesamerun_exec.isChecked():
			self.main_window.opensesamerun_exec = ""
			self.ui.edit_opensesamerun_exec.setText("")
		else:
			if self.ui.edit_opensesamerun_exec.text() == "":
				if os.name == "nt":
					self.ui.edit_opensesamerun_exec.setText("opensesamerun.exe")
				else:
					self.ui.edit_opensesamerun_exec.setText("opensesamerun")
			self.main_window.opensesamerun_exec = str(self.ui.edit_opensesamerun_exec.text())

		config.set_config("new_experiment_dialog", self.ui.checkbox_new_experiment_dialog.isChecked())
		config.set_config("scintilla_auto_indent", self.ui.checkbox_scintilla_auto_indent.isChecked())
		config.set_config("scintilla_brace_match", self.ui.checkbox_scintilla_brace_match.isChecked())
		config.set_config("scintilla_custom_font", self.ui.checkbox_scintilla_custom_font.isChecked())
		config.set_config("scintilla_eol_visible", self.ui.checkbox_scintilla_eol_visible.isChecked())
		config.set_config("scintilla_folding", self.ui.checkbox_scintilla_folding.isChecked())
		config.set_config("scintilla_indentation_guides", self.ui.checkbox_scintilla_indentation_guides.isChecked())
		config.set_config("scintilla_line_numbers", self.ui.checkbox_scintilla_line_numbers.isChecked())
		config.set_config("scintilla_right_margin", self.ui.checkbox_scintilla_right_margin.isChecked())
		config.set_config("scintilla_syntax_highlighting", self.ui.checkbox_scintilla_syntax_highlighting.isChecked())
		config.set_config("scintilla_whitespace_visible", self.ui.checkbox_scintilla_whitespace_visible.isChecked())
		config.set_config("scintilla_font_family", str(self.ui.font_scintilla_font_family.currentFont().family()))
		config.set_config("scintilla_font_size", self.ui.spinbox_scintilla_font_size.value())

		# Create a semicolon-separated list of disabled plugins
		l = []
		for plugin in plugins.list_plugins(filter_disabled=False):
			if not self.checkbox_plugins[plugin].isChecked():
				l.append(plugin)
		config.set_config("disabled_plugins", ";".join(l))

		self.main_window.style = self.ui.combobox_style.currentText()
		self.main_window.set_style()
		self.main_window.save_state()

		self.lock = False
    def apply(self):
        """Apply the controls"""

        if self.lock:
            return
        self.lock = True
        debug.msg()

        config.set_config(u'immediate_rename', \
         self.ui.checkbox_immediately_rename.isChecked())
        self.main_window.experiment.auto_response = \
         self.ui.checkbox_autoresponse.isChecked()
        self.main_window.ui.action_enable_auto_response.setChecked( \
         self.ui.checkbox_autoresponse.isChecked())

        if self.ui.checkbox_toolbar_text.isChecked():
            self.main_window.ui.toolbar_main.setToolButtonStyle( \
             QtCore.Qt.ToolButtonTextUnderIcon)
        else:
            self.main_window.ui.toolbar_main.setToolButtonStyle( \
             QtCore.Qt.ToolButtonIconOnly)

        old_size = config.get_config(u'toolbar_size')
        if self.ui.checkbox_small_toolbar.isChecked():
            new_size = 16
        else:
            new_size = 32
        if old_size != new_size:
            config.set_config(u"toolbar_size", new_size)
            self.main_window.theme.set_toolbar_size(config.get_config( \
             "toolbar_size"))

        if self.ui.checkbox_enable_autosave.isChecked():
            config.set_config(u'autosave_interval', 60000 * \
             self.ui.spinbox_autosave_interval.value())
        else:
            config.set_config(u'autosave_interval', 0)
        config.set_config(u'autosave_max_age', \
         self.ui.spinbox_autosave_max_age.value())
        self.main_window.start_autosave_timer()

        config.set_config(u'auto_update_check', \
         self.ui.checkbox_auto_update_check.isChecked())

        from libqtopensesame import runners
        for runner in runners.runner_list:
            if runner in self.ui.combobox_runner.currentText():
                config.set_config(u'runner', runner)

        config.set_config(u'theme', unicode( \
         self.ui.combobox_theme.currentText()))

        # Create a semicolon-separated list of disabled plugins
        l = []
        for plugin in plugins.list_plugins(filter_disabled=False):
            if not self.checkbox_plugins[plugin].isChecked():
                l.append(plugin)
        config.set_config(u"disabled_plugins", ";".join(l))

        config.set_config(u'style', unicode( \
         self.ui.combobox_style.currentText()))
        self.main_window.save_state()

        self.lock = False