Example #1
0
    def __init__(self, box):
        """Create the sidebar.
        @box: Parent widget."""

        # Create the notebook and add to parent.
        self.notebook = gtk.Notebook()
        box.pack_start(self.notebook, False, False, 0)

        # Get and set sidebar width.
        width = main.config.getint('sidebar','width')
        self.notebook.set_size_request(width, -1)

        # Append color properies to the sidebar notebook.
        self.color = SidebarColor()
        self.notebook.append_page(self.color.box, gtk.Label(_('Color')))

        # Append layers tree to the sidebar notebook.
        self.layers = SidebarLayers()
        self.notebook.append_page(self.layers.box, gtk.Label(_('Objects')))

        # Append tools properties to sidebar notebook.
        self.tool = gtk.VBox(False, 0)
        self.tool.set_border_width(10)
        self.toolgroup = MultiWidgetGroup(self.tool)
        activetool = main.plugins.activetool
        toolimg_path = os.path.join(main.imgpath, activetool.icon)
        toolimg = gtk.image_new_from_file(toolimg_path)
        self.notebook.append_page(self.tool, toolimg)

        # Display the above widgets (from now will be dynamically displayed).
        self.notebook.show_all()

        # Append tool GUIs to the tool notebook page.
        for name, plug in main.plugins.childs.items():
            if plug.type == 'tool':
                widget = plug.gui()
                gutils.expander(widget)
                MultiWidgetPresets(plug, widget, False)
                self.toolgroup.append(name, widget)

        # Display the properties of active tool (the first one).
        self.toolgroup.show(main.plugins.activetool.name)
    def __init__(self):
        """Create the sidebar color object at program start, including the
        interface controllers."""

        # Configure box.
        self.box = gtk.VBox(False, 0)
        self.box.set_border_width(10)

        # Append callback to color update stack.
        main.color.updated_todo.append(self.update)

        # Red controller.
        self.color_r = MultiWidgetSpin(
            self.box,
            _('Red') + ' (R)',
            True,
            0,
            255,
            main.color.rgb[0],
            lambda x: main.color.set_rgb_component(x, 0))

        # Green controller.
        self.color_g = MultiWidgetSpin(
            self.box,
            _('Green') + ' (G)',
            True,
            0,
            255,
            main.color.rgb[1],
            lambda x: main.color.set_rgb_component(x, 1))

        # Blue controller.
        self.color_b = MultiWidgetSpin(
            self.box,
            _('Blue') + ' (B)',
            True,
            0,
            255,
            main.color.rgb[2],
            lambda x: main.color.set_rgb_component(x, 2))

        # Separator between rgb and hsv.
        gutils.separator(self.box)

        # Hue controller.
        self.color_h = MultiWidgetSpin(
            self.box,
            _('Hue') + ' (H)',
            True,
            0,
            359,
            main.color.hsv[0],
            lambda x: main.color.set_hsv_component(x, 0))

        # Saturation controller.
        self.color_s = MultiWidgetSpin(
            self.box,
            _('Saturation') + ' (S)',
            True,
            0,
            100,
            main.color.hsv[1],
            lambda x: main.color.set_hsv_component(x, 1))

        # Value controller.
        self.color_v = MultiWidgetSpin(
            self.box,
            _('Value') + ' (V)',
            True,
            0,
            100,
            main.color.hsv[2],
            lambda x: main.color.set_hsv_component(x, 2))

        # Separator between hsv and hexadecimal.
        gutils.separator(self.box)

        self.color_hex = MultiWidgetEntry(
            self.box,
            _('Hexadecimal'),
            6,
            main.color.hex,
            main.color.set_hex)

        # Gap to the box bottom.
        gutils.expander(self.box)
        gutils.separator(self.box)

        # Clear button.
        self.clear = MultiWidgetClear(
            self.box,
            1,
            main.color.clear)