<commit_before>#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
A PyQt5 custom 'display' widget used by Morse Trainer.

Display two lines of English text.  Allow colour change to background
for individual characters.  Allow outline highlighting for any group
of two vertical characters.  Allow tooltip text for any group of two
vertical characters.

display = Display(...)              # constructor

display.clear()                     # whole display cleared

display_id = display.insert_upper(ch, fg=None)  # insert char in upper row
display_id = display.insert_lower(ch, fg=None)  # insert char in lower row

display.set_tooltip(text)           # set tooltip at display end
display.update_tooltip(text)        # change tooltip at display end

display.set_highlight()             # set tooltip on latest column
"""

import platform

import utils

from PyQt5.QtWidgets import QWidget, QTableWidget, QPushButton, QMessageBox
from PyQt5.QtWidgets import QToolTip
from PyQt5.QtCore import QObject, Qt, pyqtSignal, QPoint
from PyQt5.QtGui import QPainter, QFont, QColor, QPen
import logger
log = logger.Log('debug.log', logger.Log.CRITICAL)


class Display(QWidget):
    """Widget to display two rows of text for the Morse Trainer."""

    # define colours
    AskTextColour = Qt.black
    AnsTextGoodColour = Qt.blue
    AnsTextBadColour = Qt.red
    HighlightColour = QColor(255, 255, 153)
    HighlightEdgeColour = QColor(234, 234, 234)
    HoverColour = Qt.black
    HoverBGNoneColour = QColor(255, 255, 255, alpha=0)
    HoverBGTooltipColour = QColor(255, 0, 0, alpha=100)

    # set platform-dependent sizes
    if platform.system() == 'Windows':
        DefaultWidgetHeight = 55
        DefaultWidgetWidth = 600
        BaselineOffsetUpper = 24
        BaselineOffsetLower = 48
        FontSize = 30
        TooltipFontSize = 4
        TextLeftOffset = 3
        RoundedRadius = 3.0
        TooltipOffset = 33
        TooltipLineOffset = 13
        DisplayFont = 'Courier'
    elif platform.system() == 'Linux':
        DefaultWidgetHeight = 85
        DefaultWidgetWidth = 600
        BaselineOffsetUpper = 40
        BaselineOffsetLower = 80
        FontSize = 40
        TooltipFontSize = 4
        TextLeftOffset = 3
        RoundedRadius = 3.0
        TooltipOffset = 33<commit_msg>Layout changes Win7/Linux<commit_after>#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
A PyQt5 custom 'display' widget used by Morse Trainer.

Display two lines of English text.  Allow colour change to background
for individual characters.  Allow outline highlighting for any group
of two vertical characters.  Allow tooltip text for any group of two
vertical characters.

display = Display(...)              # constructor

display.clear()                     # whole display cleared

display_id = display.insert_upper(ch, fg=None)  # insert char in upper row
display_id = display.insert_lower(ch, fg=None)  # insert char in lower row

display.set_tooltip(text)           # set tooltip at display end
display.update_tooltip(text)        # change tooltip at display end

display.set_highlight()             # set tooltip on latest column
"""

import platform

import utils

from PyQt5.QtWidgets import QWidget, QTableWidget, QPushButton, QMessageBox
from PyQt5.QtWidgets import QToolTip
from PyQt5.QtCore import QObject, Qt, pyqtSignal, QPoint
from PyQt5.QtGui import QPainter, QFont, QColor, QPen
import logger
log = logger.Log('debug.log', logger.Log.CRITICAL)


class Display(QWidget):
    """Widget to display two rows of text for the Morse Trainer."""

    # define colours
    AskTextColour = Qt.black
    AnsTextGoodColour = Qt.blue
    AnsTextBadColour = Qt.red
    HighlightColour = QColor(255, 255, 153)
    HighlightEdgeColour = QColor(234, 234, 234)
    HoverColour = Qt.black
    HoverBGNoneColour = QColor(255, 255, 255, alpha=0)
    HoverBGTooltipColour = QColor(255, 0, 0, alpha=100)

    # set platform-dependent sizes
    if platform.system() == 'Windows':
        DefaultWidgetHeight = 74
        DefaultWidgetWidth = 600
        BaselineOffsetUpper = 34
        BaselineOffsetLower = 68
        FontSize = 40
        TooltipFontSize = 4
        TextLeftOffset = 3
        RoundedRadius = 3.0
        TooltipOffset = 33
        TooltipLineOffset = 13
        DisplayFont = 'Courier'
    elif platform.system() == 'Linux':
        DefaultWidgetHeight = 85
        DefaultWidgetWidth = 600
        BaselineOffsetUpper = 38
        BaselineOffsetLower = 76
        FontSize = 40
        TooltipFontSize = 4
        TextLeftOffset = 3
        RoundedRadius = 3.0
        TooltipOffset = 33
{'fraction_non_alphanumeric': 0.07627118644067797, 'fraction_numerical': 0.03455019556714472, 'mean_word_length': 2.8745791245791246, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6286001', 'n_tokens_mistral': 1473, 'n_tokens_neox': 1313, 'n_words': 425}