Skip to content
Snippets Groups Projects

Error handling in GUI

Merged Jacob Wahlman requested to merge 83-error-handling-in-gui into develop
2 unresolved threads
3 files
+ 32
9
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 10
8
@@ -3,23 +3,25 @@ Drag button class.
@@ -3,23 +3,25 @@ Drag button class.
This class creates a dragbutton which can be clicked, dragged and dropped.
This class creates a dragbutton which can be clicked, dragged and dropped.
"""
"""
import os.path
import os.path
from PyQt5.QtWidgets import QPushButton
from PyQt5.QtWidgets import QPushButton
from PyQt5.QtCore import Qt, QSize
from PyQt5.QtCore import Qt, QSize
from PyQt5.QtGui import QIcon
from PyQt5.QtGui import QIcon
 
from utils import decorate_class, handle_error
 
 
@decorate_class(handle_error)
class DragButton(QPushButton):
class DragButton(QPushButton):
def __init__(self, name, operation, operation_path_name, window, parent = None):
def __init__(self, name, operation, operation_path_name, window, parent = None):
self.name = name
self.name = name
self.__window = window
self._window = window
self.operation = operation
self.operation = operation
self.operation_path_name = operation_path_name
self.operation_path_name = operation_path_name
self.clicked = 0
self.clicked = 0
self.pressed = False
self.pressed = False
super(DragButton, self).__init__(self.__window)
super(DragButton, self).__init__(self._window)
def mousePressEvent(self, event):
def mousePressEvent(self, event):
self._mouse_press_pos = None
self._mouse_press_pos = None
@@ -29,7 +31,7 @@ class DragButton(QPushButton):
@@ -29,7 +31,7 @@ class DragButton(QPushButton):
self._mouse_press_pos = event.globalPos()
self._mouse_press_pos = event.globalPos()
self._mouse_move_pos = event.globalPos()
self._mouse_move_pos = event.globalPos()
for signal in self.__window.signalList:
for signal in self._window.signalList:
signal.update()
signal.update()
self.clicked += 1
self.clicked += 1
@@ -40,7 +42,7 @@ class DragButton(QPushButton):
@@ -40,7 +42,7 @@ class DragButton(QPushButton):
path_to_image = os.path.join('operation_icons', self.operation_path_name + '_grey.png')
path_to_image = os.path.join('operation_icons', self.operation_path_name + '_grey.png')
self.setIcon(QIcon(path_to_image))
self.setIcon(QIcon(path_to_image))
self.setIconSize(QSize(50, 50))
self.setIconSize(QSize(50, 50))
self.__window.pressed_button.append(self)
self._window.pressed_button.append(self)
elif self.clicked == 2:
elif self.clicked == 2:
self.clicked = 0
self.clicked = 0
@@ -50,7 +52,7 @@ class DragButton(QPushButton):
@@ -50,7 +52,7 @@ class DragButton(QPushButton):
path_to_image = os.path.join('operation_icons', self.operation_path_name + '.png')
path_to_image = os.path.join('operation_icons', self.operation_path_name + '.png')
self.setIcon(QIcon(path_to_image))
self.setIcon(QIcon(path_to_image))
self.setIconSize(QSize(50, 50))
self.setIconSize(QSize(50, 50))
self.__window.pressed_button.remove(self)
self._window.pressed_button.remove(self)
super(DragButton, self).mousePressEvent(event)
super(DragButton, self).mousePressEvent(event)
@@ -63,8 +65,8 @@ class DragButton(QPushButton):
@@ -63,8 +65,8 @@ class DragButton(QPushButton):
self.move(new_pos)
self.move(new_pos)
self._mouse_move_pos = global_pos
self._mouse_move_pos = global_pos
self.__window.update()
self._window.update()
super(DragButton, self).mouseMoveEvent(event)
super(DragButton, self).mouseMoveEvent(event)
def mouseReleaseEvent(self, event):
def mouseReleaseEvent(self, event):
Loading