Just always use a lambda ; it's innocuous
							parent
							
								
									b6c68e381d
								
							
						
					
					
						commit
						318f3b45c5
					
				|  | @ -412,9 +412,14 @@ class LinkedSplits(QWidget): | ||||||
|             self.xaxis.hide() |             self.xaxis.hide() | ||||||
|             self.xaxis = xaxis |             self.xaxis = xaxis | ||||||
| 
 | 
 | ||||||
|         if sidepane: |         class LambdaQFrame(QFrame): | ||||||
|  |             '''One-off ``QFrame`` which composes a layout | ||||||
|  |             of a chart + sidepane ``FieldsForm`` (if provided). | ||||||
| 
 | 
 | ||||||
|             class ChartandPane(QFrame): |             ''' | ||||||
|  |             sidepane: FieldsForm | ||||||
|  |             hbox: QtGui.QHBoxLayout | ||||||
|  |             chart: Optional['ChartPlotWidget'] = None | ||||||
| 
 | 
 | ||||||
|             def __init__( |             def __init__( | ||||||
|                 self, |                 self, | ||||||
|  | @ -424,40 +429,14 @@ class LinkedSplits(QWidget): | ||||||
| 
 | 
 | ||||||
|                 super().__init__(parent) |                 super().__init__(parent) | ||||||
| 
 | 
 | ||||||
|                     # self.chart = cpw |  | ||||||
|                 self.sidepane = sidepane |                 self.sidepane = sidepane | ||||||
|                     # cpw.chart_and_pane = self |  | ||||||
|                     # self.setStyleSheet( |  | ||||||
|                     #     f"""QFrame {{ |  | ||||||
|                     #         color : {hcolor('default_darkest')}; |  | ||||||
|                     #         background-color : {hcolor('default_darkest')}; |  | ||||||
|                     #     }} |  | ||||||
|                     #     """ |  | ||||||
|                     # ) |  | ||||||
| 
 | 
 | ||||||
|                 hbox = self.hbox = QtGui.QHBoxLayout(self) |                 hbox = self.hbox = QtGui.QHBoxLayout(self) | ||||||
|                 hbox.setAlignment(Qt.AlignTop | Qt.AlignLeft) |                 hbox.setAlignment(Qt.AlignTop | Qt.AlignLeft) | ||||||
|                 hbox.setContentsMargins(0, 0, 0, 0) |                 hbox.setContentsMargins(0, 0, 0, 0) | ||||||
|                 hbox.setSpacing(3) |                 hbox.setSpacing(3) | ||||||
| 
 | 
 | ||||||
|                 def sizeHint(self) -> QtCore.QSize: |         qframe = LambdaQFrame(self.splitter) | ||||||
|                     return self.chart.sizeHint() + sidepane.sizeHint() |  | ||||||
| 
 |  | ||||||
|             paned_chart = ChartandPane(parent=self.splitter) |  | ||||||
| 
 |  | ||||||
|         #     splitter_widget = QWidget(self) |  | ||||||
|         #     splitter_widget.setSizePolicy( |  | ||||||
|         #         QSizePolicy.Expanding, |  | ||||||
|         #         QSizePolicy.Expanding, |  | ||||||
|         #     ) |  | ||||||
| 
 |  | ||||||
|         #     hbox = QtGui.QHBoxLayout(splitter_widget) |  | ||||||
|         #     hbox.setAlignment(Qt.AlignTop | Qt.AlignRight) |  | ||||||
|         #     hbox.setContentsMargins(0, 0, 0, 0) |  | ||||||
|         #     hbox.setSpacing(3) |  | ||||||
| 
 |  | ||||||
|         # else: |  | ||||||
|         #     splitter_widget = cpw |  | ||||||
| 
 | 
 | ||||||
|         cpw = ChartPlotWidget( |         cpw = ChartPlotWidget( | ||||||
| 
 | 
 | ||||||
|  | @ -467,8 +446,7 @@ class LinkedSplits(QWidget): | ||||||
|             data_key=array_key or name, |             data_key=array_key or name, | ||||||
| 
 | 
 | ||||||
|             array=array, |             array=array, | ||||||
|             # parent=self.splitter, |             parent=qframe, | ||||||
|             parent=paned_chart if sidepane else self.splitter, |  | ||||||
|             linkedsplits=self, |             linkedsplits=self, | ||||||
|             axisItems={ |             axisItems={ | ||||||
|                 'bottom': xaxis, |                 'bottom': xaxis, | ||||||
|  | @ -479,26 +457,17 @@ class LinkedSplits(QWidget): | ||||||
|             **cpw_kwargs, |             **cpw_kwargs, | ||||||
|         ) |         ) | ||||||
| 
 | 
 | ||||||
|  |         qframe.chart = cpw | ||||||
|  |         qframe.hbox.addWidget(cpw) | ||||||
|  | 
 | ||||||
|  |         # add sidepane **after** chart; place it on axis side | ||||||
|         if sidepane: |         if sidepane: | ||||||
|             paned_chart.chart = cpw |             qframe.hbox.addWidget( | ||||||
|             paned_chart.hbox.addWidget(cpw) |  | ||||||
|             # hbox.addWidget(cpw) |  | ||||||
|             paned_chart.hbox.addWidget( |  | ||||||
|                 sidepane, |                 sidepane, | ||||||
|                 alignment=Qt.AlignTop |                 alignment=Qt.AlignTop | ||||||
|             ) |             ) | ||||||
|             cpw.sidepane = sidepane |             cpw.sidepane = sidepane | ||||||
| 
 | 
 | ||||||
|         # splitter_widget.setMinimumHeight(cpw.height()) |  | ||||||
|         # splitter_widget.setMinimumWidth(cpw.width()) |  | ||||||
|         # splitter_widget.show() |  | ||||||
| 
 |  | ||||||
|         # hbox.addWidget(cpw) |  | ||||||
|         # hbox.addWidget(sidepane) |  | ||||||
| 
 |  | ||||||
|         # cpw.sidepane = sidepane |  | ||||||
|         # cpw.hbox = hbox |  | ||||||
| 
 |  | ||||||
|         # give viewbox as reference to chart |         # give viewbox as reference to chart | ||||||
|         # allowing for kb controls and interactions on **this** widget |         # allowing for kb controls and interactions on **this** widget | ||||||
|         # (see our custom view mode in `._interactions.py`) |         # (see our custom view mode in `._interactions.py`) | ||||||
|  | @ -534,8 +503,11 @@ class LinkedSplits(QWidget): | ||||||
|             # track by name |             # track by name | ||||||
|             self.subplots[name] = cpw |             self.subplots[name] = cpw | ||||||
| 
 | 
 | ||||||
|  |             if sidepane: | ||||||
|  |                 # TODO: use a "panes" collection to manage this? | ||||||
|                 sidepane.setMinimumWidth(self.chart.sidepane.width()) |                 sidepane.setMinimumWidth(self.chart.sidepane.width()) | ||||||
|             self.splitter.addWidget(paned_chart if sidepane else cpw) | 
 | ||||||
|  |             self.splitter.addWidget(qframe) | ||||||
| 
 | 
 | ||||||
|             # scale split regions |             # scale split regions | ||||||
|             self.set_split_sizes() |             self.set_split_sizes() | ||||||
|  | @ -683,8 +655,6 @@ class ChartPlotWidget(pg.PlotWidget): | ||||||
|         a = self._arrays['ohlc'] |         a = self._arrays['ohlc'] | ||||||
|         lbar = max(l, a[0]['index']) |         lbar = max(l, a[0]['index']) | ||||||
|         rbar = min(r, a[-1]['index']) |         rbar = min(r, a[-1]['index']) | ||||||
|         # lbar = max(l, 0) |  | ||||||
|         # rbar = min(r, len(self._arrays['ohlc'])) |  | ||||||
|         return l, lbar, rbar, r |         return l, lbar, rbar, r | ||||||
| 
 | 
 | ||||||
|     def default_view( |     def default_view( | ||||||
|  | @ -789,6 +759,7 @@ class ChartPlotWidget(pg.PlotWidget): | ||||||
|         pdi_kwargs.update(_pdi_defaults) |         pdi_kwargs.update(_pdi_defaults) | ||||||
| 
 | 
 | ||||||
|         data_key = array_key or name |         data_key = array_key or name | ||||||
|  | 
 | ||||||
|         # curve = pg.PlotDataItem( |         # curve = pg.PlotDataItem( | ||||||
|         # curve = pg.PlotCurveItem( |         # curve = pg.PlotCurveItem( | ||||||
|         curve = FastAppendCurve( |         curve = FastAppendCurve( | ||||||
|  | @ -824,7 +795,7 @@ class ChartPlotWidget(pg.PlotWidget): | ||||||
| 
 | 
 | ||||||
|         # register curve graphics and backing array for name |         # register curve graphics and backing array for name | ||||||
|         self._graphics[name] = curve |         self._graphics[name] = curve | ||||||
|         self._arrays[name] = data |         self._arrays[data_key or name] = data | ||||||
| 
 | 
 | ||||||
|         if overlay: |         if overlay: | ||||||
|             anchor_at = ('bottom', 'left') |             anchor_at = ('bottom', 'left') | ||||||
|  | @ -843,7 +814,7 @@ class ChartPlotWidget(pg.PlotWidget): | ||||||
|             if add_label: |             if add_label: | ||||||
|                 self.linked.cursor.contents_labels.add_label( |                 self.linked.cursor.contents_labels.add_label( | ||||||
|                     self, |                     self, | ||||||
|                     name, |                     data_key or name, | ||||||
|                     anchor_at=anchor_at |                     anchor_at=anchor_at | ||||||
|                 ) |                 ) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue