Skip to content

Commit

Permalink
Merge pull request Xi-CAM#44 from danielballan/use-splitters
Browse files Browse the repository at this point in the history
Use Splitter to make layout interactively configurable.
  • Loading branch information
awalter-bnl authored Jun 27, 2019
2 parents fc135b9 + 97906ad commit 453d08f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
15 changes: 7 additions & 8 deletions bluesky_browser/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import time
from . import __version__

from qtpy.QtCore import QDateTime
from qtpy.QtCore import QDateTime, Qt
from qtpy.QtWidgets import (
QApplication,
QWidget,
QMainWindow,
QHBoxLayout,
QVBoxLayout)
QSplitter)
from .search import SearchWidget, SearchState
from .summary import SummaryWidget
from .viewer.viewer import Viewer
Expand All @@ -39,18 +39,17 @@ def __init__(self, *args,
self.search_widget = SearchWidget()
self.summary_widget = SummaryWidget()

left_pane = QVBoxLayout()
left_pane = QSplitter(Qt.Vertical)
left_pane.addWidget(self.search_widget)
left_pane.addWidget(self.summary_widget)

right_pane = QVBoxLayout()
self.viewer = Viewer(menuBar=menuBar)

right_pane.addWidget(self.viewer)

layout = QHBoxLayout()
layout.addLayout(left_pane)
layout.addLayout(right_pane)
splitter = QSplitter(Qt.Horizontal)
layout.addWidget(splitter)
splitter.addWidget(left_pane)
splitter.addWidget(self.viewer)
self.setLayout(layout)

def show_double_clicked_entry(index):
Expand Down
6 changes: 4 additions & 2 deletions bluesky_browser/viewer/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ def subfactory(self, name, descriptor_doc):
# incorrect info into descriptors. We try to detect and correct
# that here.
if ndim == 2:
image_keys[key] = data_key['shape']
shape = data_key['shape']
image_keys[key] = shape
elif ndim == 3:
# ophyd <1.4.0 gives (x, y, z) where z is 0
# Maybe the better way to detect this is start['version']['ophyd'].
Expand All @@ -107,7 +108,8 @@ def subfactory(self, name, descriptor_doc):
"from %r to %r", key, data_key['shape'], shape)
else:
# Assume we are getting correct metadata.
image_keys[key] = data_key['shape'][1:] # Stash (y, x) shape alone.
shape = data_key['shape'][1:] # Stash (y, x) shape alone.
image_keys[key] = shape
else:
continue
log.debug('%s has %d-dimensional image of shape %r',
Expand Down
13 changes: 9 additions & 4 deletions bluesky_browser/viewer/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@

from event_model import RunRouter, Filler
from intake_bluesky.core import parse_handler_registry
from qtpy.QtCore import Signal, QThread
from qtpy.QtCore import Signal, Qt, QThread
from qtpy.QtWidgets import (
QAction,
QActionGroup,
QInputDialog,
QSplitter,
QVBoxLayout,
)
from traitlets.traitlets import List, Dict, DottedObjectName
from traitlets.traitlets import List, Dict, DottedObjectName, Integer

from .header_tree import HeaderTreeFactory
from .baseline import BaselineFactory
Expand All @@ -33,6 +34,7 @@ class Viewer(ConfigurableMoveableTabContainer):
Contains multiple TabbedViewingAreas
"""
tab_titles = Signal([tuple])
num_viewing_areas = Integer(2, config=True)

def __init__(self, *args, menuBar, **kwargs):
super().__init__(*args, **kwargs)
Expand All @@ -45,10 +47,13 @@ def __init__(self, *args, menuBar, **kwargs):

self._live_run_router = RunRouter([self.route_live_stream])

self._containers = [TabbedViewingArea(self, menuBar=menuBar) for _ in range(2)]
self._containers = [TabbedViewingArea(self, menuBar=menuBar) for _ in
range(self.num_viewing_areas)]
layout = QVBoxLayout()
splitter = QSplitter(Qt.Vertical)
layout.addWidget(splitter)
for container in self._containers:
layout.addWidget(container)
splitter.addWidget(container)
self.setLayout(layout)

overplot_group = QActionGroup(self)
Expand Down

0 comments on commit 453d08f

Please sign in to comment.