Skip to content
Snippets Groups Projects
Select Git revision
  • ce63537a5bd1b7a4b47f613694b0902a5d1a0b76
  • master default protected
  • v2.0-dev protected
  • zikeliml/Task-96-dotExporterForAST
  • zikeliml/124-rework-tutorials
  • fma
  • fhennig/v2.0-deprecations
  • holzer-master-patch-46757
  • 66-absolute-access-is-probably-not-copied-correctly-after-_eval_subs
  • gpu_bufferfield_fix
  • hyteg
  • vectorization_sqrt_fix
  • target_dh_refactoring
  • const_fix
  • improved_comm
  • gpu_liveness_opts
  • release/1.3.7 protected
  • release/1.3.6 protected
  • release/2.0.dev0 protected
  • release/1.3.5 protected
  • release/1.3.4 protected
  • release/1.3.3 protected
  • release/1.3.2 protected
  • release/1.3.1 protected
  • release/1.3 protected
  • release/1.2 protected
  • release/1.1.1 protected
  • release/1.1 protected
  • release/1.0.1 protected
  • release/1.0 protected
  • release/0.4.4 protected
  • last/Kerncraft
  • last/OpenCL
  • last/LLVM
  • release/0.4.3 protected
  • release/0.4.2 protected
36 results

qtgui.py

Blame
  • qtgui.py 1.30 KiB
    import sys
    from PyQt5.QtWidgets import QWidget, QApplication, QTreeWidget, QTreeWidgetItem, QHBoxLayout
    from pystencils.astnodes import Block, LoopOverCoordinate, KernelFunction
    
    
    def debugGUI(ast):
        app = QApplication.instance()
        if app is None:
            app = QApplication(sys.argv)
        else:
            print('QApplication instance already exists: %s' % str(app))
        ex = DebugTree()
        ex.insert_ast(ast)
        app.exec_()
    
    
    class DebugTree(QWidget):
        def __init__(self):
            super().__init__()
            self.initUI()
    
        def initUI(self):
            self.tree = QTreeWidget(self)
            self.tree.setColumnCount(1)
            self.tree.setHeaderLabel('repr')
    
            hbox = QHBoxLayout()
            hbox.stretch(1)
            hbox.addWidget(self.tree)
    
            self.setWindowTitle('Debug')
            self.setLayout(hbox)
            self.show()
    
        def insert_ast(self, node, parent=None):
            if parent is None:
                parent = self.tree
            if isinstance(node, Block):  # Blocks are represented with the tree structure
                item = parent
            else:
                item = QTreeWidgetItem(parent)
                item.setText(0, repr(node))
    
            if node.func in [LoopOverCoordinate, KernelFunction]:
                self.tree.expandItem(item)
    
            for child in node.args:
                self.insert_ast(child, item)