Skip to content

Commit 2ff686a

Browse files
committed
layout helper
1 parent a72e2b9 commit 2ff686a

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

Source/GUI/Qt.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from PySide6.QtWidgets import (
55
QApplication, QMainWindow, QWidget, QVBoxLayout, QHBoxLayout, QTabWidget,
66
QLabel, QComboBox, QPushButton, QPlainTextEdit, QLineEdit, QFileDialog,
7-
QMessageBox, QCheckBox
7+
QMessageBox, QCheckBox, QBoxLayout
88
)
99
from PySide6.QtCore import Qt, QTimer, QThread, Signal, QUrl
1010
from PySide6.QtWebEngineWidgets import QWebEngineView
@@ -319,7 +319,7 @@
319319
,"CMD:Settings:Display:Scroll Speed:<0 to 65,535>"
320320
,"CMD:Settings:Display:Invert:<True/False>"]
321321

322-
def movable_widget(widget:QWidget, SpacingX, SpacingY,
322+
def movable_widget(layout:QBoxLayout, widget:QWidget, SpacingX, SpacingY,
323323
AlignmentX:Qt.AlignmentFlag=Qt.AlignmentFlag.AlignCenter,
324324
AlignmentY:Qt.AlignmentFlag=Qt.AlignmentFlag.AlignCenter):
325325

@@ -328,8 +328,10 @@ def movable_widget(widget:QWidget, SpacingX, SpacingY,
328328
LayoutV.addSpacing(SpacingY)
329329

330330
LayoutH = QHBoxLayout()
331-
LayoutH.addLayout(LayoutV)
332331
LayoutH.addSpacing(SpacingX)
332+
LayoutH.addLayout(LayoutV)
333+
334+
layout.addLayout(LayoutH)
333335

334336
return LayoutH
335337

@@ -407,7 +409,7 @@ def create_control_panel(self):
407409
# create a horizontal layout that will hold all items in a single row for connecting to HamMessenger
408410
control_row = QHBoxLayout()
409411

410-
###
412+
'''###
411413
# create a horizontal layout that will hold the port label, combobox, and refresh button
412414
port_combo_qbox = QHBoxLayout()
413415
# create the port label and add it to the port horizontal layout
@@ -431,19 +433,21 @@ def create_control_panel(self):
431433
# set the spacing of all items in the port horizontal layout to 0 so they are all close
432434
port_combo_qbox.setSpacing(0)
433435
# finally, add the port horizontal layout to the control row horizontal layout
434-
control_row.addLayout(port_combo_qbox)
436+
control_row.addLayout(port_combo_qbox)'''
437+
438+
port_combo_qbox = QHBoxLayout()
439+
label = QLabel("Port:")
440+
port_label = movable_widget(port_combo_qbox, label, 0, 0, Qt.AlignmentFlag.AlignCenter, Qt.AlignmentFlag.AlignCenter)
441+
442+
self.port_combo = QComboBox()
443+
combobox = movable_widget(port_combo_qbox, self.port_combo, 0, 0, Qt.AlignmentFlag.AlignCenter, Qt.AlignmentFlag.AlignCenter)
435444

436-
'''port_combo_qbox = QHBoxLayout()
437-
port_label = movable_widget(QLabel("Port:"),0,0,Qt.AlignmentFlag.AlignCenter,Qt.AlignmentFlag.AlignCenter)
438-
port_combo_qbox.addLayout(port_label)
439-
self.port_combo = movable_widget(QComboBox(),0,0,Qt.AlignmentFlag.AlignCenter,Qt.AlignmentFlag.AlignCenter)
440-
port_combo_qbox.addLayout(self.port_combo)
441445
button = QPushButton("Refresh")
442446
button.clicked.connect(self.populate_serial_ports)
443-
refresh_button = movable_widget(button,0,0,Qt.AlignmentFlag.AlignCenter,Qt.AlignmentFlag.AlignCenter)
444-
port_combo_qbox.addLayout(refresh_button)
447+
refresh_button = movable_widget(port_combo_qbox, button, 0, 3, Qt.AlignmentFlag.AlignCenter, Qt.AlignmentFlag.AlignCenter)
448+
445449
port_combo_qbox.setSpacing(0)
446-
control_row.addLayout(port_combo_qbox)'''
450+
control_row.addLayout(port_combo_qbox)
447451

448452
# add some spacing between the port horizontal layout and the baud horizontal layout
449453
#control_row.addSpacing(20)

0 commit comments

Comments
 (0)