Skip to content
Snippets Groups Projects
Commit 6e5f0938 authored by Thomas Holene Løkkeborg's avatar Thomas Holene Løkkeborg
Browse files

#125 kjørt filer gjennom black

parent d65fa2bd
No related branches found
No related tags found
1 merge request!70#125 løsning til oppløsningstrøbbel ved å bruke px ikke pt i font
Pipeline #82912 failed
......@@ -436,7 +436,9 @@ class InlineEditableSOIView(QScrollArea):
creation_date = soi_date_string_to_user_friendly_string(self.soi.date)
label_creation_date = QLabel("Opprettet: {}".format(creation_date))
label_creation_date.setStyleSheet("background-color: rgba(0,0,0,0%)")
label_creation_date.setFont(qfont_with_pixel_size("Times New Roman", 25))
label_creation_date.setFont(
qfont_with_pixel_size("Times New Roman", 25)
)
# Source: https://stackoverflow.com/a/8638114/3545896
# CAUTION: does not work if font is set through stylesheet
label_width = (
......@@ -494,7 +496,9 @@ class InlineEditableSOIView(QScrollArea):
label_copy_number_header.setStyleSheet(
"background-color: rgba(0,0,0,0%)"
)
label_copy_number_header.setFont(qfont_with_pixel_size("Times New Roman", 25))
label_copy_number_header.setFont(
qfont_with_pixel_size("Times New Roman", 25)
)
# Source: https://stackoverflow.com/a/8638114/3545896
# CAUTION: does not work if font is set through stylesheet
label_width = (
......
......@@ -4,7 +4,11 @@ from secrets import choice
from PySide2.QtWidgets import QTableWidgetItem
from PySide2 import QtGui
from PySide2.QtCore import Qt
from soitool.modules.module_base import resize_table, qfont_with_pixel_size, TABLE_CELL_DEFAULT_FONT
from soitool.modules.module_base import (
resize_table,
qfont_with_pixel_size,
TABLE_CELL_DEFAULT_FONT,
)
from soitool.modules.code_table_base import CodeTableBase
# Characters for first column,
......@@ -21,7 +25,9 @@ CODE_LENGTH = 25
CODE_CHARACTER_TYPE = "ascii"
# Font for authentication codes, should be a monospaced font
CODE_FONT = qfont_with_pixel_size("Consolas", TABLE_CELL_DEFAULT_FONT.pixelSize(), QtGui.QFont.SansSerif)
CODE_FONT = qfont_with_pixel_size(
"Consolas", TABLE_CELL_DEFAULT_FONT.pixelSize(), QtGui.QFont.SansSerif
)
# Adds space between sets of characters, 0 => no spaces
# If code is 123456 and interval is 2, code will be 12 34 56
......
......@@ -2,6 +2,7 @@
from abc import ABC
from PySide2 import QtGui
def qfont_with_pixel_size(font_family, pixel_size, weight=None):
"""Provide a QFont with given family and pixel size.
......@@ -24,11 +25,13 @@ def qfont_with_pixel_size(font_family, pixel_size, weight=None):
font.setPixelSize(pixel_size)
return font
# Font for module headline
HEADLINE_FONT = qfont_with_pixel_size("Arial", 24, 100)
TABLE_CELL_DEFAULT_FONT = qfont_with_pixel_size("Arial", 16)
class ModuleBase(ABC):
"""Interface for SOI-modules."""
......
......@@ -13,7 +13,11 @@ from PySide2.QtWidgets import (
)
from PySide2.QtCore import QSize, Qt
from PySide2.QtGui import QIcon, QFontMetricsF
from soitool.modules.module_base import ModuleBase, HEADLINE_FONT, qfont_with_pixel_size
from soitool.modules.module_base import (
ModuleBase,
HEADLINE_FONT,
qfont_with_pixel_size,
)
class TextEditWithSizeOfContent(QTextEdit):
......@@ -113,7 +117,9 @@ class FreeTextModule(ModuleBase, QWidget, metaclass=Meta):
self.line_edit_header = LineEditWithSizeOfContent()
self.line_edit_header.setFont(HEADLINE_FONT)
self.text_edit_body = TextEditWithSizeOfContent()
self.text_edit_body.setFont(qfont_with_pixel_size("Arial", HEADLINE_FONT.pixelSize()))
self.text_edit_body.setFont(
qfont_with_pixel_size("Arial", HEADLINE_FONT.pixelSize())
)
# When the contents of these widgets change we need to manually trigger
# adjust of size, even on self. Without adjust of size on self the
......
......@@ -3,7 +3,11 @@ import string
from PySide2.QtWidgets import QTableWidgetItem
from PySide2 import QtGui
from PySide2.QtCore import Qt
from soitool.modules.module_base import resize_table, qfont_with_pixel_size, TABLE_CELL_DEFAULT_FONT
from soitool.modules.module_base import (
resize_table,
qfont_with_pixel_size,
TABLE_CELL_DEFAULT_FONT,
)
from soitool.modules.code_table_base import CodeTableBase
# Characters for first and second column
......@@ -21,7 +25,9 @@ SPACE_INTERVAL = 4
SPACE_AMOUNT = 3
# Font for subtractorcodes
CODE_FONT = qfont_with_pixel_size("Arial", TABLE_CELL_DEFAULT_FONT.pixelSize(), QtGui.QFont.SansSerif)
CODE_FONT = qfont_with_pixel_size(
"Arial", TABLE_CELL_DEFAULT_FONT.pixelSize(), QtGui.QFont.SansSerif
)
HEADLINE_TEXT = "Subtraktorkoder"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment