Skip to content

Commit 614dffb

Browse files
authored
Merge pull request #118 from labscript-suite/pyside6
PySide6 compatibility
2 parents 4965d40 + d951f9b commit 614dffb

3 files changed

Lines changed: 32 additions & 65 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ dependencies = [
3232
"labscript>=3.0.0",
3333
"labscript_utils>=3.3.0",
3434
"pandas>=0.13",
35-
"qtutils>=2.2.2",
35+
"qtutils>=4.0",
3636
"matplotlib",
3737
]
3838
dynamic = ["version"]

runmanager/__main__.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def tabLayoutChange(self):
204204
if total_height > self.parent().height():
205205
# Don't paint over the top of the scroll buttons:
206206
scroll_buttons_area_height = 2*max(self.style().pixelMetric(QtWidgets.QStyle.PM_TabBarScrollButtonWidth),
207-
qapplication.globalStrut().width())
207+
self.style().pixelMetric(QtWidgets.QStyle.PM_LayoutHorizontalSpacing))
208208
self.paint_clip = self.width(), self.parent().height() - scroll_buttons_area_height
209209
else:
210210
self.paint_clip = None
@@ -240,8 +240,9 @@ def paintEvent(self, event):
240240

241241
def tabSizeHint(self, index):
242242
fontmetrics = QtGui.QFontMetrics(self.font())
243-
text_width = fontmetrics.width(self.tabText(index))
244-
text_height = fontmetrics.height()
243+
text_size = fontmetrics.size(QtCore.Qt.TextSingleLine, self.tabText(index))
244+
text_width = text_size.width()
245+
text_height = text_size.height()
245246
height = text_height + 15
246247
height = max(self.minheight, height)
247248
width = text_width + 15
@@ -366,7 +367,7 @@ def __init__(self, *args):
366367
p.setColor(
367368
group,
368369
QtGui.QPalette.HighlightedText,
369-
p.color(QtGui.QPalette.Active, QtGui.QPalette.Foreground)
370+
p.color(QtGui.QPalette.Active, QtGui.QPalette.WindowText)
370371
)
371372
self.setPalette(p)
372373

@@ -976,7 +977,7 @@ def on_tableView_globals_context_menu_requested(self, point):
976977
menu.addAction(self.action_globals_set_selected_true)
977978
menu.addAction(self.action_globals_set_selected_false)
978979
menu.addAction(self.action_globals_delete_selected)
979-
menu.exec_(QtGui.QCursor.pos())
980+
menu.exec(QtGui.QCursor.pos())
980981

981982
def on_globals_delete_selected_triggered(self):
982983
selected_indexes = self.ui.tableView_globals.selectedIndexes()
@@ -1648,12 +1649,12 @@ def connect_signals(self):
16481649
self.groups_model.itemChanged, self.on_groups_model_item_changed)
16491650

16501651
# Keyboard shortcuts:
1651-
engage_shortcut = QtWidgets.QShortcut('F5', self.ui,
1652+
engage_shortcut = QtGui.QShortcut('F5', self.ui,
16521653
lambda: self.ui.pushButton_engage.clicked.emit(False))
16531654
engage_shortcut.setAutoRepeat(False)
1654-
QtWidgets.QShortcut('ctrl+W', self.ui, self.close_current_tab)
1655-
QtWidgets.QShortcut('ctrl+Tab', self.ui, lambda: self.switch_tabs(+1))
1656-
QtWidgets.QShortcut('ctrl+shift+Tab', self.ui, lambda: self.switch_tabs(-1))
1655+
QtGui.QShortcut('ctrl+W', self.ui, self.close_current_tab)
1656+
QtGui.QShortcut('ctrl+Tab', self.ui, lambda: self.switch_tabs(+1))
1657+
QtGui.QShortcut('ctrl+shift+Tab', self.ui, lambda: self.switch_tabs(-1))
16571658

16581659
def on_close_event(self):
16591660
save_data = self.get_save_data()
@@ -1875,7 +1876,7 @@ def on_treeView_axes_context_menu_requested(self, point):
18751876
# menu = QtWidgets.QMenu(self.ui)
18761877
# menu.addAction(self.action_axes_check_selected)
18771878
# menu.addAction(self.action_axes_uncheck_selected)
1878-
# menu.exec_(QtGui.QCursor.pos())
1879+
# menu.exec(QtGui.QCursor.pos())
18791880
pass
18801881

18811882
def on_axes_check_selected_triggered(self, *args):
@@ -2047,7 +2048,7 @@ def on_treeView_groups_context_menu_requested(self, point):
20472048
copy_menu.addAction(filename, lambda filepath=filepath: self.on_groups_copy_selected_groups_triggered(filepath, False))
20482049
move_menu.addAction(filename, lambda filepath=filepath: self.on_groups_copy_selected_groups_triggered(filepath, True))
20492050

2050-
menu.exec_(QtGui.QCursor.pos())
2051+
menu.exec(QtGui.QCursor.pos())
20512052

20522053
def on_groups_copy_selected_groups_triggered(self, dest_globals_file=None, delete_source_group=False):
20532054
selected_indexes = self.ui.treeView_groups.selectedIndexes()
@@ -3715,5 +3716,5 @@ def handler(self, request_data):
37153716
# Upon seeing a ctrl-c interrupt, quit the event loop
37163717
signal.signal(signal.SIGINT, lambda *args: qapplication.exit())
37173718

3718-
qapplication.exec_()
3719+
qapplication.exec()
37193720
remote_server.shutdown()

runmanager/main.ui

Lines changed: 18 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,28 @@
3232

3333
QPushButton:hover {
3434
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
35-
stop: 0 #f6f7fa, stop: 1 #dadbde);
36-
border: 1px solid #8f8f91;
35+
stop: 0 palette(light), stop: 1 palette(window));
36+
border: 1px solid palette(dark);
3737
border-radius: 3px;
3838
}
3939

