-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
I checked the related issues and couldn't find the same issue.
I am using the latest Textual version (7.5.0).
The bug
I get a "zero division error" when I run my Textual app. The error is raised in: site-packages/textual/timer.py:163 in _run.
It seems to only happen when I use the GraphView widget from netext.
I believe that the crash is caused by a call from my Textual app to set_call_graph in my widget:
import networkx as nx
from netext.edge_rendering.modes import EdgeSegmentDrawingMode
from netext.edge_routing.modes import EdgeRoutingMode
from netext.layout_engines import LayoutDirection, SugiyamaLayout
from netext.properties.arrow_tips import ArrowTip
from netext.textual_widget.widget import GraphView
from rich.style import Style
from textual.app import ComposeResult
from textual.widgets import Static
class CallGraph(Static):
def compose(self) -> ComposeResult:
yield GraphView(nx.DiGraph())
def on_mount(self):
self.loading = True
def _style(self):
g = self.query_one(GraphView).graph
nx.set_node_attributes(g, Style(color="green"), "$style")
nx.set_node_attributes(g, Style(color="white"), "$content-style")
nx.set_edge_attributes(g, EdgeRoutingMode.ORTHOGONAL, "$edge-routing-mode")
nx.set_edge_attributes(
g, EdgeSegmentDrawingMode.BOX, "$edge-segment-drawing-mode"
)
nx.set_edge_attributes(g, ArrowTip.NONE, "$start-arrow-tip")
nx.set_edge_attributes(g, ArrowTip.ARROW, "$end-arrow-tip")
nx.set_edge_attributes(g, Style(color="blue"), "$style")
async def set_call_graph(self, graph: nx.DiGraph) -> None:
self.ready()
await self.query_one(GraphView).remove()
await self.mount(
GraphView(
graph,
layout_engine=SugiyamaLayout(direction=LayoutDirection.LEFT_RIGHT),
)
)
self._style()
def update(self, k: object, v: object) -> None:
graph = self.query_one(GraphView)
graph.add_node(k)
graph.add_node(v)
graph.add_edge(k, v)
self.ready()
self._style()
def hilight(self, k: object) -> None:
# TODO:Update style of specific node
# self.query_one(GraphView).update(k)
# for u, v in self.graph.edges():
# self.ready()
pass
def due(self) -> None:
# TODO: Blink the border
self.styles.border = ("dashed", "yellow")
self.styles.opacity = 0.8
self.border_title = "Call graph: due for reloading"
def ready(self) -> None:
self.loading = False
self.styles.border = ("solid", "blue")
self.styles.opacity = 1.0
self.border_title = "Call graph"Textual Diagnostics
Versions
| Name | Value |
|---|---|
| Textual | 7.5.0 |
| Rich | 14.3.2 |
Python
| Name | Value |
|---|---|
| Version | 3.14.2 |
| Implementation | CPython |
| Compiler | Clang 17.0.0 (clang-1700.6.3.2) |
| Executable | /Users/cactus/Library/Caches/uv/archive-v0/-HobocSzp8mrunkklOkv2/bin/python |
Operating System
| Name | Value |
|---|---|
| System | Darwin |
| Release | 24.5.0 |
| Version | Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:26 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T8112 |
Terminal
| Name | Value |
|---|---|
| Terminal Application | tmux (3.6a) |
| TERM | xterm-256color |
| COLORTERM | truecolor |
| FORCE_COLOR | Not set |
| NO_COLOR | Not set |
Rich Console options
| Name | Value |
|---|---|
| size | width=317, height=90 |
| legacy_windows | False |
| min_width | 1 |
| max_width | 317 |
| is_terminal | True |
| encoding | utf-8 |
| max_height | 90 |
| justify | None |
| overflow | None |
| no_wrap | False |
| highlight | None |
| markup | None |
| height | None |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels