示例#1
0
    def __init__(self, mainframe, path):
        """ Initialize the main Frame """
        ttk.Frame.__init__(self, master=mainframe)
        self.master.title('Advanced Zoom v3.0')
        self.master.geometry('800x600')  # size of the main window
        # self.master.rowconfigure(0, weight=1)  # make the CanvasImage widget expandable
        # self.master.columnconfigure(0, weight=1)

        navbar = Frame(self.master, width=100)
        navbar.pack(anchor=W, fill=Y, expand=False, side=LEFT)  # <----

        button = ttk.Button(navbar, text="object 1", command=self.btn1)
        button.grid(column=1, row=1)

        button = ttk.Button(navbar, text="object 2", command=self.btn2)
        button.grid(column=1, row=2)

        content_frame = Frame(self.master)
        content_frame.pack(anchor=N, fill=BOTH, expand=True, side=LEFT)
        content_frame.rowconfigure(
            0, weight=1)  # make the CanvasImage widget expandable
        content_frame.columnconfigure(0, weight=1)

        self.canvas = DrawTools(content_frame, path)  # create widget
        self.canvas.grid(row=0, column=0)  # show widget

        self.obj1 = Myobj1(self.canvas)
        self.obj2 = Myobj2(self.canvas)
示例#2
0
    def open_image_loc(self):

        image = filedialog.askopenfilename(
            initialdir=self.controller.working_dir)

        if isinstance(image, str) and image != "":

            dir_name = os.path.dirname(image)
            rel_path = os.path.relpath(image, dir_name)

            # only allow images from the working dir
            if self.controller.working_dir != dir_name:
                print("mis-match")
                self.warningBox("Image not from working directory")
                return

            # current session
            self.med_image = image
            self.canvas = DrawTools(self.content_frame, image)  # create widget
            self.canvas.grid(row=0, column=0)  # show widget

            # update canvas object for children
            for obj in self.objects:
                self.objects[obj].update_canvas(self.canvas)

            # save to json for future sessions
            # self.master_dict["IMAGES"]["PRE-SKY"] = image
            self.master_dict["IMAGES"]["PRE-SKY"] = rel_path

            # save to pat.json
            self.controller.save_json()
示例#3
0
    def __init__(self, mainframe, path):
        """ Initialize the main Frame """
        ttk.Frame.__init__(self, master=mainframe)
        self.master.title('Advanced Zoom v3.0')
        self.master.geometry('800x600')  # size of the main window
        # self.master.rowconfigure(0, weight=1)  # make the CanvasImage widget expandable
        # self.master.columnconfigure(0, weight=1)

        # navbar
        navbar = Frame(self.master, width=100)
        navbar.pack(anchor=W, fill=Y, expand=False, side=LEFT)

        self.frames = {}
        for F in (Menu1, Menu2, Menu3):
            page_name = F.__name__
            frame = F(parent=navbar, controller=self)
            self.frames[page_name] = frame

            # put all of the pages in the same location;
            # the one on the top of the stacking order
            # will be the one that is visible.
            frame.grid(row=0, column=0, sticky="nsew")

        # # btn 1
        # button = ttk.Button(navbar, text="object 1", command=self.btn1)
        # button.grid(column=1, row=1)
        # # btn 2
        # button = ttk.Button(navbar, text="object 2", command=self.btn2)
        # button.grid(column=1, row=2)

        # add menu bar
        menubar = Menu(self.master)
        filemenu = Menu(menubar, tearoff=0)
        filemenu.add_command(label="New", command=self.donothing)
        filemenu.add_command(label="Open", command=self.donothing)
        filemenu.add_command(label="Save", command=self.donothing)
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=self.master.quit)
        menubar.add_cascade(label="File", menu=filemenu)
        helpmenu = Menu(menubar, tearoff=0)
        helpmenu.add_command(label="Help Index", command=self.donothing)
        helpmenu.add_command(label="About...", command=self.donothing)
        menubar.add_cascade(label="Help", menu=helpmenu)
        self.master.config(menu=menubar)

        # canvas frame
        content_frame = Frame(self.master)
        content_frame.pack(anchor=N, fill=BOTH, expand=True, side=LEFT)
        content_frame.rowconfigure(
            0, weight=1)  # make the CanvasImage widget expandable
        content_frame.columnconfigure(0, weight=1)

        # gui for draw tools
        self.canvas = DrawTools(content_frame, path)  # create widget
        self.canvas.grid(row=0, column=0)  # show widget

        # create objects
        self.obj1 = Myobj1(self.canvas)
        self.obj2 = Myobj2(self.canvas)
示例#4
0
    def resetImg(self, image):
        self.canvas.destroy()
        self.canvas = DrawTools(self.content_frame, image)  # create widget
        self.canvas.grid(row=0, column=0)  # show widget

        # update canvas object for children
        for obj in self.objects:
            self.objects[obj].update_canvas(self.canvas)
示例#5
0
    def __init__(self, mainframe, path):
        """ Initialize the main Frame """
        ttk.Frame.__init__(self, master=mainframe)
        self.master.title('Advanced Zoom v3.0')
        self.master.geometry('800x600')  # size of the main window
        # self.master.rowconfigure(0, weight=1)  # make the CanvasImage widget expandable
        # self.master.columnconfigure(0, weight=1)

        navbar = Frame(self.master, width=100)
        navbar.pack(anchor=W, fill=Y, expand=False, side=LEFT)  # <----

        button = ttk.Button(navbar, text="object 1", command=self.btn1)
        button.grid(column=1, row=1)

        button = ttk.Button(navbar, text="object 2", command=self.btn2)
        button.grid(column=1, row=2)

        content_frame = Frame(self.master)
        content_frame.pack(anchor=N, fill=BOTH, expand=True, side=LEFT)
        content_frame.rowconfigure(
            0, weight=1)  # make the CanvasImage widget expandable
        content_frame.columnconfigure(0, weight=1)

        self.master_dict = {}

        # for F in (Menu1, Menu2, Menu3):
        # 	page_name = F.__name__

        # obj11 = AFTA()
        # print(obj11.name)
        # obj22 = HKA()
        # print(obj22.name)
        # obj3 = MNSA()
        # print(obj3.name)
        # obj4 = ALDFA()
        # print(obj4.name)
        # obj5 = MLDFA()
        # print(obj5.name)
        # obj6 = MPTA()
        # print(obj6.name)
        # obj7 = VCA()
        # print(obj7.name)

        self.draw_tools = DrawTools(content_frame, path)  # create widget
        self.draw_tools.grid(row=0, column=0)  # show widget

        self.obj1 = MainAnatomy(self.draw_tools, self.master_dict)
        self.obj2 = Myobj2(self.draw_tools)
示例#6
0
	def update_dict(self, master_dict):
		
		# update dictionaries
		self.master_dict = master_dict
		for obj in self.objects:
			self.objects[obj].update_dict(master_dict)

		# found json data, load image from json
		if self.master_dict["IMAGES"]["PRE-LAT"] != None:

			# self.med_image = self.master_dict["IMAGES"]["PRE-LAT"]
			self.med_image = self.controller.working_dir + "/" + self.master_dict["IMAGES"]["PRE-LAT"]
			self.canvas = DrawTools(self.content_frame, self.med_image)  # create widget
			self.canvas.grid(row=0, column=0)  # show widget

			# update canvas object for children
			for obj in self.objects:			
				self.objects[obj].update_canvas(self.canvas)
示例#7
0
class PRE_SKY_View(tk.Frame):
    def __init__(self, parent, controller, master_dict):
        tk.Frame.__init__(self, parent)
        self.controller = controller

        # choosen by user OR
        # loaded from pat.json
        self.med_image = ""
        self.canvas = ""
        self.master_dict = master_dict

        # topbar
        self.topbar = Frame(self, height=100)
        self.topbar.pack(anchor=E, fill=X, expand=False, side=TOP)

        # make buttons in the topbar
        for x, text in enumerate(["SA", "P_TILT"]):
            # print(text)
            button = ttk.Button(self.topbar,
                                text=text,
                                command=lambda text=text: self.show_menu(text))
            button.grid(column=x, row=1)

        # left navbar
        self.navbar = Frame(self, width=100)
        self.navbar.pack(anchor=W, fill=Y, expand=False, side=LEFT)

        self.content_frame = Frame(self, bg="red")
        self.content_frame.pack(anchor=N, fill=BOTH, expand=True, side=LEFT)
        self.content_frame.rowconfigure(
            0, weight=1)  # make the CanvasImage widget expandable
        self.content_frame.columnconfigure(0, weight=1)

        # create menus
        self.menus = {}
        for M in (SA_Menu, P_TILT_Menu):
            page_name = M.__name__
            menu = M(parent=self.navbar, controller=self)
            self.menus[page_name] = menu

            # put all of the pages in the same location;
            # the one on the top of the stacking order
            # will be the one that is visible.
            menu.grid(row=0, column=0, sticky="nsew")

        self.objects = {}
        for Obj in (SA, P_TILT):
            obj_name = Obj.__name__
            # print(obj_name)
            self.objects[obj_name] = Obj(self.canvas,
                                         self.master_dict,
                                         controller=self,
                                         op_type="PRE-OP")

    def show_frame(self, page_name):
        '''Show a frame for the given page name'''
        frame = self.menus[page_name]
        frame.tkraise()

    def warningBox(self, message):
        '''Display a warning box with message'''
        messagebox.showwarning("Warning", message)

    def save_json(self):
        '''bubble to top'''
        self.controller.save_json()

    def escapeFunc(self):
        if self.canvas != "":
            try:
                self.canvas.cur_obj.escapeObjFunc()
            except Exception as e:
                raise e

    def is_set_med_image(self):
        if self.med_image != "":
            return True
        return False

    def update_dict(self, master_dict):

        # update dictionaries
        self.master_dict = master_dict
        for obj in self.objects:
            self.objects[obj].update_dict(master_dict)

        # found json data, load image from json
        if self.master_dict["IMAGES"]["PRE-SKY"] != None:

            # self.med_image = self.master_dict["IMAGES"]["PRE-SKY"]
            self.med_image = self.controller.working_dir + "/" + self.master_dict[
                "IMAGES"]["PRE-SKY"]
            self.canvas = DrawTools(self.content_frame,
                                    self.med_image)  # create widget
            self.canvas.grid(row=0, column=0)  # show widget

            # update canvas object for children
            for obj in self.objects:
                self.objects[obj].update_canvas(self.canvas)

    def open_image_loc(self):

        image = filedialog.askopenfilename(
            initialdir=self.controller.working_dir)

        if isinstance(image, str) and image != "":

            dir_name = os.path.dirname(image)
            rel_path = os.path.relpath(image, dir_name)

            # only allow images from the working dir
            if self.controller.working_dir != dir_name:
                print("mis-match")
                self.warningBox("Image not from working directory")
                return

            # current session
            self.med_image = image
            self.canvas = DrawTools(self.content_frame, image)  # create widget
            self.canvas.grid(row=0, column=0)  # show widget

            # update canvas object for children
            for obj in self.objects:
                self.objects[obj].update_canvas(self.canvas)

            # save to json for future sessions
            # self.master_dict["IMAGES"]["PRE-SKY"] = image
            self.master_dict["IMAGES"]["PRE-SKY"] = rel_path

            # save to pat.json
            self.controller.save_json()

    def menu_btn_click(self, obj_name, action):
        '''Route menu click to object page'''
        self.objects[obj_name].menu_btn_click(action)

    def updateMenuLabel(self, label_text, menu_obj):
        '''Set label text for user instructions'''
        self.menus[menu_obj].setLabelText(label_text)

    def unsetObjs(self, obj_name):
        '''Reset variable for inactive objects'''
        for obj in self.objects:
            # except obj_name call unset
            if obj == obj_name: continue
            self.objects[obj].unset()

    def show_menu(self, obj_name):
        '''Show corresponding menu to the object and set cur_object in drawtools'''
        menu = obj_name + "_Menu"
        self.canvas.setObject(self.objects[obj_name])
        self.objects[obj_name].draw()
        self.unsetObjs(obj_name)
        self.show_frame(menu)

    def resetImg(self, image):
        self.canvas.destroy()
        self.canvas = DrawTools(self.content_frame, image)  # create widget
        self.canvas.grid(row=0, column=0)  # show widget

        # update canvas object for children
        for obj in self.objects:
            self.objects[obj].update_canvas(self.canvas)

    def checkbox_click(self, obj_name, action, val):
        try:
            self.objects[obj_name].checkbox_click(action, val)
        except Exception as e:
            raise e

    # point resize functs
    def getViewPointSize(self):
        return int(self.master_dict["POINT_SIZES"]["PRE-SKY"])

    def resizeRedraw(self):
        '''redraw with new point size'''
        print('resizeRedraw')
        for obj in self.objects:
            self.objects[obj].draw()
            self.objects[obj].unset()
示例#8
0
    def __init__(self, mainframe, path):
        """ Initialize the main Frame """
        ttk.Frame.__init__(self, master=mainframe)
        self.master.title('Advanced Zoom v3.0')
        self.master.geometry('800x600')  # size of the main window
        # self.master.rowconfigure(0, weight=1)  # make the CanvasImage widget expandable
        # self.master.columnconfigure(0, weight=1)

        # topbar
        topbar = Frame(self.master, height=100, bg="red")
        topbar.pack(anchor=E, fill=X, expand=False, side=TOP)  # <----

        # make buttons in the topbar
        for x, text in enumerate(["UNI_TIB_VAL", "UNI_FEM_VAL"]):
            # print(text)
            button = ttk.Button(topbar,
                                text=text,
                                command=lambda text=text: self.show_menu(text))
            button.grid(column=x, row=1)

        # left navbar
        navbar = Frame(self.master, width=100)
        navbar.pack(anchor=W, fill=Y, expand=False, side=LEFT)  # <----

        # create menus
        self.frames = {}
        for F in (UNI_TIB_VAL_Menu, UNI_FEM_VAL_Menu):
            page_name = F.__name__
            frame = F(parent=navbar, controller=self)
            self.frames[page_name] = frame

            # put all of the pages in the same location;
            # the one on the top of the stacking order
            # will be the one that is visible.
            frame.grid(row=0, column=0, sticky="nsew")

        # button = ttk.Button(navbar, text="object 1", command=self.btn1)
        # button.grid(column=1, row=1)

        # button = ttk.Button(navbar, text="object 2", command=self.btn2)
        # button.grid(column=1, row=2)

        menubar = Menu(self.master)
        filemenu = Menu(menubar, tearoff=0)
        filemenu.add_command(label="New", command=self.donothing)
        filemenu.add_command(label="Open", command=self.donothing)
        filemenu.add_command(label="Save", command=self.donothing)
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=self.master.quit)
        menubar.add_cascade(label="File", menu=filemenu)

        helpmenu = Menu(menubar, tearoff=0)
        helpmenu.add_command(label="Help Index", command=self.donothing)
        helpmenu.add_command(label="About...", command=self.donothing)
        menubar.add_cascade(label="Help", menu=helpmenu)
        self.master.config(menu=menubar)

        content_frame = Frame(self.master)
        content_frame.pack(anchor=N, fill=BOTH, expand=True, side=LEFT)
        content_frame.rowconfigure(
            0, weight=1)  # make the CanvasImage widget expandable
        content_frame.columnconfigure(0, weight=1)

        self.canvas = DrawTools(content_frame, path)  # create widget
        self.canvas.grid(row=0, column=0)  # show widget

        self.master_dict = {}

        # =========== PUT IN A FUNCTION ==============================
        try:
            my_file = Path("patient.json")
            if my_file.is_file():
                # file exists
                print("fil exists")

                with open(my_file) as f:
                    d = json.load(f)
                    self.master_dict = d
                    print(d)

        except Exception as e:
            raise e
        # =========================================

        self.objects = {}
        for Obj in (UNI_TIB_VAL, UNI_FEM_VAL):
            obj_name = Obj.__name__
            print(obj_name)
            self.objects[obj_name] = Obj(self.canvas,
                                         self.master_dict,
                                         controller=self)
