Skip to content
Snippets Groups Projects
Commit 39ff67c3 authored by Jacob Wahlman's avatar Jacob Wahlman :ok_hand:
Browse files

fixed smaller things

parent be118f72
Branches
No related tags found
1 merge request!46Resolve "Resize GUI Window"
Pipeline #14935 passed
...@@ -23,7 +23,7 @@ QStatusBar, QMenuBar, QLineEdit, QPushButton, QSlider, QScrollArea, QVBoxLayout, ...@@ -23,7 +23,7 @@ QStatusBar, QMenuBar, QLineEdit, QPushButton, QSlider, QScrollArea, QVBoxLayout,
QHBoxLayout, QDockWidget, QToolBar, QMenu, QLayout, QSizePolicy, QListWidget,\ QHBoxLayout, QDockWidget, QToolBar, QMenu, QLayout, QSizePolicy, QListWidget,\
QListWidgetItem, QGraphicsView, QGraphicsScene, QShortcut QListWidgetItem, QGraphicsView, QGraphicsScene, QShortcut
from PyQt5.QtCore import Qt, QSize, QSize 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 MIN_WIDTH_SCENE = 600
...@@ -62,27 +62,23 @@ class MainWindow(QMainWindow): ...@@ -62,27 +62,23 @@ class MainWindow(QMainWindow):
self.create_graphics_view() self.create_graphics_view()
def resizeEvent(self, event): def resizeEvent(self, event):
oldSize = event.oldSize() self.ui.operation_box.setGeometry(10, 10, self.ui.operation_box.width(), self.height())
if event.oldSize() == QSize(-1, -1): self.graphic_view.setGeometry(self.ui.operation_box.width() + 20, 0, self.width() - self.ui.operation_box.width() - 20, self.height())
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)
super(MainWindow, self).resizeEvent(event) super(MainWindow, self).resizeEvent(event)
def create_graphics_view(self): def create_graphics_view(self):
self.scene = QGraphicsScene(self) self.scene = QGraphicsScene(self)
self.graphic_view = QGraphicsView(self.scene, self) self.graphic_view = QGraphicsView(self.scene, self)
self.graphic_view.setRenderHint(QPainter.Antialiasing) 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) self.graphic_view.setDragMode(QGraphicsView.ScrollHandDrag)
def wheelEvent(self, event): def wheelEvent(self, event):
old_zoom = self.zoom if event.modifiers() == Qt.ControlModifier:
self.zoom += event.angleDelta().y()/2500 old_zoom = self.zoom
self.graphic_view.scale(self.zoom, self.zoom) self.zoom += event.angleDelta().y()/2500
self.zoom = old_zoom self.graphic_view.scale(self.zoom, self.zoom)
self.zoom = old_zoom
def exit_app(self, checked): def exit_app(self, checked):
QApplication.quit() QApplication.quit()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment