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


Python Canvas.create_arc方法代码示例

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


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

示例1: __init__

# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import create_arc [as 别名]

#.........这里部分代码省略.........

      y: Y-offset where to display.
      label: Name of the side. Will probably be one of "previous", "current",
      "base", or
      "expt".
      stats: Statistics for this run. This is a
      :py:class:`farg.core.run_stats.RunStats`
      object.
    """
    self.canvas.create_text(10, y, anchor=NW, text=label)
    self.CreatePieChart(kPieChartXOffset, y + 20, stats)
    self.CreateHistogram(kHistogramXOffset, y + 20, stats)
    self.DisplayBasicStats(kBasicStatsXOffset, y + 20, stats)

  def CreatePieChart(self, x_offset, y_offset, stats):
    """Create PieChart.

    Args:
      x_offset: X-offset for Pie.
      y_offset: Y-offset for Pie.
      stats: Stats to display. Instance of
        :py:class:`~farg.core.run_stats.RunStats`.
    """
    stats_per_state = stats.stats_per_state
    state_to_counts = dict((x, len(y.codelet_counts))
                           for x, y in stats_per_state.items())
    total_runs = sum(state_to_counts.values())
    if total_runs == 0:
      return
    start = 0
    for state, count in state_to_counts.items():
      extent = 359.9 * count / total_runs
      color = StateToColor(state)
      self.canvas.create_arc(
          x_offset,
          y_offset,
          x_offset + kPieChartDiameter,
          y_offset + kPieChartDiameter,
          start=start,
          extent=extent,
          fill=color)
      start += extent
    self.canvas.create_text(
        x_offset + kPieChartDiameter / 2,
        y_offset + kPieChartDiameter + 5,
        anchor=N,
        text='%d Runs' % total_runs)

  def CreateHistogram(self, x_offset, y_offset, stats):
    """Create histogram of codelet run times.

    Args:
      x_offset: X-offset for Pie.
      y_offset: Y-offset for Pie.
      stats: Stats to display. Instance of
        :py:class:`~farg.core.run_stats.RunStats`.
    """
    all_runs = []
    for state, stats_for_state in stats.stats_per_state.items():
      all_runs.extend((state, x_offset)
                      for x_offset in stats_for_state.codelet_counts)
    all_runs = sorted(
        (x_offset for x_offset in all_runs if x_offset[1] > 0),
        key=lambda x_offset: x_offset[1])
    count = len(all_runs)
    if count == 0:
开发者ID:amahabal,项目名称:PySeqsee,代码行数:70,代码来源:non_interactive.py


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