예제 #1
0
    def __init__(self, parent, app, cms_ref, onchange=None):
        self.cms = cms_ref
        self.app = app
        self.callback = onchange
        wal.HPanel.__init__(self, parent)

        current_palette = self.get_current_palette()
        self.palviewer = PaletteViewer(self, self.cms, current_palette,
                                       self.on_change)
        self.pack(self.palviewer, fill=True)
        self.pack((5, 5))

        view_panel = wal.VPanel(self)
        view_panel.pack(wal.Label(view_panel, _('Palette:')),
                        align_center=False)

        pal_list = self.get_palette_list()
        self.pal = wal.Combolist(view_panel,
                                 items=pal_list,
                                 onchange=self.change_palette)
        current_palette_name = current_palette.model.name
        self.pal.set_active(pal_list.index(current_palette_name))
        view_panel.pack(self.pal, fill=True)

        self.sticker = ColorSticker(view_panel, self.cms)
        view_panel.pack(self.sticker, padding=5)
        self.pack(view_panel, fill=True, expand=True)
        self.palviewer.set_active_color()
예제 #2
0
파일: colorctrls.py 프로젝트: Scrik/sk1-wx
	def __init__(self, parent, app, cms, onchange=None):
		self.cms = cms
		self.app = app
		self.callback = onchange
		wal.HPanel.__init__(self, parent)

		current_palette = self.get_current_palette()
		self.palviewer = PaletteViewer(self, self.cms, current_palette,
									self.on_change)
		self.pack(self.palviewer, fill=True)
		self.pack((5, 5))

		view_panel = wal.VPanel(self)
		view_panel.pack(wal.Label(view_panel, _('Palette:')), align_center=False)

		pal_list = self.get_palette_list()
		self.pal = wal.Combolist(view_panel, items=pal_list,
								onchange=self.change_palette)
		current_palette_name = current_palette.model.name
		self.pal.set_active(pal_list.index(current_palette_name))
		view_panel.pack(self.pal, fill=True)

		self.sticker = ColorSticker(view_panel, self.cms)
		view_panel.pack(self.sticker, padding=5)
		self.pack(view_panel, fill=True, expand=True)
		self.palviewer.set_active_color()
예제 #3
0
class PaletteMixer(wal.HPanel):
    callback = None
    color = None

    def __init__(self, parent, app, cms_ref, onchange=None):
        self.cms = cms_ref
        self.app = app
        self.callback = onchange
        wal.HPanel.__init__(self, parent)

        current_palette = self.get_current_palette()
        self.palviewer = PaletteViewer(self, self.cms, current_palette,
                                       self.on_change)
        self.pack(self.palviewer, fill=True)
        self.pack((5, 5))

        view_panel = wal.VPanel(self)
        view_panel.pack(wal.Label(view_panel, _('Palette:')),
                        align_center=False)

        pal_list = self.get_palette_list()
        self.pal = wal.Combolist(view_panel,
                                 items=pal_list,
                                 onchange=self.change_palette)
        current_palette_name = current_palette.model.name
        self.pal.set_active(pal_list.index(current_palette_name))
        view_panel.pack(self.pal, fill=True)

        self.sticker = ColorSticker(view_panel, self.cms)
        view_panel.pack(self.sticker, padding=5)
        self.pack(view_panel, fill=True, expand=True)
        self.palviewer.set_active_color()

    def change_palette(self):
        palette_name = self.get_palette_name_by_index(self.pal.get_active())
        current_palette = self.get_palette_by_name(palette_name)
        self.palviewer.draw_palette(current_palette)
        self.palviewer.set_active_color()
        self.on_change()

    def on_change(self):
        self.color = self.palviewer.get_color()
        self.sticker.set_color(self.color)
        if self.callback:
            self.callback(self.color)

    def get_color(self):
        return self.color

    # ===Stuff
    def get_current_palette(self):
        current_palette_name = config.palette
        if not current_palette_name:
            return self.app.palettes.palette_in_use
        return self.get_palette_by_name(current_palette_name)

    def get_palette_list(self):
        palettes = self.app.palettes.palettes
        pal_list = palettes.keys()
        pal_list.sort()
        return pal_list

    def get_palette_by_name(self, name):
        palettes = self.app.palettes.palettes
        pal_list = self.get_palette_list()
        if name not in pal_list:
            name = self.app.palettes.get_default_palette_name()
        return palettes[name]

    def get_palette_name_by_index(self, index):
        pal_list = self.get_palette_list()
        return pal_list[index]

    def get_index_by_palette_name(self, name=''):
        pal_list = self.get_palette_list()
        if name not in pal_list:
            name = self.app.palettes.get_default_palette_name()
        return pal_list.index(name)
예제 #4
0
파일: colorctrls.py 프로젝트: Scrik/sk1-wx
class Palette_Mixer(wal.HPanel):

	callback = None

	def __init__(self, parent, app, cms, onchange=None):
		self.cms = cms
		self.app = app
		self.callback = onchange
		wal.HPanel.__init__(self, parent)

		current_palette = self.get_current_palette()
		self.palviewer = PaletteViewer(self, self.cms, current_palette,
									self.on_change)
		self.pack(self.palviewer, fill=True)
		self.pack((5, 5))

		view_panel = wal.VPanel(self)
		view_panel.pack(wal.Label(view_panel, _('Palette:')), align_center=False)

		pal_list = self.get_palette_list()
		self.pal = wal.Combolist(view_panel, items=pal_list,
								onchange=self.change_palette)
		current_palette_name = current_palette.model.name
		self.pal.set_active(pal_list.index(current_palette_name))
		view_panel.pack(self.pal, fill=True)

		self.sticker = ColorSticker(view_panel, self.cms)
		view_panel.pack(self.sticker, padding=5)
		self.pack(view_panel, fill=True, expand=True)
		self.palviewer.set_active_color()

	def change_palette(self):
		palette_name = self.get_palette_name_by_index(self.pal.get_active())
		current_palette = self.get_palette_by_name(palette_name)
		self.palviewer.draw_palette(current_palette)
		self.palviewer.set_active_color()
		self.on_change()

	def on_change(self):
		self.color = self.palviewer.get_color()
		self.sticker.set_color(self.color)
		if self.callback: self.callback(self.color)

	def get_color(self):
		return self.color

	#===Stuff
	def get_current_palette(self):
		current_palette_name = config.palette
		if not current_palette_name:
			return self.app.palettes.palette_in_use
		return self.get_palette_by_name(current_palette_name)

	def get_palette_list(self):
		palettes = self.app.palettes.palettes
		pal_list = palettes.keys()
		pal_list.sort()
		return pal_list

	def get_palette_by_name(self, name):
		palettes = self.app.palettes.palettes
		pal_list = self.get_palette_list()
		if not name in pal_list:
			name = self.app.palettes.get_default_palette_name()
		return palettes[name]

	def get_palette_name_by_index(self, index):
		pal_list = self.get_palette_list()
		return pal_list[index]

	def get_index_by_palette_name(self, name=''):
		pal_list = self.get_palette_list()
		if not name in pal_list:
			name = self.app.palettes.get_default_palette_name()
		return pal_list.index(name)