Source code for m2isar.backends.viewer.utils

# SPDX-License-Identifier: Apache-2.0
#
# This file is part of the M2-ISA-R project: https://github.com/tum-ei-eda/M2-ISA-R
#
# Copyright (C) 2022
# Chair of Electrical Design Automation
# Technical University of Munich

"""Utility stuff for M2-ISA-R viewer"""

from typing import TYPE_CHECKING

if TYPE_CHECKING:
	from tkinter import ttk

[docs] class TreeGenContext: """Data keeping class for recursive TreeView generation""" def __init__(self, tree: "ttk.Treeview", parent) -> None:
[docs] self.tree = tree
[docs] self.parent_stack = [parent]
@property
[docs] def parent(self): return self.parent_stack[-1]
[docs] def push(self, new_id): self.parent_stack.append(new_id)
[docs] def pop(self): return self.parent_stack.pop()