Skip to content

Commit 04dd58a

Browse files
committed
(fix) layout
1 parent c3fde00 commit 04dd58a

3 files changed

Lines changed: 29 additions & 25 deletions

File tree

Changelog.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2024-12-28 -- v0.9.7
2+
-- Fixed layout issue
13

24
2024-12-27 -- v0.9.6
35
-- Fixed issue with closing the main window after opening and closing the immutable words list.

negar_gui/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import platform
22
from pathlib import Path
33

4-
__version__ = "0.9.6"
4+
__version__ = "0.9.7"
55

66
APPDATA = "AppData/Roaming/" if platform.system() == "Windows" else "."
77
SETTING_FILE = Path.home() / f"{APPDATA}negar-gui/settings.toml"

negar_gui/main.py

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import logging
2626
from docopt import docopt
2727
from pyperclip import copy as pyclipcopy
28+
from PyQt6.QtWidgets import QHBoxLayout, QSpacerItem, QSizePolicy
2829
from PyQt6.QtCore import (
2930
QAbstractTableModel,
3031
Qt,
@@ -498,37 +499,38 @@ def _grid_layout(self, layout="h"):
498499
widgets = (
499500
self.input_editor_label,
500501
self.input_editor,
501-
self.output_editor_label,
502-
self.comparative_output_chkbox,
503-
# self.output_lbl_comp_chk_layout,
504502
self.output_editor,
505503
)
506504
for widget in widgets:
507505
self.gridLayout.removeWidget(widget)
508506
widget.setParent(None)
507+
self.horizontalLayout.setParent(None)
508+
self.output_lbl_comp_chk_layout.setParent(None)
509509
# (row, col, rowspan, colspan)
510-
elements = (
511-
(
512-
(0, 0, 1, 1), # Position: 0x0 1 rowspan 1 colspan
513-
(1, 0, 1, 1), # Position: 1x0 1 rowspan 1 colspan
514-
(0, 1, 1, 1), # Position: 0x1 1 rowspan 1 colspan
515-
(0, 1, 1, 1), # Position: 0x1 1 rowspan 1 colspan
516-
(1, 1, 1, 1), # Position: 1x1 1 rowspan 1 colspan
517-
)
518-
if layout == "v"
519-
else (
520-
(0, 0, 1, 2), # Position: 0x0 1 rowspan 2 colspan
521-
(1, 0, 1, 2), # Position: 1x0 1 rowspan 2 colspan
522-
(2, 0, 1, 2), # Position: 2x0 1 rowspan 2 colspan
523-
(2, 1, 1, 2), # Position: 2x0 1 rowspan 2 colspan
524-
(3, 0, 1, 2), # Position: 3x0 1 rowspan 2 colspan
525-
)
526-
)
510+
elements = {
511+
"v": ( # VERTICAL
512+
(0, 0, 1, 1),
513+
(1, 0, 1, 1),
514+
(1, 1, 1, 1),
515+
),
516+
"h": ( # HORIZONTAL
517+
(0, 0, 1, 2),
518+
(1, 0, 1, 2),
519+
(3, 0, 1, 2),
520+
),
521+
}
527522
for i, widget in enumerate(widgets):
528-
self.gridLayout.addWidget(widget, *elements[i])
529-
self.output_lbl_comp_chk_layout.addWidget(self.output_editor_label)
530-
self.output_lbl_comp_chk_layout.addWidget(self.comparative_output_chkbox)
531-
# self.output_lbl_comp_chk_layout.addItem(self.output_spacer)
523+
self.gridLayout.addWidget(widget, *elements[layout][i])
524+
525+
self.horizontalLayout = QHBoxLayout()
526+
spacerMin = QSpacerItem(7, 0, QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Minimum)
527+
spacerMax = QSpacerItem(0, 0, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Maximum)
528+
self.horizontalLayout.addWidget(self.output_editor_label)
529+
self.horizontalLayout.addItem(spacerMin)
530+
self.horizontalLayout.addWidget(self.comparative_output_chkbox)
531+
self.horizontalLayout.addItem(spacerMax)
532+
span = {"v": (0, 1, 1, 2), "h": (2, 1, 1, 1)}
533+
self.gridLayout.addLayout(self.horizontalLayout, *span[layout])
532534

533535
def _grid_full_input(self):
534536
widgets = (self.output_editor_label, self.output_editor)

0 commit comments

Comments
 (0)