Skip to content

Commit

Permalink
GUI refinement on data table
Browse files Browse the repository at this point in the history
  • Loading branch information
zhe-slac committed Jan 28, 2025
1 parent 3b8b645 commit b026cd6
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 12 deletions.
38 changes: 28 additions & 10 deletions src/badger/gui/acr/pages/home_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
QSplitter,
QVBoxLayout,
QWidget,
QLabel,
)

from badger.archive import (
Expand Down Expand Up @@ -92,7 +93,7 @@ def init_ui(self):

# History run browser
self.history_browser = history_browser = HistoryNavigator()
history_browser.setMinimumWidth(360)
history_browser.setFixedWidth(360)

# Splitter
splitter = QSplitter(Qt.Horizontal)
Expand All @@ -115,8 +116,21 @@ def init_ui(self):
vbox_run_view.addWidget(run_monitor)

# Data table
panel_table = QWidget()
panel_table.setMinimumHeight(180)
vbox_table = QVBoxLayout(panel_table)
vbox_table.setContentsMargins(0, 0, 0, 0)
title_label = QLabel("Run Data")
title_label.setStyleSheet("""
background-color: #455364;
font-weight: bold;
padding: 4px;
""")
title_label.setAlignment(Qt.AlignCenter) # Center-align the title
vbox_table.addWidget(title_label, 0)
self.run_table = run_table = data_table()
run_table.set_uneditable() # should not be editable
vbox_table.addWidget(run_table, 1)

# Routine view
self.routine_view = routine_view = QWidget() # for consistent bg
Expand All @@ -138,12 +152,16 @@ def init_ui(self):
splitter_run = QSplitter(Qt.Horizontal)
splitter_run.setStretchFactor(0, 1)
splitter_run.setStretchFactor(1, 1)
splitter_run.setStretchFactor(2, 0)
vbox_run.addWidget(splitter_run, 1)

splitter_data = QSplitter(Qt.Vertical)
splitter_data.setStretchFactor(0, 1)
splitter_data.setStretchFactor(1, 0)
splitter_data.addWidget(panel_monitor)
splitter_data.addWidget(panel_table)

splitter_run.addWidget(routine_view)
splitter_run.addWidget(panel_monitor)
splitter_run.addWidget(run_table)
splitter_run.addWidget(splitter_data)

vbox_run.addWidget(run_action_bar, 0)

Expand All @@ -152,12 +170,9 @@ def init_ui(self):
splitter.addWidget(panel_run)

# Set initial sizes (left fixed, middle and right equal)
total_width = 1640 # Total width of the splitter
fixed_width = 360 # Fixed width for the left panel
remaining_width = total_width - fixed_width
equal_width = remaining_width // 2
splitter.setSizes([fixed_width, remaining_width])
splitter_run.setSizes([equal_width, equal_width, 0])
splitter.setSizes([1, 1])
splitter_run.setSizes([1, 1])
splitter_data.setSizes([800, 180])

self.status_bar = status_bar = BadgerStatusBar()
status_bar.set_summary("Badger is ready!")
Expand Down Expand Up @@ -300,6 +315,9 @@ def table_selection_changed(self):

return

if row == -1:
return

self.run_monitor.jump_to_solution(row)

def toggle_lock(self, lock, lock_tab=1):
Expand Down
2 changes: 1 addition & 1 deletion src/badger/gui/acr/windows/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def init_ui(self) -> None:
if os.getenv("DEMO"):
self.resize(1280, 720)
else:
self.resize(1640, 800)
self.resize(1720, 960)
self.center()

# Add menu bar
Expand Down
15 changes: 14 additions & 1 deletion src/badger/gui/default/components/data_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@
}
"""

stylesheet_data = """
QTableWidget
{
margin: 0px 8px 8px 8px;
alternate-background-color: #262E38;
}
QTableWidget::item::selected
{
background-color: #B3E5FC;
color: #000000;
}
"""


# https://stackoverflow.com/questions/60715462/how-to-copy-and-paste-multiple-cells-in-qtablewidget-in-pyqt5
class TableWithCopy(QTableWidget):
Expand Down Expand Up @@ -103,7 +116,7 @@ def add_row(table, row):
def data_table(data=None):
table = TableWithCopy()
table.setAlternatingRowColors(True)
table.setStyleSheet(stylesheet)
table.setStyleSheet(stylesheet_data)
# table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
return update_table(table, data)

Expand Down

0 comments on commit b026cd6

Please sign in to comment.