Reimplemented functional statusbar.

This commit is contained in:
Nicole Rappe 2025-02-25 23:11:03 -07:00
parent 1cab85ac87
commit 0c0c31db35

View File

@ -48,8 +48,6 @@ try:
PipeItem.paint = _custom_paint_pipe
NodeItem.paint = _custom_paint_node
print("Patched PipeItem.paint and NodeItem.paint to override colors.")
except ImportError as e:
print(f"WARNING: Could not patch PipeItem or NodeItem: {e}")
except Exception as e:
@ -261,7 +259,7 @@ if __name__ == "__main__":
# SECTION: Enhanced Graph Wrapper for QMainWindow
# This section wraps the NodeGraph widget in a QMainWindow with:
# - A menu bar at the top (named "Workflows" menu)
# - A blank status bar at the bottom
# - A status bar at the bottom
# - A central QSplitter dividing the window horizontally:
# * Left side (2/3): the NodeGraph widget
# * Right side (1/3): an empty text box for future use
@ -297,6 +295,45 @@ if __name__ == "__main__":
# Create and set a blank status bar at the bottom.
main_window.setStatusBar(QtWidgets.QStatusBar())
# ---------------------------------------------------------------------
# SECTION: Status Bar Enhancement - Dynamic Status Display
# Add a QLabel to the status bar that shows:
# - The number of nodes in the graph.
# - A fixed update rate (500ms).
# - A clickable hyperlink to the Flask API server.
status_bar = main_window.statusBar()
status_label = QtWidgets.QLabel()
status_label.setTextFormat(QtCore.Qt.RichText) # Enable rich text for clickable links.
status_label.setStyleSheet("color: white;") # Set default text color to white.
status_label.setOpenExternalLinks(True) # Allow hyperlinks to be clickable.
status_bar.setSizeGripEnabled(False) # Disable resizing via the size grip.
status_bar.addWidget(status_label)
status_bar.setStyleSheet("""
QStatusBar::item {
border: none; /* remove the line around items */
}
""")
def update_status():
node_count = len(graph.all_nodes())
api_link = (
'<a href="http://127.0.0.1:5000/data" '
'style="color: rgb(60, 120, 180); text-decoration: none;">'
'http://127.0.0.1:5000/data</a>'
)
status_label.setText(
f'Nodes: {node_count} | Update Rate: 500ms | Flask API Server: {api_link}'
)
# Create the timer, pass the main_window as parent, and store the reference.
status_timer = QtCore.QTimer(main_window)
status_timer.timeout.connect(update_status)
status_timer.start(500)
main_window._status_timer = status_timer # Keep a reference so it's not GCed
# ---------------------------------------------------------------------
# Create a QSplitter for horizontal division.
splitter = QtWidgets.QSplitter(QtCore.Qt.Horizontal)
@ -311,6 +348,14 @@ if __name__ == "__main__":
splitter.setStretchFactor(0, 2)
splitter.setStretchFactor(1, 1)
# Reduce the Size of the Splitter Handle
splitter.setHandleWidth(1)
splitter.setStyleSheet("""
QSplitter::handle {
background: none;
}
""")
# Set the splitter as the central widget of the main window.
main_window.setCentralWidget(splitter)