示例#9
0
class MainWindow(ttk.Frame):
    """ Main window class """
    def __init__(self, mainframe, path):
        """ Initialize the main Frame """
        ttk.Frame.__init__(self, master=mainframe)
        self.master.title('Advanced Zoom v3.0')
        self.master.geometry('800x600')  # size of the main window
        # self.master.rowconfigure(0, weight=1)  # make the CanvasImage widget expandable
        # self.master.columnconfigure(0, weight=1)

        # topbar
        topbar = Frame(self.master, height=100, bg="red")
        topbar.pack(anchor=E, fill=X, expand=False, side=TOP)  # <----

        # make buttons in the topbar
        for x, text in enumerate(["UNI_TIB_VAL", "UNI_FEM_VAL"]):
            # print(text)
            button = ttk.Button(topbar,
                                text=text,
                                command=lambda text=text: self.show_menu(text))
            button.grid(column=x, row=1)

        # left navbar
        navbar = Frame(self.master, width=100)
        navbar.pack(anchor=W, fill=Y, expand=False, side=LEFT)  # <----

        # create menus
        self.frames = {}
        for F in (UNI_TIB_VAL_Menu, UNI_FEM_VAL_Menu):
            page_name = F.__name__
            frame = F(parent=navbar, controller=self)
            self.frames[page_name] = frame

            # put all of the pages in the same location;
            # the one on the top of the stacking order
            # will be the one that is visible.
            frame.grid(row=0, column=0, sticky="nsew")

        # button = ttk.Button(navbar, text="object 1", command=self.btn1)
        # button.grid(column=1, row=1)

        # button = ttk.Button(navbar, text="object 2", command=self.btn2)
        # button.grid(column=1, row=2)

        menubar = Menu(self.master)
        filemenu = Menu(menubar, tearoff=0)
        filemenu.add_command(label="New", command=self.donothing)
        filemenu.add_command(label="Open", command=self.donothing)
        filemenu.add_command(label="Save", command=self.donothing)
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=self.master.quit)
        menubar.add_cascade(label="File", menu=filemenu)

        helpmenu = Menu(menubar, tearoff=0)
        helpmenu.add_command(label="Help Index", command=self.donothing)
        helpmenu.add_command(label="About...", command=self.donothing)
        menubar.add_cascade(label="Help", menu=helpmenu)
        self.master.config(menu=menubar)

        content_frame = Frame(self.master)
        content_frame.pack(anchor=N, fill=BOTH, expand=True, side=LEFT)
        content_frame.rowconfigure(
            0, weight=1)  # make the CanvasImage widget expandable
        content_frame.columnconfigure(0, weight=1)

        self.canvas = DrawTools(content_frame, path)  # create widget
        self.canvas.grid(row=0, column=0)  # show widget

        self.master_dict = {}

        # =========== PUT IN A FUNCTION ==============================
        try:
            my_file = Path("patient.json")
            if my_file.is_file():
                # file exists
                print("fil exists")

                with open(my_file) as f:
                    d = json.load(f)
                    self.master_dict = d
                    print(d)

        except Exception as e:
            raise e
        # =========================================

        self.objects = {}
        for Obj in (UNI_TIB_VAL, UNI_FEM_VAL):
            obj_name = Obj.__name__
            print(obj_name)
            self.objects[obj_name] = Obj(self.canvas,
                                         self.master_dict,
                                         controller=self)

    def donothing(self):
        x = 0

    def show_menu(self, obj_name):
        '''Show corresponding menu to the object and set cur_object in drawtools'''
        menu = obj_name + "_Menu"
        self.canvas.setObject(self.objects[obj_name])
        self.objects[obj_name].draw()
        self.unsetObjs(obj_name)
        self.show_frame(menu)

    def show_frame(self, page_name):
        '''Show a frame for the given page name'''
        frame = self.frames[page_name]
        frame.tkraise()

    def menu_btn_click(self, obj_name, action):
        '''Route menu click to object page'''
        self.objects[obj_name].menu_btn_click(action)

    def updateMenuLabel(self, label_text, menu_obj):
        '''Set label text for user instructions'''
        self.frames[menu_obj].setLabelText(label_text)

    def warningBox(self, message):
        '''Display a warning box with message'''
        messagebox.showwarning("Warning", message)

    def unsetObjs(self, obj_name):
        '''Reset variable for inactive objects'''
        for obj in self.objects:
            # except obj_name call unset
            if obj == obj_name: continue
            self.objects[obj].unset()