示例#1
0
 def create_dock_widget_area(self):
     docWidget = QDockWidget("Script Jobs")
     docWidget.setWidget(self.dock_widget)
     # docWidget.setLayout(layout)
     docWidget.DockWidgetFeatures(QDockWidget.DockWidgetVerticalTitleBar)
     docWidget.setFloating(False)
     self.addDockWidget(Qt.LeftDockWidgetArea, docWidget, Qt.Vertical)
示例#2
0
    def __setup_sub_window_dock(self, window: QWidget, config: dict,
                                sub_window_data: SimpleNamespace):
        dock_name = config.get('DockName', '')
        dock_area = config.get('DockArea', Qt.NoDockWidgetArea)
        dock_show = config.get('DockShow', False)
        dock_float = config.get('DockFloat', False)

        dock_wnd = QDockWidget(dock_name, self)
        dock_wnd.setAllowedAreas(Qt.RightDockWidgetArea | Qt.LeftDockWidgetArea
                                 | Qt.TopDockWidgetArea
                                 | Qt.BottomDockWidgetArea)
        # With this setting, the dock widget cannot be closed
        # dock_wnd.setFeatures(QDockWidget.DockWidgetFloatable | QDockWidget.DockWidgetMovable)
        if dock_area != Qt.NoDockWidgetArea:
            self.addDockWidget(dock_area, dock_wnd)
        else:
            self.addDockWidget(Qt.TopDockWidgetArea, dock_wnd)
            dock_wnd.setFloating(True)
            dock_wnd.setAllowedAreas(Qt.NoDockWidgetArea)

        dock_wnd.setWidget(window)
        if dock_float:
            dock_wnd.setFloating(True)
            # self.geometry().center() - dock_wnd.rect().center()
            # dock_wnd.move()
        if dock_show:
            dock_wnd.show()
        else:
            dock_wnd.hide()
        sub_window_data.dock_wnd = dock_wnd
示例#3
0
    def __init__(self):
        super().__init__()
        self.resize(800, 600)

        dockWidget = QDockWidget('Dock', self)

        self.textEdit = QTextEdit()
        self.textEdit.setFontPointSize(16)

        self.listWidget = QListWidget()
        self.listWidget.addItem('Google')
        self.listWidget.addItem('Facebook')
        self.listWidget.addItem('Microsoft')
        self.listWidget.addItem('Apple')
        self.listWidget.itemDoubleClicked.connect(self.get_list_item)

        p = subprocess.Popen(["matchbox-keyboard", "--xid"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        id = int(p.stdout.readline())
        window = QtGui.QWindow.fromWinId(id)
        widget = QWidget.createWindowContainer(window)
        widget.setMinimumWidth(600)
        widget.setMinimumHeight(300)


        dockWidget.setWidget(widget)
        dockWidget.setFloating(False)

        self.setCentralWidget(self.textEdit)
        self.addDockWidget(Qt.RightDockWidgetArea, dockWidget)
示例#4
0
 def addROI(self,roi = None):
     if self.roiwidget is None:
         self.roiwidget = ROIPlotWidget(roi_target = self.p1,
                                        view = self.view,
                                        parent = self)
         roiTab = QDockWidget("roi cam {0}".format(self.iCam), self)
         roiTab.setWidget(self.roiwidget)
         roiTab.setAllowedAreas(Qt.LeftDockWidgetArea |
                                Qt.RightDockWidgetArea |
                                Qt.BottomDockWidgetArea |
                                Qt.TopDockWidgetArea)
         roiTab.setFeatures(QDockWidget.DockWidgetMovable |
                            QDockWidget.DockWidgetFloatable |
                            QDockWidget.DockWidgetClosable)
         self.parent.addDockWidget(Qt.BottomDockWidgetArea
                                   ,roiTab)
         roiTab.setFloating(True)
         roiTab.resize(600,150)
         
         def closetab(ev):
             # This probably does not clean up memory...
             if not self.roiwidget is None:
                 [self.p1.removeItem(r)
                  for r in self.roiwidget.items()]
                 del self.roiwidget
                 self.roiwidget = None
             ev.accept()
         roiTab.closeEvent = closetab
     self.roiwidget.add_roi(roi)
示例#5
0
文件: pqt5.py 项目: pytnam/pytnam
 def viewPlotMethod(self, data):
     plotDockWidget = QDockWidget("Plot", self)
     PlotLWidget = pg.GraphicsLayoutWidget(
     )  #pyqtgraph class for making widget-ready plots
     #PlotLWidget.useOpenGL(True) sucks
     asd = PlotLWidget.addPlot()
     asd.hideAxis("left")
     #PlotLWidget.nextRow = super().newNextRow
     pen_list = ["r", "g", "c", "m", "y", "k", "w"]
     x = 0  #only 10 lines now
     coeff = 0
     for key in sorted(data["signal"].keys()):
         # if key == "info":
         #     continue
         if x >= 10:
             break
         curve1 = pg.PlotCurveItem(data["signal"][key][1] + coeff,
                                   pen=[
                                       random.randint(0, 256),
                                       random.randint(0, 256),
                                       random.randint(0, 256), 255
                                   ])  # (connect = all)
         asd.addItem(curve1)
         x += 1
         coeff += 3000
     #plotObject.plot(values[1])
     #asd.showAxis('bottom')
     plotDockWidget.setWidget(
         PlotLWidget)  #making PlotWidget object set as QDockWidget
     plotDockWidget.setFloating(
         0)  #in default its docked in MainWindow, 1 = floating around
     self.addDockWidget(Qt.RightDockWidgetArea, plotDockWidget)
示例#6
0
文件: main.py 项目: GliaHQ/Glia
class MainWindow(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)

        # Menu Bar
        self.menu_bar = self.menuBar()
        self.file_menu = self.menu_bar.addMenu("File")
        self.edit_menu = self.menu_bar.addMenu("Edit")
        self.view_menu = self.menu_bar.addMenu("View")
        self.tools_menu = self.menu_bar.addMenu("Tools")

        # Project Browser
        self.project_dock = QDockWidget("Project", self)
        self.project_dock.setFloating(False)
        self.project_dock.setAllowedAreas(Qt.AllDockWidgetAreas)

        self.project = QListWidget(self)  # Mock Project Browser
        self.project.addItem("main.py")
        self.project.addItem("test.java")
        self.project.addItem("stats.r")
        self.project_dock.setWidget(self.project)
        self.addDockWidget(Qt.LeftDockWidgetArea, self.project_dock)

        # Workspace
        self.workspace = QTabWidget()
        self.workspace.setTabPosition(QTabWidget.South)
        self.setCentralWidget(self.workspace)

        # Editor
        self.editor_tabs = EditorTabs()
        self.workspace.addTab(self.editor_tabs, "Editor")

        # Monitor
        self.monitor = QWidget()
        self.workspace.addTab(self.monitor, "Monitor")

        # Jupyter Widget
        self.jupyter_dock = QDockWidget("Jupyter", self)
        self.jupyter_dock.setFloating(False)
        self.jupyter_dock.setAllowedAreas(Qt.AllDockWidgetAreas)

        self.jupyter = TabbedJupyterWidget()
        self.jupyter_dock.setWidget(self.jupyter)
        self.addDockWidget(Qt.RightDockWidgetArea, self.jupyter_dock)

        # Window Properties
        self.setWindowTitle("Mock Layout for Glia")

        # Status Bar
        self.status_bar = QStatusBar(self)
        self.setStatusBar(self.status_bar)

    def closeEvent(self, event):
        """
        Finish up any tasks. Stop all running widgets, it's threads and
        any I/O tasks.
        """
        for child in self.findChildren(QObject):
            if hasattr(child, "stop_running"):
                child.stop_running()
class MainWindow(QMainWindow):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setCursor(Qt.ArrowCursor)
        self.eyePrompt = EyePrompt()

        self.setWindowIcon(QtGui.QIcon("assets/HSL-logo.png"))
        self.setWindowTitle("HSL | Eye Tracking Data Collection")
        self.setGeometry(100, 100, 900, 900)

        bar = self.menuBar()
        file = bar.addMenu("File")
        file.addAction("New")
        file.addAction("Save")

        # Building the Data Output widget
        self.dataOutput = QDockWidget("Data Output", self)
        self.dataOutputOptions = DataOutputOptions(diskDir)
        self.dataOutput.setWidget(self.dataOutputOptions)
        self.dataOutput.setFloating(False)

        self.setCentralWidget(QTextEdit())
        self.addDockWidget(Qt.RightDockWidgetArea, self.dataOutput)

    def keyPressEvent(self, e: QKeyEvent) -> None:
        k = e.key()
        if k == Qt.Key_Return:
            pass
    def createDockWidget(self) -> None:
        dockWidget = DockWidget("Executed Operations", self)
        self.addDockWidget(Qt.RightDockWidgetArea, dockWidget)

        self.listWidget = ListWidget()
        dockWidget.setWidget(self.listWidget)
        dockWidget.setFloating(False)
        self.listWidget.setSpacing(10)
示例#9
0
    def __init__(self):
        super().__init__()

        dockWidget = QDockWidget("Explorer", self)

        self.editor = QPlainTextEdit()
        self.editor.document().setDefaultFont(QFont("monospace"))
        self.editor.zoomIn(2)

        self.explorer = QTreeView()
        self.model = QFileSystemModel(self.explorer)
        self.root = self.model.setRootPath("../..")
        self.explorer.setModel(self.model)
        self.explorer.setRootIndex(self.root)
        self.file_path = None

        # Instances of menus and message
        self.custom_menu = Custom_menu(self, self.explorer, self.model,
                                       self.editor, app)
        self.menu = Menu(self, self.explorer, self.editor, self.model)
        self.message = Message(self)

        # Menu bar
        self.file_menu = self.menuBar().addMenu("&File")
        self.help_menu = self.menuBar().addMenu("&Help")
        self.menu.menu_actions()

        # Other custom tweaks
        self.explorer.setSortingEnabled(True)
        self.explorer.setMinimumWidth(400)
        self.explorer.setContextMenuPolicy(Qt.CustomContextMenu)
        self.resize(1500, 900)

        # Enabling renaming on context menu
        self.model.setReadOnly(False)
        self.explorer.setEditTriggers(self.explorer.NoEditTriggers)

        # Change default explorers column width
        self.header = self.explorer.header()
        self.header.setSectionResizeMode(0, QHeaderView.Interactive)
        self.header.setDefaultSectionSize(200)
        self.header.setSectionResizeMode(1, QHeaderView.ResizeToContents)
        self.header.setSectionResizeMode(2, QHeaderView.ResizeToContents)

        # Setting editor as central widget
        self.setCentralWidget(self.editor)
        self.addDockWidget(Qt.LeftDockWidgetArea, dockWidget)

        # Setting view as widget of dock widget
        dockWidget.setWidget(self.explorer)
        dockWidget.setFloating(False)

        ### Double & right click
        self.explorer.doubleClicked.connect(self.custom_menu.on_double_click)
        self.explorer.customContextMenuRequested.connect(
            self.custom_menu.context_menu)
    def right_down_text_edit(self):
        layout = QHBoxLayout()

        items = QDockWidget("Payable", self)

        listWidget = QListWidget()
        listWidget.addItem('Item1')
        items.setWidget(listWidget)
        items.setFloating(False)
        self.setCentralWidget(QTextEdit())
        self.addDockWidget(Qt.RightDockWidgetArea, items)
        self.setLayout(layout)
示例#11
0
    def create_dock_widget_area(self):
        docWidget = QDockWidget("Script Jobs")

        # Updated by Pinkesh Shah on 05-May-20 to disable Scheduler layout
        # Start Region
        docWidget.setWidget(self.dock_widget)
        # docWidget.setWidget(self.dockWidgetGroupBox)
        # End Region

        # docWidget.setLayout(layout)
        docWidget.DockWidgetFeatures(QDockWidget.DockWidgetVerticalTitleBar)
        docWidget.setFloating(False)
        self.addDockWidget(Qt.LeftDockWidgetArea, docWidget, Qt.Vertical)

        docWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
示例#12
0
class DockDialog(QMainWindow):
    def __init__(self):
        super().__init__()
        self.title = "PyQt5 StackedWidget"
        self.top = 200
        self.left = 500
        self.width = 400
        self.height = 300
        self.setWindowIcon(QtGui.QIcon("icon.png"))
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)

        self.createDockWidget()

        self.settings = QSettings("PyEcog", "PyEcog_tests")
        print("reading cofigurations from: " + self.settings.fileName())
        self.settings.beginGroup("MainWindow")
        self.restoreGeometry(
            self.settings.value("windowGeometry", type=QByteArray))
        self.restoreState(self.settings.value("windowState", type=QByteArray))
        self.show()

    def createDockWidget(self):
        menubar = self.menuBar()
        file = menubar.addMenu("File")
        file.addAction("New")
        file.addAction("Save")
        file.addAction("Close")
        self.dock = QDockWidget("Dockable", self)
        self.listWiget = QListWidget()
        list = ["Python", "C++", "Java", "C#"]
        self.listWiget.addItems(list)
        self.dock.setWidget(self.listWiget)
        self.dock.setFloating(False)
        self.dock.setObjectName("DockableList")
        self.setCentralWidget(QTextEdit())
        self.addDockWidget(Qt.RightDockWidgetArea, self.dock)

    def closeEvent(self, event):
        print('closing')
        settings = QSettings("PyEcog", "PyEcog_tests")
        settings.beginGroup("MainWindow")
        windowGeometry = self.saveGeometry()
        settings.setValue("windowGeometry", windowGeometry)
        windowState = self.saveState()
        settings.setValue("windowState", windowState)
        settings.endGroup()
        self.saveState()
示例#13
0
    def __setup_sub_window_dock(self, window: QWidget, config: dict, sub_window_data: SimpleNamespace):
        dock_name = config.get('DockName', '')
        dock_area = config.get('DockArea', Qt.NoDockWidgetArea)
        dock_show = config.get('DockShow', False)
        dock_float = config.get('DockFloat', False)

        dock_wnd = QDockWidget(dock_name, self)
        self.addDockWidget(dock_area, dock_wnd)

        dock_wnd.setWidget(window)
        if dock_float:
            dock_wnd.setFloating(True)
            dock_wnd.move(self.geometry().center() - dock_wnd.rect().center())
        if dock_show:
            dock_wnd.show()

        sub_window_data.dock_wnd = dock_wnd
示例#14
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setCursor(Qt.ArrowCursor)

        iconPath = resource_path("HSL-logo.png")
        self.setWindowIcon(QtGui.QIcon(iconPath))
        self.setWindowTitle("HSL | Blink Detection Data Collection")
        self.setGeometry(500, 300, 500, 300)  # x,y,width,height

        # main widget
        self.main_ui_widget = MainWidget(disk_dir)
        main_widget = QDockWidget("", self)
        main_widget.setWidget(self.main_ui_widget)
        main_widget.setFloating(False)
        self.addDockWidget(Qt.LeftDockWidgetArea, main_widget)

        # menu bar
        self.menu_bar = MenuBar(disk_dir, self)
示例#15
0
    def loadWidget(self, p):
        print(p.text())
        if p.text() == " &New":
            MainWindow.count = MainWindow.count + 1
            dockWidget = QDockWidget("Image Viewer " + str(MainWindow.count),
                                     self)
            dockWidget.setWidget(Window())
            dockWidget.setFloating(False)
            self.addDockWidget(Qt.TopDockWidgetArea, dockWidget)

        if p.text() == " &LoadDie":
            image = QPixmap()
            image.load("resources/images/pyDexIcon.png")
            image = image.scaled(self.width(), self.height())
            palette = QPalette()
            palette.setBrush(self.backgroundRole(), QBrush(image))
            self.setPalette(palette)
        '''   
示例#16
0
class DockDemo(QMainWindow):
    def __init__(self, parent=None):
        super(DockDemo, self).__init__(parent)
        layout = QHBoxLayout()

        self.items = QDockWidget('Expression Tree', self)

        self.treeModel = FunctionModel(simple_expr())
        self.treeView = QTreeView(self)
        self.treeView.setModel(self.treeModel)

        self.items.setWidget(self.treeView)
        self.items.setFloating(False)
        self.setCentralWidget(QTextEdit())
        self.addDockWidget(Qt.LeftDockWidgetArea, self.items)

        self.setLayout(layout)
        self.setWindowTitle('Dock')
    def initUi(self):
        self.statusBar().showMessage('Pick One')

        self.setGeometry(self.left, self.top, self.width, self.height)
        self.setWindowTitle('Picture Finder')

        self.setCentralWidget(self.Center)

        # dock widget
        webBrowser = QDockWidget("Picture Browser")
        webBrowser.setWidget(self.WebWidget)
        webBrowser.setGeometry(500, 300, 500, 500)

        self.Center.addSig.connect(self.addToFinalList)

        self.addDockWidget(Qt.RightDockWidgetArea, webBrowser)
        webBrowser.setFloating(True)
        self.show()
示例#18
0
 def histogramWin(self):
     if self.hist is None:
         histTab = QDockWidget("histogram cam {0}".format(self.iCam), self)
         widget = QWidget()
         layout = QGridLayout()
         widget.setLayout(layout)
         win = pg.GraphicsLayoutWidget()
         p1 = win.addPlot()
         p1.getViewBox().invertY(True)
         p1.hideAxis('left')
         p1.hideAxis('bottom')
         
         self.hist = pg.HistogramLUTItem()
         self.hist.axis.setPen('k')
         p1.addItem(self.hist)
         self.hist.setImageItem(self.view)
         layout.addWidget(win,0,0)
         histTab.setWidget(widget)
         histTab.setAllowedAreas(Qt.LeftDockWidgetArea |
                                 Qt.RightDockWidgetArea |
                                 Qt.BottomDockWidgetArea |
                                 Qt.TopDockWidgetArea)
         histTab.setFeatures(QDockWidget.DockWidgetMovable |
                             QDockWidget.DockWidgetFloatable |
                             QDockWidget.DockWidgetClosable)
         self.parent.addDockWidget(Qt.BottomDockWidgetArea
                                   ,histTab)
         histTab.setFloating(True)
     
         histTab.resize(200,200)
     try:
         histstate = self.hist.saveState()
     except Exception as err:
         display('[ERROR] - could not save histogram state. "pip install pyqtgraph --upgrade" might solve it.')
         print(err)
     def closefun(ev):
         try:
             self.hist.restoreState(histstate)
         except Exception as err:
             print(err)
             pass
         self.hist = None
         ev.accept()
     histTab.closeEvent = closefun
示例#19
0
    def create_stack_window(self,
                            stack: Images,
                            title: str,
                            position=QtCore.Qt.TopDockWidgetArea,
                            floating=False) -> QDockWidget:
        dock = QDockWidget(title, self)

        # this puts the new stack window into the centre of the window
        self.setCentralWidget(dock)

        # add the dock widget into the main window
        self.addDockWidget(position, dock)

        # we can get the stack visualiser widget with dock_widget.widget
        dock.setWidget(StackVisualiserView(self, dock, stack))

        dock.setFloating(floating)

        return dock
示例#20
0
    def __init__(self):
        super().__init__()
        self.resize(800, 600)

        dockWidget = QDockWidget('Dock', self)

        self.textEdit = QTextEdit()
        self.textEdit.setFontPointSize(16)

        self.listWidget = QListWidget()
        self.listWidget.addItem('Google')
        self.listWidget.addItem('Facebook')
        self.listWidget.addItem('Microsoft')
        self.listWidget.addItem('Apple')
        self.listWidget.itemDoubleClicked.connect(self.get_list_item)

        dockWidget.setWidget(self.listWidget)
        dockWidget.setFloating(False)

        self.setCentralWidget(self.textEdit)
        self.addDockWidget(Qt.RightDockWidgetArea, dockWidget)
示例#21
0
class DockDemo(QWidget):
    def __init__(self):
        QWidget.__init__(self)

    def init(self):
        self.setGeometry(300, 300, 300, 250)
        self.setStyleSheet('background-color:white;')

        self.btn1 = QPushButton('Button', self)

        self.dock1 = QDockWidget('My First Dock', self)
        self.dock1.move(20, 20)
        self.dock1.resize(200, 100)
        self.dock1.setWidget(self.btn1)

        self.dock1.setFloating(False)
        self.dock1.setFeatures(self.dock1.DockWidgetClosable
                               | self.dock1.DockWidgetMovable)
        self.dock1.setFeatures(self.dock1.NoDockWidgetFeatures)

        self.show()
示例#22
0
    def history_subwindow(self):
        """
        Summary of the function:
        ------------------------
        (a) Defining the sub-window for showing executed docker containers history

        Parameters:
        -----------
        :arg: None
        :return: A dock-widget object (sub-window)
        """
        dock_widget = QDockWidget(self)
        # dock_widget.setTitleBarWidget(self.subdoc_custom_title_bar("history"))
        dock_widget.setTitleBarWidget(QWidget(None))
        dock_widget.setFloating(False)
        dock_widget.setFont(self.subdoc_font_customization())
        dock_widget.setFeatures(dock_widget.NoDockWidgetFeatures)
        dock_widget.setFixedHeight((int(self.screen_height * 3.9) // 10))
        dock_widget.setFixedWidth(self.screen_width // 2)
        dock_widget.setStyleSheet(css_layout.dockwidget_layout)
        dock_widget.setAllowedAreas(Qt.RightDockWidgetArea)
        return dock_widget
示例#23
0
    def userstats_subwindow(self):
        """
        Summary of the function:
        ------------------------
        (a) Defining the sub-window for the User Statistics

        Parameters:
        -----------
        :arg: None
        :return: A dock-widget object (sub-window)
        """
        dock_widget = QDockWidget(self)
        # dock_widget.setTitleBarWidget(self.subdoc_custom_title_bar("userstats"))
        dock_widget.setTitleBarWidget(QWidget(None))
        dock_widget.setFloating(False)
        dock_widget.setFont(self.subdoc_font_customization())
        dock_widget.setFeatures(dock_widget.NoDockWidgetFeatures)
        dock_widget.setFixedHeight((int(self.screen_height * 3.4) // 10))
        dock_widget.setFixedWidth(self.screen_width // 2)
        dock_widget.setStyleSheet(css_layout.dockwidget_layout)
        dock_widget.setAllowedAreas(Qt.TopDockWidgetArea)
        return dock_widget
示例#24
0
class ExprApp(QMainWindow):
    def __init__(self, parent=None):
        super(ExprApp, self).__init__(parent)
        self._init_main_window()
        self._init_tree_dock()
        self.setWindowTitle("Expression Browser")

    def _init_tree_dock(self):
        self.tree_dock = QDockWidget("Expression Tree", self)
        self.tree_view = QTreeView(self.tree_dock)
        self.set_expr(simple_expr())

        self.tree_dock.setWidget(self.tree_view)
        self.tree_dock.setFloating(False)
        self.addDockWidget(Qt.LeftDockWidgetArea, self.tree_dock)

    def set_expr(self, expr):
        self.tree_model = FunctionModel(expr)
        self.tree_view.setModel(self.tree_model)

    def _init_main_window(self):
        self.setCentralWidget(QTextEdit())
示例#25
0
class MainWindow(QMainWindow):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setCursor(Qt.ArrowCursor)

        self.setWindowIcon(QtGui.QIcon("assets/HSL-logo.png"))
        self.setWindowTitle("HSL | Eye Tracking Data Collection")
        self.setGeometry(100, 100, 900, 900)

        bar = self.menuBar()
        file = bar.addMenu("File")
        file.addAction("New")
        file.addAction("Save")

        # Building the Data Output widget
        self.data_output = QDockWidget("Data Output", self)
        self.data_output_options = DataOutputOptions(disk_dir)
        self.data_output.setWidget(self.data_output_options)
        self.data_output.setFloating(False)

        self.setCentralWidget(QTextEdit())
        self.addDockWidget(Qt.RightDockWidgetArea, self.data_output)

    def shutdown(self):
        self.data_output_options.shutdown()

    def keyPressEvent(self, e: QKeyEvent) -> None:
        k = e.key()
        if k == Qt.Key_R:
            try:
                prompter = EyePrompt()
                prompter.showFullScreen()
                prompter.cycleLength = 2
                prompter.serializer = self.data_output_options.create_serializer(
                )
                prompter.startPrompts()
            except ValueError:
                pass
示例#26
0
    def enqueued_containers_subwindow(self):
        """
        Summary of the function:
        ------------------------
        (a) Defining the sub-window for showing the enqueued containers information

        Parameters:
        -----------
        :arg: None
        :return: A dock-widget object (sub-window)
        """
        dock_widget = QDockWidget(self)
        # dock_widget.setTitleBarWidget(self.subdoc_custom_title_bar("enqueued"))
        dock_widget.setTitleBarWidget(QWidget(None))
        dock_widget.setFloating(False)
        dock_widget.setFont(self.subdoc_font_customization())
        dock_widget.setFeatures(dock_widget.NoDockWidgetFeatures)
        dock_widget.setFixedHeight(
            (int(self.screen_height * 4.6) // 10))  # 48%
        dock_widget.setFixedWidth(int(self.screen_width * 4.97) // 10)
        dock_widget.setStyleSheet(css_layout.dockwidget_layout)
        dock_widget.setAllowedAreas(Qt.RightDockWidgetArea)
        return dock_widget
示例#27
0
    def __init__(self, parent=None):
        super().__init__(parent=parent)
        self.setWindowTitle("QMainWindow使用QDockWidget")
        self.setCentralWidget(QTextEdit())

        # 设置QMainWindow的菜单栏
        menu_bar = self.menuBar()
        menu_file = menu_bar.addMenu("文件")
        menu_file.addAction("新建")
        menu_file.addAction("保存")
        action_quit = menu_file.addAction("退出")
        action_quit.triggered.connect(self.to_quit)

        # 设置QDockWidget使用的QListWidget
        list_widget = QListWidget()
        list_widget.addItem("list 1")
        list_widget.addItem("lsit 2")
        list_widget.addItem("list 3")
        # 实例化一个QDockWidget, 父控件为QMainWindow
        dock_widget = QDockWidget("Dock控件", parent=self)
        dock_widget.setWidget(list_widget)  # 设置显示的控件为
        dock_widget.setFloating(False)

        self.addDockWidget(Qt.RightDockWidgetArea, dock_widget)
示例#28
0
 def status_subwindow(self):
     """
     Summary of the function:
     ------------------------
     (a) Defining the sub-window for the priority queue status
     (b) Info would be blank for initial loading
     
     Parameters:
     -----------
     :arg: None
     :return: A dock-widget object
     """
     dock_widget = QDockWidget(self)
     # dock_widget.setTitleBarWidget(self.subdoc_custom_title_bar("status"))
     dock_widget.setTitleBarWidget(QWidget(None))
     dock_widget.setFont(self.subdoc_font_customization())
     dock_widget.setFloating(False)
     dock_widget.setFeatures(dock_widget.NoDockWidgetFeatures)
     dock_widget.setFixedWidth(self.screen_width // 2)
     dock_widget.setFixedHeight(int(self.screen_height * 2.1) //
                                10)  # 25% of total height
     dock_widget.setStyleSheet(css_layout.dockwidget_layout)
     dock_widget.setAllowedAreas(Qt.LeftDockWidgetArea)
     return dock_widget
class DockDemo(QMainWindow):
    def __init__(self):
        super(DockDemo, self).__init__()
        self.initUi()

    def initUi(self):
        layout = QHBoxLayout()
        bar = self.menuBar()
        file = bar.addMenu("File")
        file.addAction("New")
        file.addAction("save")
        file.addAction("quit")
        self.items = QDockWidget("Dockable", self)
        self.listWidget = QListWidget()
        self.listWidget.addItem("item1")
        self.listWidget.addItem("item2")
        self.listWidget.addItem("item3")
        self.items.setWidget(self.listWidget)
        self.items.setFloating(False)
        self.setCentralWidget(QTextEdit())
        self.addDockWidget(Qt.RightDockWidgetArea, self.items)
        self.setLayout(layout)
        self.setWindowTitle("Dock demo")
        self.show()
示例#30
0
class Editor(QMainWindow):
	
	def __init__(self):
		super().__init__()
		Tiles.initTiles()
		self.initUI()
		
	# Initialisation de l'affichage
	def initUI(self):
		# Créer la frame
		self.frame = Frame(self)
		self.setCentralWidget(self.frame)

		# Taille de la fenêtreQFileDialog.getOpenFileName(self, "Ouvrir un fichier", "/home")
		self.setFixedSize(640, 480)
		# Centrage
		self.center()
		# Nom de la fenêtre
		self.setWindowTitle("Editor")

		# Menus
		mainMenu = self.menuBar()
		fileMenu = mainMenu.addMenu("Fichier")

		# Actions du menu Fichier
		self.newAction = QAction("&Nouveau", self, icon=QIcon("res/editor/new-file.png"), shortcut="Ctrl+N", statusTip="Créer une carte", triggered=self.newFile)
		self.openAction = QAction("&Ouvrir", self, icon=QIcon("res/editor/open-file.png"), shortcut="Ctrl+O", statusTip="Charger une carte", triggered=self.openFile)
		self.saveAction = QAction("&Enregistrer", self, icon=QIcon("res/editor/save.png"), shortcut="Ctrl+S", statusTip="Enregistrer", triggered=self.save)
		self.exitAction = QAction("&Quitter", self, icon=QIcon("res/editor/exit.svg"), shortcut="Alt+F4", statusTip="Quitter l'application", triggered=self.quit)
		fileMenu.addAction(self.newAction)
		fileMenu.addAction(self.openAction)
		fileMenu.addAction(self.saveAction)
		fileMenu.addAction(self.exitAction)

		# Barre latérale
		self.items = QDockWidget("Matériel", self)
		self.tabs = Sidebar(self)
		self.items.setWidget(self.tabs)
		self.items.setFloating(False)
		self.addDockWidget(Qt.RightDockWidgetArea, self.items)
		
		# Afficher tout
		self.show()

	# Centrer la fenêtre
	def center(self):
		screen = QDesktopWidget().screenGeometry()
		size = self.geometry()
		self.move((screen.width()-size.width())/2, (screen.height()-size.height())/2)

	# Nouveau fichier
	def newFile(self):
		self.lsd = LevelSizeDialog(self)

	# Ouvrir un fichier
	def openFile(self):
		fname = QFileDialog.getOpenFileName(self, "Ouvrir un fichier", "res", "Carte (*.kdm)")

		if fname[0] != '':
		
			with open(fname[0], 'r') as mapr:
				mapdata=mapr.read().split()
				print(mapdata)
				w=int(mapdata[0])
				h=int(mapdata[1])

				# Taille (pixels)
				self.frame.width = w*32
				self.frame.height = h*32
				
				# Nombre de tuiles
				self.frame.tw = w
				self.frame.th = h

				#placer tuiles
				self.frame.tiles = [[0 for i in range(w)] for j in range(h)]
				for i in range(w):
					for j in range(h):
						self.frame.tiles[j][i]=int(mapdata[2+i+j*w])

				#placer objets
				if len(self.frame.sprites) > 0:
					del self.frame.sprites[:]
				for i in range(w*h+2, len(mapdata)-1, 3):
					self.frame.sprites.append( EditorSprite(mapdata[i], int(mapdata[i+1]), int(mapdata[i+2]), int(self.frame.objects[mapdata[i]][1]), int(self.frame.objects[mapdata[i]][2]), self.frame.objects[mapdata[i]][0]))
					
	# Enregistrer
	def save(self):
		fname = QFileDialog.getSaveFileName(self, "Enregistrer", "res", "Carte (*.kdm)")

		if fname[0] != '':
			with open(fname[0], 'w') as mapr:
				mapr.write(str(self.frame.tw) + ' ' + str(self.frame.th) + '\n')
				for i in range(self.frame.th):
					line = ""
					for j in range(self.frame.tw):
						line += str(self.frame.tiles[i][j]) + ' '
					mapr.write(line + '\n')

				for s in self.frame.sprites:
					mapr.write(s.type + ' ' + str(s.x) + ' ' + str(s.y) + '\n')

	# Quitter
	def quit(self):
		# Créer la boite
		msgBox = QMessageBox()
		msgBox.setText("Voulez-vous vraiment quitter?")
		msgBox.setStandardButtons(QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel)
		msgBox.setDefaultButton(QMessageBox.Cancel)

		# L'afficher et tester quel button a été appuyé
		if msgBox.exec() == QMessageBox.Yes:
			QApplication.instance().quit()
示例#31
0
class SquidGui( QMainWindow ):
    defaults = {}
    defaults.update(SquidAxon.defaults)
    defaults.update(ClampCircuit.defaults)
    defaults.update({'runtime': 50.0,
                  'simdt': 0.01,
                  'plotdt': 0.1,
                  'vclamp.holdingV': 0.0,
                  'vclamp.holdingT': 10.0,
                  'vclamp.prepulseV': 0.0,
                  'vclamp.prepulseT': 0.0,
                  'vclamp.clampV': 50.0,
                  'vclamp.clampT': 20.0,
                  'iclamp.baseI': 0.0,
                  'iclamp.firstI': 0.1,
                  'iclamp.firstT': 40.0,
                  'iclamp.firstD': 5.0,
                  'iclamp.secondI': 0.0,
                  'iclamp.secondT': 0.0,
                  'iclamp.secondD': 0.0
                  })
    def __init__(self, *args):
        QMainWindow.__init__(self, *args)
        self.squid_setup = SquidSetup()
        self._plotdt = SquidGui.defaults['plotdt']
        self._plot_dict = defaultdict(list)
        self.setWindowTitle('Squid Axon simulation')        
        self.setDockNestingEnabled(True)
        self._createRunControl()
        self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self._runControlDock) 
        self._runControlDock.setFeatures(QDockWidget.AllDockWidgetFeatures)	 
        self._createChannelControl()
        self._channelCtrlBox.setWindowTitle('Channel properties')
        self._channelControlDock.setFeatures(QDockWidget.AllDockWidgetFeatures)	 
        self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self._channelControlDock) 
        self._createElectronicsControl()
        self._electronicsDock.setFeatures(QDockWidget.AllDockWidgetFeatures)	 
        self._electronicsDock.setWindowTitle('Electronics')
        self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self._electronicsDock) 
        self._createPlotWidget()             
        self.setCentralWidget(self._plotWidget)
        self._createStatePlotWidget()
        self._createHelpMessage()
        self._helpWindow.setVisible(False)
        self._statePlotWidget.setWindowFlags(QtCore.Qt.Window)
        self._statePlotWidget.setWindowTitle('State plot')
        self._initActions()
        self._createRunToolBar()
        self._createPlotToolBar()

    def getFloatInput(self, widget, name):
        try:
            return float(str(widget.text()))
        except ValueError:
            QMessageBox.critical(self, 'Invalid input', 'Please enter a valid number for {}'.format(name))
            raise

        
    def _createPlotWidget(self):
        self._plotWidget = QWidget()
        self._plotFigure = Figure()
        self._plotCanvas = FigureCanvas(self._plotFigure)
        self._plotCanvas.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self._plotCanvas.updateGeometry()
        self._plotCanvas.setParent(self._plotWidget)
        self._plotCanvas.mpl_connect('scroll_event', self._onScroll)
        self._plotFigure.set_canvas(self._plotCanvas)
        # Vm and command voltage go in the same subplot
        self._vm_axes = self._plotFigure.add_subplot(2,2,1, title='Membrane potential')
        self._vm_axes.set_ylim(-20.0, 120.0)
        # Channel conductances go to the same subplot
        self._g_axes = self._plotFigure.add_subplot(2,2,2, title='Channel conductance')
        self._g_axes.set_ylim(0.0, 0.5)
        # Injection current for Vclamp/Iclamp go to the same subplot
        self._im_axes = self._plotFigure.add_subplot(2,2,3, title='Injection current')
        self._im_axes.set_ylim(-0.5, 0.5)
        # Channel currents go to the same subplot
        self._i_axes = self._plotFigure.add_subplot(2,2,4, title='Channel current')
        self._i_axes.set_ylim(-10, 10)
        for axis in self._plotFigure.axes:
            axis.set_autoscale_on(False)
        layout = QVBoxLayout()
        layout.addWidget(self._plotCanvas)
        self._plotNavigator = NavigationToolbar(self._plotCanvas, self._plotWidget)
        layout.addWidget(self._plotNavigator)
        self._plotWidget.setLayout(layout)

    def _createStatePlotWidget(self):        
        self._statePlotWidget = QWidget()
        self._statePlotFigure = Figure()
        self._statePlotCanvas = FigureCanvas(self._statePlotFigure)
        self._statePlotCanvas.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self._statePlotCanvas.updateGeometry()
        self._statePlotCanvas.setParent(self._statePlotWidget)
        self._statePlotFigure.set_canvas(self._statePlotCanvas)
        self._statePlotFigure.subplots_adjust(hspace=0.5)
        self._statePlotAxes = self._statePlotFigure.add_subplot(2,1,1, title='State plot')
        self._state_plot, = self._statePlotAxes.plot([], [], label='state')
        self._activationParamAxes = self._statePlotFigure.add_subplot(2,1,2, title='H-H activation parameters vs time')
        self._activationParamAxes.set_xlabel('Time (ms)')
        #for axis in self._plotFigure.axes:
        #    axis.autoscale(False)
        self._stateplot_xvar_label = QLabel('Variable on X-axis')
        self._stateplot_xvar_combo = QComboBox()
        self._stateplot_xvar_combo.addItems(['V', 'm', 'n', 'h'])
        self._stateplot_xvar_combo.setCurrentText('V')
        self._stateplot_xvar_combo.setEditable(False)
        self._stateplot_xvar_combo.currentIndexChanged[str].connect( self._statePlotXSlot )
        self._stateplot_yvar_label = QLabel('Variable on Y-axis')
        self._stateplot_yvar_combo = QComboBox()
        self._stateplot_yvar_combo.addItems(['V', 'm', 'n', 'h'])
        self._stateplot_yvar_combo.setCurrentIndex(2)
        self._stateplot_yvar_combo.setEditable(False)
        self._stateplot_yvar_combo.currentIndexChanged[str].connect(self._statePlotYSlot)
        self._statePlotNavigator = NavigationToolbar(self._statePlotCanvas, self._statePlotWidget)
        frame = QFrame()
        frame.setFrameStyle(QFrame.StyledPanel + QFrame.Raised)
        layout = QHBoxLayout()
        layout.addWidget(self._stateplot_xvar_label)
        layout.addWidget(self._stateplot_xvar_combo)
        layout.addWidget(self._stateplot_yvar_label)
        layout.addWidget(self._stateplot_yvar_combo)
        frame.setLayout(layout)
        self._closeStatePlotAction = QAction('Close', self)
        self._closeStatePlotAction.triggered.connect(self._statePlotWidget.close)
        self._closeStatePlotButton = QToolButton()
        self._closeStatePlotButton.setDefaultAction(self._closeStatePlotAction)
        layout = QVBoxLayout()
        layout.addWidget(frame)
        layout.addWidget(self._statePlotCanvas)
        layout.addWidget(self._statePlotNavigator)
        layout.addWidget(self._closeStatePlotButton)
        self._statePlotWidget.setLayout(layout)  
        # Setting the close event so that when the help window is
        # closed the ``State plot`` button becomes unchecked
        self._statePlotWidget.closeEvent = lambda event: self._showStatePlotAction.setChecked(False)

    def _createRunControl(self):
        self._runControlBox = QGroupBox(self)
        self._runControlBox.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        self._runTimeLabel = QLabel("Run time (ms)", self._runControlBox)
        self._simTimeStepLabel = QLabel("Simulation time step (ms)", self._runControlBox)
        self._runTimeEdit = QLineEdit('%g' % (SquidGui.defaults['runtime']), self._runControlBox)
        set_default_line_edit_size(self._runTimeEdit)
        self._simTimeStepEdit = QLineEdit('%g' % (SquidGui.defaults['simdt']), self._runControlBox)
        set_default_line_edit_size(self._simTimeStepEdit)
        layout = QGridLayout()
        layout.addWidget(self._runTimeLabel, 0, 0)
        layout.addWidget(self._runTimeEdit, 0, 1)
        layout.addWidget(self._simTimeStepLabel, 1, 0)
        layout.addWidget(self._simTimeStepEdit, 1, 1)
        layout.setColumnStretch(2, 1.0)
        layout.setRowStretch(2, 1.0)
        self._runControlBox.setLayout(layout)
        self._runControlDock = QDockWidget('Simulation', self)
        self._runControlDock.setWidget(self._runControlBox)

    def _createChannelControl(self):
        self._channelControlDock = QDockWidget('Channels', self)
        self._channelCtrlBox = QGroupBox(self)
        self._naConductanceToggle = QCheckBox('Block Na+ channel', self._channelCtrlBox)
        self._naConductanceToggle.setToolTip('<html>%s</html>' % (tooltip_NaChan))
        self._kConductanceToggle = QCheckBox('Block K+ channel', self._channelCtrlBox)
        self._kConductanceToggle.setToolTip('<html>%s</html>' % (tooltip_KChan))
        self._kOutLabel = QLabel('[K+]out (mM)', self._channelCtrlBox)
        self._kOutEdit = QLineEdit('%g' % (self.squid_setup.squid_axon.K_out), 
                                         self._channelCtrlBox)
        self._kOutLabel.setToolTip('<html>%s</html>' % (tooltip_Nernst))
        self._kOutEdit.setToolTip('<html>%s</html>' % (tooltip_Nernst))
        set_default_line_edit_size(self._kOutEdit)
        self._naOutLabel = QLabel('[Na+]out (mM)', self._channelCtrlBox)
        self._naOutEdit = QLineEdit('%g' % (self.squid_setup.squid_axon.Na_out), 
                                         self._channelCtrlBox)
        self._naOutLabel.setToolTip('<html>%s</html>' % (tooltip_Nernst))
        self._naOutEdit.setToolTip('<html>%s</html>' % (tooltip_Nernst))
        set_default_line_edit_size(self._naOutEdit)
        self._kInLabel = QLabel('[K+]in (mM)', self._channelCtrlBox)
        self._kInEdit = QLineEdit('%g' % (self.squid_setup.squid_axon.K_in), 
                                         self._channelCtrlBox)
        self._kInEdit.setToolTip(tooltip_Nernst)
        self._naInLabel = QLabel('[Na+]in (mM)', self._channelCtrlBox)
        self._naInEdit = QLineEdit('%g' % (self.squid_setup.squid_axon.Na_in), 
                                         self._channelCtrlBox)
        self._naInEdit.setToolTip('<html>%s</html>' % (tooltip_Nernst))
        self._temperatureLabel = QLabel('Temperature (C)', self._channelCtrlBox)
        self._temperatureEdit = QLineEdit('%g' % (self.defaults['temperature'] - CELSIUS_TO_KELVIN),
                                                self._channelCtrlBox)
        self._temperatureEdit.setToolTip('<html>%s</html>' % (tooltip_Nernst))
        set_default_line_edit_size(self._temperatureEdit)
        for child in self._channelCtrlBox.children():
            if isinstance(child, QLineEdit):
                set_default_line_edit_size(child)
        layout = QGridLayout(self._channelCtrlBox)
        layout.addWidget(self._naConductanceToggle, 0, 0)
        layout.addWidget(self._kConductanceToggle, 1, 0)
        layout.addWidget(self._naOutLabel, 2, 0)
        layout.addWidget(self._naOutEdit, 2, 1)
        layout.addWidget(self._naInLabel, 3, 0)
        layout.addWidget(self._naInEdit, 3, 1)
        layout.addWidget(self._kOutLabel, 4, 0)
        layout.addWidget(self._kOutEdit, 4, 1)
        layout.addWidget(self._kInLabel, 5, 0)
        layout.addWidget(self._kInEdit, 5, 1)
        layout.addWidget(self._temperatureLabel, 6, 0)
        layout.addWidget(self._temperatureEdit, 6, 1)
        layout.setRowStretch(7, 1.0)
        self._channelCtrlBox.setLayout(layout)
        self._channelControlDock.setWidget(self._channelCtrlBox)
        return self._channelCtrlBox        

    def __get_stateplot_data(self, name):
        data = []
        if name == 'V':
            data = self.squid_setup.vm_table.vector
        elif name == 'm':
            data = self.squid_setup.m_table.vector
        elif name == 'h':
            data = self.squid_setup.h_table.vector
        elif name == 'n':
            data = self.squid_setup.n_table.vector
        else:
            raise ValueError('Unrecognized selection: %s' % name )
        return numpy.asarray(data)
    
    def _statePlotYSlot(self, selectedItem):
        ydata = self.__get_stateplot_data(str(selectedItem))
        self._state_plot.set_ydata(ydata)
        self._statePlotAxes.set_ylabel(selectedItem)
        if str(selectedItem) == 'V':
            self._statePlotAxes.set_ylim(-20, 120)
        else:
            self._statePlotAxes.set_ylim(0, 1)
        self._statePlotCanvas.draw()
        
    def _statePlotXSlot(self, selectedItem):
        xdata = self.__get_stateplot_data(str(selectedItem))
        self._state_plot.set_xdata(xdata)
        self._statePlotAxes.set_xlabel(selectedItem)
        if str(selectedItem) == 'V':
            self._statePlotAxes.set_xlim(-20, 120)
        else:
            self._statePlotAxes.set_xlim(0, 1)
        self._statePlotCanvas.draw()

    def _createElectronicsControl(self):
        """Creates a tabbed widget of voltage clamp and current clamp controls"""
        self._electronicsTab = QTabWidget(self)
        self._electronicsTab.addTab(self._getIClampCtrlBox(), 'Current clamp')
        self._electronicsTab.addTab(self._getVClampCtrlBox(), 'Voltage clamp')
        self._electronicsDock = QDockWidget(self)
        self._electronicsDock.setWidget(self._electronicsTab)

    def _getVClampCtrlBox(self):
        vClampPanel = QGroupBox(self)
        self._vClampCtrlBox = vClampPanel
        self._holdingVLabel = QLabel("Holding Voltage (mV)", vClampPanel)
        self._holdingVEdit = QLineEdit('%g' % (SquidGui.defaults['vclamp.holdingV']), vClampPanel)
        self._holdingTimeLabel = QLabel("Holding Time (ms)", vClampPanel)
        self._holdingTimeEdit = QLineEdit('%g' % (SquidGui.defaults['vclamp.holdingT']), vClampPanel)
        self._prePulseVLabel = QLabel("Pre-pulse Voltage (mV)", vClampPanel)
        self._prePulseVEdit = QLineEdit('%g' % (SquidGui.defaults['vclamp.prepulseV']), vClampPanel)
        self._prePulseTimeLabel = QLabel("Pre-pulse Time (ms)", vClampPanel)
        self._prePulseTimeEdit = QLineEdit('%g' % (SquidGui.defaults['vclamp.prepulseT']), vClampPanel)
        self._clampVLabel = QLabel("Clamp Voltage (mV)", vClampPanel)
        self._clampVEdit = QLineEdit('%g' % (SquidGui.defaults['vclamp.clampV']), vClampPanel)
        self._clampTimeLabel = QLabel("Clamp Time (ms)", vClampPanel)
        self._clampTimeEdit = QLineEdit('%g' % (SquidGui.defaults['vclamp.clampT']), vClampPanel)
        for child in vClampPanel.children():
            if isinstance(child, QLineEdit):
                set_default_line_edit_size(child)
        layout = QGridLayout(vClampPanel)
        layout.addWidget(self._holdingVLabel, 0, 0)
        layout.addWidget(self._holdingVEdit, 0, 1)
        layout.addWidget(self._holdingTimeLabel, 1, 0)
        layout.addWidget(self._holdingTimeEdit, 1, 1)
        layout.addWidget(self._prePulseVLabel, 2, 0)
        layout.addWidget(self._prePulseVEdit, 2, 1)
        layout.addWidget(self._prePulseTimeLabel,3,0)
        layout.addWidget(self._prePulseTimeEdit, 3, 1)
        layout.addWidget(self._clampVLabel, 4, 0)
        layout.addWidget(self._clampVEdit, 4, 1)
        layout.addWidget(self._clampTimeLabel, 5, 0)
        layout.addWidget(self._clampTimeEdit, 5, 1)
        layout.setRowStretch(6, 1.0)
        vClampPanel.setLayout(layout)
        return self._vClampCtrlBox

    def _getIClampCtrlBox(self):
        iClampPanel = QGroupBox(self)
        self._iClampCtrlBox = iClampPanel
        self._baseCurrentLabel = QLabel("Base Current Level (uA)",iClampPanel)
        self._baseCurrentEdit = QLineEdit('%g' % (SquidGui.defaults['iclamp.baseI']),iClampPanel)
        self._firstPulseLabel = QLabel("First Pulse Current (uA)", iClampPanel)
        self._firstPulseEdit = QLineEdit('%g' % (SquidGui.defaults['iclamp.firstI']), iClampPanel)
        self._firstDelayLabel = QLabel("First Onset Delay (ms)", iClampPanel)
        self._firstDelayEdit = QLineEdit('%g' % (SquidGui.defaults['iclamp.firstD']),iClampPanel)
        self._firstPulseWidthLabel = QLabel("First Pulse Width (ms)", iClampPanel)
        self._firstPulseWidthEdit = QLineEdit('%g' % (SquidGui.defaults['iclamp.firstT']), iClampPanel)
        self._secondPulseLabel = QLabel("Second Pulse Current (uA)", iClampPanel)
        self._secondPulseEdit = QLineEdit('%g' % (SquidGui.defaults['iclamp.secondI']), iClampPanel)
        self._secondDelayLabel = QLabel("Second Onset Delay (ms)", iClampPanel)
        self._secondDelayEdit = QLineEdit('%g' % (SquidGui.defaults['iclamp.secondD']),iClampPanel)
        self._secondPulseWidthLabel = QLabel("Second Pulse Width (ms)", iClampPanel)
        self._secondPulseWidthEdit = QLineEdit('%g' % (SquidGui.defaults['iclamp.secondT']), iClampPanel)
        self._pulseMode = QComboBox(iClampPanel)
        self._pulseMode.addItem("Single Pulse")
        self._pulseMode.addItem("Pulse Train")
        for child in iClampPanel.children():
            if isinstance(child, QLineEdit):
                set_default_line_edit_size(child)
        layout = QGridLayout(iClampPanel)
        layout.addWidget(self._baseCurrentLabel, 0, 0)
        layout.addWidget(self._baseCurrentEdit, 0, 1)
        layout.addWidget(self._firstPulseLabel, 1, 0)
        layout.addWidget(self._firstPulseEdit, 1, 1)
        layout.addWidget(self._firstDelayLabel, 2, 0)
        layout.addWidget(self._firstDelayEdit, 2, 1)
        layout.addWidget(self._firstPulseWidthLabel, 3, 0)
        layout.addWidget(self._firstPulseWidthEdit, 3, 1)
        layout.addWidget(self._secondPulseLabel, 4, 0)
        layout.addWidget(self._secondPulseEdit, 4, 1)
        layout.addWidget(self._secondDelayLabel, 5, 0)
        layout.addWidget(self._secondDelayEdit, 5, 1)
        layout.addWidget(self._secondPulseWidthLabel, 6, 0)
        layout.addWidget(self._secondPulseWidthEdit, 6, 1)
        layout.addWidget(self._pulseMode, 7, 0, 1, 2)
        layout.setRowStretch(8, 1.0)        
        # layout.setSizeConstraint(QLayout.SetFixedSize)
        iClampPanel.setLayout(layout)
        return self._iClampCtrlBox

    def _overlayPlots(self, overlay):        
        if not overlay:
            for axis in (self._plotFigure.axes + self._statePlotFigure.axes):
                title = axis.get_title()
                axis.clear()
                axis.set_title(title)
            suffix = ''
        else:
            suffix = '_%d' % (len(self._plot_dict['vm']))
        self._vm_axes.set_xlim(0.0, self._runtime)
        self._g_axes.set_xlim(0.0, self._runtime)
        self._im_axes.set_xlim(0.0, self._runtime)
        self._i_axes.set_xlim(0.0, self._runtime)
        self._vm_plot, = self._vm_axes.plot([], [], label='Vm%s'%(suffix))
        self._plot_dict['vm'].append(self._vm_plot)
        self._command_plot, = self._vm_axes.plot([], [], label='command%s'%(suffix))
        self._plot_dict['command'].append(self._command_plot)
        # Channel conductances go to the same subplot
        self._gna_plot, = self._g_axes.plot([], [], label='Na%s'%(suffix))
        self._plot_dict['gna'].append(self._gna_plot)
        self._gk_plot, = self._g_axes.plot([], [], label='K%s'%(suffix))
        self._plot_dict['gk'].append(self._gk_plot)
        # Injection current for Vclamp/Iclamp go to the same subplot
        self._iclamp_plot, = self._im_axes.plot([], [], label='Iclamp%s'%(suffix))
        self._vclamp_plot, = self._im_axes.plot([], [], label='Vclamp%s'%(suffix))
        self._plot_dict['iclamp'].append(self._iclamp_plot)
        self._plot_dict['vclamp'].append(self._vclamp_plot)
        # Channel currents go to the same subplot
        self._ina_plot, = self._i_axes.plot([], [], label='Na%s'%(suffix))
        self._plot_dict['ina'].append(self._ina_plot)
        self._ik_plot, = self._i_axes.plot([], [], label='K%s'%(suffix))
        self._plot_dict['ik'].append(self._ik_plot)
        # self._i_axes.legend()
        # State plots
        self._state_plot, = self._statePlotAxes.plot([], [], label='state%s'%(suffix))
        self._plot_dict['state'].append(self._state_plot)
        self._m_plot, = self._activationParamAxes.plot([],[], label='m%s'%(suffix))
        self._h_plot, = self._activationParamAxes.plot([], [], label='h%s'%(suffix))
        self._n_plot, = self._activationParamAxes.plot([], [], label='n%s'%(suffix))
        self._plot_dict['m'].append(self._m_plot)
        self._plot_dict['h'].append(self._h_plot)
        self._plot_dict['n'].append(self._n_plot)
        if self._showLegendAction.isChecked():
            for axis in (self._plotFigure.axes + self._statePlotFigure.axes):            
                axis.legend()

    def _updateAllPlots(self):
        self._updatePlots()
        self._updateStatePlot()

    def _updatePlots(self):
        if len(self.squid_setup.vm_table.vector) <= 0:
            return        
        vm = numpy.asarray(self.squid_setup.vm_table.vector)
        cmd = numpy.asarray(self.squid_setup.cmd_table.vector)
        ik = numpy.asarray(self.squid_setup.ik_table.vector)
        ina = numpy.asarray(self.squid_setup.ina_table.vector)
        iclamp = numpy.asarray(self.squid_setup.iclamp_table.vector)
        vclamp = numpy.asarray(self.squid_setup.vclamp_table.vector)
        gk = numpy.asarray(self.squid_setup.gk_table.vector)
        gna = numpy.asarray(self.squid_setup.gna_table.vector)
        time_series = numpy.linspace(0, self._plotdt * len(vm), len(vm))        
        self._vm_plot.set_data(time_series, vm)
        time_series = numpy.linspace(0, self._plotdt * len(cmd), len(cmd))        
        self._command_plot.set_data(time_series, cmd)
        time_series = numpy.linspace(0, self._plotdt * len(ik), len(ik))
        self._ik_plot.set_data(time_series, ik)
        time_series = numpy.linspace(0, self._plotdt * len(ina), len(ina))
        self._ina_plot.set_data(time_series, ina)
        time_series = numpy.linspace(0, self._plotdt * len(iclamp), len(iclamp))
        self._iclamp_plot.set_data(time_series, iclamp)
        time_series = numpy.linspace(0, self._plotdt * len(vclamp), len(vclamp))
        self._vclamp_plot.set_data(time_series, vclamp)
        time_series = numpy.linspace(0, self._plotdt * len(gk), len(gk))
        self._gk_plot.set_data(time_series, gk)
        time_series = numpy.linspace(0, self._plotdt * len(gna), len(gna))
        self._gna_plot.set_data(time_series, gna)
        # self._vm_axes.margins(y=0.1)
        # self._g_axes.margin(y=0.1)
        # self._im_axes.margins(y=0.1)
        # self._i_axes.margins(y=0.1)
        if self._autoscaleAction.isChecked():
            for axis in self._plotFigure.axes:
                axis.relim()
                axis.margins(0.1, 0.1)
                axis.autoscale_view(tight=True)
        else:
            self._vm_axes.set_ylim(-20.0, 120.0)
            self._g_axes.set_ylim(0.0, 0.5)
            self._im_axes.set_ylim(-0.5, 0.5)
            self._i_axes.set_ylim(-10, 10)
        self._vm_axes.set_xlim(0.0, time_series[-1])
        self._g_axes.set_xlim(0.0, time_series[-1])
        self._im_axes.set_xlim(0.0, time_series[-1])
        self._i_axes.set_xlim(0.0, time_series[-1])
        self._plotCanvas.draw()

    def _updateStatePlot(self):
        if len(self.squid_setup.vm_table.vector) <= 0:
            return
        sx = str(self._stateplot_xvar_combo.currentText())
        sy = str(self._stateplot_yvar_combo.currentText())
        xdata = self.__get_stateplot_data(sx)
        ydata = self.__get_stateplot_data(sy)
        minlen = min(len(xdata), len(ydata))
        self._state_plot.set_data(xdata[:minlen], ydata[:minlen])
        self._statePlotAxes.set_xlabel(sx)
        self._statePlotAxes.set_ylabel(sy)
        if sx == 'V':
            self._statePlotAxes.set_xlim(-20, 120)
        else:
            self._statePlotAxes.set_xlim(0, 1)
        if sy == 'V':
            self._statePlotAxes.set_ylim(-20, 120)
        else:
            self._statePlotAxes.set_ylim(0, 1)
        self._activationParamAxes.set_xlim(0, self._runtime)
        m = self.__get_stateplot_data('m')
        n = self.__get_stateplot_data('n')
        h = self.__get_stateplot_data('h')
        time_series = numpy.linspace(0, self._plotdt*len(m), len(m))
        self._m_plot.set_data(time_series, m)
        time_series = numpy.linspace(0, self._plotdt*len(h), len(h))
        self._h_plot.set_data(time_series, h)
        time_series = numpy.linspace(0, self._plotdt*len(n), len(n))
        self._n_plot.set_data(time_series, n)
        if self._autoscaleAction.isChecked():
            for axis in self._statePlotFigure.axes:
                axis.relim()
                axis.set_autoscale_on(True)
                axis.autoscale_view(True)
        self._statePlotCanvas.draw()

    def _runSlot(self):
        if moose.isRunning():
            print('Stopping simulation in progress ...')
            moose.stop()
        self._runtime = self.getFloatInput(self._runTimeEdit, self._runTimeLabel.text())
        self._overlayPlots(self._overlayAction.isChecked())
        self._simdt = self.getFloatInput(self._simTimeStepEdit, self._simTimeStepLabel.text())
        clampMode = None
        singlePulse = True
        if self._electronicsTab.currentWidget() == self._vClampCtrlBox:
            clampMode = 'vclamp'
            baseLevel = self.getFloatInput(self._holdingVEdit, self._holdingVLabel.text())
            firstDelay = self.getFloatInput(self._holdingTimeEdit, self._holdingTimeLabel.text())
            firstWidth = self.getFloatInput(self._prePulseTimeEdit, self._prePulseTimeLabel.text())
            firstLevel = self.getFloatInput(self._prePulseVEdit, self._prePulseVLabel.text())
            secondDelay = firstWidth
            secondWidth = self.getFloatInput(self._clampTimeEdit, self._clampTimeLabel.text())
            secondLevel = self.getFloatInput(self._clampVEdit, self._clampVLabel.text())
            if not self._autoscaleAction.isChecked():
                self._im_axes.set_ylim(-10.0, 10.0)
        else:
            clampMode = 'iclamp'
            baseLevel = self.getFloatInput(self._baseCurrentEdit, self._baseCurrentLabel.text())
            firstDelay = self.getFloatInput(self._firstDelayEdit, self._firstDelayLabel.text())
            firstWidth = self.getFloatInput(self._firstPulseWidthEdit, self._firstPulseWidthLabel.text())
            firstLevel = self.getFloatInput(self._firstPulseEdit, self._firstPulseLabel.text())
            secondDelay = self.getFloatInput(self._secondDelayEdit, self._secondDelayLabel.text())
            secondLevel = self.getFloatInput(self._secondPulseEdit, self._secondPulseLabel.text())
            secondWidth = self.getFloatInput(self._secondPulseWidthEdit, self._secondPulseWidthLabel.text())
            singlePulse = (self._pulseMode.currentIndex() == 0)
            if not self._autoscaleAction.isChecked():
                self._im_axes.set_ylim(-0.4, 0.4)
        self.squid_setup.clamp_ckt.configure_pulses(baseLevel=baseLevel,
                                                    firstDelay=firstDelay,
                                                    firstWidth=firstWidth,
                                                    firstLevel=firstLevel,
                                                    secondDelay=secondDelay,
                                                    secondWidth=secondWidth,
                                                    secondLevel=secondLevel,
                                                    singlePulse=singlePulse)
        if self._kConductanceToggle.isChecked():
            self.squid_setup.squid_axon.specific_gK = 0.0
        else:
            self.squid_setup.squid_axon.specific_gK = SquidAxon.defaults['specific_gK']
        if self._naConductanceToggle.isChecked():
            self.squid_setup.squid_axon.specific_gNa = 0.0
        else:
            self.squid_setup.squid_axon.specific_gNa = SquidAxon.defaults['specific_gNa']
        self.squid_setup.squid_axon.celsius = self.getFloatInput(self._temperatureEdit, self._temperatureLabel.text())
        self.squid_setup.squid_axon.K_out = self.getFloatInput(self._kOutEdit, self._kOutLabel.text())
        self.squid_setup.squid_axon.Na_out = self.getFloatInput(self._naOutEdit, self._naOutLabel.text())
        self.squid_setup.squid_axon.K_in = self.getFloatInput(self._kInEdit, self._kInLabel.text())
        self.squid_setup.squid_axon.Na_in = self.getFloatInput(self._naInEdit, self._naInLabel.text())
        self.squid_setup.squid_axon.updateEk()
        self.squid_setup.schedule(self._simdt, self._plotdt, clampMode)
        # The following line is for use with Qthread
        self.squid_setup.run(self._runtime)
        self._updateAllPlots()

    def _toggleDocking(self, on):
        self._channelControlDock.setFloating(on)
        self._electronicsDock.setFloating(on)
        self._runControlDock.setFloating(on)
        
    def _restoreDocks(self):
        self._channelControlDock.setVisible(True)
        self._electronicsDock.setVisible(True)
        self._runControlDock.setVisible(True)

    def _initActions(self):
        self._runAction = QAction(self.tr('Run'), self)
        self._runAction.setShortcut(self.tr('F5'))
        self._runAction.setToolTip('Run simulation (F5)')
        self._runAction.triggered.connect( self._runSlot)
        self._resetToDefaultsAction = QAction(self.tr('Restore defaults'), self)
        self._resetToDefaultsAction.setToolTip('Reset all settings to their default values')
        self._resetToDefaultsAction.triggered.connect( self._useDefaults)
        self._showLegendAction = QAction(self.tr('Display legend'), self)
        self._showLegendAction.setCheckable(True)
        self._showLegendAction.toggled.connect(self._showLegend)
        self._showStatePlotAction = QAction(self.tr('State plot'), self)
        self._showStatePlotAction.setCheckable(True)
        self._showStatePlotAction.setChecked(False)
        self._showStatePlotAction.toggled.connect(self._statePlotWidget.setVisible)
        self._autoscaleAction  = QAction(self.tr('Auto-scale plots'), self)
        self._autoscaleAction.setCheckable(True)
        self._autoscaleAction.setChecked(False)
        self._autoscaleAction.toggled.connect(self._autoscale)
        self._overlayAction = QAction('Overlay plots', self)
        self._overlayAction.setCheckable(True)
        self._overlayAction.setChecked(False) 
        self._dockAction = QAction('Undock all', self)
        self._dockAction.setCheckable(True)
        self._dockAction.setChecked(False)
        #  self._dockAction.toggle.connect( self._toggleDocking)
        self._restoreDocksAction = QAction('Show all', self)
        self._restoreDocksAction.triggered.connect( self._restoreDocks)
        self._quitAction = QAction(self.tr('&Quit'), self)
        self._quitAction.setShortcut(self.tr('Ctrl+Q'))
        self._quitAction.triggered.connect(qApp.closeAllWindows)

        

    def _createRunToolBar(self):
        self._simToolBar = self.addToolBar(self.tr('Simulation control'))
        self._simToolBar.addAction(self._quitAction)
        self._simToolBar.addAction(self._runAction)
        self._simToolBar.addAction(self._resetToDefaultsAction)
        self._simToolBar.addAction(self._dockAction)
        self._simToolBar.addAction(self._restoreDocksAction)

    def _createPlotToolBar(self):
        self._plotToolBar = self.addToolBar(self.tr('Plotting control'))
        self._plotToolBar.addAction(self._showLegendAction)
        self._plotToolBar.addAction(self._autoscaleAction)
        self._plotToolBar.addAction(self._overlayAction)
        self._plotToolBar.addAction(self._showStatePlotAction)
        self._plotToolBar.addAction(self._helpAction)
        self._plotToolBar.addAction(self._helpBiophysicsAction)

    def _showLegend(self, on):
        if on:
            for axis in (self._plotFigure.axes + self._statePlotFigure.axes):            
                axis.legend().set_visible(True)
        else:
            for axis in (self._plotFigure.axes + self._statePlotFigure.axes):            
                axis.legend().set_visible(False)
        self._plotCanvas.draw()
        self._statePlotCanvas.draw()

    def _autoscale(self, on):
        if on:
            for axis in (self._plotFigure.axes + self._statePlotFigure.axes):            
                axis.relim()
                axis.set_autoscale_on(True)
                axis.autoscale_view(True)
        else:
            for axis in self._plotFigure.axes:
                axis.set_autoscale_on(False)            
            self._vm_axes.set_ylim(-20.0, 120.0)
            self._g_axes.set_ylim(0.0, 0.5)
            self._im_axes.set_ylim(-0.5, 0.5)
            self._i_axes.set_ylim(-10, 10)
        self._plotCanvas.draw()
        self._statePlotCanvas.draw()
        
    def _useDefaults(self):
        self._runTimeEdit.setText('%g' % (self.defaults['runtime']))
        self._simTimeStepEdit.setText('%g' % (self.defaults['simdt']))
        self._overlayAction.setChecked(False)
        self._naConductanceToggle.setChecked(False)
        self._kConductanceToggle.setChecked(False)
        self._kOutEdit.setText('%g' % (SquidGui.defaults['K_out']))
        self._naOutEdit.setText('%g' % (SquidGui.defaults['Na_out']))
        self._kInEdit.setText('%g' % (SquidGui.defaults['K_in']))
        self._naInEdit.setText('%g' % (SquidGui.defaults['Na_in']))
        self._temperatureEdit.setText('%g' % (SquidGui.defaults['temperature'] - CELSIUS_TO_KELVIN))
        self._holdingVEdit.setText('%g' % (SquidGui.defaults['vclamp.holdingV']))
        self._holdingTimeEdit.setText('%g' % (SquidGui.defaults['vclamp.holdingT']))
        self._prePulseVEdit.setText('%g' % (SquidGui.defaults['vclamp.prepulseV']))
        self._prePulseTimeEdit.setText('%g' % (SquidGui.defaults['vclamp.prepulseT']))
        self._clampVEdit.setText('%g' % (SquidGui.defaults['vclamp.clampV']))
        self._clampTimeEdit.setText('%g' % (SquidGui.defaults['vclamp.clampT']))
        self._baseCurrentEdit.setText('%g' % (SquidGui.defaults['iclamp.baseI']))
        self._firstPulseEdit.setText('%g' % (SquidGui.defaults['iclamp.firstI']))
        self._firstDelayEdit.setText('%g' % (SquidGui.defaults['iclamp.firstD']))
        self._firstPulseWidthEdit.setText('%g' % (SquidGui.defaults['iclamp.firstT']))
        self._secondPulseEdit.setText('%g' % (SquidGui.defaults['iclamp.secondI']))
        self._secondDelayEdit.setText('%g' % (SquidGui.defaults['iclamp.secondD']))
        self._secondPulseWidthEdit.setText('%g' % (SquidGui.defaults['iclamp.secondT']))
        self._pulseMode.setCurrentIndex(0)

    def _onScroll(self, event):
        if event.inaxes is None:
            return  
        axes = event.inaxes
        zoom = 0.0
        if event.button == 'up':
            zoom = -1.0
        elif event.button == 'down':
            zoom = 1.0
        if zoom != 0.0:
            self._plotNavigator.push_current()
            axes.get_xaxis().zoom(zoom)
            axes.get_yaxis().zoom(zoom)        
        self._plotCanvas.draw()

    def closeEvent(self, event):
        qApp.closeAllWindows()

    def _showBioPhysicsHelp(self):
        self._createHelpMessage()
        self._helpMessageText.setText('<html><p>%s</p><p>%s</p><p>%s</p><p>%s</p><p>%s</p></html>' % 
                                      (tooltip_Nernst, 
                                       tooltip_Erest,
                                       tooltip_KChan,
                                       tooltip_NaChan,
                                       tooltip_Im))
        self._helpWindow.setVisible(True)

    def _showRunningHelp(self):
        self._createHelpMessage()
        self._helpMessageText.setSource(QtCore.QUrl(self._helpBaseURL))
        self._helpWindow.setVisible(True)

    def _createHelpMessage(self):
        if hasattr(self, '_helpWindow'):
            return
        self._helpWindow = QWidget()
        self._helpWindow.setWindowFlags(QtCore.Qt.Window)
        layout = QVBoxLayout()
        self._helpWindow.setLayout(layout)
        self._helpMessageArea = QScrollArea()
        self._helpMessageText = QTextBrowser()
        self._helpMessageText.setOpenExternalLinks(True)
        self._helpMessageArea.setWidget(self._helpMessageText)
        layout.addWidget(self._helpMessageText)
        self._squidGuiPath = os.path.dirname(os.path.abspath(__file__))
        self._helpBaseURL = os.path.join(self._squidGuiPath,'help.html')
        self._helpMessageText.setSource(QtCore.QUrl(self._helpBaseURL))
        self._helpMessageText.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self._helpMessageArea.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self._helpMessageText.setMinimumSize(800, 600)
        self._closeHelpAction = QAction('Close', self)
        self._closeHelpAction.triggered.connect(self._helpWindow.close)        
        # Setting the close event so that the ``Help`` button is
        # unchecked when the help window is closed
        self._helpWindow.closeEvent = lambda event: self._helpAction.setChecked(False)
        self._helpTOCAction = QAction('Help running demo', self)
        self._helpTOCAction.triggered.connect( self._jumpToHelpTOC)                
        # This panel is for putting two buttons using horizontal
        # layout
        panel = QFrame()
        panel.setFrameStyle(QFrame.StyledPanel + QFrame.Raised)
        layout.addWidget(panel)
        layout = QHBoxLayout()
        panel.setLayout(layout)
        self._helpAction = QAction('Help running', self)
        self._helpAction.triggered.connect(self._showRunningHelp)
        self._helpBiophysicsAction = QAction('Help biophysics', self)
        self._helpBiophysicsAction.triggered.connect(self._showBioPhysicsHelp)
        self._helpTOCButton = QToolButton()
        self._helpTOCButton.setDefaultAction(self._helpTOCAction)
        self._helpBiophysicsButton = QToolButton()
        self._helpBiophysicsButton.setDefaultAction(self._helpBiophysicsAction)
        layout.addWidget(self._helpTOCButton)
        layout.addWidget(self._helpBiophysicsButton)
        self._closeHelpButton = QToolButton()
        self._closeHelpButton.setDefaultAction(self._closeHelpAction)
        layout.addWidget(self._closeHelpButton)
        
    def _jumpToHelpTOC(self):
        self._helpMessageText.setSource(QtCore.QUrl(self._helpBaseURL))