コード例 #1
0
ファイル: polygon.py プロジェクト: sk1project/sk1-wx
class PolygonCfgPlugin(CtxPlugin):

    name = "PolygonCfgPlugin"

    def __init__(self, app, parent):
        CtxPlugin.__init__(self, app, parent)
        events.connect(events.CONFIG_MODIFIED, self.config_changed)

    def build(self):
        bmp = get_bmp(self, icons.CTX_POLYGON_CFG, _("Number of angles for newly created polygon"))
        self.add(bmp, 0, LEFT | CENTER, 2)

        self.num_spin = FloatSpin(
            self,
            config.default_polygon_num,
            (3.0, 1000.0),
            1.0,
            0,
            width=3,
            onchange=self.changes,
            spin_overlay=config.spin_overlay,
        )
        self.add(self.num_spin, 0, LEFT | CENTER, 2)

    def changes(self, *args):
        val = self.num_spin.get_value()
        if not config.default_polygon_num == val:
            config.default_polygon_num = val

    def config_changed(self, *args):
        if args[0][0] == "default_polygon_num":
            val = self.num_spin.get_point_value()
            if not config.default_polygon_num == val:
                self.num_spin.set_point_value(config.default_polygon_num)
コード例 #2
0
 def __init__(self,
              app,
              parent,
              val=0.0,
              step=1.0,
              onchange=None,
              onenter=None,
              can_be_negative=False):
     self.app = app
     self.insp = app.insp
     self.point_value = val
     self.ucallback = onchange
     if can_be_negative: self.point_range = (-100000.0, 100000.0)
     if self.insp.is_doc(): self.units = app.current_doc.model.doc_units
     val = self.point_value * point_dict[self.units]
     FloatSpin.__init__(self,
                        parent,
                        val,
                        self.point_range,
                        step=step,
                        width=5,
                        onchange=self.update_point_value,
                        onenter=onenter,
                        spin_overlay=config.spin_overlay)
     self._set_digits(unit_accuracy[self.units])
     self.set_value(self.point_value * point_dict[self.units])
コード例 #3
0
ファイル: polygon.py プロジェクト: sk1project/sk1-wx
class PolygonPlugin(CtxPlugin):

    name = "PolygonPlugin"
    update_flag = False

    def __init__(self, app, parent):
        CtxPlugin.__init__(self, app, parent)
        events.connect(events.DOC_CHANGED, self.update)
        events.connect(events.SELECTION_CHANGED, self.update)

    def build(self):
        bmp = get_bmp(self, icons.CTX_POLYGON_NUM, _("Number of polygon angles"))
        self.add(bmp, 0, LEFT | CENTER, 2)

        self.num_spin = FloatSpin(
            self, 5, (3.0, 1000.0), 1.0, 0, width=3, onchange=self.changes, spin_overlay=config.spin_overlay
        )
        self.add(self.num_spin, 0, LEFT | CENTER, 2)

    def changes(self, *args):
        if self.update_flag:
            return
        val = self.num_spin.get_value()
        if self.insp.is_selection():
            selection = self.app.current_doc.selection
            if self.insp.is_obj_polygon(selection.objs[0]):
                self.app.current_doc.api.set_polygon_corners_num(val)

    def update(self, *args):
        if self.insp.is_selection():
            selection = self.app.current_doc.selection
            if self.insp.is_obj_polygon(selection.objs[0]):
                self.update_flag = True
                self.num_spin.set_value(selection.objs[0].corners_num)
                self.update_flag = False
コード例 #4
0
ファイル: unitctrls.py プロジェクト: Scrik/sk1-wx
	def __init__(self, parent, val=0.0, val_range=(-360.0, 360.0),
				 onchange=None, onenter=None, check_focus=False):
		self.angle_value = val
		self.ucallback = onchange
		FloatSpin.__init__(self, parent, val, val_range, step=1.0, width=5,
						onchange=self.update_angle_value, onenter=onenter,
						check_focus=check_focus, spin_overlay=config.spin_overlay)
コード例 #5
0
ファイル: polygon.py プロジェクト: devurandom/sk1-wx
class PolygonCfgPlugin(CtxPlugin):
    name = 'PolygonCfgPlugin'

    def __init__(self, app, parent):
        CtxPlugin.__init__(self, app, parent)
        events.connect(events.CONFIG_MODIFIED, self.config_changed)

    def build(self):
        bmp = get_bmp(self, icons.CTX_POLYGON_CFG,
            _('Number of angles for newly created polygon'))
        self.add(bmp, 0, LEFT | CENTER, 2)

        self.num_spin = FloatSpin(self, config.default_polygon_num,
            (3.0, 1000.0), 1.0, 0,
            onchange=self.changes)
        self.add(self.num_spin, 0, LEFT | CENTER, 2)

    def changes(self, *args):
        val = self.num_spin.get_value()
        if not config.default_polygon_num == val:
            config.default_polygon_num = val

    def config_changed(self, *args):
        if args[0][0] == 'default_polygon_num':
            val = self.num_spin.get_point_value()
            if not config.default_polygon_num == val:
                self.num_spin.set_point_value(config.default_polygon_num)
コード例 #6
0
ファイル: polygon.py プロジェクト: devurandom/sk1-wx
class PolygonPlugin(CtxPlugin):
    name = 'PolygonPlugin'
    update_flag = False

    def __init__(self, app, parent):
        CtxPlugin.__init__(self, app, parent)
        events.connect(events.DOC_CHANGED, self.update)
        events.connect(events.SELECTION_CHANGED, self.update)

    def build(self):
        bmp = get_bmp(self, icons.CTX_POLYGON_NUM,
            _('Number of polygon angles'))
        self.add(bmp, 0, LEFT | CENTER, 2)

        self.num_spin = FloatSpin(self, 5, (3.0, 1000.0), 1.0, 0,
            onchange=self.changes)
        self.add(self.num_spin, 0, LEFT | CENTER, 2)

    def changes(self, *args):
        if self.update_flag: return
        val = self.num_spin.get_value()
        if self.insp.is_selection():
            selection = self.app.current_doc.selection
            if self.insp.is_obj_polygon(selection.objs[0]):
                self.app.current_doc.api.set_polygon_corners_num(val)

    def update(self, *args):
        if self.insp.is_selection():
            selection = self.app.current_doc.selection
            if self.insp.is_obj_polygon(selection.objs[0]):
                self.update_flag = True
                self.num_spin.set_value(selection.objs[0].corners_num)
                self.update_flag = False
コード例 #7
0
    def build(self):
        bmp = get_bmp(self, icons.CTX_ROUNDED_RECT, _('Rounded rectangle'))
        self.add(bmp, 0, LEFT | CENTER, 2)

        self.slider = Slider(self,
                             0, (0, 100),
                             onchange=self.slider_changes,
                             on_final_change=self.slider_final_changes)
        self.add(self.slider, 0, LEFT | CENTER, 2)

        self.num_spin = FloatSpin(self,
                                  0, (0.0, 100.0),
                                  1.0,
                                  0,
                                  width=3,
                                  onchange=self.changes,
                                  spin_overlay=config.spin_overlay)
        self.add(self.num_spin, 0, LEFT | CENTER, 2)

        self.switch = RectAngleSwitch(self, onchange=self.switch_changed)
        self.add(self.switch, 0, LEFT | CENTER, 3)
        self.switch.hide()

        self.keep_ratio = RatioToggle(self, onchange=self.lock_changed)
        self.add(self.keep_ratio, 0, LEFT | CENTER, 3)
コード例 #8
0
ファイル: polygon.py プロジェクト: devurandom/sk1-wx
    def build(self):
        bmp = get_bmp(self, icons.CTX_POLYGON_NUM,
            _('Number of polygon angles'))
        self.add(bmp, 0, LEFT | CENTER, 2)

        self.num_spin = FloatSpin(self, 5, (3.0, 1000.0), 1.0, 0,
            onchange=self.changes)
        self.add(self.num_spin, 0, LEFT | CENTER, 2)
コード例 #9
0
ファイル: polygon.py プロジェクト: devurandom/sk1-wx
    def build(self):
        bmp = get_bmp(self, icons.CTX_POLYGON_CFG,
            _('Number of angles for newly created polygon'))
        self.add(bmp, 0, LEFT | CENTER, 2)

        self.num_spin = FloatSpin(self, config.default_polygon_num,
            (3.0, 1000.0), 1.0, 0,
            onchange=self.changes)
        self.add(self.num_spin, 0, LEFT | CENTER, 2)
コード例 #10
0
ファイル: unitctrls.py プロジェクト: sk1project/sk1-wx
	def __init__(self, app, parent, val=0.0, step=1.0,
				 onchange=None, onenter=None, can_be_negative=False):
		self.app = app
		self.insp = app.insp
		self.point_value = val
		self.ucallback = onchange
		if can_be_negative:self.point_range = (-100000.0, 100000.0)
		if self.insp.is_doc(): self.units = app.current_doc.model.doc_units
		val = self.point_value * point_dict[self.units]
		FloatSpin.__init__(self, parent, val, self.point_range,
						step=step, width=5,
						onchange=self.update_point_value, onenter=onenter,
						spin_overlay=config.spin_overlay)
		self._set_digits(unit_accuracy[self.units])
		self.set_value(self.point_value * point_dict[self.units])
コード例 #11
0
ファイル: polygon.py プロジェクト: sk1project/sk1-wx
    def build(self):
        bmp = get_bmp(self, icons.CTX_POLYGON_NUM, _("Number of polygon angles"))
        self.add(bmp, 0, LEFT | CENTER, 2)

        self.num_spin = FloatSpin(
            self, 5, (3.0, 1000.0), 1.0, 0, width=3, onchange=self.changes, spin_overlay=config.spin_overlay
        )
        self.add(self.num_spin, 0, LEFT | CENTER, 2)
コード例 #12
0
ファイル: unitctrls.py プロジェクト: wenlibin02/sk1-wx
 def __init__(self,
              parent,
              val=0.0,
              val_range=(-360.0, 360.0),
              onchange=None,
              onenter=None,
              check_focus=False):
     self.angle_value = val
     self.ucallback = onchange
     FloatSpin.__init__(self,
                        parent,
                        val,
                        val_range,
                        step=1.0,
                        width=5,
                        onchange=self.update_angle_value,
                        onenter=onenter,
                        check_focus=check_focus)
コード例 #13
0
ファイル: polygon.py プロジェクト: sk1project/sk1-wx
    def build(self):
        bmp = get_bmp(self, icons.CTX_POLYGON_CFG, _("Number of angles for newly created polygon"))
        self.add(bmp, 0, LEFT | CENTER, 2)

        self.num_spin = FloatSpin(
            self,
            config.default_polygon_num,
            (3.0, 1000.0),
            1.0,
            0,
            width=3,
            onchange=self.changes,
            spin_overlay=config.spin_overlay,
        )
        self.add(self.num_spin, 0, LEFT | CENTER, 2)
コード例 #14
0
ファイル: rect.py プロジェクト: Scrik/sk1-wx
	def build(self):
		bmp = get_bmp(self, icons.CTX_ROUNDED_RECT, _('Rounded rectangle'))
		self.add(bmp, 0, LEFT | CENTER, 2)

		self.slider = Slider(self, 0, (0, 100), onchange=self.slider_changes,
							on_final_change=self.slider_final_changes)
		self.add(self.slider, 0, LEFT | CENTER, 2)

		self.num_spin = FloatSpin(self, 0, (0.0, 100.0), 1.0, 0,
							width=3, onchange=self.changes,
							spin_overlay=config.spin_overlay)
		self.add(self.num_spin, 0, LEFT | CENTER, 2)

		self.switch = RectAngleSwitch(self, onchange=self.switch_changed)
		self.add(self.switch, 0, LEFT | CENTER, 3)
		self.switch.hide()

		self.keep_ratio = RatioToggle(self, onchange=self.lock_changed)
		self.add(self.keep_ratio, 0, LEFT | CENTER, 3)
コード例 #15
0
	def build(self):
		flags = LEFT | CENTER
		pflags = ALL | EXPAND
		#---------Labels
		p = HPanel(self)
		props = [
			('Normal font', False, 0),
			('Bold font', True, 0),
			('-1 font', False, -1),
			('+1 font', False, 1),
			('+2 font', False, 2),
			('+2 bold font', True, 2),
			('+2 red bold font', True, 2, (255, 0, 0)),
			]
		for item in props:
			p.pack(Label(p, *item), padding=5)

		self.pack(p, fill=True)
		self.pack(HLine(self), fill=True, padding=5)

		#---------HtmlLabels
		p = HPanel(self)

		p.pack(HtmlLabel(p, 'http://sk1project.org'), padding=5)
		p.pack(HtmlLabel(p, 'Download site', 'http://sk1project.org'), padding=5)

		self.pack(p, fill=True)
		self.pack(HLine(self), fill=True, padding=5)

		#---------Buttons
		p = HPanel(self)

		p.pack(Button(p, 'Native button'), padding=5)
		txt = 'Native default button'
		p.pack(Button(p, 'Native default button', default=True, tooltip=txt), padding=5)
		p.pack(Button(p, 'Native button with callback', onclick=self.test), padding=5)

		self.pack(p, fill=True)
		self.pack(HLine(self), fill=True, padding=5)

		#---------Checkboxes
		p = HPanel(self)

		p.add(Checkbox(p, 'Native checkbox'), 0, flags, 5)
		p.add(Checkbox(p, 'Native checkbox (checked)', True), 0, flags, 5)
		p.add(Checkbox(p, 'Checkbox with callback', onclick=self.test), 0, flags, 5)
		self.pack(p, fill=True, padding=5)
		self.pack(HLine(self), fill=True, padding=5)

		#---------Radiobuttons
		p = HPanel(self, border=BOTTOM, space=2)

		p.add(Radiobutton(p.panel, 'Native radiobutton', group=True), 0, flags, 5)
		p.add(Radiobutton(p.panel, 'Native radiobutton (selected)'), 0, flags, 5)
		p.add(Radiobutton(p.panel, 'Radiobutton with callback', onclick=self.test), 0, flags, 5)

		self.add(p, 0, pflags)

		#---------Combolist
		p = HPanel(self, border=BOTTOM, space=2)

		sample = ['zero', 'one', 'two', 'three', 'four five', 'six seven eight']
		p.add(Label(p, 'Native combolist:'), 0, flags, 5)
		p.add(Combolist(p, items=sample), 0, flags, 5)
		p.add(Label(p, 'Native combolist with callback:'), 0, flags, 5)
		p.add(Combolist(p, items=sample, onchange=self.test), 0, flags, 5)

		self.add(p, 0, pflags)

		#---------Combobox
		p = HPanel(self, border=BOTTOM, space=2)

		sample = ['zero', 'one', 'two', 'three', 'four five', 'six seven eight']
		p.add(Label(p, 'Native combobox:'), 0, flags, 5)
		p.add(Combobox(p, 'value', items=sample), 0, flags, 5)
		p.add(Label(p, 'Native combobox with callback:'), 0, flags, 5)
		p.add(Combobox(p, items=sample, width=15, onchange=self.test), 0, flags, 5)

		self.add(p, 0, pflags)

		#---------Text entry
		p = HPanel(self, border=BOTTOM, space=2)

		p.add(Label(p, 'Native text entry:'), 0, flags, 5)
		p.add(Entry(p, 'value', width=5), 0, flags, 5)
		p.add(Label(p, 'Native text entry with callback:'), 0, flags, 5)
		p.add(Entry(p, 'value', onchange=self.test), 0, flags, 5)

		self.add(p, 0, pflags)

		#---------Multiline Text entry
		p = HPanel(self, border=BOTTOM, space=2)

		p.add(Label(p, 'Multiline text entry:'), 0, flags, 5)
		p.add(Entry(p, 'value', size=(150, 50), multiline=True), 0, flags, 5)
		p.add(Label(p, 'Multiline text entry with callback:'), 0, flags, 5)
		p.add(Entry(p, 'value', size=(150, 50), multiline=True,
				onchange=self.test), 0, flags, 5)

		self.add(p, 0, pflags)

		#---------Spin
		p = HPanel(self, border=BOTTOM, space=2)

		p.add(Label(p, 'Native spin control:'), 0, flags, 5)
		p.add(Spin(p, 1, (0, 90), onchange=self.test), 0, flags, 5)
		p.add(Label(p, 'Float spin control:'), 0, flags, 5)
		self.spin = FloatSpin(p.panel, 1.3, (0.0, 90.0), 0.01, 3, width=5,
					onchange=self.test)
		p.add(self.spin, 0, flags, 5)
		p.add(Button(p, 'Get value', onclick=self.test_spin), 0, flags, 5)

		self.add(p, 0, pflags)

		#---------Slider
		p = HPanel(self, border=BOTTOM, space=2)

		p.add(Label(p, 'Native slider:'), 0, flags, 5)
		p.add(Slider(p.panel, 25, (0, 255), onchange=self.test), 0, flags, 5)

		self.add(p, 0, pflags)

		#---------Labeled panel
		p = HPanel(self)

		panel = LabeledPanel(p, 'The panel')
		panel.add((0, 50), 0, flags, 0)
		panel.add(Label(p, 'Native Labeled Panel'), 0, flags, 0)
		p.box_add(panel.box, 0, flags, 5)


		panel = LabeledPanel(p)
		panel.add((0, 50), 0, flags, 0)
		panel.add(Label(p, 'Headless Labeled Panel'), 0, flags, 0)
		p.box_add(panel.box, 0, flags, 5)

		p.add(VLine(p), 0, ALL | EXPAND, 3)

		nb = Notebook(p)
		page = VPanel(nb)
		page.add((50, 100))
		nb.add_page(page, 'First page')
		page = VPanel(nb)
		page.add((50, 100))
		nb.add_page(page, 'Second page')
		p.add(nb, 1, ALL | EXPAND, 3)

		self.add(p, 0, pflags)
コード例 #16
0
class RectanglePlugin(CtxPlugin):

    name = 'RectanglePlugin'
    corners = [0, 0, 0, 0]
    orig_corners = [0, 0, 0, 0]
    update_flag = False
    active_corner = 0

    def __init__(self, app, parent):
        CtxPlugin.__init__(self, app, parent)
        events.connect(events.DOC_CHANGED, self.update)
        events.connect(events.SELECTION_CHANGED, self.update)

    def build(self):
        bmp = get_bmp(self, icons.CTX_ROUNDED_RECT, _('Rounded rectangle'))
        self.add(bmp, 0, LEFT | CENTER, 2)

        self.slider = Slider(self,
                             0, (0, 100),
                             onchange=self.slider_changes,
                             on_final_change=self.slider_final_changes)
        self.add(self.slider, 0, LEFT | CENTER, 2)

        self.num_spin = FloatSpin(self,
                                  0, (0.0, 100.0),
                                  1.0,
                                  0,
                                  width=3,
                                  onchange=self.changes,
                                  spin_overlay=config.spin_overlay)
        self.add(self.num_spin, 0, LEFT | CENTER, 2)

        self.switch = RectAngleSwitch(self, onchange=self.switch_changed)
        self.add(self.switch, 0, LEFT | CENTER, 3)
        self.switch.hide()

        self.keep_ratio = RatioToggle(self, onchange=self.lock_changed)
        self.add(self.keep_ratio, 0, LEFT | CENTER, 3)

    def lock_changed(self, *args):
        self.switch.set_visible(not self.keep_ratio.get_active())
        self.parent.Layout()
        if self.keep_ratio.get_active():
            val = self.corners[self.active_corner]
            self.active_corner = 0
            self.switch.set_index(0)
            if not self.update_flag: self.apply_changes(val)
        self.update_vals()

    def switch_changed(self):
        self.active_corner = self.switch.get_index()
        self.update_vals()

    def slider_changes(self):
        if self.update_flag: return
        self.apply_changes(self.slider.get_value() / 100.0)

    def slider_final_changes(self):
        if self.update_flag: return
        self.apply_changes(self.slider.get_value() / 100.0, True)

    def changes(self, *args):
        if self.update_flag: return
        self.apply_changes(self.num_spin.get_value() / 100.0)

    def apply_changes(self, val, final=False):
        if self.insp.is_selection():
            selection = self.app.current_doc.selection
            if self.insp.is_obj_rect(selection.objs[0]):
                if self.keep_ratio.get_active():
                    self.corners = [val, val, val, val]
                else:
                    self.corners[self.active_corner] = val
                api = self.app.current_doc.api
                if final:
                    api.set_rect_corners_final(self.corners, self.orig_corners)
                    self.orig_corners = [] + self.corners
                else:
                    api.set_rect_corners(self.corners)

    def update_vals(self):
        self.update_flag = True
        self.slider.set_value(int(self.corners[self.active_corner] * 100))
        self.num_spin.set_value(self.corners[self.active_corner] * 100.0)
        self.update_flag = False

    def update(self, *args):
        if self.insp.is_selection():
            selection = self.app.current_doc.selection
            if self.insp.is_obj_rect(selection.objs[0]):
                corners = [] + selection.objs[0].corners
                if self.corners == corners:
                    self.update_vals()
                else:
                    self.corners = corners
                    self.orig_corners = [] + corners
                    self.update_flag = True
                    state = (corners[0] == corners[1] == corners[2] ==
                             corners[3])
                    self.keep_ratio.set_active(state)
                    self.lock_changed()
