Skip to content

Commit 2ee711c

Browse files
committed
split into left/right
1 parent 94ee959 commit 2ee711c

File tree

1 file changed

+25
-55
lines changed

1 file changed

+25
-55
lines changed

spikeinterface_gui/backend_qt.py

Lines changed: 25 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -185,42 +185,6 @@ def make_views(self):
185185

186186

187187
def create_main_layout(self):
188-
"""
189-
We rely on PyQt docks so that the user can adjust the size of each widget. These
190-
are made iteratively by splitting an existing dock. The algorithm to create the
191-
splits based on our layout dict is in three steps. It is complicated, so we provide
192-
an example. Let's "*" represent a zone with something in it and "o" a zone without.
193-
Consider the example
194-
195-
1 2 3 4
196-
* * o *
197-
* o * *
198-
199-
First, we determine which columns should be two rows long. Then split the docks
200-
around these. In this case, only column 2 should be long. So the split is
201-
202-
1 2 3 4
203-
* | * | o *
204-
* | o | * *
205-
206-
Next, for each sub-region, we split vertically. The second column cannot be split.
207-
208-
1 2 3 4
209-
* | * | o *
210-
- - -
211-
* | o | * *
212-
213-
Finally, in each sub-sub-region, we check how many times we need to split horizontally.
214-
Here the lower 3/4 row can be split
215-
216-
1 2 3 4
217-
* | * | o *
218-
- - -
219-
* | o | * | *
220-
221-
Each final region contains exactly one zone. All of our possible layouts can be split up
222-
in this way.
223-
"""
224188
import warnings
225189

226190
warnings.filterwarnings("ignore", category=RuntimeWarning, module="pyqtgraph")
@@ -235,10 +199,28 @@ def create_main_layout(self):
235199
view_names = [view_name for view_name in view_names if view_name in self.views.keys()]
236200
widgets_zone[zone] = view_names
237201

238-
all_zones = [f'zone{a}' for a in range(1,9)]
239-
all_zones_array = np.transpose(np.reshape(all_zones, (2,4)))
202+
self.make_dock(widgets_zone, ['zone1', 'zone2', 'zone5', 'zone6'], "left")
203+
self.make_dock(widgets_zone, ['zone3', 'zone4', 'zone7', 'zone8'], "right")
204+
205+
# make tabs
206+
for zone, view_names in widgets_zone.items():
207+
n = len(widgets_zone[zone])
208+
if n < 2:
209+
# no tab here
210+
continue
211+
view_name0 = widgets_zone[zone][0]
212+
for i in range(1, n):
213+
view_name = widgets_zone[zone][i]
214+
dock = self.docks[view_name]
215+
self.tabifyDockWidget(self.docks[view_name0], dock)
216+
# make visible the first of each zone
217+
self.docks[view_name0].raise_()
218+
219+
def make_dock(self, widgets_zone, all_zones, side_of_window):
220+
221+
all_zones_array = np.transpose(np.reshape(all_zones, (2,2)))
240222
is_zone = np.array([(widgets_zone.get(zone) is not None) and (len(widgets_zone.get(zone)) > 0) for zone in all_zones])
241-
is_zone_array = np.reshape(is_zone, (2,4))
223+
is_zone_array = np.reshape(is_zone, (2,2))
242224

243225
# If the first non-zero zero (from left to right) is on the bottom, move it up
244226
for column_index, zones_in_columns in enumerate(is_zone_array):
@@ -252,15 +234,15 @@ def create_main_layout(self):
252234
continue
253235

254236
is_zone = np.array([(widgets_zone.get(zone) is not None) and (len(widgets_zone.get(zone)) > 0) for zone in all_zones])
255-
is_zone_array = np.reshape(is_zone, (2,4))
237+
is_zone_array = np.reshape(is_zone, (2,2))
256238
original_zone_array = copy(is_zone_array)
257239

258240
# First we split horizontally any columns which are two rows long.
259241
# For later, group the zones between these splits
260242
all_groups = []
261243
group = []
262244
for col_index, zones in enumerate(all_zones_array):
263-
col = col_index % 4
245+
col = col_index % 2
264246
is_a_zone = original_zone_array[:,col]
265247
num_row_0, _ = get_size_top_row(0, col, is_zone_array, original_zone_array)
266248
# this function affects is_zone_array so must be run
@@ -282,7 +264,7 @@ def create_main_layout(self):
282264
first_zone = all_groups[0][0]
283265
first_dock = widgets_zone[first_zone][0]
284266
dock = self.docks[first_dock]
285-
self.addDockWidget(areas['left'], dock)
267+
self.addDockWidget(areas[side_of_window], dock)
286268

287269
for group in reversed(all_groups[1:]):
288270
digits = np.array([int(s[-1]) for s in group])
@@ -327,19 +309,7 @@ def create_main_layout(self):
327309
zone_name = widgets_zone[zone][0]
328310
self.splitDockWidget(self.docks[first_zone_name], self.docks[zone_name], orientations['horizontal'])
329311

330-
# make tabs
331-
for zone, view_names in widgets_zone.items():
332-
n = len(widgets_zone[zone])
333-
if n < 2:
334-
# no tab here
335-
continue
336-
view_name0 = widgets_zone[zone][0]
337-
for i in range(1, n):
338-
view_name = widgets_zone[zone][i]
339-
dock = self.docks[view_name]
340-
self.tabifyDockWidget(self.docks[view_name0], dock)
341-
# make visible the first of each zone
342-
self.docks[view_name0].raise_()
312+
343313

344314
# used by to tell the launcher this is closed
345315
def closeEvent(self, event):

0 commit comments

Comments
 (0)