Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/anonymizer/anonymizer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import faulthandler
import ctypes
import json
import logging
import os
Expand Down Expand Up @@ -58,6 +59,11 @@ def get_app_state_path(self) -> Path:
return self.logs_dir / ".anonymizer_state.json"

def __init__(self, logs_dir: Path):
if sys.platform.startswith("win"):
# Enable DPI awareness for Windows (improves scaling on high-DPI/4K monitors)
#ctk.deactivate_automatic_dpi_awareness() # TODO: implement dpi awareness for all views for Windows OS
ctypes.windll.shcore.SetProcessDpiAwareness(1)

super().__init__()
self.logs_dir: Path = logs_dir
ctk.set_appearance_mode("System") # Modes: "System" (standard), "Dark", "Light"
Expand All @@ -66,15 +72,15 @@ def __init__(self, logs_dir: Path):
logger.error(f"Theme file not found: {theme}, reverting to dark-blue theme")
theme = "dark-blue"
ctk.set_default_color_theme(theme)
ctk.deactivate_automatic_dpi_awareness() # TODO: implement dpi awareness for all views for Windows OS

logging.info(f"ctk.ThemeManager.theme:\n{pformat(ThemeManager.theme)}")
self.mono_font = self._init_mono_font()

ctk.AppearanceModeTracker.add(self._appearance_mode_change)
self._appearance_mode_change(ctk.get_appearance_mode()) # initialize non-ctk widget styles

if sys.platform.startswith("win"):
self.iconbitmap("assets\\icons\\rsna_icon.ico", default="assets\\icons\\rsna_icon.ico")
self.iconbitmap("assets\\icons\\rsna_icon.ico", default="assets\\icons\\rsna_icon.ico")

self.recent_project_dirs: list[Path] = []
self.current_open_project_dir: Path | None = None
Expand Down
2 changes: 1 addition & 1 deletion src/anonymizer/assets/locales/de/html/1_übersicht.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
see https://github.com/bauripalash/tkhtmlview?tab=readme-ov-file#html-support -->
<html>
<body>
<div style="color: #014F8F; font-size: 14px;">
<div style="color: THEME_COLOR; font-size: 14px;">
<h2>Einführung</h2>
<p>
Der RSNA DICOM Anonymizer ist ein plattformübergreifendes, eigenständiges De-Identifikations-Werkzeug.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
siehe https://github.com/bauripalash/tkhtmlview?tab=readme-ov-file#html-support -->
<html>
<body>
<div style="color: #014F8F;font-size: 14px;">
<div style="color: THEME_COLOR;font-size: 14px;">

<h3>DICOM Standard zur De-Identifikation</h3>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
siehe https://github.com/bauripalash/tkhtmlview?tab=readme-ov-file#html-support -->
<html>
<body>
<div style="color: #014F8F;font-size: 14px;">
<div style="color: THEME_COLOR;font-size: 14px;">

<h2>Verwaltung von Anonymisierungsprojekten</h2>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
siehe https://github.com/bauripalash/tkhtmlview?tab=readme-ov-file#html-support -->
<html>
<body>
<div style="color: #014F8F; font-size: 14px;">
<div style="color: THEME_COLOR; font-size: 14px;">
<!-- <h1 style="text-align: center;">RSNA DICOM Anonymizer Project Settings</h1> -->

<h2>Projekteinstellungen</h2>
Expand Down
2 changes: 1 addition & 1 deletion src/anonymizer/assets/locales/de/html/5_bedienung.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
siehe https://github.com/bauripalash/tkhtmlview?tab=readme-ov-file#html-support -->
<html>
<body>
<div style="color: #014F8F; font-size: 14px;">
<div style="color: THEME_COLOR; font-size: 14px;">

<h2>Dateien importieren</h2>

Expand Down
2 changes: 1 addition & 1 deletion src/anonymizer/assets/locales/de/html/6_lizenz.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html>
<body>
<div style="color: #014F8F; font-size: 14px;">
<div style="color: THEME_COLOR; font-size: 14px;">
<h3>Lizenz</h3>
Die RSNA DICOM Anonymizer-Software wird unter der
<a href="http://mirc.rsna.org/rsnapubliclicense.pdf">RSNA Public License</a> veröffentlicht.
Expand Down
2 changes: 1 addition & 1 deletion src/anonymizer/assets/locales/en_US/html/1_overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
see https://github.com/bauripalash/tkhtmlview?tab=readme-ov-file#html-support -->
<html>
<body>
<div style="color: #014F8F; font-size: 14px;">
<div style="color: THEME_COLOR; font-size: 14px;">
<!-- <h1 style="text-align: center;">RSNA DICOM Anonymizer Overview</h1> -->

<h2>Introduction</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
see https://github.com/bauripalash/tkhtmlview?tab=readme-ov-file#html-support -->
<html>
<body>
<div style="color: #014F8F;font-size: 14px;">
<div style="color: THEME_COLOR;font-size: 14px;">

<h3>DICOM Standard De-identification Protocol</h3>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
see https://github.com/bauripalash/tkhtmlview?tab=readme-ov-file#html-support -->
<html>
<body>
<div style="color: #014F8F;font-size: 14px;">
<div style="color: THEME_COLOR;font-size: 14px;">

<h2>Managing Anonymization Projects</h2>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
see https://github.com/bauripalash/tkhtmlview?tab=readme-ov-file#html-support -->
<html>
<body>
<div style="color: #014F8F; font-size: 14px;">
<div style="color: THEME_COLOR; font-size: 14px;">
<!-- <h1 style="text-align: center;">RSNA DICOM Anonymizer Project Settings</h1> -->

<h2>Project Settings</h2>
Expand Down
2 changes: 1 addition & 1 deletion src/anonymizer/assets/locales/en_US/html/5_operation.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
see https://github.com/bauripalash/tkhtmlview?tab=readme-ov-file#html-support -->
<html>
<body>
<div style="color: #014F8F; font-size: 14px;">
<div style="color: THEME_COLOR; font-size: 14px;">
<!-- <h1 style="text-align: center;">RSNA DICOM Anonymizer Operation</h1> -->

<h2>Importing files</h2>
Expand Down
20 changes: 10 additions & 10 deletions src/anonymizer/assets/locales/en_US/html/6_license.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html>
<body>
<div style="color: #014F8F; font-size: 14px;">
<div style="color: THEME_COLOR; font-size: 14px;">
<h3>License</h3>
The RSNA DICOM Anonymizer software is released under the
<a href="http://mirc.rsna.org/rsnapubliclicense.pdf">RSNA Public License.</a>
Expand All @@ -16,16 +16,16 @@ <h3>Dependencies</h3>
<li><a href="https://github.com/boto/boto3">boto3</a></li>
<li><a href="https://github.com/theorchard/openpyxl">openpyxl</a></li>
<li><a href="https://github.com/giampaolo/psutil">psutil</a></li>
<li><a href="https://github.com/pydicom/pylibjpeg">pylibjpeg</a><li>
<li><a href="https://github.com/pydicom/pylibjpeg">pylibjpeg</a></li>
<li><a href="https://github.com/numpy/numpy">numpy</a></li>
<li><a href="https://github.com/opencv/opencv-python">opencv-python-headless</a><li></li>
<li><a href="https://github.com/JaidedAI/EasyOCR">easyocr</a><li></li>
<li><a href="https://github.com/pyca/cryptography">cryptography</a><li></li>
<li><a href="https://github.com/psf/requests">requests</a><li></li>
<li><a href="https://github.com/requests/requests-oauthlib">requests-oauthlib</a><li></li>
<li><a href="https://github.com/toml-lang/toml">toml</a><li></li>
<li><a href="https://github.com/pallets/click">click</a><li></li>
<li><a href="khttps://github.com/lidatong/dataclasses-json">dataclasses-json</a><li></li>
<li><a href="https://github.com/opencv/opencv-python">opencv-python-headless</a></li>
<li><a href="https://github.com/JaidedAI/EasyOCR">easyocr</a></li>
<li><a href="https://github.com/pyca/cryptography">cryptography</a></li>
<li><a href="https://github.com/psf/requests">requests</a></li>
<li><a href="https://github.com/requests/requests-oauthlib">requests-oauthlib</a></li>
<li><a href="https://github.com/toml-lang/toml">toml</a></li>
<li><a href="https://github.com/pallets/click">click</a></li>
<li><a href="khttps://github.com/lidatong/dataclasses-json">dataclasses-json</a></li>
</ol>
<h3>Dependencies open source licenses</h3>
The software above, included in the RSNA DICOM Anonymizer, is released under the following licenses:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
ver https://github.com/bauripalash/tkhtmlview?tab=readme-ov-file#html-support -->
<html>
<body>
<div style="color: #014F8F; font-size: 14px;">
<div style="color: THEME_COLOR; font-size: 14px;">
<!-- <h1 style="text-align: center;">Visión general del Anonimizador DICOM de RSNA</h1> -->

