presik_pos/app/tools.py

44 lines
1.1 KiB
Python
Raw Normal View History

2020-04-19 17:54:08 +02:00
import os
2022-12-28 00:09:58 +01:00
# from PyQt5.QtGui import QIcon
from PySide6.QtGui import QIcon, QGuiApplication
# from PyQt5.QtWidgets import QDesktopWidget
2021-01-26 21:45:15 +01:00
2020-04-19 17:54:08 +02:00
current_dir = os.path.dirname(__file__)
def get_icon(name):
2021-04-13 17:10:17 +02:00
name = name if name else 'fork'
2021-04-12 18:29:53 +02:00
path_icon = os.path.join(current_dir, 'share', name + '.svg')
return QIcon(path_icon)
2020-04-19 17:54:08 +02:00
def to_numeric(number):
return str(round(number, 2))
def to_float(number, digits):
return str(round(number, 4))
2021-01-26 21:45:15 +01:00
def get_screen():
2022-12-28 00:09:58 +01:00
screen = QGuiApplication.primaryScreen().size()
# screen = QDesktopWidget().screenGeometry()
2021-01-26 21:45:15 +01:00
width = screen.width()
height = screen.height()
return width, height
2023-10-20 23:43:40 +02:00
def compare_versions(version_validate, version_required):
v1_parts = version_validate.split('.')
v2_parts = version_required.split('.')
for i in range(max(len(v1_parts), len(v2_parts))):
v1_num = int(v1_parts[i]) if i < len(v1_parts) else 0
v2_num = int(v2_parts[i]) if i < len(v2_parts) else 0
if v1_num < v2_num:
return "lower"
elif v1_num > v2_num:
return "higher"
return 'equal'