-
Notifications
You must be signed in to change notification settings - Fork 1
/
interface_recorder.py
87 lines (62 loc) · 2.45 KB
/
interface_recorder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import os
import tkinter as tk
import sys
from tkinter import filedialog
from tkinter import ttk
from openslide import open_slide
from openslide.deepzoom import DeepZoomGenerator
from modules.recorder import Recorder
class FileSelection:
def __init__(self, master):
self.master = master
self.frame = tk.Frame(self.master)
# select file button
select_button = tk.Button(self.frame, text='Select File')
select_button.pack(fill=tk.X)
select_button.bind('<Button-1>', self.file_selection)
self.frame.pack(padx=50, pady=50)
if len(sys.argv) >= 2:
root.tiles_directory = sys.argv[1]
else:
root.tiles_directory = None
def file_selection(self, event):
# open the file selection menu and get the file path
root.file_path = filedialog.askopenfilename()
# separate the file name from the full path
root.file_name = os.path.basename(root.file_path)
print("root.file_path: {}".format(root.file_path))
self.frame.pack_forget()
self.app = LevelSelection(self.master)
class LevelSelection:
def __init__(self, master):
frame = tk.Frame(root)
frame.focus_force()
slide = open_slide(root.file_path)
dz_generator = DeepZoomGenerator(slide)
select_level = ttk.Label(frame, text="Select Initial Level")
select_level.pack()
# combo box for initial level
selection = ttk.Combobox(
frame, values=[i for i in range(dz_generator.level_count)])
selection.pack()
# confirm button
confirm = tk.Button(frame, text='OK')
confirm.pack()
def on_button_press(event):
frame.pack_forget()
Recorder(root, deep_zoom_object=dz_generator, level=int(selection.get()))
# print ("Recorder")
# # if tiles_dirctory is provided in args, the visualiser tool is run
# if root.tiles_directory is None:
# Recorder(root, deep_zoom_object=dz_generator, level=int(selection.get()))
# print ("Recorder")
# else:
# Visualiser(root, deep_zoom_object=dz_generator, level=int(selection.get()))
# print ("Visualiser")
confirm.bind('<Button-1>', on_button_press)
frame.pack(padx=50, pady=50)
root = tk.Tk()
root.minsize(width=250, height=125)
root.title("WSI Viewer")
app = FileSelection(root)
root.mainloop()