Skip to content
Snippets Groups Projects

Add status bar to SFG GUI

Merged Oscar Gustafsson requested to merge sfgguistatusbar into master
1 file
+ 20
0
Compare changes
  • Side-by-side
  • Inline
+ 20
0
@@ -27,6 +27,7 @@ from qtpy.QtWidgets import (
@@ -27,6 +27,7 @@ from qtpy.QtWidgets import (
QListWidgetItem,
QListWidgetItem,
QMainWindow,
QMainWindow,
QShortcut,
QShortcut,
 
QStatusBar,
)
)
import b_asic.core_operations
import b_asic.core_operations
@@ -107,6 +108,10 @@ class SFGMainWindow(QMainWindow):
@@ -107,6 +108,10 @@ class SFGMainWindow(QMainWindow):
get_icon('close'), "Clear workspace", self._clear_workspace
get_icon('close'), "Clear workspace", self._clear_workspace
)
)
 
# Create status bar
 
self._statusbar = QStatusBar(self)
 
self.setStatusBar(self._statusbar)
 
# Add operations
# Add operations
self._max_recent_files = 4
self._max_recent_files = 4
self._recent_files_actions: List[QAction] = []
self._recent_files_actions: List[QAction] = []
@@ -275,6 +280,7 @@ class SFGMainWindow(QMainWindow):
@@ -275,6 +280,7 @@ class SFGMainWindow(QMainWindow):
sfg.name = name
sfg.name = name
self._load_sfg(sfg, positions)
self._load_sfg(sfg, positions)
self._logger.info("Loaded SFG from path: " + str(module))
self._logger.info("Loaded SFG from path: " + str(module))
 
self.update_statusbar(f"Loaded SFG from {module}")
def _load_sfg(self, sfg: SFG, positions=None) -> None:
def _load_sfg(self, sfg: SFG, positions=None) -> None:
if positions is None:
if positions is None:
@@ -374,6 +380,17 @@ class SFGMainWindow(QMainWindow):
@@ -374,6 +380,17 @@ class SFGMainWindow(QMainWindow):
self._logger.info("Exiting the application.")
self._logger.info("Exiting the application.")
QApplication.quit()
QApplication.quit()
 
def update_statusbar(self, msg: str) -> None:
 
"""
 
Write *msg* to the statusbar with temporarily policy.
 
 
Parameters
 
----------
 
msg : str
 
The message to write.
 
"""
 
self._statusbar.showMessage(msg)
 
def _clear_workspace(self) -> None:
def _clear_workspace(self) -> None:
self._logger.info("Clearing workspace from operations and SFGs.")
self._logger.info("Clearing workspace from operations and SFGs.")
self._pressed_operations.clear()
self._pressed_operations.clear()
@@ -385,6 +402,7 @@ class SFGMainWindow(QMainWindow):
@@ -385,6 +402,7 @@ class SFGMainWindow(QMainWindow):
self._sfg_dict.clear()
self._sfg_dict.clear()
self._scene.clear()
self._scene.clear()
self._logger.info("Workspace cleared.")
self._logger.info("Workspace cleared.")
 
self.update_statusbar("Workspace cleared.")
def create_sfg_from_toolbar(self) -> None:
def create_sfg_from_toolbar(self) -> None:
inputs = []
inputs = []
@@ -409,6 +427,7 @@ class SFGMainWindow(QMainWindow):
@@ -409,6 +427,7 @@ class SFGMainWindow(QMainWindow):
sfg = SFG(inputs=inputs, outputs=outputs, name=name)
sfg = SFG(inputs=inputs, outputs=outputs, name=name)
self._logger.info("Created SFG with name: %s from selected operations." % name)
self._logger.info("Created SFG with name: %s from selected operations." % name)
 
self.update_statusbar(f"Created SFG: {name}")
def check_equality(signal: Signal, signal_2: Signal) -> bool:
def check_equality(signal: Signal, signal_2: Signal) -> bool:
source_operation = cast(Operation, signal.source_operation)
source_operation = cast(Operation, signal.source_operation)
@@ -643,6 +662,7 @@ class SFGMainWindow(QMainWindow):
@@ -643,6 +662,7 @@ class SFGMainWindow(QMainWindow):
try:
try:
attr_operation = self._operations_from_name[item.text()]()
attr_operation = self._operations_from_name[item.text()]()
self.add_operation(attr_operation)
self.add_operation(attr_operation)
 
self.update_statusbar(f"{item.text()} added.")
except Exception as e:
except Exception as e:
self._logger.error(
self._logger.error(
"Unexpected error occurred while creating operation: " + str(e)
"Unexpected error occurred while creating operation: " + str(e)
Loading