예제 #1
0
	def __init__(self, sketchpad, parent = None, embed = True):
	
		"""
		Constructor
		
		Arguments:
		sketchpad -- a libopensesame.sketchpad instance
		
		Keyword arguments:
		parent -- a parent widget (default = None)
		"""
			
		QtGui.QWidget.__init__(self, parent)
												
		# Setup the UI
		self.ui = sketchpad_widget_ui.Ui_Form()
		self.ui.setupUi(self)
		self.ui.view.setViewportMargins(0, 0, 0, 0)
		
		self.sketchpad = sketchpad
		self.embed = embed
		
		self.zoom = 1.0
		self.scene = canvas(self)		
		self.ui.view.setScene(self.scene)
		self.item_list = []	
				
		self.vbox_items = QtGui.QVBoxLayout()
		self.ui.widget_items.setLayout(self.vbox_items)
		
		self.ui.button_line.clicked.connect(self.set_line)
		self.ui.button_rect.clicked.connect(self.set_rect)
		self.ui.button_ellipse.clicked.connect(self.set_ellipse)
		self.ui.button_circle.clicked.connect(self.set_circle)
		self.ui.button_arrow.clicked.connect(self.set_arrow)
		self.ui.button_textline.clicked.connect(self.set_textline)
		self.ui.button_fixdot.clicked.connect(self.set_fixdot)
		self.ui.button_image.clicked.connect(self.set_image)
		self.ui.button_gabor.clicked.connect(self.set_gabor)		
		self.ui.button_noise_patch.clicked.connect(self.set_noise)						
		self.ui.button_edit_script.clicked.connect(self.edit_script)
		self.ui.button_colorpicker.clicked.connect(self.colorpicker)		
		self.ui.edit_color.editingFinished.connect(self.set_tool)
		self.ui.spin_penwidth.valueChanged.connect(self.set_tool)
		self.ui.spin_zoom.valueChanged.connect(self.set_tool)
		self.ui.spin_scale.valueChanged.connect(self.set_tool)
		self.ui.spin_grid.valueChanged.connect(self.set_tool)		
		self.ui.spin_arrow_size.valueChanged.connect(self.set_tool)
		self.ui.checkbox_fill.stateChanged.connect(self.set_tool)
		self.ui.checkbox_center.stateChanged.connect(self.set_tool)
		self.ui.checkbox_show_grid.stateChanged.connect(self.set_tool)
		self.ui.combobox_font_family.currentIndexChanged.connect(self.set_tool)
		self.ui.spin_font_size.valueChanged.connect(self.set_tool)		
		self.ui.edit_show_if.editingFinished.connect(self.set_tool)
		
		self.ui.edit_color.setText(self.sketchpad.get("foreground"))
		
		self.set_line()
		self.refresh()
		self.sketchpad.experiment.main_window.theme.apply_theme(self)
예제 #2
0
	def __init__(self, sketchpad, parent = None):
	
		"""
		Initialize the sketchpad widget
		"""
			
		QtGui.QWidget.__init__(self, parent)
												
		# Setup the UI
		self.ui = sketchpad_widget_ui.Ui_Form()
		self.ui.setupUi(self)
		self.ui.view.setViewportMargins(0, 0, 0, 0)
		
		self.sketchpad = sketchpad
		
		self.zoom = 1.0
		self.scene = canvas(self)		
		self.ui.view.setScene(self.scene)
		self.item_list = []	
				
		self.vbox_items = QtGui.QVBoxLayout()
		self.ui.widget_items.setLayout(self.vbox_items)
		
		QtCore.QObject.connect(self.ui.button_line, QtCore.SIGNAL("clicked()"), self.set_line)
		QtCore.QObject.connect(self.ui.button_rect, QtCore.SIGNAL("clicked()"), self.set_rect)
		QtCore.QObject.connect(self.ui.button_ellipse, QtCore.SIGNAL("clicked()"), self.set_ellipse)
		QtCore.QObject.connect(self.ui.button_circle, QtCore.SIGNAL("clicked()"), self.set_circle)
		QtCore.QObject.connect(self.ui.button_arrow, QtCore.SIGNAL("clicked()"), self.set_arrow)
		QtCore.QObject.connect(self.ui.button_textline, QtCore.SIGNAL("clicked()"), self.set_textline)
		QtCore.QObject.connect(self.ui.button_fixdot, QtCore.SIGNAL("clicked()"), self.set_fixdot)
		QtCore.QObject.connect(self.ui.button_image, QtCore.SIGNAL("clicked()"), self.set_image)
		QtCore.QObject.connect(self.ui.button_gabor, QtCore.SIGNAL("clicked()"), self.set_gabor)		
		QtCore.QObject.connect(self.ui.button_noise_patch, QtCore.SIGNAL("clicked()"), self.set_noise)		
				
		QtCore.QObject.connect(self.ui.button_edit_script, QtCore.SIGNAL("clicked()"), self.sketchpad.open_script_tab)
		
		QtCore.QObject.connect(self.ui.edit_color, QtCore.SIGNAL("editingFinished()"), self.set_tool)
		QtCore.QObject.connect(self.ui.spin_penwidth, QtCore.SIGNAL("valueChanged(int)"), self.set_tool)
		QtCore.QObject.connect(self.ui.spin_zoom, QtCore.SIGNAL("valueChanged(int)"), self.set_tool)
		QtCore.QObject.connect(self.ui.spin_scale, QtCore.SIGNAL("valueChanged(double)"), self.set_tool)
		QtCore.QObject.connect(self.ui.spin_grid, QtCore.SIGNAL("valueChanged(int)"), self.set_tool)		
		QtCore.QObject.connect(self.ui.spin_arrow_size, QtCore.SIGNAL("valueChanged(int)"), self.set_tool)
		QtCore.QObject.connect(self.ui.checkbox_fill, QtCore.SIGNAL("stateChanged(int)"), self.set_tool)
		QtCore.QObject.connect(self.ui.checkbox_center, QtCore.SIGNAL("stateChanged(int)"), self.set_tool)
		QtCore.QObject.connect(self.ui.checkbox_show_grid, QtCore.SIGNAL("stateChanged(int)"), self.set_tool)
		QtCore.QObject.connect(self.ui.combobox_font_family, QtCore.SIGNAL("currentIndexChanged(int)"), self.set_tool)
		QtCore.QObject.connect(self.ui.spin_font_size, QtCore.SIGNAL("valueChanged(int)"), self.set_tool)		
		QtCore.QObject.connect(self.ui.edit_show_if, QtCore.SIGNAL("editingFinished()"), self.set_tool)
		
		self.ui.edit_color.setText(self.sketchpad.get("foreground"))
		
		self.set_line()
		self.refresh()
예제 #3
0
    def __init__(self, sketchpad, parent=None):
        """
		Initialize the sketchpad widget
		"""

        QtGui.QWidget.__init__(self, parent)

        # Setup the UI
        self.ui = sketchpad_widget_ui.Ui_Form()
        self.ui.setupUi(self)
        self.ui.view.setViewportMargins(0, 0, 0, 0)

        self.sketchpad = sketchpad

        self.zoom = 1.0
        self.scene = canvas(self)
        self.ui.view.setScene(self.scene)
        self.item_list = []

        self.vbox_items = QtGui.QVBoxLayout()
        self.ui.widget_items.setLayout(self.vbox_items)

        QtCore.QObject.connect(self.ui.button_line, QtCore.SIGNAL("clicked()"),
                               self.set_line)
        QtCore.QObject.connect(self.ui.button_rect, QtCore.SIGNAL("clicked()"),
                               self.set_rect)
        QtCore.QObject.connect(self.ui.button_ellipse,
                               QtCore.SIGNAL("clicked()"), self.set_ellipse)
        QtCore.QObject.connect(self.ui.button_circle,
                               QtCore.SIGNAL("clicked()"), self.set_circle)
        QtCore.QObject.connect(self.ui.button_arrow,
                               QtCore.SIGNAL("clicked()"), self.set_arrow)
        QtCore.QObject.connect(self.ui.button_textline,
                               QtCore.SIGNAL("clicked()"), self.set_textline)
        QtCore.QObject.connect(self.ui.button_fixdot,
                               QtCore.SIGNAL("clicked()"), self.set_fixdot)
        QtCore.QObject.connect(self.ui.button_image,
                               QtCore.SIGNAL("clicked()"), self.set_image)
        QtCore.QObject.connect(self.ui.button_gabor,
                               QtCore.SIGNAL("clicked()"), self.set_gabor)
        QtCore.QObject.connect(self.ui.button_noise_patch,
                               QtCore.SIGNAL("clicked()"), self.set_noise)

        QtCore.QObject.connect(self.ui.button_edit_script,
                               QtCore.SIGNAL("clicked()"),
                               self.sketchpad.open_script_tab)

        QtCore.QObject.connect(self.ui.edit_color,
                               QtCore.SIGNAL("editingFinished()"),
                               self.set_tool)
        QtCore.QObject.connect(self.ui.spin_penwidth,
                               QtCore.SIGNAL("valueChanged(int)"),
                               self.set_tool)
        QtCore.QObject.connect(self.ui.spin_zoom,
                               QtCore.SIGNAL("valueChanged(int)"),
                               self.set_tool)
        QtCore.QObject.connect(self.ui.spin_scale,
                               QtCore.SIGNAL("valueChanged(double)"),
                               self.set_tool)
        QtCore.QObject.connect(self.ui.spin_grid,
                               QtCore.SIGNAL("valueChanged(int)"),
                               self.set_tool)
        QtCore.QObject.connect(self.ui.spin_arrow_size,
                               QtCore.SIGNAL("valueChanged(int)"),
                               self.set_tool)
        QtCore.QObject.connect(self.ui.checkbox_fill,
                               QtCore.SIGNAL("stateChanged(int)"),
                               self.set_tool)
        QtCore.QObject.connect(self.ui.checkbox_center,
                               QtCore.SIGNAL("stateChanged(int)"),
                               self.set_tool)
        QtCore.QObject.connect(self.ui.checkbox_show_grid,
                               QtCore.SIGNAL("stateChanged(int)"),
                               self.set_tool)
        QtCore.QObject.connect(self.ui.combobox_font_family,
                               QtCore.SIGNAL("currentIndexChanged(int)"),
                               self.set_tool)
        QtCore.QObject.connect(self.ui.spin_font_size,
                               QtCore.SIGNAL("valueChanged(int)"),
                               self.set_tool)
        QtCore.QObject.connect(self.ui.edit_show_if,
                               QtCore.SIGNAL("editingFinished()"),
                               self.set_tool)

        self.ui.edit_color.setText(self.sketchpad.get("foreground"))

        self.set_line()
        self.refresh()
예제 #4
0
    def __init__(self, sketchpad, parent=None, embed=True):
        """
		Constructor

		Arguments:
		sketchpad -- a libopensesame.sketchpad instance

		Keyword arguments:
		parent -- a parent widget (default=None)
		"""

        QtGui.QWidget.__init__(self, parent)

        # Setup the UI
        self.ui = sketchpad_widget_ui.Ui_sketchpad_widget()
        self.ui.setupUi(self)
        self.ui.view.setViewportMargins(0, 0, 0, 0)

        self.sketchpad = sketchpad
        self.embed = embed

        self.zoom = 1.0
        self.scene = canvas(self)
        self.ui.view.setScene(self.scene)
        self.item_list = []

        self.vbox_items = QtGui.QVBoxLayout()
        self.ui.widget_items.setLayout(self.vbox_items)

        # Initialize custom color and font widgets
        self.ui.edit_color.initialize(self.sketchpad.experiment, color= \
         self.sketchpad.get('foreground', _eval=False))
        QtCore.QObject.connect(self.ui.edit_color, QtCore.SIGNAL( \
         "set_color"), self.set_tool)
        self.ui.widget_font.initialize(self.sketchpad.experiment)
        QtCore.QObject.connect(self.ui.widget_font, QtCore.SIGNAL( \
         "font_changed"), self.set_tool)

        self.ui.button_line.clicked.connect(self.set_line)
        self.ui.button_rect.clicked.connect(self.set_rect)
        self.ui.button_ellipse.clicked.connect(self.set_ellipse)
        self.ui.button_circle.clicked.connect(self.set_circle)
        self.ui.button_arrow.clicked.connect(self.set_arrow)
        self.ui.button_textline.clicked.connect(self.set_textline)
        self.ui.button_fixdot.clicked.connect(self.set_fixdot)
        self.ui.button_image.clicked.connect(self.set_image)
        self.ui.button_gabor.clicked.connect(self.set_gabor)
        self.ui.button_noise_patch.clicked.connect(self.set_noise)
        self.ui.button_edit_script.clicked.connect(self.edit_script)
        self.ui.spin_penwidth.valueChanged.connect(self.set_tool)
        self.ui.spin_zoom.valueChanged.connect(self.set_tool)
        self.ui.spin_scale.valueChanged.connect(self.set_tool)
        self.ui.spin_grid.valueChanged.connect(self.set_tool)
        self.ui.spin_arrow_size.valueChanged.connect(self.set_tool)
        self.ui.checkbox_fill.stateChanged.connect(self.set_tool)
        self.ui.checkbox_center.stateChanged.connect(self.set_tool)
        self.ui.checkbox_html.stateChanged.connect(self.set_tool)
        self.ui.checkbox_show_grid.stateChanged.connect(self.set_tool)
        self.ui.edit_show_if.editingFinished.connect(self.set_tool)

        self.set_line()
        self.refresh()
        self.sketchpad.experiment.main_window.theme.apply_theme(self)