add icons

This commit is contained in:
Ross Kruger
2024-02-25 09:06:00 +00:00
parent 5ecfb26a80
commit abeb24dd00
6 changed files with 74 additions and 43 deletions
+73 -43
View File
@@ -79,6 +79,9 @@ import contextlib
# import watchdog.observers # import watchdog.observers
__VERSION__ = 0.1
__APP_NAME__ = "Uploader"
anonymizer = dicognito.anonymizer.Anonymizer() anonymizer = dicognito.anonymizer.Anonymizer()
# determine if application is a script file or frozen exe # determine if application is a script file or frozen exe
@@ -154,6 +157,7 @@ def annonymise(
run_gui: bool = True, run_gui: bool = True,
file_list: bool = False, file_list: bool = False,
dev: bool = False, dev: bool = False,
remove_files_on_annonymisation: bool = True,
): ):
logger.debug(locals()) logger.debug(locals())
if run_gui: # Let the GUI handle it all if run_gui: # Let the GUI handle it all
@@ -164,6 +168,7 @@ def annonymise(
clear_files=False, clear_files=False,
clear_files_on_close=True, clear_files_on_close=True,
dev=dev, dev=dev,
remove_files_on_annonymisation=remove_files_on_annonymisation,
) )
return return
if path.is_dir(): if path.is_dir():
@@ -312,8 +317,13 @@ class LoginDialog(wx.Dialog):
self.main_sizer.Add(self.error_text) self.main_sizer.Add(self.error_text)
self.Bind(wx.EVT_CLOSE, self.on_close)
self.SetSizer(main_sizer) self.SetSizer(main_sizer)
def on_close(self, event):
self.Destroy()
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
def on_login(self, event): def on_login(self, event):
""" """
@@ -555,11 +565,13 @@ class AnonGui(wx.App):
self.frame = wx.Frame( self.frame = wx.Frame(
None, None,
wx.ID_ANY, wx.ID_ANY,
title="Uploader", title=__APP_NAME__,
style=wx.DEFAULT_FRAME_STYLE | wx.STAY_ON_TOP, style=wx.DEFAULT_FRAME_STYLE | wx.STAY_ON_TOP,
size=(300, 300), size=(300, 400),
) )
self.frame.SetIcon(wx.Icon("icon/icon1.ico"))
self.panel = wx.Panel(self.frame, wx.ID_ANY) self.panel = wx.Panel(self.frame, wx.ID_ANY)
self.file_detail_map = {} self.file_detail_map = {}
@@ -576,26 +588,26 @@ class AnonGui(wx.App):
self.panel.sizer = wx.BoxSizer(wx.VERTICAL) self.panel.sizer = wx.BoxSizer(wx.VERTICAL)
self.link_rapid_upload = hl.HyperLinkCtrl( #self.link_rapid_upload = hl.HyperLinkCtrl(
self.panel, # self.panel,
wx.ID_ANY, # wx.ID_ANY,
"Rapid", # "Rapid",
URL=f"{self.base_site_url}/rapids/create/", # URL=f"{self.base_site_url}/rapids/create/",
) #)
# self.panel.sizer.Add(self.link_rapid_upload, 0, wx.ALL, 10) ## self.panel.sizer.Add(self.link_rapid_upload, 0, wx.ALL, 10)
self.link_long_upload = hl.HyperLinkCtrl( #self.link_long_upload = hl.HyperLinkCtrl(
self.panel, # self.panel,
wx.ID_ANY, # wx.ID_ANY,
"Long Series", # "Long Series",
URL=f"{self.base_site_url}/longs/create/series", # URL=f"{self.base_site_url}/longs/create/series",
) #)
self.link_atlas_case = hl.HyperLinkCtrl( #self.link_atlas_case = hl.HyperLinkCtrl(
self.panel, # self.panel,
wx.ID_ANY, # wx.ID_ANY,
"Atlas Case", # "Atlas Case",
URL=f"{self.base_site_url}/atlas/case/create/", # URL=f"{self.base_site_url}/atlas/case/create/",
) #)
# self.panel.sizer.Add(self.link_long_upload, 0, wx.ALL, 10) # self.panel.sizer.Add(self.link_long_upload, 0, wx.ALL, 10)
# Create menu bar # Create menu bar
@@ -616,6 +628,8 @@ class AnonGui(wx.App):
#file_menu.Append(wx.ID_SAVE, "&Save") #file_menu.Append(wx.ID_SAVE, "&Save")
#file_menu.AppendSeparator() #file_menu.AppendSeparator()
file_menu.Append(wx.ID_EXIT, "&Exit") file_menu.Append(wx.ID_EXIT, "&Exit")
self.Bind(wx.EVT_MENU, lambda evt: wx.Exit(), id=wx.ID_EXIT)
self.menu_bar.Append(file_menu, "&File") self.menu_bar.Append(file_menu, "&File")
@@ -683,11 +697,11 @@ class AnonGui(wx.App):
# Set menu bar # Set menu bar
self.frame.SetMenuBar(self.menu_bar) self.frame.SetMenuBar(self.menu_bar)
hoz_links = wx.BoxSizer(wx.HORIZONTAL) #hoz_links = wx.BoxSizer(wx.HORIZONTAL)
hoz_links.Add(self.link_rapid_upload, 1, wx.EXPAND) #hoz_links.Add(self.link_rapid_upload, 1, wx.EXPAND)
hoz_links.Add(self.link_long_upload, 1, wx.EXPAND) #hoz_links.Add(self.link_long_upload, 1, wx.EXPAND)
hoz_links.Add(self.link_atlas_case, 1, wx.EXPAND) #hoz_links.Add(self.link_atlas_case, 1, wx.EXPAND)
self.panel.sizer.Add(hoz_links, 1, wx.EXPAND) #self.panel.sizer.Add(hoz_links, 1, wx.EXPAND)
# self.dirctrl = wx.GenericDirCtrl(self.panel, wx.ID_ANY, # self.dirctrl = wx.GenericDirCtrl(self.panel, wx.ID_ANY,
# dir=dir, # dir=dir,
@@ -695,7 +709,7 @@ class AnonGui(wx.App):
# wx.DIRCTRL_3D_INTERNAL | # wx.DIRCTRL_3D_INTERNAL |
# wx.DIRCTRL_MULTIPLE, # wx.DIRCTRL_MULTIPLE,
# filter="Dicom files (*.dcm)|*.dcm") # filter="Dicom files (*.dcm)|*.dcm")
upload_drag_sizer = wx.BoxSizer(wx.HORIZONTAL) bottom_button_sizer = wx.BoxSizer(wx.HORIZONTAL)
self.drag_button = wx.Button( self.drag_button = wx.Button(
self.panel, id=wx.ID_ANY, label="Drag" self.panel, id=wx.ID_ANY, label="Drag"
) )
@@ -705,8 +719,8 @@ class AnonGui(wx.App):
) )
self.upload_button.SetToolTip("Upload files to the server. You must be logged in.") self.upload_button.SetToolTip("Upload files to the server. You must be logged in.")
self.upload_button.Disable() self.upload_button.Disable()
upload_drag_sizer.Add(self.upload_button, 4, wx.EXPAND) bottom_button_sizer.Add(self.upload_button, 4, wx.EXPAND)
upload_drag_sizer.Add(self.drag_button, 1, wx.EXPAND) bottom_button_sizer.Add(self.drag_button, 1, wx.EXPAND)
# Use some sizers to see layout options # Use some sizers to see layout options
# self.panel.sizer.Add(self.dirctrl, 1, wx.EXPAND) # self.panel.sizer.Add(self.dirctrl, 1, wx.EXPAND)
@@ -755,7 +769,7 @@ class AnonGui(wx.App):
self.panel.sizer.Add(self.list_ctrl, 8, wx.EXPAND) self.panel.sizer.Add(self.list_ctrl, 8, wx.EXPAND)
#self.panel.sizer.Add(self.drag_button, 2, wx.EXPAND) #self.panel.sizer.Add(self.drag_button, 2, wx.EXPAND)
#self.panel.sizer.Add(self.upload_button, 2, wx.EXPAND) #self.panel.sizer.Add(self.upload_button, 2, wx.EXPAND)
self.panel.sizer.Add(upload_drag_sizer, 2, wx.EXPAND) self.panel.sizer.Add(bottom_button_sizer, 1, wx.EXPAND)
self.progress_sizer = wx.BoxSizer(wx.VERTICAL) self.progress_sizer = wx.BoxSizer(wx.VERTICAL)
self.progress_bar = wx.Gauge( self.progress_bar = wx.Gauge(
@@ -807,13 +821,13 @@ class AnonGui(wx.App):
def import_from_dir(self, event): def import_from_dir(self, event):
default_path = str(self.input_dir.resolve()) default_path = str(self.input_dir.resolve())
with wx.DirDialog( with wx.DirDialog(
self.frame, "Choose a directory", style=wx.DD_DIR_MUST_EXIST, defaultPath=default_path self.frame, "Choose a directory to import dicom files from.", style=wx.DD_DIR_MUST_EXIST, defaultPath=default_path
) as dlg: ) as dlg:
if dlg.ShowModal() == wx.ID_OK: if dlg.ShowModal() == wx.ID_OK:
load_path = Path(dlg.GetPath()) load_path = Path(dlg.GetPath())
self.AnnonymiseFilesInDir(load_path, self.dir) self.AnnonymiseFilesInDir(load_path, self.dir, remove_original=False)
def AnnonymiseFilesInDir(self, input_dir, output_dir): def AnnonymiseFilesInDir(self, input_dir, output_dir, remove_original: bool | None=None):
logger.debug("AnnonymiseFilesInDir") logger.debug("AnnonymiseFilesInDir")
logger.debug(f"input: {input_dir} / output {output_dir}") logger.debug(f"input: {input_dir} / output {output_dir}")
if input_dir.is_dir(): if input_dir.is_dir():
@@ -829,6 +843,10 @@ class AnonGui(wx.App):
logger.debug(files) logger.debug(files)
if remove_original is None:
remove_original = self.remove_files_on_annonymisation
# files = order_files_by_dicom_attribute(files) # files = order_files_by_dicom_attribute(files)
# progress_dialog = wx.ProgressDialog( # progress_dialog = wx.ProgressDialog(
@@ -852,7 +870,7 @@ class AnonGui(wx.App):
i += 1 i += 1
# new_filepath = Path(output_dir).joinpath(f"IMG_{i:03}.dcm") # new_filepath = Path(output_dir).joinpath(f"IMG_{i:03}.dcm")
dataset, filepath = anonymize_file(file, new_filepath, remove_original=self.remove_files_on_annonymisation) dataset, filepath = anonymize_file(file, new_filepath, remove_original=remove_original)
self.add_datails_to_file_detail_map(dataset, filepath) self.add_datails_to_file_detail_map(dataset, filepath)
# progress_dialog.Destroy() # progress_dialog.Destroy()
@@ -864,8 +882,8 @@ class AnonGui(wx.App):
self.progress_text.SetLabelText(text) self.progress_text.SetLabelText(text)
self.progress_bar.SetRange(total) self.progress_bar.SetRange(total)
self.progress_sizer.ShowItems(show=True) self.progress_sizer.ShowItems(show=True)
self.panel.Layout()
self.panel.sizer.Fit(self.panel) self.panel.sizer.Fit(self.panel)
self.frame.Layout()
try: try:
class P: class P:
@@ -877,6 +895,7 @@ class AnonGui(wx.App):
def update(self, n: int): def update(self, n: int):
self.gui.progress_bar.SetValue(n) self.gui.progress_bar.SetValue(n)
self.gui.progress_text.SetLabelText(f"{self.text} : {n}") self.gui.progress_text.SetLabelText(f"{self.text} : {n}")
self.gui.frame.Refresh()
yield P(self, total, text) yield P(self, total, text)
finally: finally:
@@ -900,12 +919,18 @@ class AnonGui(wx.App):
def on_about_box(self, event=None): def on_about_box(self, event=None):
description = f""" description = f"""
An upload/export tool A dicom export/upload tool
Settings Settings
-------- --------
Watch/import dir: {self.input_dir} Watch/import dir: {self.input_dir}
Annonymised files dir: {self.dir} Annonymised files dir: {self.dir}
clear files on start: {self.clear_files_on_start}
clear files on close: {self.clear_files_on_close}
remove files on annonymisations: {self.remove_files_on_annonymisation}
base site url: {self.base_site_url}
""" """
licence = """GPL""" licence = """GPL"""
@@ -913,15 +938,17 @@ class AnonGui(wx.App):
info = wx.adv.AboutDialogInfo() info = wx.adv.AboutDialogInfo()
# info.SetIcon(wx.Icon('hunter.png', wx.BITMAP_TYPE_PNG)) # info.SetIcon(wx.Icon('hunter.png', wx.BITMAP_TYPE_PNG))
info.SetName("RadUploader") info.SetName(__APP_NAME__)
info.SetVersioe("0.1") info.SetVersion(__VERSION__)
info.SetDescription(description) info.SetDescription(description)
info.SetIcon(wx.Icon("icon/icon1.png", desiredWidth=100))
info.SetLicence(licence) info.SetLicence(licence)
wx.adv.AboutBox(info) wx.adv.AboutBox(info)
def OnExit(self): def OnExit(self, event=None):
print("on exit")
if self.clear_files_on_close: if self.clear_files_on_close:
self.ClearFiles(load_dir=False) self.ClearFiles(load_dir=False)
@@ -1242,6 +1269,9 @@ class AnonGui(wx.App):
self.list_ctrl.UpdateData(DATA) self.list_ctrl.UpdateData(DATA)
self.populate_series_grid() self.populate_series_grid()
self.frame.Refresh()
self.frame.Layout()
# progress_dialog.Destroy() # progress_dialog.Destroy()
# if hashes: # if hashes:
+1
View File
@@ -34,4 +34,5 @@ exe = EXE(
target_arch=None, target_arch=None,
codesign_identity=None, codesign_identity=None,
entitlements_file=None, entitlements_file=None,
icon='icon\\icon1.ico'
) )
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 401 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 690 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB