示例#1
0
    def __init__(self, parent, printer, app):
        self.app = app
        self.printer = printer
        units = app.current_doc.model.doc_units
        text = uc2const.unit_short_names[units]

        wal.LabeledPanel.__init__(self, parent, _('Margins') + ' (%s)' % text)

        self.pack((1, 1), expand=True, padding=2)

        mrgs = self.printer.margins
        self.top_spin = StaticUnitSpin(self.app, self, mrgs[0])
        self.pack(self.top_spin)

        self.pack((5, 5))

        hpanel = wal.HPanel(self)
        self.left_spin = StaticUnitSpin(self.app, self, mrgs[3])
        hpanel.pack(self.left_spin)
        hpanel.pack((5, 5))
        self.right_spin = StaticUnitSpin(self.app, self, mrgs[1])
        hpanel.pack(self.right_spin)

        self.pack(hpanel)

        self.pack((5, 5))

        self.bottom_spin = StaticUnitSpin(self.app, self, mrgs[2])
        self.pack(self.bottom_spin)

        self.pack((1, 1), expand=True, padding=2)
示例#2
0
    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 __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 build(self):
        self.printsys = self.get_printsys()
        self.prn_list = self.printsys.get_printer_names()
        if self.prn_list:
            self.active_printer = self.printsys.get_default_printer()
            hpanel = wal.HPanel(self)
            hpanel.pack(wal.Label(hpanel, _('Printer:')))
            hpanel.pack((5, 5))
            self.prn_combo = wal.Combolist(hpanel,
                                           items=self.prn_list,
                                           onchange=self.set_data)
            hpanel.pack(self.prn_combo, fill=True, expand=True)
            index = self.prn_list.index(self.active_printer.get_name())
            self.prn_combo.set_active(index)
            self.pack(hpanel, fill=True, padding_all=5)

            self.pack((10, 10))

            # ---Panels
            self.insp = self.app.insp
            units = uc2const.UNIT_MM
            if self.insp.is_doc():
                units = self.app.current_doc.model.doc_units
            units_text = uc2const.unit_short_names[units]

            # ---Shift panel
            shifts = self.active_printer.shifts
            hpanel = wal.HPanel(self)
            txt = _('Printing shift') + ' (%s)' % units_text
            spanel = wal.LabeledPanel(hpanel, text=txt)
            spanel.pack((1, 1), expand=True)

            grid = wal.GridPanel(spanel, 2, 2, 5, 5)

            grid.pack(wal.Label(grid, _('Horizontal shift:')))
            self.hshift = StaticUnitSpin(self.app,
                                         grid,
                                         shifts[0],
                                         can_be_negative=True,
                                         onchange=self.save_data,
                                         onenter=self.save_data)
            grid.pack(self.hshift)

            grid.pack(wal.Label(grid, _('Vertical shift:')))
            self.vshift = StaticUnitSpin(self.app,
                                         grid,
                                         shifts[1],
                                         can_be_negative=True,
                                         onchange=self.save_data,
                                         onenter=self.save_data)
            grid.pack(self.vshift)

            spanel.pack(grid, padding_all=5)
            spanel.pack((1, 1), expand=True)

            hpanel.pack(spanel, fill=True, expand=True)

            hpanel.pack((5, 5))

            # ---Margin panel
            txt = _('Printing margins') + ' (%s)' % units_text
            mpanel = wal.LabeledPanel(hpanel, text=txt)
            mpanel.pack((5, 5))

            mrgs = self.active_printer.margins
            self.top_spin = StaticUnitSpin(self.app,
                                           mpanel,
                                           mrgs[0],
                                           onchange=self.save_data,
                                           onenter=self.save_data)
            mpanel.pack(self.top_spin)

            mpanel.pack((5, 5))

            hp = wal.HPanel(self)
            self.left_spin = StaticUnitSpin(self.app,
                                            hp,
                                            mrgs[3],
                                            onchange=self.save_data,
                                            onenter=self.save_data)
            hp.pack(self.left_spin)
            hp.pack((5, 5))
            self.right_spin = StaticUnitSpin(self.app,
                                             hp,
                                             mrgs[1],
                                             onchange=self.save_data,
                                             onenter=self.save_data)
            hp.pack(self.right_spin)

            mpanel.pack(hp)

            mpanel.pack((5, 5))

            self.bottom_spin = StaticUnitSpin(self.app,
                                              mpanel,
                                              mrgs[2],
                                              onchange=self.save_data,
                                              onenter=self.save_data)
            mpanel.pack(self.bottom_spin)

            mpanel.pack((10, 10))
            # ---

            hpanel.pack(mpanel, fill=True, expand=True)

            self.pack(hpanel, fill=True)

            self.pack((10, 10))

            # ---Calibration page
            text = _("To measure actual print area and vertical/horizontal "
                     "printing shift, just print the calibration page on "
                     "A4/Letter paper.")

            label = wal.Label(self, text)
            label.wrap(470)
            self.pack(label, fill=True, padding_all=5, align_center=False)

            self.a4_calibrate_btn = wal.Button(
                self,
                _('Print A4 calibration page'),
                onclick=self.print_calibration_a4)
            self.pack(self.a4_calibrate_btn)

            self.pack((5, 5))

            self.letter_calibrate_btn = wal.Button(
                self,
                _('Print Letter calibration page'),
                onclick=self.print_calibration_letter)
            self.pack(self.letter_calibrate_btn)

            self.pack((5, 5))

        else:
            self.pack((5, 5), expand=True)
            self.pack(get_bmp(self, icons.PD_NO_PRINTERS), padding=10)
            self.pack(wal.Label(self, _('No printers found')))
            self.pack((10, 10))
            self.pack((5, 5), expand=True)
        self.built = True