Skip to content

Commit 3e024b1

Browse files
committed
Added margins when printing
1 parent 219301e commit 3e024b1

8 files changed

Lines changed: 73 additions & 9 deletions

File tree

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 2018-04-24 v1.1.1
4+
5+
+ Added margins when printing
6+
37
## 2018-04-17 v1.1.0
48

59
+ SFR (http://www.sportsystem.ru) timekeeping system support on Windows (only last model U5a with HID Interface). Thanks to Alexander Kurdumov for support and equipment sample.

changelog_ru.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Список изменений
22

3+
## 2018-04-24 v1.1.1
4+
5+
+ Добавлены поля при печати
6+
37
## 2018-04-17 v1.1.0
48

59
+ Поддержка чтения чипов системы электронной отметки SFR на Windows, http://www.sportsystem.ru. (Выражаем благодарность Александру Курдюмову за поддержку)

languages/ru_RU/LC_MESSAGES/sportorg.po

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,6 +1545,21 @@ msgstr "Открыть WDB файл"
15451545
msgid "Save WDB file"
15461546
msgstr "Сохранить WDB файл"
15471547

1548+
msgid "Margins"
1549+
msgstr "Поля"
1550+
1551+
msgid "Left"
1552+
msgstr "Слева"
1553+
1554+
msgid "Top"
1555+
msgstr "Сверху"
1556+
1557+
msgid "Right"
1558+
msgstr "Справа"
1559+
1560+
msgid "Bottom"
1561+
msgstr "Снизу"
1562+
15481563
#~ msgid "Auto connect to station"
15491564
#~ msgstr "Автоматическое подключение станции SPORTident"
15501565

sportorg.iss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
33

44
#define MyAppName "SportOrg"
5-
#define MyAppVersion "v1.1.0"
6-
#define MyVersionInfoVersion "1.1.0.0"
5+
#define MyAppVersion "v1.1.1"
6+
#define MyVersionInfoVersion "1.1.1.0"
77
#define MyAppPublisher "Danil Akhtarov, Sergei Kobelev"
88
#define MyAppURL "http://sportorg.o-ural.ru/"
99
#define MyAppExeName "SportOrg.exe"

sportorg/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from sportorg.core.version import Version
66

77
NAME = 'SportOrg'
8-
VERSION = Version(1, 1, 0, 0, 'v')
8+
VERSION = Version(1, 1, 1, 0, 'v')
99
DEBUG = True
1010

1111

sportorg/gui/dialogs/print_properties.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
from PyQt5 import QtPrintSupport
44
from PyQt5.QtGui import QIcon
55
from PyQt5.QtPrintSupport import QPrinter, QPrintDialog, QAbstractPrintDialog
6-
from PyQt5.QtWidgets import QFormLayout, QLabel, QDialog, QPushButton, QCheckBox, QDialogButtonBox
6+
from PyQt5.QtWidgets import QFormLayout, QLabel, QDialog, QPushButton, QCheckBox, QDialogButtonBox, QGroupBox, \
7+
QDoubleSpinBox
78

89
from sportorg import config
910
from sportorg.core.template import get_templates
@@ -75,6 +76,19 @@ def select_custom_path():
7576
self.print_splits_checkbox = QCheckBox(_('Print splits'))
7677
self.layout.addRow(self.print_splits_checkbox)
7778

79+
self.margin_group_box = QGroupBox(_('Margins'))
80+
self.margin_layout = QFormLayout()
81+
self.item_margin_left = QDoubleSpinBox()
82+
self.margin_layout.addRow(QLabel(_('Left')), self.item_margin_left)
83+
self.item_margin_top = QDoubleSpinBox()
84+
self.margin_layout.addRow(QLabel(_('Top')), self.item_margin_top)
85+
self.item_margin_right = QDoubleSpinBox()
86+
self.margin_layout.addRow(QLabel(_('Right')), self.item_margin_right)
87+
self.item_margin_bottom = QDoubleSpinBox()
88+
self.margin_layout.addRow(QLabel(_('Bottom')), self.item_margin_bottom)
89+
self.margin_group_box.setLayout(self.margin_layout)
90+
self.layout.addRow(self.margin_group_box)
91+
7892
self.set_values()
7993

8094
def cancel_changes():
@@ -122,6 +136,11 @@ def set_values(self):
122136
if template:
123137
self.item_template.setCurrentText(template)
124138

139+
self.item_margin_left.setValue(obj.get_setting('print_margin_left', 5.0))
140+
self.item_margin_top.setValue(obj.get_setting('print_margin_top', 5.0))
141+
self.item_margin_right.setValue(obj.get_setting('print_margin_right', 5.0))
142+
self.item_margin_bottom.setValue(obj.get_setting('print_margin_bottom', 5.0))
143+
125144
def select_printer(self):
126145
try:
127146
printer = QtPrintSupport.QPrinter()
@@ -141,3 +160,8 @@ def apply_changes_impl(self):
141160
obj.set_setting('split_printer', split_printer)
142161
obj.set_setting('split_printout', self.print_splits_checkbox.isChecked())
143162
obj.set_setting('split_template', self.item_template.currentText())
163+
164+
obj.set_setting('print_margin_left', self.item_margin_left.value())
165+
obj.set_setting('print_margin_top', self.item_margin_top.value())
166+
obj.set_setting('print_margin_right', self.item_margin_right.value())
167+
obj.set_setting('print_margin_bottom', self.item_margin_bottom.value())

sportorg/modules/printing/model.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,11 @@ def split_printout(result):
2828
template = get_text_from_file(template_path, **spl.get_dict_printout(person))
2929
if not printer:
3030
raise NoPrinterSelectedException('No printer selected')
31-
print_html(printer, template)
31+
print_html(
32+
printer,
33+
template,
34+
obj.get_setting('print_margin_left', 5.0),
35+
obj.get_setting('print_margin_top', 5.0),
36+
obj.get_setting('print_margin_right', 5.0),
37+
obj.get_setting('print_margin_bottom', 5.0),
38+
)

sportorg/modules/printing/printing.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@
1212

1313

1414
class PrintProcess(Process):
15-
def __init__(self, printer_name, html):
15+
def __init__(self, printer_name, html, left=5.0, top=5.0, right=5.0, bottom=5.0):
1616
super().__init__()
1717
self.printer_name = printer_name
1818
self.html = html
19+
self.margin_left = left
20+
self.margin_top = top
21+
self.margin_right = right
22+
self.margin_bottom = bottom
1923

2024
def run(self):
2125
try:
@@ -36,7 +40,13 @@ def run(self):
3640
text_document = QTextDocument()
3741

3842
printer.setFullPage(True)
39-
printer.setPageMargins(1, 1, 1, 1, QPrinter.Millimeter)
43+
printer.setPageMargins(
44+
self.margin_left,
45+
self.margin_top,
46+
self.margin_right,
47+
self.margin_bottom,
48+
QPrinter.Millimeter
49+
)
4050

4151
page_size = QSizeF()
4252
page_size.setHeight(printer.height())
@@ -50,8 +60,8 @@ def run(self):
5060
logging.error(str(e))
5161

5262

53-
def print_html(printer_name, html):
54-
thread = PrintProcess(printer_name, html)
63+
def print_html(printer_name, html, left=5.0, top=5.0, right=5.0, bottom=5.0):
64+
thread = PrintProcess(printer_name, html, left, top, right, bottom)
5565
thread.start()
5666
logging.info('printing poccess started')
5767

0 commit comments

Comments
 (0)