Skip to content
Snippets Groups Projects

Resolve "Resize GUI Window"

Merged Jacob Wahlman requested to merge 87-resize-gui-window into develop
1 file
+ 9
13
Compare changes
  • Side-by-side
  • Inline
@@ -23,7 +23,7 @@ QStatusBar, QMenuBar, QLineEdit, QPushButton, QSlider, QScrollArea, QVBoxLayout,
QHBoxLayout, QDockWidget, QToolBar, QMenu, QLayout, QSizePolicy, QListWidget,\
QListWidgetItem, QGraphicsView, QGraphicsScene, QShortcut
from PyQt5.QtCore import Qt, QSize, QSize
from PyQt5.QtGui import QIcon, QFont, QPainter, QPen, QBrush, QKeySequence
from PyQt5.QtGui import QIcon, QFont, QPainter, QPen, QBrush, QKeySequence, QColor
MIN_WIDTH_SCENE = 600
@@ -62,27 +62,23 @@ class MainWindow(QMainWindow):
self.create_graphics_view()
def resizeEvent(self, event):
oldSize = event.oldSize()
if event.oldSize() == QSize(-1, -1):
oldSize = event.size()
newWidth = oldSize.width() * (oldSize.width() / event.size().width())
newHeight = oldSize.height() * (oldSize.height() / event.size().height())
self.graphic_view.setGeometry(250, 40, newWidth - 300, newHeight - 100)
self.ui.operation_box.setGeometry(10, 10, self.ui.operation_box.width(), self.height())
self.graphic_view.setGeometry(self.ui.operation_box.width() + 20, 0, self.width() - self.ui.operation_box.width() - 20, self.height())
super(MainWindow, self).resizeEvent(event)
def create_graphics_view(self):
self.scene = QGraphicsScene(self)
self.graphic_view = QGraphicsView(self.scene, self)
self.graphic_view.setRenderHint(QPainter.Antialiasing)
self.graphic_view.setGeometry(0, 0, self.width(), self.height())
self.graphic_view.setGeometry(self.ui.operation_box.width(), 0, self.width(), self.height())
self.graphic_view.setDragMode(QGraphicsView.ScrollHandDrag)
def wheelEvent(self, event):
old_zoom = self.zoom
self.zoom += event.angleDelta().y()/2500
self.graphic_view.scale(self.zoom, self.zoom)
self.zoom = old_zoom
if event.modifiers() == Qt.ControlModifier:
old_zoom = self.zoom
self.zoom += event.angleDelta().y()/2500
self.graphic_view.scale(self.zoom, self.zoom)
self.zoom = old_zoom
def exit_app(self, checked):
QApplication.quit()
Loading