4040
QPushButton:pressed {
4141
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
42-
stop: 0 #dadbde, stop: 1 #f6f7fa);
43-
border: 1px solid #8f8f91;
42+
stop: 0 palette(window), stop: 1 palette(light));
43+
border: 1px solid palette(dark);
4444
border-radius: 3px;
4545
}
4646

4747
QPushButton:checked {
48-
background-color: #dadbde;
49-
border: 1px solid #8f8f91;
48+
background-color: palette(window);
49+
border: 1px solid palette(dark);
5050
border-radius: 3px;
5151
}
5252

5353
QPushButton:hover:checked {
5454
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
55-
stop: 0 #dadbde, stop: 1 #f6f7fa);
56-
border: 1px solid #8f8f91;
55+
stop: 0 palette(window), stop: 1 palette(light));
56+
border: 1px solid palette(dark);
5757
border-radius: 3px;
5858
}
5959

@@ -64,28 +64,28 @@ QToolButton {
6464

6565
QToolButton:hover {
6666
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
67-
stop: 0 #f6f7fa, stop: 1 #dadbde);
68-
border: 1px solid #8f8f91;
67+
stop: 0 palette(light), stop: 1 palette(window));
68+
border: 1px solid palette(dark);
6969
border-radius: 3px;
7070
}
7171

7272
QToolButton:pressed {
7373
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
74-
stop: 0 #dadbde, stop: 1 #f6f7fa);
75-
border: 1px solid #8f8f91;
74+
stop: 0 palette(window), stop: 1 palette(light));
75+
border: 1px solid palette(dark);
7676
border-radius: 3px;
7777
}
7878

7979
QToolButton:checked {
80-
background-color: #dadbde;
81-
border: 1px solid #8f8f91;
80+
background-color: palette(window);
81+
border: 1px solid palette(dark);
8282
border-radius: 3px;
8383
}
8484

8585
QToolButton:hover:checked {
8686
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
87-
stop: 0 #dadbde, stop: 1 #f6f7fa);
88-
border: 1px solid #8f8f91;
87+
stop: 0 palette(window), stop: 1 palette(light));
88+
border: 1px solid palette(dark);
8989
border-radius: 3px;
9090
}
9191
</string>
@@ -449,23 +449,6 @@ subprocess</string>
449449
<property name="toolTip">
450450
<string>Select folder ...</string>
451451
</property>
452-
<property name="styleSheet">
453-
<string notr="true">QToolButton{
454-
border: none;
455-
background: white;
456-
padding: 2px;
457-
}
458-
459-
QToolButton:hover {
460-
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
461-
stop: 0 #f6f7fa, stop: 1 #dadbde);
462-
}
463-
464-
QToolButton:pressed {
465-
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
466-
stop: 0 #dadbde, stop: 1 #f6f7fa);
467-
}</string>
468-
</property>
469452
<property name="text">
470453
<string>...</string>
471454
</property>
@@ -484,10 +467,7 @@ QToolButton:hover {
484467
<bool>false</bool>
485468
</property>
486469
<property name="styleSheet">
487-
<string notr="true">QToolButton{
488-
background: rgb(224,224,224);
489-
padding: 3px;
490-
}</string>
470+
<string notr="true"/>
491471
</property>
492472
<property name="frameShape">
493473
<enum>QFrame::StyledPanel</enum>
@@ -534,21 +514,7 @@ QToolButton:hover {
534514
<string>Select a file ...</string>
535515
</property>
536516
<property name="styleSheet">
537-
<string notr="true">QToolButton{
538-
border: none;
539-
background: white;
540-
padding: 2px;
541-
}
542-
543-
QToolButton:hover {
544-
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
545-
stop: 0 #f6f7fa, stop: 1 #dadbde);
546-
}
547-
548-
QToolButton:pressed {
549-
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
550-
stop: 0 #dadbde, stop: 1 #f6f7fa);
551-
}</string>
517+
<string notr="true"/>
552518
</property>
553519
<property name="text">
554520
<string>...</string>

0 commit comments

Comments
 (0)