Skip to content

Commit ca7a06b

Browse files
committed
Title + padding
1 parent dde98bb commit ca7a06b

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

bindsnet/rendering/app.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
class Application():
99
def __init__(self, network: GUINetwork, width=1400, height=900, title="BindsNET GUI",
10+
header: str | None = None,
1011
step_rate: int | str = 500, draw_fps: float | None = None):
1112
self.width, self.height = width, height
1213
self.network = network
@@ -32,7 +33,21 @@ def __init__(self, network: GUINetwork, width=1400, height=900, title="BindsNET
3233
size=(self.width, self.height),
3334
show=True,
3435
)
35-
self.grid = self.canvas.central_widget.add_grid(margin=10)
36+
# Top-level layout: an optional centered title spanning the full width, above
37+
# the grid of plotting widgets. When there's no title we still reserve a small
38+
# spacer row so the topmost axis tick labels aren't clipped by the canvas edge.
39+
self.layout = self.canvas.central_widget.add_grid(margin=0)
40+
next_row = 0
41+
if header is not None:
42+
self.title_label = scene.Label(header, color='white', font_size=20, bold=True)
43+
self.title_label.height_max = 48
44+
self.layout.add_widget(self.title_label, row=next_row, col=0)
45+
else:
46+
self.title_label = None
47+
self.layout.add_widget(row=next_row, col=0).height_max = 12 # top padding
48+
next_row += 1
49+
50+
self.grid = self.layout.add_grid(row=next_row, col=0, margin=10)
3651

3752
# Migrate network tensors to shared OpenGL buffers
3853
network.migrate()

examples/rendering/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
INH_TO_EXC_CONNECTIVITY,
2727
EXC_TO_INH_CONNECTIVITY,
2828
)
29-
app = Application(network, 1400, 900, step_rate=99999999999, draw_fps=DRAW_FPS)
29+
app = Application(network, 1400, 900, header="BindsNET Network Activity",
30+
step_rate=99999999999, draw_fps=DRAW_FPS)
3031
inputs = {"I": torch.rand(SIM_TIME, BATCH_SIZE, IN_SIZE, device=DEVICE) > 0.90}
3132
app.add_widget(
3233
RasterPlot(layer_name="EXC_LIF", max_timesteps=500),

0 commit comments

Comments
 (0)