Skip to content

Commit

Permalink
Fixes for render_widget='scene' in Qt back end
Browse files Browse the repository at this point in the history
  • Loading branch information
ejeschke committed Feb 25, 2024
1 parent 843f428 commit ba4bad3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ginga/qtw/ImageViewQt.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def drawBackground(self, painter, rect):
if pixmap is None:
return
x1, y1, x2, y2 = rect.getCoords()
x1, y1, x2, y2 = int(x1), int(y1), int(x2), int(y2)
width = x2 - x1 + 1
height = y2 - y1 + 1

Expand All @@ -63,6 +64,7 @@ def drawBackground(self, painter, rect):
def resizeEvent(self, event):
rect = self.geometry()
x1, y1, x2, y2 = rect.getCoords()
x1, y1, x2, y2 = int(x1), int(y1), int(x2), int(y2)
width = x2 - x1 + 1
height = y2 - y1 + 1

Expand Down Expand Up @@ -174,6 +176,8 @@ def __init__(self, logger=None, rgbmap=None, settings=None, render=None):
elif self.wtype == 'scene':
self.scene = QtGui.QGraphicsScene()
self.imgwin = RenderGraphicsView(self.scene)
self.imgwin.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.imgwin.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
elif self.wtype == 'opengl':
if not have_opengl:
raise ImageViewQtError("Please install 'pyopengl' to use render: '%s'" % (render))
Expand Down Expand Up @@ -221,9 +225,8 @@ def configure_window(self, width, height):
# See http://stackoverflow.com/questions/3513788/qt-qgraphicsview-without-scrollbar
width, height = width - 2, height - 2
self.scene.setSceneRect(1, 1, width - 2, height - 2)

# tell renderer about our new size
#self.renderer.resize((width, height))
self.imgwin.fitInView(self.scene.sceneRect(),
QtCore.Qt.IgnoreAspectRatio)

if self.wtype == 'opengl':
pass
Expand Down
5 changes: 5 additions & 0 deletions ginga/qtw/Widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ def focus(self):
# self.widget.raise_()

def resize(self, width, height):
_wd, _ht = self.get_size()
if width < 0:
width = _wd
if height < 0:
height = _ht
self.widget.resize(int(width), int(height))

def show(self):
Expand Down

0 comments on commit ba4bad3

Please sign in to comment.