def build_tree(keys): global tango_bst global tango_view global naive_bst global naive_view tango_bst = tg.TangoTree(keys) tango_view = treeview.TreeView(tango_bst, node_attributes=['d', 'min_d', 'max_d'], node_shape=tg.node_shape, plot_bg=colors['black-grey']) naive_bst = tango_bst.parody naive_view = treeview.TreeView(tree=naive_bst, layout_algorithm=SimpleBinaryTreeLayout, plot_bg=colors['black-grey']) figures['Auxilary trees'] = dict(data=tango_view.view(), layout=tango_view.create_layout()) figures['Perfectly balanced binary search tree']['data'] = dict( data=naive_view.view(), layout=naive_view.create_layout())
def __init__(self): super(MainWindow, self).__init__() self.projectdir = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'example') self.eeldir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'eel', 'eel') if sys.platform == "win32": self.eeldir += '.exe' self.treeView = treeview.TreeView(self) self.output = QtGui.QTextEdit() self.output.setReadOnly(True) self.font = QtGui.QFont() self.font.setFamily('Monaco') self.font.setStyleHint(QtGui.QFont.Monospace) self.font.setFixedPitch(True) self.output.setFont(self.font) self.mdi = QtGui.QMdiArea() self.mdi.setViewMode(self.mdi.TabbedView) self.mdi.setTabsClosable(True) self.mdi.setTabsMovable(True) backf = QtGui.QBrush( QtGui.QPixmap(os.path.join('images', 'background.png'))) self.mdi.setBackground(backf) self.toolBar = self.addToolBar(toolbar.ToolBar(self)) self.statusBar().showMessage('Ready', 2000) self.vsplitter = QtGui.QSplitter(QtCore.Qt.Vertical) self.vsplitter.addWidget(self.mdi) self.vsplitter.addWidget(self.output) self.output.hide() self.c_displayed = False splitter = QtGui.QSplitter(QtCore.Qt.Horizontal) splitter.addWidget(self.treeView) splitter.addWidget(self.vsplitter) self.setCentralWidget(splitter) self.setWindowTitle("Stellar - " + os.path.basename(self.projectdir)) self.resize(640, 480) self.show()
#res = [] #print("START") tango_bst = tg.TangoTree(range(1, 16)) naive_bst = tango_bst.parody #tango_bst.search(9) #tango_bst.search(15) #tango_bst.search(3) for i in range(100): val = rd.randint(1, 15) #res += [val] #tango_bst.search(val) #print("END") #print(res) tango_view = treeview.TreeView(tango_bst, node_attributes=['d', 'min_d', 'max_d'], node_shape=tg.node_shape, plot_bg=colors['black-grey']) naive_view = treeview.TreeView(tree=naive_bst, layout_algorithm=SimpleBinaryTreeLayout, plot_bg=colors['black-grey']) figures = { 'Perfectly balanced binary search tree': dict(data=naive_view.view(), layout=naive_view.create_layout()), 'Auxilary trees': dict(data=tango_view.view(), layout=tango_view.create_layout()) } #----------------------------------------------------------------------------------------------------------------- app.config['suppress_callback_exceptions'] = True
def __init__(self, model, allActions, parent=None): """Initialize the main window. Arguments: model -- the initial data model allActions -- a dict containing the upper level actions parent -- the parent window, usually None """ super().__init__(parent) self.allActions = allActions.copy() self.allowCloseFlag = True self.winActions = {} self.toolbars = [] self.rightTabActList = [] self.setAttribute(Qt.WA_DeleteOnClose) self.setAcceptDrops(True) self.setStatusBar(QStatusBar()) self.setCaption() self.setupActions() self.setupMenus() self.setupToolbars() self.restoreToolbarPosition() self.treeView = treeview.TreeView(model, self.allActions) self.breadcrumbSplitter = QSplitter(Qt.Vertical) self.setCentralWidget(self.breadcrumbSplitter) self.breadcrumbView = breadcrumbview.BreadcrumbView(self.treeView) self.breadcrumbSplitter.addWidget(self.breadcrumbView) self.breadcrumbView.setVisible(globalref. genOptions['InitShowBreadcrumb']) self.treeSplitter = QSplitter() self.breadcrumbSplitter.addWidget(self.treeSplitter) self.treeStack = QStackedWidget() self.treeSplitter.addWidget(self.treeStack) self.treeStack.addWidget(self.treeView) self.treeView.shortcutEntered.connect(self.execShortcut) self.treeView.selectionModel().selectionChanged.connect(self. updateRightViews) self.treeFilterView = None self.rightTabs = QTabWidget() self.treeSplitter.addWidget(self.rightTabs) self.rightTabs.setTabPosition(QTabWidget.South) self.rightTabs.tabBar().setFocusPolicy(Qt.NoFocus) self.outputSplitter = QSplitter(Qt.Vertical) self.rightTabs.addTab(self.outputSplitter, _('Data Output')) parentOutputView = outputview.OutputView(self.treeView, False) parentOutputView.highlighted[str].connect(self.statusBar().showMessage) self.outputSplitter.addWidget(parentOutputView) childOutputView = outputview.OutputView(self.treeView, True) childOutputView.highlighted[str].connect(self.statusBar().showMessage) self.outputSplitter.addWidget(childOutputView) self.editorSplitter = QSplitter(Qt.Vertical) self.rightTabs.addTab(self.editorSplitter, _('Data Edit')) parentEditView = dataeditview.DataEditView(self.treeView, self.allActions, False) parentEditView.shortcutEntered.connect(self.execShortcut) parentEditView.focusOtherView.connect(self.focusNextView) parentEditView.inLinkSelectMode.connect(self.treeView. toggleNoMouseSelectMode) self.treeView.skippedMouseSelect.connect(parentEditView. internalLinkSelected) self.editorSplitter.addWidget(parentEditView) childEditView = dataeditview.DataEditView(self.treeView, self.allActions, True) childEditView.shortcutEntered.connect(self.execShortcut) childEditView.focusOtherView.connect(self.focusNextView) childEditView.inLinkSelectMode.connect(self.treeView. toggleNoMouseSelectMode) self.treeView.skippedMouseSelect.connect(childEditView. internalLinkSelected) parentEditView.hoverFocusActive.connect(childEditView.endEditor) childEditView.hoverFocusActive.connect(parentEditView.endEditor) parentEditView.inLinkSelectMode.connect(childEditView. updateInLinkSelectMode) childEditView.inLinkSelectMode.connect(parentEditView. updateInLinkSelectMode) self.editorSplitter.addWidget(childEditView) self.titleSplitter = QSplitter(Qt.Vertical) self.rightTabs.addTab(self.titleSplitter, _('Title List')) parentTitleView = titlelistview.TitleListView(self.treeView, False) parentTitleView.shortcutEntered.connect(self.execShortcut) self.titleSplitter.addWidget(parentTitleView) childTitleView = titlelistview.TitleListView(self.treeView, True) childTitleView.shortcutEntered.connect(self.execShortcut) self.titleSplitter.addWidget(childTitleView) self.rightTabs.currentChanged.connect(self.updateRightViews) self.updateFonts()