Compare commits
2
Commits
e4c5847fd1
...
5ecfb26a80
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ecfb26a80 | ||
|
|
858ff6c9cb |
+103
-36
@@ -522,6 +522,7 @@ class AnonGui(wx.App):
|
||||
|
||||
if self.instance.IsAnotherRunning():
|
||||
logger.debug("Another instance detected")
|
||||
wx.adv.NotificationMessage("Another instance detected", "Trigger refresh").Show()
|
||||
context = zmq.Context()
|
||||
socket = context.socket(zmq.PUSH)
|
||||
socket.connect("tcp://127.0.0.1:5556")
|
||||
@@ -596,6 +597,92 @@ class AnonGui(wx.App):
|
||||
URL=f"{self.base_site_url}/atlas/case/create/",
|
||||
)
|
||||
# self.panel.sizer.Add(self.link_long_upload, 0, wx.ALL, 10)
|
||||
|
||||
# Create menu bar
|
||||
self.menu_bar = wx.MenuBar()
|
||||
|
||||
|
||||
# Create File menu
|
||||
file_menu = wx.Menu()
|
||||
|
||||
|
||||
# Create Load menu item
|
||||
load_item = wx.MenuItem(file_menu, wx.ID_ANY, "&Import Directory")
|
||||
#load_item.SetToolTip("Click to manually load dicom from a directory.")
|
||||
file_menu.Append(load_item)
|
||||
|
||||
self.Bind(wx.EVT_MENU, self.import_from_dir, load_item)
|
||||
#file_menu.Append(wx.ID_OPEN, "&Open")
|
||||
#file_menu.Append(wx.ID_SAVE, "&Save")
|
||||
#file_menu.AppendSeparator()
|
||||
file_menu.Append(wx.ID_EXIT, "&Exit")
|
||||
self.menu_bar.Append(file_menu, "&File")
|
||||
|
||||
|
||||
# Create Images menu
|
||||
images_menu = wx.Menu()
|
||||
|
||||
# Create Clear Files menu item
|
||||
clear_files_item = wx.MenuItem(images_menu, wx.ID_ANY, "&Clear files")
|
||||
#clear_files_item.SetToolTip("Click to clear all files.")
|
||||
images_menu.Append(clear_files_item)
|
||||
|
||||
self.menu_bar.Append(images_menu, "&Images")
|
||||
|
||||
# Create Reorder Files menu item
|
||||
reorder_files_item = wx.MenuItem(images_menu, wx.ID_ANY, "&Reorder")
|
||||
#reorder_files_item.SetToolTip("Click to reorder files as they are shown below. This will sequentially rename the files. Please note this is usually better done once the files have been uploaded.")
|
||||
images_menu.Append(reorder_files_item)
|
||||
|
||||
self.Bind(wx.EVT_MENU, self.on_reorder_files, reorder_files_item)
|
||||
|
||||
# Bind Clear Files menu item event
|
||||
self.Bind(wx.EVT_MENU, self.ClearFiles, clear_files_item)
|
||||
|
||||
|
||||
# Create Reannonymise Files menu item
|
||||
reannonymise_files_item = wx.MenuItem(images_menu, wx.ID_ANY, "&Reannonymise")
|
||||
#reannonymise_files_item.SetToolTip("Click to reannonymise the currently loaded files.")
|
||||
images_menu.Append(reannonymise_files_item)
|
||||
|
||||
self.Bind(wx.EVT_MENU, self.on_reannonymise_files, reannonymise_files_item)
|
||||
|
||||
|
||||
# Create Refresh Files menu item
|
||||
refresh_files_item = wx.MenuItem(images_menu, wx.ID_ANY, "&Refresh")
|
||||
images_menu.Append(refresh_files_item)
|
||||
|
||||
self.Bind(wx.EVT_MENU, lambda evt: self.LoadDir(), refresh_files_item)
|
||||
|
||||
|
||||
# Create Item creation menu
|
||||
create_menu = wx.Menu()
|
||||
|
||||
create_menu_items = (
|
||||
("&Rapid", f"/rapids/create/"),
|
||||
("&Long Series", f"/longs/create/series"),
|
||||
("&Atlas Case", f"/atlas/case/create/"),
|
||||
)
|
||||
|
||||
for label, url in create_menu_items:
|
||||
item = wx.MenuItem(create_menu, wx.ID_ANY, label)
|
||||
create_menu.Append(item)
|
||||
self.Bind(wx.EVT_MENU, lambda evt, url=url: webbrowser.open(f"{self.base_site_url}{url}"), item)
|
||||
|
||||
self.menu_bar.Append(create_menu, "&Create")
|
||||
|
||||
# Create Help menu
|
||||
help_menu = wx.Menu()
|
||||
help_menu.Append(wx.ID_HELP, "&Help")
|
||||
help_menu.Append(wx.ID_ABOUT, "&About")
|
||||
self.menu_bar.Append(help_menu, "&Help")
|
||||
|
||||
self.Bind(wx.EVT_MENU, self.on_about_box, id=wx.ID_ABOUT)
|
||||
self.Bind(wx.EVT_MENU, self.on_help, id=wx.ID_HELP)
|
||||
|
||||
# Set menu bar
|
||||
self.frame.SetMenuBar(self.menu_bar)
|
||||
|
||||
hoz_links = wx.BoxSizer(wx.HORIZONTAL)
|
||||
hoz_links.Add(self.link_rapid_upload, 1, wx.EXPAND)
|
||||
hoz_links.Add(self.link_long_upload, 1, wx.EXPAND)
|
||||
@@ -651,43 +738,16 @@ class AnonGui(wx.App):
|
||||
self.login_button.SetForegroundColour(wx.BLUE)
|
||||
self.login_button.SetBackgroundColour(wx.WHITE)
|
||||
self.login_button.SetToolTip("Click to login to the server")
|
||||
self.clear_files_button = wx.Button(
|
||||
self.panel, id=wx.ID_ANY, label="Clear files"
|
||||
)
|
||||
self.clear_files_button.SetToolTip("Click to clear all files.")
|
||||
self.refresh_files_button = wx.Button(self.panel, id=wx.ID_ANY, label="Refresh")
|
||||
self.reorder_files_button = wx.Button(self.panel, id=wx.ID_ANY, label="Reorder")
|
||||
self.reorder_files_button.SetToolTip("Click to reorder files as they are shown below. This will sequentially rename the files. Please note this is usually better done once the files have been uploaded.")
|
||||
self.reannonymise_files_button = wx.Button(
|
||||
self.panel, id=wx.ID_ANY, label="Reannonymise"
|
||||
)
|
||||
self.reannonymise_files_button.SetToolTip("Click to reannonymise the currently loaded files.")
|
||||
self.manual_load_button = wx.Button(self.panel, id=wx.ID_ANY, label="Load")
|
||||
self.manual_load_button.SetToolTip("Click to manually load dicom from a directory.")
|
||||
|
||||
|
||||
# wx.Bind(self.clear_files_button, )
|
||||
self.Bind(wx.EVT_BUTTON, self.Login, self.login_button)
|
||||
self.Bind(wx.EVT_BUTTON, self.ClearFiles, self.clear_files_button)
|
||||
self.Bind(wx.EVT_BUTTON, lambda evt: self.LoadDir(), self.refresh_files_button)
|
||||
self.Bind(wx.EVT_BUTTON, self.ReorderFiles, self.reorder_files_button)
|
||||
self.Bind(wx.EVT_BUTTON, self.ReAnnonymiseFiles, self.reannonymise_files_button)
|
||||
#self.Bind(
|
||||
# wx.EVT_BUTTON,
|
||||
# lambda evt: self.AnnonymiseFilesInDir(self.input_dir, self.dir),
|
||||
# self.manual_load_button,
|
||||
#)
|
||||
self.Bind(wx.EVT_BUTTON, self.import_from_dir, self.manual_load_button)
|
||||
|
||||
#self.Bind(wx.EVT_BUTTON, self.ClearFiles, self.clear_files_button)
|
||||
# Use some sizers to see layout options
|
||||
# self.panel.sizer.Add(self.dirctrl, 1, wx.EXPAND)
|
||||
|
||||
hoz = wx.BoxSizer(wx.HORIZONTAL)
|
||||
hoz.Add(self.login_button, 1, wx.EXPAND)
|
||||
hoz.Add(self.clear_files_button, 1, wx.EXPAND)
|
||||
hoz.Add(self.refresh_files_button, 1, wx.EXPAND)
|
||||
hoz.Add(self.reorder_files_button, 1, wx.EXPAND)
|
||||
hoz.Add(self.reannonymise_files_button, 1, wx.EXPAND)
|
||||
hoz.Add(self.manual_load_button, 1, wx.EXPAND)
|
||||
|
||||
self.panel.sizer.Add(hoz, 1, wx.EXPAND)
|
||||
|
||||
@@ -747,7 +807,7 @@ class AnonGui(wx.App):
|
||||
def import_from_dir(self, event):
|
||||
default_path = str(self.input_dir.resolve())
|
||||
with wx.DirDialog(
|
||||
self.frame, "Choose a directory", style=wx.DD_DEFAULT_STYLE, defaultPath=default_path
|
||||
self.frame, "Choose a directory", style=wx.DD_DIR_MUST_EXIST, defaultPath=default_path
|
||||
) as dlg:
|
||||
if dlg.ShowModal() == wx.ID_OK:
|
||||
load_path = Path(dlg.GetPath())
|
||||
@@ -831,17 +891,21 @@ class AnonGui(wx.App):
|
||||
logger.debug(keycode)
|
||||
if keycode == wx.WXK_F1:
|
||||
logger.debug("you pressed the F1!")
|
||||
self.OnAboutBox()
|
||||
self.on_help()
|
||||
return
|
||||
event.Skip()
|
||||
|
||||
def OnAboutBox(self, event=None):
|
||||
def on_help(self, event=None):
|
||||
webbrowser.open(f"{self.base_site_url}/atlas/help")
|
||||
|
||||
def on_about_box(self, event=None):
|
||||
description = f"""
|
||||
An upload/export tool
|
||||
|
||||
Settings
|
||||
--------
|
||||
Watch dir: {self.dir}
|
||||
Watch/import dir: {self.input_dir}
|
||||
Annonymised files dir: {self.dir}
|
||||
"""
|
||||
|
||||
licence = """GPL"""
|
||||
@@ -850,7 +914,7 @@ class AnonGui(wx.App):
|
||||
|
||||
# info.SetIcon(wx.Icon('hunter.png', wx.BITMAP_TYPE_PNG))
|
||||
info.SetName("RadUploader")
|
||||
info.SetVersion("0.1")
|
||||
info.SetVersioe("0.1")
|
||||
info.SetDescription(description)
|
||||
|
||||
info.SetLicence(licence)
|
||||
@@ -872,6 +936,9 @@ class AnonGui(wx.App):
|
||||
self.file_duplicate_check = {}
|
||||
if dir is None:
|
||||
dir = self.dir
|
||||
|
||||
logger.debug(f"LoadDir : {dir} / refresh: {refresh} / clear_file_detail_map: {clear_file_detail_map}")
|
||||
|
||||
if refresh:
|
||||
self.files = {}
|
||||
self.series_map = {}
|
||||
@@ -944,7 +1011,7 @@ class AnonGui(wx.App):
|
||||
# viewer.MainLoop()
|
||||
break
|
||||
|
||||
def ReAnnonymiseFiles(self, event):
|
||||
def on_reannonymise_files(self, event):
|
||||
global anonymizer
|
||||
anonymizer = dicognito.anonymizer.Anonymizer()
|
||||
paths = []
|
||||
@@ -969,7 +1036,7 @@ class AnonGui(wx.App):
|
||||
|
||||
self.LoadDir(self.dir, clear_file_detail_map=True)
|
||||
|
||||
def ReorderFiles(self, event):
|
||||
def on_reorder_files(self, event):
|
||||
paths = []
|
||||
|
||||
# self.file_observer.pause()
|
||||
|
||||
Reference in New Issue
Block a user