示例#1
0
    def init_edit_widget(self, stretch=True):

        """
		desc:
			Builds the UI.

		keywords:
			stretch:
				desc:	Indicates whether a vertical stretch should be added to
						the bottom of the controls. This is necessary if the
						controls don't expand.
				type:	bool
		"""

        # Header widget
        self.header = header_widget.header_widget(self)
        self.user_hint_widget = user_hint_widget.user_hint_widget(self.experiment.main_window, self)
        self.header_hbox = QtGui.QHBoxLayout()
        self.header_item_icon = self.theme.qlabel(self.item_icon())
        self.header_hbox.addWidget(self.header_item_icon)
        self.header_hbox.addWidget(self.header)
        self.header_hbox.setContentsMargins(0, 2, 0, 0)

        # Maximize button
        self.button_toggle_maximize = QtGui.QPushButton(self.theme.qicon(u"view-fullscreen"), u"")
        self.button_toggle_maximize.setToolTip(_(u"Toggle pop-out"))
        self.button_toggle_maximize.setIconSize(QtCore.QSize(16, 16))
        self.button_toggle_maximize.clicked.connect(self.toggle_maximize)
        self.header_hbox.addWidget(self.button_toggle_maximize)
        # View button
        self.button_view = item_view_button(self)
        self.header_hbox.addWidget(self.button_view)
        # Help button
        self.button_help = QtGui.QPushButton(self.theme.qicon(u"help"), u"")
        self.button_help.setToolTip(_(u"Tell me more about the %s item") % self.item_type)
        self.button_help.setIconSize(QtCore.QSize(16, 16))
        self.button_help.clicked.connect(self.open_help_tab)
        self.header_hbox.addWidget(self.button_help)

        self.header_widget = QtGui.QWidget()
        self.header_widget.setLayout(self.header_hbox)

        # The edit_grid is the layout that contains the actual controls for the
        # items.
        self.edit_grid = QtGui.QGridLayout()
        self.edit_grid.setColumnStretch(2, 2)
        self.edit_grid_widget = QtGui.QWidget()
        self.edit_grid_widget.setLayout(self.edit_grid)

        # The edit_vbox contains the edit_grid and the header widget
        self.edit_vbox = QtGui.QVBoxLayout()
        self.edit_vbox.addWidget(self.user_hint_widget)
        self.edit_vbox.addWidget(self.edit_grid_widget)
        self.edit_vbox.setContentsMargins(0, 0, 0, 0)
        self.edit_vbox.setSpacing(0)
        if stretch:
            self.edit_vbox.addStretch()
        self._edit_widget = QtGui.QWidget()
        self._edit_widget.setWindowIcon(self.theme.qicon(self.item_type))
        self._edit_widget.setLayout(self.edit_vbox)

        # The _script_widget contains the script editor
        from QProgEdit import QTabManager

        self._script_widget = QTabManager(handlerButtonText=_(u"Apply and close"), cfg=cfg)
        self._script_widget.focusLost.connect(self.apply_script_changes)
        self._script_widget.cursorRowChanged.connect(self.apply_script_changes)
        self._script_widget.handlerButtonClicked.connect(self.set_view_controls)
        self._script_widget.addTab(u"Script").setLang(u"OpenSesame")

        # The container_widget is the top-level widget that is actually inserted
        # into the tab widget.
        self.splitter = qtitem_splitter(self)
        if self.initial_view == u"controls":
            self.set_view_controls()
        elif self.initial_view == u"script":
            self.set_view_script()
        elif self.initial_view == u"split":
            self.set_view_split()
        else:
            debug.msg(u"Invalid initial_view: %s" % self.initial_view, reason=u"warning")
            self.set_view_controls()
        self.splitter.splitterMoved.connect(self.splitter_moved)
        self.container_vbox = QtGui.QVBoxLayout()
        self.container_vbox.setContentsMargins(4, 0, 4, 4)
        self.container_vbox.addWidget(self.header_widget)
        self.container_vbox.addWidget(self.splitter)
        self.container_widget = QtGui.QWidget()
        self.container_widget.setLayout(self.container_vbox)
        self.container_widget.on_activate = self.show_tab
        self.container_widget.__item__ = self.name
示例#2
0
	def init_edit_widget(self, stretch=True):

		"""
		desc:
			Builds the UI.

		keywords:
			stretch:
				desc:	Indicates whether a vertical stretch should be added to
						the bottom of the controls. This is necessary if the
						controls don't expand.
				type:	bool
		"""

		# Header widget
		self.header = header_widget.header_widget(self)
		self.header_hbox = QtWidgets.QHBoxLayout()
		self.header_item_icon = self.theme.qlabel(self.item_icon())
		self.header_hbox.addWidget(self.header_item_icon)
		self.header_hbox.addWidget(self.header)
		self.header_hbox.setContentsMargins(0, 0, 0, 0)
		self.header_hbox.setSpacing(12)

		# Maximize button
		self.button_toggle_maximize = QtWidgets.QPushButton(
			self.theme.qicon(u'view-fullscreen'), u'')
		self.button_toggle_maximize.setToolTip(_(u'Toggle pop-out'))
		self.button_toggle_maximize.setIconSize(QtCore.QSize(16, 16))
		self.button_toggle_maximize.clicked.connect(self.toggle_maximize)
		self.header_hbox.addWidget(self.button_toggle_maximize)
		# View button
		self.button_view = item_view_button(self)
		self.header_hbox.addWidget(self.button_view)
		# Help button
		self.button_help = QtWidgets.QPushButton(self.theme.qicon(u"help"), u"")
		self.button_help.setToolTip(
			_(u"Tell me more about the %s item") % self.item_type)
		self.button_help.setIconSize(QtCore.QSize(16, 16))
		self.button_help.clicked.connect(self.open_help_tab)
		self.header_hbox.addWidget(self.button_help)

		self.header_widget = QtWidgets.QWidget()
		self.header_widget.setLayout(self.header_hbox)

		# The edit_grid is the layout that contains the actual controls for the
		# items.
		self.edit_grid = QtWidgets.QFormLayout()
		if self.label_align == u'right':
			self.edit_grid.setLabelAlignment(QtCore.Qt.AlignRight)
		self.edit_grid.setFieldGrowthPolicy(
			QtWidgets.QFormLayout.FieldsStayAtSizeHint)
		self.edit_grid.setContentsMargins(0, 0, 0, 0)
		self.edit_grid.setVerticalSpacing(6)
		self.edit_grid.setHorizontalSpacing(12)
		self.edit_grid_widget = QtWidgets.QWidget()
		self.edit_grid_widget.setLayout(self.edit_grid)

		# The edit_vbox contains the edit_grid and the header widget
		self.edit_vbox = QtWidgets.QVBoxLayout()
		self.edit_vbox.addWidget(self.edit_grid_widget)
		self.edit_vbox.setContentsMargins(0, 0, 0, 0)
		self.edit_vbox.setSpacing(12)
		if stretch:
			self.edit_vbox.addStretch()
		self._edit_widget = QtWidgets.QWidget()
		self._edit_widget.setWindowIcon(self.theme.qicon(self.item_type))
		self._edit_widget.setLayout(self.edit_vbox)

		# The _script_widget contains the script editor
		from QProgEdit import QTabManager
		self._script_widget = QTabManager(
			handlerButtonText=_(u'Apply and close'), cfg=cfg)
		self._script_widget.focusLost.connect(self.apply_script_changes)
		self._script_widget.cursorRowChanged.connect(self.apply_script_changes)
		self._script_widget.handlerButtonClicked.connect(
			self.apply_script_changes_and_switch_view)
		self._script_widget.addTab(u'Script').setLang(u'OpenSesame')

		# The container_widget is the top-level widget that is actually inserted
		# into the tab widget.
		self.splitter = qtitem_splitter(self)
		if self.initial_view == u'controls':
			self.set_view_controls()
		elif self.initial_view == u'script':
			self.set_view_script()
		elif self.initial_view == u'split':
			self.set_view_split()
		else:
			debug.msg(u'Invalid initial_view: %s' % self.initial_view,
				reason=u'warning')
			self.set_view_controls()
		self.splitter.splitterMoved.connect(self.splitter_moved)
		self.container_vbox = QtWidgets.QVBoxLayout()
		self.container_vbox.setContentsMargins(12, 12, 12, 12)
		self.container_vbox.setSpacing(18)
		self.container_vbox.addWidget(self.header_widget)
		self.container_vbox.addWidget(self.splitter)
		self.container_widget = QtWidgets.QWidget()
		self.container_widget.setLayout(self.container_vbox)
		self.container_widget.on_activate = self.show_tab
		self.container_widget.__item__ = self.name
示例#3
0
    def init_edit_widget(self, stretch=True):
        """
		desc:
			Builds the UI.

		keywords:
			stretch:
				desc:	Indicates whether a vertical stretch should be added to
						the bottom of the controls. This is necessary if the
						controls don't expand.
				type:	bool
		"""

        # Header widget
        self.header = header_widget.header_widget(self)
        self.header_hbox = QtWidgets.QHBoxLayout()
        self.header_item_icon = self.theme.qlabel(self.item_icon())
        self.header_hbox.addWidget(self.header_item_icon)
        self.header_hbox.addWidget(self.header)
        self.header_hbox.setContentsMargins(0, 0, 0, 0)
        self.header_hbox.setSpacing(12)

        # Maximize button
        self.button_toggle_maximize = QtWidgets.QPushButton(
            self.theme.qicon(u'view-fullscreen'), u'')
        self.button_toggle_maximize.setToolTip(_(u'Toggle pop-out'))
        self.button_toggle_maximize.setIconSize(QtCore.QSize(16, 16))
        self.button_toggle_maximize.clicked.connect(self.toggle_maximize)
        self.header_hbox.addWidget(self.button_toggle_maximize)
        # View button
        self.button_view = item_view_button(self)
        self.header_hbox.addWidget(self.button_view)
        # Help button
        self.button_help = QtWidgets.QPushButton(self.theme.qicon(u"help"),
                                                 u"")
        self.button_help.setToolTip(
            _(u"Tell me more about the %s item") % self.item_type)
        self.button_help.setIconSize(QtCore.QSize(16, 16))
        self.button_help.clicked.connect(self.open_help_tab)
        self.header_hbox.addWidget(self.button_help)

        self.header_widget = QtWidgets.QWidget()
        self.header_widget.setLayout(self.header_hbox)

        # The edit_grid is the layout that contains the actual controls for the
        # items.
        self.edit_grid = QtWidgets.QFormLayout()
        if self.label_align == u'right':
            self.edit_grid.setLabelAlignment(QtCore.Qt.AlignRight)
        self.edit_grid.setFieldGrowthPolicy(
            QtWidgets.QFormLayout.FieldsStayAtSizeHint)
        self.edit_grid.setContentsMargins(0, 0, 0, 0)
        self.edit_grid.setVerticalSpacing(6)
        self.edit_grid.setHorizontalSpacing(12)
        self.edit_grid_widget = QtWidgets.QWidget()
        self.edit_grid_widget.setLayout(self.edit_grid)

        # The edit_vbox contains the edit_grid and the header widget
        self.edit_vbox = QtWidgets.QVBoxLayout()
        self.edit_vbox.addWidget(self.edit_grid_widget)
        self.edit_vbox.setContentsMargins(0, 0, 0, 0)
        self.edit_vbox.setSpacing(12)
        if stretch:
            self.edit_vbox.addStretch()
        self._edit_widget = QtWidgets.QWidget()
        self._edit_widget.setWindowIcon(self.theme.qicon(self.item_type))
        self._edit_widget.setLayout(self.edit_vbox)

        # The _script_widget contains the script editor
        from QProgEdit import QTabManager
        self._script_widget = QTabManager(
            handlerButtonText=_(u'Apply and close'), cfg=cfg)
        self._script_widget.focusLost.connect(self.apply_script_changes)
        self._script_widget.cursorRowChanged.connect(self.apply_script_changes)
        self._script_widget.handlerButtonClicked.connect(
            self.apply_script_changes_and_switch_view)
        self._script_widget.addTab(u'Script').setLang(u'OpenSesame')

        # The container_widget is the top-level widget that is actually inserted
        # into the tab widget.
        self.splitter = qtitem_splitter(self)
        if self.initial_view == u'controls':
            self.set_view_controls()
        elif self.initial_view == u'script':
            self.set_view_script()
        elif self.initial_view == u'split':
            self.set_view_split()
        else:
            debug.msg(u'Invalid initial_view: %s' % self.initial_view,
                      reason=u'warning')
            self.set_view_controls()
        self.splitter.splitterMoved.connect(self.splitter_moved)
        self.container_vbox = QtWidgets.QVBoxLayout()
        self.container_vbox.setContentsMargins(12, 12, 12, 12)
        self.container_vbox.setSpacing(18)
        self.container_vbox.addWidget(self.header_widget)
        self.container_vbox.addWidget(self.splitter)
        self.container_widget = QtWidgets.QWidget()
        self.container_widget.setLayout(self.container_vbox)
        self.container_widget.on_activate = self.show_tab
        self.container_widget.__item__ = self.name
示例#4
0
    def init_edit_widget(self, stretch=True):
        """
		desc:
			Builds the UI.

		keywords:
			stretch:
				desc:	Indicates whether a vertical stretch should be added to
						the bottom of the controls. This is necessary if the
						controls don't expand.
				type:	bool
		"""

        # Header widget
        self.header = header_widget.header_widget(self)
        self.user_hint_widget = user_hint_widget.user_hint_widget(
            self.experiment.main_window, self)
        self.header_hbox = QtGui.QHBoxLayout()
        self.header_item_icon = self.experiment.label_image(self.item_icon())
        self.header_hbox.addWidget(self.header_item_icon)
        self.header_hbox.addWidget(self.header)
        self.header_hbox.setContentsMargins(0, 5, 0, 10)

        # Maximize button
        self.button_toggle_maximize = QtGui.QPushButton(
            self.theme.qicon(u'view-fullscreen'), u'')
        self.button_toggle_maximize.setToolTip(_(u'Toggle pop-out'))
        self.button_toggle_maximize.setIconSize(QtCore.QSize(16, 16))
        self.button_toggle_maximize.clicked.connect(self.toggle_maximize)
        self.header_hbox.addWidget(self.button_toggle_maximize)
        # View button
        self.button_view = item_view_button(self)
        self.header_hbox.addWidget(self.button_view)
        # Help button
        self.button_help = QtGui.QPushButton(self.experiment.icon(u"help"),
                                             u"")
        self.button_help.setToolTip(
            _(u"Tell me more about the %s item") % self.item_type)
        self.button_help.setIconSize(QtCore.QSize(16, 16))
        self.button_help.clicked.connect(self.open_help_tab)
        self.header_hbox.addWidget(self.button_help)

        self.header_widget = QtGui.QWidget()
        self.header_widget.setLayout(self.header_hbox)

        # The edit_grid is the layout that contains the actual controls for the
        # items.
        self.edit_grid = QtGui.QGridLayout()
        self.edit_grid.setColumnStretch(2, 2)
        self.edit_grid_widget = QtGui.QWidget()
        self.edit_grid.setMargin(0)
        self.edit_grid_widget.setLayout(self.edit_grid)

        # The edit_vbox contains the edit_grid and the header widget
        self.edit_vbox = QtGui.QVBoxLayout()
        self.edit_vbox.setMargin(5)
        self.edit_vbox.addWidget(self.user_hint_widget)
        self.edit_vbox.addWidget(self.edit_grid_widget)
        if stretch:
            self.edit_vbox.addStretch()
        self._edit_widget = QtGui.QWidget()
        self._edit_widget.setWindowIcon(self.experiment.icon(self.item_type))
        self._edit_widget.setLayout(self.edit_vbox)

        # The _script_widget contains the script editor
        from QProgEdit import QTabManager
        self._script_widget = QTabManager(
            handlerButtonText=_(u'Apply and close'), cfg=cfg)
        self._script_widget.focusLost.connect(self.apply_script_changes)
        self._script_widget.handlerButtonClicked.connect(
            self.set_view_controls)
        self._script_widget.addTab(u'Script').setLang(u'OpenSesame')

        # The container_widget is the top-level widget that is actually inserted
        # into the tab widget.
        self.splitter = qtitem_splitter(self)
        if self.initial_view == u'controls':
            self.set_view_controls()
        elif self.initial_view == u'script':
            self.set_view_script()
        elif self.initial_view == u'split':
            self.set_view_split()
        else:
            debug.msg(u'Invalid initial_view: %s' % self.initial_view,
                      reason=u'warning')
            self.set_view_controls()
        self.splitter.splitterMoved.connect(self.splitter_moved)
        self.container_vbox = QtGui.QVBoxLayout()
        self.container_vbox.addWidget(self.header_widget)
        self.container_vbox.addWidget(self.splitter)
        self.container_widget = QtGui.QWidget()
        self.container_widget.setLayout(self.container_vbox)
        self.container_widget.on_activate = self.show_tab