当前位置: 首页>>代码示例>>Python>>正文


Python Controller.getPanel方法代码示例

本文整理汇总了Python中stem.control.Controller.getPanel方法的典型用法代码示例。如果您正苦于以下问题:Python Controller.getPanel方法的具体用法?Python Controller.getPanel怎么用?Python Controller.getPanel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stem.control.Controller的用法示例。


在下文中一共展示了Controller.getPanel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: initController

# 需要导入模块: from stem.control import Controller [as 别名]
# 或者: from stem.control.Controller import getPanel [as 别名]
def initController(stdscr, startTime):
    """
  Spawns the controller, and related panels for it.
  
  Arguments:
    stdscr - curses window
  """

    global ARM_CONTROLLER

    # initializes the panels
    stickyPanels = [cli.headerPanel.HeaderPanel(stdscr, startTime), LabelPanel(stdscr)]
    pagePanels, firstPagePanels = [], []

    # first page: graph and log
    if CONFIG["features.panels.show.graph"]:
        firstPagePanels.append(cli.graphing.graphPanel.GraphPanel(stdscr))

    if CONFIG["features.panels.show.log"]:
        expandedEvents = cli.logPanel.expandEvents(CONFIG["startup.events"])
        firstPagePanels.append(cli.logPanel.LogPanel(stdscr, expandedEvents))

    if firstPagePanels:
        pagePanels.append(firstPagePanels)

    # second page: connections
    if not CONFIG["startup.blindModeEnabled"] and CONFIG["features.panels.show.connection"]:
        pagePanels.append([cli.connections.connPanel.ConnectionPanel(stdscr)])

    # third page: config
    if CONFIG["features.panels.show.config"]:
        pagePanels.append([cli.configPanel.ConfigPanel(stdscr, cli.configPanel.State.TOR)])

    # fourth page: torrc
    if CONFIG["features.panels.show.torrc"]:
        pagePanels.append([cli.torrcPanel.TorrcPanel(stdscr, cli.torrcPanel.Config.TORRC)])

    # initializes the controller
    ARM_CONTROLLER = Controller(stdscr, stickyPanels, pagePanels)

    # additional configuration for the graph panel
    graphPanel = ARM_CONTROLLER.getPanel("graph")

    if graphPanel:
        # statistical monitors for graph
        bwStats = cli.graphing.bandwidthStats.BandwidthStats()
        graphPanel.addStats(GraphStat.BANDWIDTH, bwStats)
        graphPanel.addStats(GraphStat.SYSTEM_RESOURCES, cli.graphing.resourceStats.ResourceStats())
        if not CONFIG["startup.blindModeEnabled"]:
            graphPanel.addStats(GraphStat.CONNECTIONS, cli.graphing.connStats.ConnStats())

        # sets graph based on config parameter
        try:
            initialStats = GRAPH_INIT_STATS.get(CONFIG["features.graph.type"])
            graphPanel.setStats(initialStats)
        except ValueError:
            pass  # invalid stats, maybe connections when in blind mode

        # prepopulates bandwidth values from state file
        if CONFIG["features.graph.bw.prepopulate"] and torTools.getConn().isAlive():
            isSuccessful = bwStats.prepopulateFromState()
            if isSuccessful:
                graphPanel.updateInterval = 4
开发者ID:gsathya,项目名称:arm,代码行数:65,代码来源:controller.py


注:本文中的stem.control.Controller.getPanel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。