<h2>Introducción</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
ver https://github.com/bauripalash/tkhtmlview?tab=readme-ov-file#html-support -->
<html>
<body>
<div style="color: #014F8F;font-size: 14px;">
<div style="color: THEME_COLOR;font-size: 14px;">

<h3>Protocolo Estándar DICOM para De-Identificación</h3>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
vea https://github.com/bauripalash/tkhtmlview?tab=readme-ov-file#html-support -->
<html>
<body>
<div style="color: #014F8F;font-size: 14px;">
<div style="color: THEME_COLOR;font-size: 14px;">

<h2>Gestión de Proyectos de Anonimización</h2>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
ver https://github.com/bauripalash/tkhtmlview?tab=readme-ov-file#html-support -->
<html>
<body>
<div style="color: #014F8F; font-size: 14px;">
<div style="color: THEME_COLOR; font-size: 14px;">
<!-- <h1 style="text-align: center;">Configuración del Proyecto Anonimizador DICOM RSNA</h1> -->

<h2>Configuración del Proyecto</h2>
Expand Down
2 changes: 1 addition & 1 deletion src/anonymizer/assets/locales/es/html/5_operación.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
ver https://github.com/bauripalash/tkhtmlview?tab=readme-ov-file#html-support -->
<html>
<body>
<div style="color: #014F8F; font-size: 14px;">
<div style="color: THEME_COLOR; font-size: 14px;">
<!-- <h1 style="text-align: center;">RSNA DICOM Anonymizer Operation</h1> -->

<h2>Importar archivos</h2>
Expand Down
2 changes: 1 addition & 1 deletion src/anonymizer/assets/locales/es/html/6_licencia.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html>
<body>
<div style="color: #014F8F; font-size: 14px;">
<div style="color: THEME_COLOR; font-size: 14px;">
<h3>Licencia</h3>
El software RSNA DICOM Anonymizer se publica bajo la
<a href="http://mirc.rsna.org/rsnapubliclicense.pdf">Licencia Pública de RSNA.</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
ver https://github.com/bauripalash/tkhtmlview?tab=readme-ov-file#html-support -->
<html>
<body>
<div style="color: #014F8F; font-size: 14px;">
<div style="color: THEME_COLOR; font-size: 14px;">
<!-- <h1 style="text-align: center;">Visión general del Anonimizador DICOM de RSNA</h1> -->

<h2>Introducción</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
ver https://github.com/bauripalash/tkhtmlview?tab=readme-ov-file#html-support -->
<html>
<body>
<div style="color: #014F8F;font-size: 14px;">
<div style="color: THEME_COLOR;font-size: 14px;">

<h3>Protocolo Estándar DICOM para De-Identificación</h3>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
ver https://github.com/bauripalash/tkhtmlview?tab=readme-ov-file#html-support -->
<html>
<body>
<div style="color: #014F8F;font-size: 14px;">
<div style="color: THEME_COLOR;font-size: 14px;">

<h3>Protocolo estándar de desidentificación DICOM</h3>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
ver https://github.com/bauripalash/tkhtmlview?tab=readme-ov-file#html-support -->
<html>
<body>
<div style="color: #014F8F; font-size: 14px;">
<div style="color: THEME_COLOR; font-size: 14px;">
<!-- <h1 style="text-align: center;">Configuración del Proyecto Anonimizador DICOM RSNA</h1> -->

<h2>Configuración del Proyecto</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
ver https://github.com/bauripalash/tkhtmlview?tab=readme-ov-file#html-support -->
<html>
<body>
<div style="color: #014F8F; font-size: 14px;">
<div style="color: THEME_COLOR; font-size: 14px;">
<!-- <h1 style="text-align: center;">RSNA DICOM Anonymizer Operation</h1> -->

<h2>Importar archivos</h2>
Expand Down
2 changes: 1 addition & 1 deletion src/anonymizer/assets/locales/es/html_bak/6_licencia.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html>
<body>
<div style="color: #014F8F; font-size: 14px;">
<div style="color: THEME_COLOR; font-size: 14px;">
<h3>Licencia</h3>
El software RSNA DICOM Anonymizer se publica bajo la
<a href="http://mirc.rsna.org/rsnapubliclicense.pdf">Licencia Pública de RSNA.</a>
Expand Down
2 changes: 1 addition & 1 deletion src/anonymizer/assets/locales/fr/html/1_aperçu.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
voir https://github.com/bauripalash/tkhtmlview?tab=readme-ov-file#html-support -->
<html>
<body>
<div style="color: #014F8F; font-size: 14px;">
<div style="color: THEME_COLOR; font-size: 14px;">
<!-- <h1 style="text-align: center;">Présentation de l'Anonymiseur DICOM de la RSNA</h1> -->

