Пример #1
0
class PaperPanel(wal.LabeledPanel):

    app = None
    printer = None
    items = []

    def __init__(self, parent, printer, app):
        self.app = app
        self.printer = printer
        wal.LabeledPanel.__init__(self, parent, _('Paper'))

        grid = wal.GridPanel(self, 2, 2, 5, 5)
        grid.add_growable_col(1)

        grid.pack(wal.Label(grid, _('Page size:')))

        self.size_combo = wal.Combolist(grid, onchange=self.on_change)
        grid.pack(self.size_combo, fill=True)

        grid.pack(wal.Label(grid, _('Width:')))

        hpanel = wal.HPanel(grid)

        self.wspin = StaticUnitSpin(self.app, hpanel)
        hpanel.pack(self.wspin)
        hpanel.pack(StaticUnitLabel(self.app, hpanel), padding=5)

        hpanel.pack((5, 5))

        hpanel.pack(wal.Label(grid, _('Height:')), padding=5)

        self.hspin = StaticUnitSpin(self.app, hpanel)
        hpanel.pack(self.hspin)
        hpanel.pack(StaticUnitLabel(self.app, hpanel), padding=5)

        grid.pack(hpanel)

        self.pack(grid, fill=True, expand=True, padding_all=10)

        self.set_data()

    def set_data(self):
        self.items = self.printer.get_format_items()
        self.size_combo.set_items(self.items)
        index = 0
        if not self.printer.def_media[:6] == 'Custom':
            index = self.printer.pf_list.index(self.printer.def_media)
        else:
            index = len(self.items) - 1
        self.size_combo.set_active(index)
        if self.printer.is_custom_supported():
            minw, minh = self.printer.customs[0]
            maxw, maxh = self.printer.customs[1]
            self.wspin.set_point_range((minw, maxw))
            self.hspin.set_point_range((minh, maxh))
        self.on_change()

    def on_change(self):
        index = self.size_combo.get_active()
        status = False
        if self.printer.is_custom_supported() and index == len(self.items) - 1:
            if not self.hspin.get_point_value() and \
            self.printer.def_media[:6] == 'Custom':
                w, h = self.printer.def_media[7:].split('x')
                w = float(w)
                h = float(h)
                self.wspin.set_point_value(w)
                self.hspin.set_point_value(h)
            status = True
        else:
            w, h = self.printer.pf_dict[self.printer.pf_list[index]][1]
            self.wspin.set_point_value(w)
            self.hspin.set_point_value(h)
        self.wspin.set_enable(status)
        self.hspin.set_enable(status)

    def save(self):
        index = self.size_combo.get_active()
        prn = self.printer
        if prn.is_custom_supported() and index == len(self.items) - 1:
            w = self.wspin.get_point_value()
            h = self.hspin.get_point_value()
            prn.def_media = 'Custom.%gx%g' % (w, h)
            prn.page_format = ('Custom', (w, h))
        else:
            prn.def_media = prn.pf_list[index]
            prn.page_format = prn.pf_dict[prn.def_media]
Пример #2
0
class PaperPanel(wal.LabeledPanel):

	app = None
	printer = None
	items = []

	def __init__(self, parent, printer, app):
		self.app = app
		self.printer = printer
		wal.LabeledPanel.__init__(self, parent, _('Paper'))

		grid = wal.GridPanel(self, 2, 2, 5, 5)
		grid.add_growable_col(1)

		grid.pack(wal.Label(grid, _('Page size:')))

		self.size_combo = wal.Combolist(grid, onchange=self.on_change)
		grid.pack(self.size_combo, fill=True)

		grid.pack(wal.Label(grid, _('Width:')))

		hpanel = wal.HPanel(grid)

		self.wspin = StaticUnitSpin(self.app, hpanel)
		hpanel.pack(self.wspin)
		hpanel.pack(StaticUnitLabel(self.app, hpanel), padding=5)

		hpanel.pack((5, 5))

		hpanel.pack(wal.Label(grid, _('Height:')), padding=5)

		self.hspin = StaticUnitSpin(self.app, hpanel)
		hpanel.pack(self.hspin)
		hpanel.pack(StaticUnitLabel(self.app, hpanel), padding=5)

		grid.pack(hpanel)

		self.pack(grid, fill=True, expand=True, padding_all=10)

		self.set_data()

	def set_data(self):
		self.items = self.printer.get_format_items()
		self.size_combo.set_items(self.items)
		index = 0
		if not self.printer.def_media[:6] == 'Custom':
			index = self.printer.pf_list.index(self.printer.def_media)
		else:
			index = len(self.items) - 1
		self.size_combo.set_active(index)
		if self.printer.is_custom_supported():
			minw, minh = self.printer.customs[0]
			maxw, maxh = self.printer.customs[1]
			self.wspin.set_point_range((minw, maxw))
			self.hspin.set_point_range((minh, maxh))
		self.on_change()

	def on_change(self):
		index = self.size_combo.get_active()
		status = False
		if self.printer.is_custom_supported() and index == len(self.items) - 1:
			if not self.hspin.get_point_value() and \
			self.printer.def_media[:6] == 'Custom':
				w, h = self.printer.def_media[7:].split('x')
				w = float(w)
				h = float(h)
				self.wspin.set_point_value(w)
				self.hspin.set_point_value(h)
			status = True
		else:
			w, h = self.printer.pf_dict[self.printer.pf_list[index]][1]
			self.wspin.set_point_value(w)
			self.hspin.set_point_value(h)
		self.wspin.set_enable(status)
		self.hspin.set_enable(status)

	def save(self):
		index = self.size_combo.get_active()
		prn = self.printer
		if prn.is_custom_supported() and index == len(self.items) - 1:
			w = self.wspin.get_point_value()
			h = self.hspin.get_point_value()
			prn.def_media = 'Custom.%gx%g' % (w, h)
			prn.page_format = ('Custom', (w, h))
		else:
			prn.def_media = prn.pf_list[index]
			prn.page_format = prn.pf_dict[prn.def_media]
Пример #3
0
class PagePanel(wal.LabeledPanel):
    app = None
    printer = None
    items = []

    def __init__(self, parent, printer, app):
        self.app = app
        self.printer = printer
        wal.LabeledPanel.__init__(self, parent, _('Document page'))

        grid = wal.GridPanel(self, 3, 2, 3, 3)
        grid.add_growable_col(1)

        grid.pack(wal.Label(grid, _('Page size:')))

        self.size_combo = wal.Combolist(grid, onchange=self.on_change)
        grid.pack(self.size_combo, fill=True)

        grid.pack(wal.Label(grid, _('Width:')))

        hpanel = wal.HPanel(grid)

        self.wspin = StaticUnitSpin(self.app, hpanel)
        hpanel.pack(self.wspin)

        hpanel.pack((5, 5))

        hpanel.pack(wal.Label(grid, _('Height:')), padding=5)

        self.hspin = StaticUnitSpin(self.app, hpanel)
        hpanel.pack(self.hspin)
        hpanel.pack(StaticUnitLabel(self.app, hpanel), padding=5)

        grid.pack(hpanel)

        grid.pack(wal.Label(grid, _('Orientation:')))

        hpanel = wal.HPanel(grid)

        self.port_opt = wal.Radiobutton(hpanel,
                                        uc2const.ORIENTS_NAMES[0],
                                        group=True)
        self.land_opt = wal.Radiobutton(hpanel, uc2const.ORIENTS_NAMES[1])

        hpanel.pack(self.port_opt)
        hpanel.pack((15, 5))
        hpanel.pack(self.land_opt)

        grid.pack(hpanel)

        self.pack(grid, fill=True, expand=True, padding_all=7)

        self.set_data()

    def set_data(self):
        self.land_opt.set_value(True)
        if self.printer.page_orientation == uc2const.PORTRAIT:
            self.port_opt.set_value(True)

        self.items = self.printer.get_format_items()
        self.size_combo.set_items(self.items)
        if not self.printer.page_format[0] == 'Custom':
            index = self.items.index(self.printer.page_format[0])
        else:
            index = len(self.items) - 1
        self.size_combo.set_active(index)

        if self.printer.is_custom_supported():
            minw, minh = self.printer.customs[0]
            maxw, maxh = self.printer.customs[1]
            self.wspin.set_point_range((minw, maxw))
            self.hspin.set_point_range((minh, maxh))
        self.on_change()

    def on_change(self):
        index = self.size_combo.get_active()
        status = False
        if index == len(self.items) - 1:
            if not self.hspin.get_point_value() and \
                            self.printer.page_format[0] == 'Custom':
                w, h = self.printer.page_format[1]
                self.wspin.set_point_value(w)
                self.hspin.set_point_value(h)
            status = True
        else:
            w, h = uc2const.PAGE_FORMATS[uc2const.PAGE_FORMAT_NAMES[index]]
            self.wspin.set_point_value(w)
            self.hspin.set_point_value(h)
        self.wspin.set_enable(status)
        self.hspin.set_enable(status)

    def save(self):
        index = self.size_combo.get_active()
        prn = self.printer
        if prn.is_custom_supported() and index == len(self.items) - 1:
            w = self.wspin.get_point_value()
            h = self.hspin.get_point_value()
            prn.page_format = ('Custom', (w, h))
        else:
            media = uc2const.PAGE_FORMAT_NAMES[index]
            w, h = uc2const.PAGE_FORMATS[media]
            prn.page_format = (media, (w, h))
        self.printer.page_orientation = uc2const.LANDSCAPE
        if self.port_opt.get_value():
            self.printer.page_orientation = uc2const.PORTRAIT
Пример #4
0
class PagePanel(wal.LabeledPanel):

	app = None
	printer = None
	items = []

	def __init__(self, parent, printer, app):
		self.app = app
		self.printer = printer
		wal.LabeledPanel.__init__(self, parent, _('Document page'))

		grid = wal.GridPanel(self, 3, 2, 3, 3)
		grid.add_growable_col(1)

		grid.pack(wal.Label(grid, _('Page size:')))

		self.size_combo = wal.Combolist(grid, onchange=self.on_change)
		grid.pack(self.size_combo, fill=True)

		grid.pack(wal.Label(grid, _('Width:')))

		hpanel = wal.HPanel(grid)

		self.wspin = StaticUnitSpin(self.app, hpanel)
		hpanel.pack(self.wspin)

		hpanel.pack((5, 5))

		hpanel.pack(wal.Label(grid, _('Height:')), padding=5)

		self.hspin = StaticUnitSpin(self.app, hpanel)
		hpanel.pack(self.hspin)
		hpanel.pack(StaticUnitLabel(self.app, hpanel), padding=5)

		grid.pack(hpanel)

		grid.pack(wal.Label(grid, _('Orientation:')))

		hpanel = wal.HPanel(grid)

		self.port_opt = wal.Radiobutton(hpanel, _('Portrait'), group=True)
		self.land_opt = wal.Radiobutton(hpanel, _('Landscape'))

		hpanel.pack(self.port_opt)
		hpanel.pack((15, 5))
		hpanel.pack(self.land_opt)

		grid.pack(hpanel)

		self.pack(grid, fill=True, expand=True, padding_all=7)

		self.set_data()

	def set_data(self):
		self.land_opt.set_value(True)
		if self.printer.page_orientation == uc2const.PORTRAIT:
			self.port_opt.set_value(True)

		self.items = self.printer.get_format_items()
		self.size_combo.set_items(self.items)
		index = 0
		if not self.printer.page_format[0] == 'Custom':
			index = self.items.index(self.printer.page_format[0])
		else:
			index = len(self.items) - 1
		self.size_combo.set_active(index)

		if self.printer.is_custom_supported():
			minw, minh = self.printer.customs[0]
			maxw, maxh = self.printer.customs[1]
			self.wspin.set_point_range((minw, maxw))
			self.hspin.set_point_range((minh, maxh))
		self.on_change()

	def on_change(self):
		index = self.size_combo.get_active()
		status = False
		if index == len(self.items) - 1:
			if not self.hspin.get_point_value() and \
			self.printer.page_format[0] == 'Custom':
				w, h = self.printer.page_format[1]
				self.wspin.set_point_value(w)
				self.hspin.set_point_value(h)
			status = True
		else:
			w, h = uc2const.PAGE_FORMATS[uc2const.PAGE_FORMAT_NAMES[index]]
			self.wspin.set_point_value(w)
			self.hspin.set_point_value(h)
		self.wspin.set_enable(status)
		self.hspin.set_enable(status)

	def save(self):
		index = self.size_combo.get_active()
		prn = self.printer
		if prn.is_custom_supported() and index == len(self.items) - 1:
			w = self.wspin.get_point_value()
			h = self.hspin.get_point_value()
			prn.page_format = ('Custom', (w, h))
		else:
			media = uc2const.PAGE_FORMAT_NAMES[index]
			w, h = uc2const.PAGE_FORMATS[media]
			prn.page_format = (media, (w, h))
		self.printer.page_orientation = uc2const.LANDSCAPE
		if self.port_opt.get_value():
			self.printer.page_orientation = uc2const.PORTRAIT