コード例 #17
0
ファイル: rect.py プロジェクト: Scrik/sk1-wx
class RectanglePlugin(CtxPlugin):

	name = 'RectanglePlugin'
	corners = [0, 0, 0, 0]
	orig_corners = [0, 0, 0, 0]
	update_flag = False
	active_corner = 0

	def __init__(self, app, parent):
		CtxPlugin.__init__(self, app, parent)
		events.connect(events.DOC_CHANGED, self.update)
		events.connect(events.SELECTION_CHANGED, self.update)

	def build(self):
		bmp = get_bmp(self, icons.CTX_ROUNDED_RECT, _('Rounded rectangle'))
		self.add(bmp, 0, LEFT | CENTER, 2)

		self.slider = Slider(self, 0, (0, 100), onchange=self.slider_changes,
							on_final_change=self.slider_final_changes)
		self.add(self.slider, 0, LEFT | CENTER, 2)

		self.num_spin = FloatSpin(self, 0, (0.0, 100.0), 1.0, 0,
							width=3, onchange=self.changes,
							spin_overlay=config.spin_overlay)
		self.add(self.num_spin, 0, LEFT | CENTER, 2)

		self.switch = RectAngleSwitch(self, onchange=self.switch_changed)
		self.add(self.switch, 0, LEFT | CENTER, 3)
		self.switch.hide()

		self.keep_ratio = RatioToggle(self, onchange=self.lock_changed)
		self.add(self.keep_ratio, 0, LEFT | CENTER, 3)

	def lock_changed(self, *args):
		self.switch.set_visible(not self.keep_ratio.get_active())
		self.parent.Layout()
		if self.keep_ratio.get_active():
			val = self.corners[self.active_corner]
			self.active_corner = 0
			self.switch.set_index(0)
			if not self.update_flag: self.apply_changes(val)
		self.update_vals()

	def switch_changed(self):
		self.active_corner = self.switch.get_index()
		self.update_vals()

	def slider_changes(self):
		if self.update_flag: return
		self.apply_changes(self.slider.get_value() / 100.0)

	def slider_final_changes(self):
		if self.update_flag: return
		self.apply_changes(self.slider.get_value() / 100.0, True)

	def changes(self, *args):
		if self.update_flag: return
		self.apply_changes(self.num_spin.get_value() / 100.0)

	def apply_changes(self, val, final=False):
		if self.insp.is_selection():
			selection = self.app.current_doc.selection
			if self.insp.is_obj_rect(selection.objs[0]):
				if self.keep_ratio.get_active():
					self.corners = [val, val, val, val]
				else:
					self.corners[self.active_corner] = val
				api = self.app.current_doc.api
				if final:
					api.set_rect_corners_final(self.corners, self.orig_corners)
					self.orig_corners = [] + self.corners
				else:
					api.set_rect_corners(self.corners)

	def update_vals(self):
		self.update_flag = True
		self.slider.set_value(int(self.corners[self.active_corner] * 100))
		self.num_spin.set_value(self.corners[self.active_corner] * 100.0)
		self.update_flag = False

	def update(self, *args):
		if self.insp.is_selection():
			selection = self.app.current_doc.selection
			if self.insp.is_obj_rect(selection.objs[0]):
				corners = [] + selection.objs[0].corners
				if self.corners == corners:
					self.update_vals()
				else:
					self.corners = corners
					self.orig_corners = [] + corners
					self.update_flag = True
					state = (corners[0] == corners[1] == corners[2] == corners[3])
					self.keep_ratio.set_active(state)
					self.lock_changed()