<h2>Introduction</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
voir https://github.com/bauripalash/tkhtmlview?tab=readme-ov-file#html-support -->
<html>
<body>
<div style="color: #014F8F;font-size: 14px;">
<div style="color: THEME_COLOR;font-size: 14px;">

<h3>Protocole de Dé-identification Standard DICOM</h3>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
voir https://github.com/bauripalash/tkhtmlview?tab=readme-ov-file#html-support -->
<html>
<body>
<div style="color: #014F8F;font-size: 14px;">
<div style="color: THEME_COLOR;font-size: 14px;">

<h2>Gestion des Projets d'Anonymisation</h2>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
voir https://github.com/bauripalash/tkhtmlview?tab=readme-ov-file#html-support -->
<html>
<body>
<div style="color: #014F8F; font-size: 14px;">
<div style="color: THEME_COLOR; font-size: 14px;">
<!-- <h1 style="text-align: center;">Paramètres du projet RSNA DICOM Anonymiseur</h1> -->

<h2>Paramètres du Projet</h2>
Expand Down
2 changes: 1 addition & 1 deletion src/anonymizer/assets/locales/fr/html/5_opération.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
voir https://github.com/bauripalash/tkhtmlview?tab=readme-ov-file#html-support -->
<html>
<body>
<div style="color: #014F8F; font-size: 14px;">
<div style="color: THEME_COLOR; font-size: 14px;">
<!-- <h1 style="text-align: center;">RSNA DICOM Anonymizer Operation</h1> -->

<h2>Importer des fichiers</h2>
Expand Down
2 changes: 1 addition & 1 deletion src/anonymizer/assets/locales/fr/html/6_licence.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html>
<body>
<div style="color: #014F8F; font-size: 14px;">
<div style="color: THEME_COLOR; font-size: 14px;">
<h3>Licence</h3>
Le logiciel RSNA DICOM Anonymizer est publié sous la
<a href="http://mirc.rsna.org/rsnapubliclicense.pdf">Licence Publique de la RSNA.</a>
Expand Down
6 changes: 3 additions & 3 deletions src/anonymizer/assets/themes/rsna_theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"CTkLabel": {
"corner_radius": 0,
"fg_color": "transparent",
"text_color": ["#014F8F", "#005DA9"]
"text_color": ["#014F8F", "white"]
},
"CTkEntry": {
"corner_radius": 6,
Expand Down Expand Up @@ -52,7 +52,7 @@
"progress_color": ["#3a7ebf", "#1f538d"],
"button_color": ["gray36", "#D5D9DE"],
"button_hover_color": ["gray20", "gray100"],
"text_color": ["#014F8F", "#005DA9"],
"text_color": ["#014F8F", "white"],
"text_color_disabled": ["gray60", "gray45"]
},
"CTkRadioButton": {
Expand Down Expand Up @@ -123,7 +123,7 @@
"border_width": 0,
"fg_color": ["gray90", "gray13"],
"border_color": ["#979DA2", "#565B5E"],
"text_color": ["#014F8F", "#005DA9"],
"text_color": ["#014F8F", "white"],
"scrollbar_button_color": ["gray55", "gray41"],
"scrollbar_button_hover_color": ["gray40", "gray53"]
},
Expand Down
7 changes: 6 additions & 1 deletion src/anonymizer/view/html_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,15 @@ def _create_widgets(self):

"""


# Read the HTML content from the file
with open(self.html_file_path, "r") as file:
html_content = file.read()

# Replace THEME_COLOR placeholder with theme color
theme_color = self._parent._apply_appearance_mode(ctk.ThemeManager.theme["CTkLabel"]["text_color"])
html_content = html_content.replace("THEME_COLOR", theme_color)

# Find all <li> elements and their content
li_elements = re.findall(r"<li>(.*?)</li>", html_content, re.DOTALL)
li_texts = [re.sub(r"<.*?>", "", li).strip() for li in li_elements] # Remove any nested HTML tags
Expand All @@ -68,7 +73,7 @@ def _create_widgets(self):
height=self.HEIGHT_LINES,
wrap="word",
background=self._bg_color,
html=RenderHTML(self.html_file_path),
)
html_widget.set_html(html_content)
html_widget.pack(fill="both", padx=10, pady=10, expand=True)
html_widget.configure(state="disabled")
Loading