Пример #1
0
    def create_widgets(self, frame, idx, set_active_layer, rename,
		       set_layer_state, set_color, context_menu):
	self.index.SetValue(idx)
	idx = (self.index,)
	self.button = UpdatedRadiobutton(frame, anchor = W, value = idx,
					 width = 10,
					 variable = self.active_var,
					 command = set_active_layer)
	self.button.bind('<ButtonPress-3>', context_menu)
	self.button.bind('<ButtonPress-2>', rename)
	self.button.bind('<Double-Button-1>', rename)
	self.var_visible = IntVar(frame)
	self.visible = UpdatedCheckbutton(frame, variable = self.var_visible,
					  indicatoron = 0, selectcolor = '',
					  command = set_layer_state,
					  args = idx)
	self.var_printable = IntVar(frame)
	self.printable = UpdatedCheckbutton(frame,
					    variable = self.var_printable,
					    indicatoron = 0, selectcolor = '',
					    command = set_layer_state,
					    args = idx)
	self.var_locked = IntVar(frame)
	self.locked = UpdatedCheckbutton(frame, variable = self.var_locked,
					 indicatoron = 0, selectcolor = '',
					 command = set_layer_state, args = idx)
	self.var_outlined = IntVar(frame)
	self.outlined = UpdatedCheckbutton(frame, variable = self.var_outlined,
					   indicatoron = 0, selectcolor = '',
					   command = set_layer_state,
					   args = idx)
	self.color = ColorButton(frame, command = set_color, args = idx,
				 width = 2,
				 dialog_master =
				 frame.master.master.master.master)
Пример #2
0
    def build_dlg(self):
        top = self.top

        self.view = SketchView(top,
                               self.document,
                               width=200,
                               height=200,
                               background='white')
        self.view.pack(side=LEFT, fill=BOTH, expand=1)

        self.opt_format = MyOptionMenu2(top, bitmap_types)
        self.opt_format.pack(side=TOP)

        frame = Frame(top)
        frame.pack(side=TOP, expand=1, fill=X)
        label = Label(frame, text='Resolution')
        label.pack(side=LEFT)
        entry = MyEntry(frame, width=4)
        entry.pack(side=LEFT)
        label = Label(frame, text='dpi')
        label.pack(side=LEFT)

        frame = Frame(top)
        frame.pack(side=TOP, expand=1, fill=X)
        label = Label(frame, text='Size')
        label.pack(side=LEFT)
        entry = MyEntry(frame, width=4)
        entry.pack(side=LEFT)
        label = Label(frame, text='x')
        label.pack(side=LEFT)
        entry = MyEntry(frame, width=4)
        entry.pack(side=LEFT)
        label = Label(frame, text='pixel')
        label.pack(side=LEFT)

        check = UpdatedCheckbutton(top, text='antialiasing')
        check.pack(side=TOP)

        frame = Frame(top)
        frame.pack(side=TOP)
        button = UpdatedButton(frame, text='Export')
        button.pack(side=LEFT)
        button = UpdatedButton(frame, text='Close', command=self.close_dlg)
        button.pack(side=LEFT)
Пример #3
0
    def build_dlg(self):
	top = self.top

	self.view = SketchView(top, self.document, width = 200, height = 200,
			       background = 'white')
	self.view.pack(side = LEFT, fill = BOTH, expand = 1)

	self.opt_format = MyOptionMenu2(top, bitmap_types)
	self.opt_format.pack(side = TOP)

	frame = Frame(top)
	frame.pack(side = TOP, expand = 1, fill = X)
	label = Label(frame, text = 'Resolution')
	label.pack(side = LEFT)
	entry = MyEntry(frame, width = 4)
	entry.pack(side = LEFT)
	label = Label(frame, text = 'dpi')
	label.pack(side = LEFT)

	frame = Frame(top)
	frame.pack(side = TOP, expand = 1, fill = X)
	label = Label(frame, text = 'Size')
	label.pack(side = LEFT)
	entry = MyEntry(frame, width = 4)
	entry.pack(side = LEFT)
	label = Label(frame, text = 'x')
	label.pack(side = LEFT)
	entry = MyEntry(frame, width = 4)
	entry.pack(side = LEFT)
	label = Label(frame, text = 'pixel')
	label.pack(side = LEFT)

	check = UpdatedCheckbutton(top, text = 'antialiasing')
	check.pack(side = TOP)

	frame = Frame(top)
	frame.pack(side =TOP)
	button = UpdatedButton(frame, text = 'Export')
	button.pack(side = LEFT)
	button = UpdatedButton(frame, text = 'Close', command = self.close_dlg)
	button.pack(side = LEFT)
Пример #4
0
 def create_widgets(self, frame, idx, set_active_layer, rename,
                    set_layer_state, set_color, context_menu):
     self.index.SetValue(idx)
     idx = (self.index, )
     self.button = UpdatedRadiobutton(frame,
                                      anchor=W,
                                      value=idx,
                                      width=10,
                                      variable=self.active_var,
                                      command=set_active_layer)
     self.button.bind('<ButtonPress-3>', context_menu)
     self.button.bind('<ButtonPress-2>', rename)
     self.button.bind('<Double-Button-1>', rename)
     self.var_visible = IntVar(frame)
     self.visible = UpdatedCheckbutton(frame,
                                       variable=self.var_visible,
                                       indicatoron=0,
                                       selectcolor='',
                                       command=set_layer_state,
                                       args=idx)
     self.var_printable = IntVar(frame)
     self.printable = UpdatedCheckbutton(frame,
                                         variable=self.var_printable,
                                         indicatoron=0,
                                         selectcolor='',
                                         command=set_layer_state,
                                         args=idx)
     self.var_locked = IntVar(frame)
     self.locked = UpdatedCheckbutton(frame,
                                      variable=self.var_locked,
                                      indicatoron=0,
                                      selectcolor='',
                                      command=set_layer_state,
                                      args=idx)
     self.var_outlined = IntVar(frame)
     self.outlined = UpdatedCheckbutton(frame,
                                        variable=self.var_outlined,
                                        indicatoron=0,
                                        selectcolor='',
                                        command=set_layer_state,
                                        args=idx)
     self.color = ColorButton(
         frame,
         command=set_color,
         args=idx,
         width=2,
         dialog_master=frame.master.master.master.master)
Пример #5
0
    def build_dlg(self):
        top = self.top

        #
        #	Undo
        #

        undo_frame = self.make_frame()
        label = Label(undo_frame, text=_("# Undo Levels:"), anchor=E)
        label.pack(side=LEFT, expand=1, fill=X)

        self.var_undo = IntVar(top)
        self.undo_entry = Entry(undo_frame,
                                textvariable=self.var_undo,
                                width=4)
        self.undo_entry.pack(side=LEFT)
        self.var_unlimited = IntVar(top)
        check = UpdatedCheckbutton(undo_frame,
                                   text=_("unlimited"),
                                   variable=self.var_unlimited,
                                   command=self.unlimited_undo)
        check.pack(side=RIGHT, expand=1, anchor=W)
        limit = preferences.undo_limit
        if limit == None:
            self.var_undo.set(10)
            self.var_unlimited.set(1)
        else:
            if limit < 0:
                limit = 0
            self.var_undo.set(limit)
            self.var_unlimited.set(0)

        #
        #	Duplication
        #

        off_frame = self.make_frame()
        var_off_x_number = DoubleVar(top)
        var_off_y_number = DoubleVar(top)
        var_off_x_unit = StringVar(top)
        var_off_y_unit = StringVar(top)
        x, y = preferences.duplicate_offset
        unit = config.preferences.default_unit
        self.var_off_x = LengthVar(x, unit, var_off_x_number, var_off_x_unit)
        self.var_off_y = LengthVar(y, unit, var_off_y_number, var_off_y_unit)
        label = Label(off_frame, text=_("Duplication Offset"))
        label.pack(side=TOP, anchor=W)
        label = Label(off_frame, text=_("Hor."))
        label.pack(side=LEFT, expand=1, anchor=E)
        entry = MyEntry(off_frame,
                        textvariable=var_off_x_number,
                        width=6,
                        command=self.var_off_x.UpdateNumber)
        entry.pack(side=LEFT, fill=X, anchor=E)
        label = Label(off_frame, text=_("Vert."))
        label.pack(side=LEFT, anchor=E)
        entry = MyEntry(off_frame,
                        textvariable=var_off_y_number,
                        width=6,
                        command=self.var_off_y.UpdateNumber)
        entry.pack(side=LEFT, fill=X, anchor=E)

        def CallBoth(arg, x=self.var_off_x, y=self.var_off_y):
            x.UpdateUnit(arg)
            y.UpdateUnit(arg)

        optmenu = create_unit_menu(off_frame,
                                   CallBoth,
                                   variable=var_off_x_unit,
                                   indicatoron=0,
                                   width=3)
        optmenu.pack(side=LEFT, expand=1, anchor=W)

        #
        #       Default Unit
        #

        self.default_unit = config.preferences.default_unit
        frame = self.make_frame()
        label = Label(frame, text=_("Default Unit"))
        label.pack(side=LEFT, expand=1)
        menu = create_unit_menu(frame,
                                self.set_unit,
                                indicatoron=0,
                                width=3,
                                text=self.default_unit)
        menu.pack(side=RIGHT, expand=1)

        #
        #	Gradient Patterns
        #

        #self.var_steps = IntVar(top)
        #self.var_steps.set(preferences.gradient_steps)
        #frame = self.make_frame()
        #label = Label(frame, text = 'Gradient Steps')

        #
        #	Standard Buttons (OK, Cancel)
        #

        but_frame = Frame(top)
        but_frame.pack(side=BOTTOM, fill=BOTH, expand=1, padx=4, pady=4)
        button = UpdatedButton(but_frame, text=_("OK"), command=self.ok)
        button.pack(side=LEFT, expand=1)
        button = UpdatedButton(but_frame,
                               text=_("Cancel"),
                               command=self.close_dlg)
        button.pack(side=RIGHT, expand=1)
