Skip to content

Commit

Permalink
(fix) layout
Browse files Browse the repository at this point in the history
  • Loading branch information
javadr committed Dec 28, 2024
1 parent c3fde00 commit 04dd58a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 25 deletions.
2 changes: 2 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
2024-12-28 -- v0.9.7
-- Fixed layout issue

2024-12-27 -- v0.9.6
-- Fixed issue with closing the main window after opening and closing the immutable words list.
Expand Down
2 changes: 1 addition & 1 deletion negar_gui/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import platform
from pathlib import Path

__version__ = "0.9.6"
__version__ = "0.9.7"

APPDATA = "AppData/Roaming/" if platform.system() == "Windows" else "."
SETTING_FILE = Path.home() / f"{APPDATA}negar-gui/settings.toml"
Expand Down
50 changes: 26 additions & 24 deletions negar_gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import logging
from docopt import docopt
from pyperclip import copy as pyclipcopy
from PyQt6.QtWidgets import QHBoxLayout, QSpacerItem, QSizePolicy
from PyQt6.QtCore import (
QAbstractTableModel,
Qt,
Expand Down Expand Up @@ -498,37 +499,38 @@ def _grid_layout(self, layout="h"):
widgets = (
self.input_editor_label,
self.input_editor,
self.output_editor_label,
self.comparative_output_chkbox,
# self.output_lbl_comp_chk_layout,
self.output_editor,
)
for widget in widgets:
self.gridLayout.removeWidget(widget)
widget.setParent(None)
self.horizontalLayout.setParent(None)
self.output_lbl_comp_chk_layout.setParent(None)
# (row, col, rowspan, colspan)
elements = (
(
(0, 0, 1, 1), # Position: 0x0 1 rowspan 1 colspan
(1, 0, 1, 1), # Position: 1x0 1 rowspan 1 colspan
(0, 1, 1, 1), # Position: 0x1 1 rowspan 1 colspan
(0, 1, 1, 1), # Position: 0x1 1 rowspan 1 colspan
(1, 1, 1, 1), # Position: 1x1 1 rowspan 1 colspan
)
if layout == "v"
else (
(0, 0, 1, 2), # Position: 0x0 1 rowspan 2 colspan
(1, 0, 1, 2), # Position: 1x0 1 rowspan 2 colspan
(2, 0, 1, 2), # Position: 2x0 1 rowspan 2 colspan
(2, 1, 1, 2), # Position: 2x0 1 rowspan 2 colspan
(3, 0, 1, 2), # Position: 3x0 1 rowspan 2 colspan
)
)
elements = {
"v": ( # VERTICAL
(0, 0, 1, 1),
(1, 0, 1, 1),
(1, 1, 1, 1),
),
"h": ( # HORIZONTAL
(0, 0, 1, 2),
(1, 0, 1, 2),
(3, 0, 1, 2),
),
}
for i, widget in enumerate(widgets):
self.gridLayout.addWidget(widget, *elements[i])
self.output_lbl_comp_chk_layout.addWidget(self.output_editor_label)
self.output_lbl_comp_chk_layout.addWidget(self.comparative_output_chkbox)
# self.output_lbl_comp_chk_layout.addItem(self.output_spacer)
self.gridLayout.addWidget(widget, *elements[layout][i])

self.horizontalLayout = QHBoxLayout()
spacerMin = QSpacerItem(7, 0, QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Minimum)
spacerMax = QSpacerItem(0, 0, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Maximum)
self.horizontalLayout.addWidget(self.output_editor_label)
self.horizontalLayout.addItem(spacerMin)
self.horizontalLayout.addWidget(self.comparative_output_chkbox)
self.horizontalLayout.addItem(spacerMax)
span = {"v": (0, 1, 1, 2), "h": (2, 1, 1, 1)}
self.gridLayout.addLayout(self.horizontalLayout, *span[layout])

def _grid_full_input(self):
widgets = (self.output_editor_label, self.output_editor)
Expand Down

0 comments on commit 04dd58a

Please sign in to comment.