diff --git a/pylablib/core/gui/widgets/layout_manager.py b/pylablib/core/gui/widgets/layout_manager.py index fb68c17..c5c7906 100644 --- a/pylablib/core/gui/widgets/layout_manager.py +++ b/pylablib/core/gui/widgets/layout_manager.py @@ -35,7 +35,7 @@ def _make_new_layout(self, kind, *args, **kwargs): raise ValueError("unrecognized layout kind: {}".format(kind)) def _set_main_layout(self): self.main_layout=self._make_new_layout(self.main_layout_kind,self) - name=getattr(self,"name") + name=getattr(self,"name",None) self.main_layout.setObjectName(name+"_main_layout" if name else "main_layout") if self.no_margins: self.main_layout.setContentsMargins(0,0,0,0) diff --git a/pylablib/core/utils/module.py b/pylablib/core/utils/module.py index c7ecf66..9e6ee02 100644 --- a/pylablib/core/utils/module.py +++ b/pylablib/core/utils/module.py @@ -173,7 +173,7 @@ def get_library_name(): return ".".join(module_name.split(".")[:-3]) -def pip_install(pkg, upgrade=True): +def pip_install(pkg, upgrade=False): """ Call ``pip install`` for a given package. @@ -188,7 +188,10 @@ def install_if_older(pkg, min_ver=""): """ Install `pkg` from the default PyPI repository if its version is lower that `min_ver` - If `min_ver` is ``None``, upgrade to the newest version regardless; if ``min_ver==""``, install only if no version is installed + If `min_ver` is ``None``, upgrade to the newest version regardless; if ``min_ver==""``, install only if no version is installed. + Return ``True`` if the package was installed. """ if get_package_version(pkg) is None or cmp_package_version(pkg,min_ver)=="<": - pip_install(pkg,upgrade=True) \ No newline at end of file + pip_install(pkg,upgrade=True) + return True + return False \ No newline at end of file diff --git a/pylablib/gui/widgets/plotters/image_plotter.py b/pylablib/gui/widgets/plotters/image_plotter.py index e232efd..72252c4 100644 --- a/pylablib/gui/widgets/plotters/image_plotter.py +++ b/pylablib/gui/widgets/plotters/image_plotter.py @@ -230,7 +230,6 @@ def setup(self, name=None, img_size=(1024,1024), min_size=None): self.setMinimumSize(QtCore.QSize(*min_size)) self.image_window=pyqtgraph.ImageView(self,imageItem=ImageItem()) self.add_to_layout(self.image_window) - self.main_layout.setStretch(0,4) self.set_colormap("hot_sat") self.image_window.ui.roiBtn.hide() self.image_window.ui.menuBtn.hide() @@ -248,16 +247,19 @@ def setup(self, name=None, img_size=(1024,1024), min_size=None): self.image_window.getView().addItem(self.hblines[1]) self.image_window.getView().addItem(self.vblines[0]) self.image_window.getView().addItem(self.vblines[1]) - self.cut_plot_window=pyqtgraph.PlotWidget(self) + self.cut_plot_panel=QLayoutManagedWidget(self) + self.add_to_layout(self.cut_plot_panel) + self.cut_plot_panel.setup(layout="vbox",no_margins=True) + self.cut_plot_window=pyqtgraph.PlotWidget(self.cut_plot_panel) + self.cut_plot_panel.add_to_layout(self.cut_plot_window) self.cut_plot_window.addLegend() self.cut_plot_window.setLabel("left","Image cut") self.cut_plot_window.showGrid(True,True,0.7) self.cut_lines=[PlotCurveItem(pen="#B0B000",name="Horizontal"), PlotCurveItem(pen="#B000B0",name="Vertical")] for c in self.cut_lines: self.cut_plot_window.addItem(c) - self.add_to_layout(self.cut_plot_window) - self.main_layout.setStretch(1,1) - self.cut_plot_window.setVisible(False) + self.cut_plot_panel.setVisible(False) + self.set_row_stretch([4,1]) self.vline.sigPositionChanged.connect(lambda: self.update_image_controls(),QtCore.Qt.DirectConnection) self.hline.sigPositionChanged.connect(lambda :self.update_image_controls(),QtCore.Qt.DirectConnection) self.image_window.getHistogramWidget().sigLevelsChanged.connect(lambda: self.update_image_controls(levels=self.image_window.getHistogramWidget().getLevels()),QtCore.Qt.DirectConnection) @@ -580,9 +582,9 @@ def update_image(self, update_controls=False, do_redraw=False, only_new_image=Tr self._last_img_paint_cnt=[cl.paint_cnt for cl in self.cut_lines] if any(autorange): self.cut_plot_window.enableAutoRange(x=autorange[0],y=autorange[1]) - self.cut_plot_window.setVisible(True) + self.cut_plot_panel.setVisible(True) else: - self.cut_plot_window.setVisible(False) + self.cut_plot_panel.setVisible(False) self.update_rectangles() self._last_paint_time=time.time() return values