Пример #6
0
    def build_dlg(self):
        top = self.top

        button_frame = self.create_std_buttons(top)
        button_frame.grid(row=5, columnspan=2, sticky='ew')

        color_frame = Frame(top, relief=GROOVE, bd=2)
        color_frame.grid(row=0, columnspan=2, sticky='ew')
        label = Label(color_frame, text=_("Color"))
        label.pack(side=LEFT, expand=1, anchor=E)
        self.color_but = ColorButton(color_frame,
                                     width=3,
                                     height=1,
                                     command=self.set_line_color)
        self.color_but.SetColor(StandardColors.black)
        self.color_but.pack(side=LEFT, expand=1, anchor=W)
        self.var_color_none = IntVar(top)
        check = UpdatedCheckbutton(color_frame,
                                   text=_("None"),
                                   variable=self.var_color_none,
                                   command=self.do_apply)
        check.pack(side=LEFT, expand=1)

        width_frame = Frame(top, relief=GROOVE, bd=2)
        width_frame.grid(row=1, columnspan=2, sticky='ew')
        label = Label(width_frame, text=_("Width"))
        label.pack(side=LEFT, expand=1, anchor=E)

        self.var_width = create_length_entry(top,
                                             width_frame,
                                             self.set_line_width,
                                             scroll_pad=0)

        tkwin = self.main_window.canvas.tkwin
        gc, bitmap, dashlist = create_dash_images(self.top.tk, tkwin,
                                                  StandardDashes())
        self.opt_dash = MyOptionMenu2(top,
                                      dashlist,
                                      command=self.set_dash,
                                      entry_type='image',
                                      highlightthickness=0)
        self.opt_dash.grid(row=2, columnspan=2, sticky='ew', ipady=2)
        self.dash_gc = gc
        self.dash_bitmap = bitmap

        gc, bitmap, arrow1, arrow2 = create_arrow_images(
            self.top.tk, tkwin, StandardArrows())
        self.opt_arrow1 = MyOptionMenu2(top,
                                        arrow1,
                                        command=self.set_arrow,
                                        args=1,
                                        entry_type='image',
                                        highlightthickness=0)
        self.opt_arrow1.grid(row=3, column=0, sticky='ew', ipady=2)
        self.opt_arrow2 = MyOptionMenu2(top,
                                        arrow2,
                                        command=self.set_arrow,
                                        args=2,
                                        entry_type='image',
                                        highlightthickness=0)
        self.opt_arrow2.grid(row=3, column=1, sticky='ew', ipady=2)
        self.arrow_gc = gc
        self.arrow_bitmap = bitmap

        self.opt_join = MyOptionMenu2(top, [(pixmaps.JoinMiter, JoinMiter),
                                            (pixmaps.JoinRound, JoinRound),
                                            (pixmaps.JoinBevel, JoinBevel)],
                                      command=self.set_line_join,
                                      entry_type='bitmap',
                                      highlightthickness=0)
        self.opt_join.grid(row=4, column=0, sticky='ew')

        self.opt_cap = MyOptionMenu2(top,
                                     [(pixmaps.CapButt, CapButt),
                                      (pixmaps.CapRound, CapRound),
                                      (pixmaps.CapProjecting, CapProjecting)],
                                     command=self.set_line_cap,
                                     entry_type='bitmap',
                                     highlightthickness=0)
        self.opt_cap.grid(row=4, column=1, sticky='ew')
        self.opt_cap.SetValue(None)
Пример #7
0
    def build_dlg(self):
	top = self.top

	# a bit of a hack to accept drops...
	top.accept_drop = (DROP_COLOR,)
	top.DropAt = self.DropAt

	# the standard buttons (apply, cancel, update...)
	button_frame = self.create_std_buttons(top)
	button_frame.pack(side = BOTTOM, fill = X, expand = 0)

	#
	self.var_transform = IntVar(top)
	self.var_transform.set(1)
	button = UpdatedCheckbutton(top, text = _("Transform Pattern"),
				    variable = self.var_transform,
				    command = self.set_fill_transform)
	button.pack(side = BOTTOM, fill = X)

	# type frame
	type_frame = Frame(top)
	type_frame.pack(side = LEFT, fill = Y, expand = 0)

	# sample
	self.sample = InteractiveSample(top, width = 60, height = 60,
					background = 'white')
	self.sample.pack(side = TOP, fill = X, anchor = N)
	self.sample.SetPattern(EmptyPattern)
	self.sample.Subscribe(CENTER, self.center_changed)
	self.sample.Subscribe(DIRECTION, self.direction_changed)

	# pattern frames
	self.frames = [None, None, None, None, None]
	self.frames[0] = PatternFrame(top)
	self.frames[1] = SolidPatternFrame(top)
	self.frames[2] = GradientPatternFrame(top)
	self.frames[3] = HatchingPatternFrame(top)
	self.frames[4] = ImageTilePatternFrame(top,
					       main_window = self.main_window)

	width = 0
	for frame in self.frames:
	    frame.Subscribe(CHANGED, self.pattern_changed, 1)
	    frame.update()
	    w = frame.winfo_reqwidth()
	    if w > width:
		width = w

	self.sample.config(width = width)

	self.var_pattern_type = IntVar(top)
	types = ((0, pixmaps.fill_none), (1, pixmaps.fill_solid),
		 (2, pixmaps.fill_gradient), (3, pixmaps.fill_hatch),
		 (4, pixmaps.fill_tile))
	for value, bitmap in types:
	    button = make_button(type_frame, bitmap = bitmap, value = value,
				 variable = self.var_pattern_type,
				 command = self.choose_pattern)
	    button.pack(side = TOP)

	# unknown
	self.frame_unknown = PatternFrame(top)

	self.active_frame = None
Пример #8
0
    def build_dlg(self):
        top = self.top

        button_frame = self.create_std_buttons(top)
        button_frame.grid(row = 5, columnspan = 2, sticky = 'ew')

        color_frame = Frame(top, relief = GROOVE, bd = 2)
        color_frame.grid(row = 0, columnspan = 2, sticky = 'ew')
        label = Label(color_frame, text = _("Color"))
        label.pack(side = LEFT, expand = 1, anchor = E)
        self.color_but = ColorButton(color_frame, width = 3, height = 1,
                                     command = self.set_line_color)
        self.color_but.SetColor(StandardColors.black)
        self.color_but.pack(side = LEFT, expand = 1, anchor = W)
        self.var_color_none = IntVar(top)
        check = UpdatedCheckbutton(color_frame, text = _("None"),
                                   variable = self.var_color_none,
                                   command = self.do_apply)
        check.pack(side = LEFT, expand = 1)

        width_frame = Frame(top, relief = GROOVE, bd = 2)
        width_frame.grid(row = 1, columnspan = 2, sticky = 'ew')
        label = Label(width_frame, text = _("Width"))
        label.pack(side = LEFT, expand = 1, anchor = E)

        self.var_width = create_length_entry(top, width_frame,
                                             self.set_line_width,
                                             scroll_pad = 0)

        tkwin = self.main_window.canvas.tkwin
        gc, bitmap, dashlist = create_dash_images(self.top.tk, tkwin,
                                                  StandardDashes())
        self.opt_dash = MyOptionMenu2(top, dashlist, command = self.set_dash,
                                      entry_type = 'image',
                                      highlightthickness = 0)
        self.opt_dash.grid(row = 2, columnspan = 2, sticky = 'ew', ipady = 2)
        self.dash_gc = gc
        self.dash_bitmap = bitmap

        gc, bitmap, arrow1, arrow2 = create_arrow_images(self.top.tk, tkwin,
                                                         StandardArrows())
        self.opt_arrow1 = MyOptionMenu2(top, arrow1, command = self.set_arrow,
                                        args = 1, entry_type = 'image',
                                        highlightthickness = 0)
        self.opt_arrow1.grid(row = 3, column = 0, sticky = 'ew', ipady = 2)
        self.opt_arrow2 = MyOptionMenu2(top, arrow2, command = self.set_arrow,
                                        args = 2, entry_type = 'image',
                                        highlightthickness = 0)
        self.opt_arrow2.grid(row = 3, column = 1, sticky = 'ew', ipady = 2)
        self.arrow_gc = gc
        self.arrow_bitmap = bitmap

        self.opt_join = MyOptionMenu2(top, [(pixmaps.JoinMiter, JoinMiter),
                                            (pixmaps.JoinRound, JoinRound),
                                            (pixmaps.JoinBevel, JoinBevel)],
                                      command = self.set_line_join,
                                      entry_type = 'bitmap',
                                      highlightthickness = 0)
        self.opt_join.grid(row = 4, column = 0, sticky = 'ew')

        self.opt_cap = MyOptionMenu2(top,
                                     [(pixmaps.CapButt, CapButt),
                                      (pixmaps.CapRound, CapRound),
                                      (pixmaps.CapProjecting, CapProjecting)],
                                     command = self.set_line_cap,
                                     entry_type = 'bitmap',
                                     highlightthickness = 0)
        self.opt_cap.grid(row = 4, column = 1, sticky = 'ew')
        self.opt_cap.SetValue(None)
Пример #9
0
    def build_dlg(self):
	top = self.top

	#
	#	Undo
	#

	undo_frame = self.make_frame()
	label = Label(undo_frame, text = _("# Undo Levels:"), anchor = E)
	label.pack(side = LEFT, expand = 1, fill = X)

	self.var_undo = IntVar(top)
	self.undo_entry = Entry(undo_frame, textvariable = self.var_undo,
				width = 4)
	self.undo_entry.pack(side = LEFT)
	self.var_unlimited = IntVar(top)
	check = UpdatedCheckbutton(undo_frame,
				   text = _("unlimited"),
				   variable = self.var_unlimited,
				   command = self.unlimited_undo)
	check.pack(side = RIGHT, expand = 1, anchor = W)
	limit = preferences.undo_limit
	if limit == None:
	    self.var_undo.set(10)
	    self.var_unlimited.set(1)
	else:
	    if limit < 0:
		limit = 0
	    self.var_undo.set(limit)
	    self.var_unlimited.set(0)


	#
	#	Duplication
	#

	off_frame = self.make_frame()
	var_off_x_number = DoubleVar(top)
	var_off_y_number = DoubleVar(top)
	var_off_x_unit = StringVar(top)
	var_off_y_unit = StringVar(top)
	x, y = preferences.duplicate_offset
        unit = config.preferences.default_unit
	self.var_off_x = LengthVar(x, unit, var_off_x_number, var_off_x_unit)
	self.var_off_y = LengthVar(y, unit, var_off_y_number, var_off_y_unit)
	label = Label(off_frame, text = _("Duplication Offset"))
	label.pack(side = TOP, anchor = W)
	label = Label(off_frame, text = _("Hor."))
	label.pack(side = LEFT, expand = 1, anchor = E)
	entry = MyEntry(off_frame, textvariable = var_off_x_number,
			width = 6, command = self.var_off_x.UpdateNumber)
	entry.pack(side = LEFT, fill = X, anchor = E)
	label = Label(off_frame, text = _("Vert."))
	label.pack(side = LEFT, anchor = E)
	entry = MyEntry(off_frame, textvariable = var_off_y_number,
			width = 6, command = self.var_off_y.UpdateNumber)
	entry.pack(side = LEFT, fill = X, anchor = E)

	def CallBoth(arg, x = self.var_off_x, y = self.var_off_y):
	    x.UpdateUnit(arg)
	    y.UpdateUnit(arg)

	optmenu = create_unit_menu(off_frame, CallBoth,
				   variable = var_off_x_unit,
				   indicatoron = 0, width = 3)
	optmenu.pack(side = LEFT, expand = 1, anchor = W)

        #
        #       Default Unit
        #

        self.default_unit = config.preferences.default_unit
        frame = self.make_frame()
        label = Label(frame, text = _("Default Unit"))
        label.pack(side = LEFT, expand = 1)
        menu = create_unit_menu(frame, self.set_unit, indicatoron = 0,
                                width = 3, text = self.default_unit)
        menu.pack(side = RIGHT, expand = 1)


	#
	#	Gradient Patterns
	#

	#self.var_steps = IntVar(top)
	#self.var_steps.set(preferences.gradient_steps)
	#frame = self.make_frame()
	#label = Label(frame, text = 'Gradient Steps')


	#
	#	Standard Buttons (OK, Cancel)
	#

	but_frame = Frame(top)
	but_frame.pack(side = BOTTOM, fill = BOTH, expand = 1,
		       padx = 4, pady = 4)
	button = UpdatedButton(but_frame, text = _("OK"), command = self.ok)
	button.pack(side = LEFT, expand = 1)
	button = UpdatedButton(but_frame, text = _("Cancel"),
			       command = self.close_dlg)
	button.pack(side = RIGHT, expand = 1)
Пример #10
0
class LayerInfo:

    def __init__(self, frame, idx, info, active_var, rename, set_active_layer,
		 set_layer_state, set_color, context_menu):
	self.index = MutableNumber()
	self.active_var = active_var
	self.create_widgets(frame, idx, set_active_layer, rename,
			    set_layer_state, set_color, context_menu)
	if info:
	    self.SetInfo(info)

    def create_widgets(self, frame, idx, set_active_layer, rename,
		       set_layer_state, set_color, context_menu):
	self.index.SetValue(idx)
	idx = (self.index,)
	self.button = UpdatedRadiobutton(frame, anchor = W, value = idx,
					 width = 10,
					 variable = self.active_var,
					 command = set_active_layer)
	self.button.bind('<ButtonPress-3>', context_menu)
	self.button.bind('<ButtonPress-2>', rename)
	self.button.bind('<Double-Button-1>', rename)
	self.var_visible = IntVar(frame)
	self.visible = UpdatedCheckbutton(frame, variable = self.var_visible,
					  indicatoron = 0, selectcolor = '',
					  command = set_layer_state,
					  args = idx)
	self.var_printable = IntVar(frame)
	self.printable = UpdatedCheckbutton(frame,
					    variable = self.var_printable,
					    indicatoron = 0, selectcolor = '',
					    command = set_layer_state,
					    args = idx)
	self.var_locked = IntVar(frame)
	self.locked = UpdatedCheckbutton(frame, variable = self.var_locked,
					 indicatoron = 0, selectcolor = '',
					 command = set_layer_state, args = idx)
	self.var_outlined = IntVar(frame)
	self.outlined = UpdatedCheckbutton(frame, variable = self.var_outlined,
					   indicatoron = 0, selectcolor = '',
					   command = set_layer_state,
					   args = idx)
	self.color = ColorButton(frame, command = set_color, args = idx,
				 width = 2,
				 dialog_master =
				 frame.master.master.master.master)

    def SetInfo(self, idx, info):
	self.index.SetValue(idx)
	p = pixmaps
	#name, visible, printable, locked, outlined, color = info
	self.button['text'] = info.Name()

        visible = info.Visible()
	self.var_visible.set(visible)
	self.visible['bitmap'] = visible and p.MiniEyeOpen or p.MiniEyeClosed

        printable = info.Printable()
	self.var_printable.set(printable)
	self.printable['bitmap']= printable and p.MiniPrintOn or p.MiniPrintOff

        locked = info.Locked()
	self.var_locked.set(locked)
	self.locked['bitmap'] = locked and p.MiniLockClosed or p.MiniLockOpen

        outlined = info.Outlined()
	self.var_outlined.set(outlined)
	bm = outlined and p.MiniOutlineOn or p.MiniOutlineOff
	self.outlined['bitmap'] = bm

	self.color.SetColor(info.OutlineColor())

        if info.is_GridLayer:
            self.locked['state'] = self.outlined['state'] \
                                   = self.printable['state'] = DISABLED
        else:
            self.locked['state'] = NORMAL
            if info.is_GuideLayer:
                self.printable['state'] = self.outlined['state'] = DISABLED
            else:
                self.printable['state'] = self.outlined['state'] = NORMAL

    def PlaceWidgets(self, idx):
	self.button.grid(row = idx, column = 0, sticky = 'NEWS')
	self.visible.grid(row = idx, column = 1, sticky = 'NEWS')
	self.printable.grid(row = idx, column = 2, sticky = 'NEWS')
	self.locked.grid(row = idx, column = 3, sticky = 'NEWS')
	self.outlined.grid(row = idx, column = 4, sticky = 'NEWS')
	self.color.grid(row = idx, column = 5, sticky = 'NEWS')

    def State(self):
	return (self.var_visible.get(),
		self.var_printable.get(),
		self.var_locked.get(),
		self.var_outlined.get())

    def Color(self):
	return self.color.Color()

    def Destroy(self):
	self.button.destroy()
	self.visible.destroy()
	self.printable.destroy()
	self.locked.destroy()
	self.outlined.destroy()
	self.color.destroy()
Пример #11
0
class LayerInfo:
    def __init__(self, frame, idx, info, active_var, rename, set_active_layer,
                 set_layer_state, set_color, context_menu):
        self.index = MutableNumber()
        self.active_var = active_var
        self.create_widgets(frame, idx, set_active_layer, rename,
                            set_layer_state, set_color, context_menu)
        if info:
            self.SetInfo(info)

    def create_widgets(self, frame, idx, set_active_layer, rename,
                       set_layer_state, set_color, context_menu):
        self.index.SetValue(idx)
        idx = (self.index, )
        self.button = UpdatedRadiobutton(frame,
                                         anchor=W,
                                         value=idx,
                                         width=10,
                                         variable=self.active_var,
                                         command=set_active_layer)
        self.button.bind('<ButtonPress-3>', context_menu)
        self.button.bind('<ButtonPress-2>', rename)
        self.button.bind('<Double-Button-1>', rename)
        self.var_visible = IntVar(frame)
        self.visible = UpdatedCheckbutton(frame,
                                          variable=self.var_visible,
                                          indicatoron=0,
                                          selectcolor='',
                                          command=set_layer_state,
                                          args=idx)
        self.var_printable = IntVar(frame)
        self.printable = UpdatedCheckbutton(frame,
                                            variable=self.var_printable,
                                            indicatoron=0,
                                            selectcolor='',
                                            command=set_layer_state,
                                            args=idx)
        self.var_locked = IntVar(frame)
        self.locked = UpdatedCheckbutton(frame,
                                         variable=self.var_locked,
                                         indicatoron=0,
                                         selectcolor='',
                                         command=set_layer_state,
                                         args=idx)
        self.var_outlined = IntVar(frame)
        self.outlined = UpdatedCheckbutton(frame,
                                           variable=self.var_outlined,
                                           indicatoron=0,
                                           selectcolor='',
                                           command=set_layer_state,
                                           args=idx)
        self.color = ColorButton(
            frame,
            command=set_color,
            args=idx,
            width=2,
            dialog_master=frame.master.master.master.master)

    def SetInfo(self, idx, info):
        self.index.SetValue(idx)
        p = pixmaps
        #name, visible, printable, locked, outlined, color = info
        self.button['text'] = info.Name()

        visible = info.Visible()
        self.var_visible.set(visible)
        self.visible['bitmap'] = visible and p.MiniEyeOpen or p.MiniEyeClosed

        printable = info.Printable()
        self.var_printable.set(printable)
        self.printable[
            'bitmap'] = printable and p.MiniPrintOn or p.MiniPrintOff

        locked = info.Locked()
        self.var_locked.set(locked)
        self.locked['bitmap'] = locked and p.MiniLockClosed or p.MiniLockOpen

        outlined = info.Outlined()
        self.var_outlined.set(outlined)
        bm = outlined and p.MiniOutlineOn or p.MiniOutlineOff
        self.outlined['bitmap'] = bm

        self.color.SetColor(info.OutlineColor())

        if info.is_GridLayer:
            self.locked['state'] = self.outlined['state'] \
                = self.printable['state'] = DISABLED
        else:
            self.locked['state'] = NORMAL
            if info.is_GuideLayer:
                self.printable['state'] = self.outlined['state'] = DISABLED
            else:
                self.printable['state'] = self.outlined['state'] = NORMAL

    def PlaceWidgets(self, idx):
        self.button.grid(row=idx, column=0, sticky='NEWS')
        self.visible.grid(row=idx, column=1, sticky='NEWS')
        self.printable.grid(row=idx, column=2, sticky='NEWS')
        self.locked.grid(row=idx, column=3, sticky='NEWS')
        self.outlined.grid(row=idx, column=4, sticky='NEWS')
        self.color.grid(row=idx, column=5, sticky='NEWS')

    def State(self):
        return (self.var_visible.get(), self.var_printable.get(),
                self.var_locked.get(), self.var_outlined.get())

    def Color(self):
        return self.color.Color()

    def Destroy(self):
        self.button.destroy()
        self.visible.destroy()
        self.printable.destroy()
        self.locked.destroy()
        self.outlined.destroy()
        self.color.destroy()
Пример #12
0
    def build_dlg(self):
        top = self.top

        # a bit of a hack to accept drops...
        top.accept_drop = (DROP_COLOR,)
        top.DropAt = self.DropAt

        # the standard buttons (apply, cancel, update...)
        button_frame = self.create_std_buttons(top)
        button_frame.pack(side = BOTTOM, fill = X, expand = 0)

        #
        self.var_transform = IntVar(top)
        self.var_transform.set(1)
        button = UpdatedCheckbutton(top, text = _("Transform Pattern"),
                                    variable = self.var_transform,
                                    command = self.set_fill_transform)
        button.pack(side = BOTTOM, fill = X)

        # type frame
        type_frame = Frame(top)
        type_frame.pack(side = LEFT, fill = Y, expand = 0)

        # sample
        self.sample = InteractiveSample(top, width = 60, height = 60,
                                        background = 'white')
        self.sample.pack(side = TOP, fill = X, anchor = N)
        self.sample.SetPattern(EmptyPattern)
        self.sample.Subscribe(CENTER, self.center_changed)
        self.sample.Subscribe(DIRECTION, self.direction_changed)

        # pattern frames
        self.frames = [None, None, None, None, None]
        self.frames[0] = PatternFrame(top)
        self.frames[1] = SolidPatternFrame(top)
        self.frames[2] = GradientPatternFrame(top)
        self.frames[3] = HatchingPatternFrame(top)
        self.frames[4] = ImageTilePatternFrame(top,
                                               main_window = self.main_window)

        width = 0
        for frame in self.frames:
            frame.Subscribe(CHANGED, self.pattern_changed, 1)
            frame.update()
            w = frame.winfo_reqwidth()
            if w > width:
                width = w

        self.sample.config(width = width)

        self.var_pattern_type = IntVar(top)
        types = ((0, pixmaps.fill_none), (1, pixmaps.fill_solid),
                 (2, pixmaps.fill_gradient), (3, pixmaps.fill_hatch),
                 (4, pixmaps.fill_tile))
        for value, bitmap in types:
            button = make_button(type_frame, bitmap = bitmap, value = value,
                                 variable = self.var_pattern_type,
                                 command = self.choose_pattern)
            button.pack(side = TOP)

        # unknown
        self.frame_unknown = PatternFrame(top)

        self.active_frame = None