Skip to content

Commit

Permalink
GUI layout bugfixes, minor module utils update
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexShkarin committed Sep 25, 2021
1 parent 4ca0933 commit 8850ba6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pylablib/core/gui/widgets/layout_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions pylablib/core/utils/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
pip_install(pkg,upgrade=True)
return True
return False
16 changes: 9 additions & 7 deletions pylablib/gui/widgets/plotters/image_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8850ba6

Please sign in to comment.