Skip to content

Commit e6380eb

Browse files
ceccopierangiolieugenioEugenioParodiSky3github-advanced-security[bot]
authored
refactor: layout item type checks and add type hints to widgets (#644)
Co-authored-by: Eugenio Parodi <eugenio.parodi@sky.uk> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 0ff7055 commit e6380eb

15 files changed

Lines changed: 788 additions & 252 deletions

File tree

β€Ž.github/codeql/codeql-config.ymlβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ paths-ignore:
77
- '**/*.egg-info/**'
88
- '**/__pycache__/**'
99
- docs/source/_build/**
10+
11+
query-filters:
12+
# Suppress "Module-level cyclic import" findings.
13+
- exclude:
14+
id: py/cyclic-import

β€Žlibs/pyTermTk/TermTk/TTkCore/constant.pyβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ class ItemFlag(Flag):
622622
'''The user can interact with the item.'''
623623

624624
# LayoutItem Types
625-
class LayoutItemTypes(int):
625+
class LayoutItemTypes(IntEnum):
626626
'''Types used internally in :mod:`~TermTk.TTkLayouts`
627627
628628
.. autosummary::

β€Žlibs/pyTermTk/TermTk/TTkLayouts/__init__.pyβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
Info and examples are available in the :ref:`Tutorial <Layout-Tutorial_Intro>`
88
'''
9+
from .layoutitem import *
910
from .layout import *
1011
from .gridlayout import *
1112
from .boxlayout import *

β€Žlibs/pyTermTk/TermTk/TTkLayouts/boxlayout.pyβ€Ž

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@
2727
__all__ = ['TTkHBoxLayout', 'TTkVBoxLayout']
2828

2929
from TermTk.TTkCore.constant import TTkK
30-
from TermTk.TTkLayouts.gridlayout import TTkGridLayout
30+
31+
from .gridlayout import TTkGridLayout
3132

3233
class TTkHBoxLayout(TTkGridLayout):
33-
''' The TTkHBoxLayout class lines up widgets horizontally
34+
'''The :py:class:`TTkHBoxLayout` class lines up widgets horizontally.
3435
3536
::
3637
@@ -47,7 +48,7 @@ class TTkHBoxLayout(TTkGridLayout):
4748
pass
4849

4950
class TTkVBoxLayout(TTkGridLayout):
50-
''' The TTkVBoxLayout class lines up widgets vertically
51+
'''The :py:class:`TTkVBoxLayout` class lines up widgets vertically.
5152
5253
::
5354
@@ -63,10 +64,33 @@ class TTkVBoxLayout(TTkGridLayout):
6364
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
6465
'''
6566
def addItem(self, item):
67+
'''Add a layout item on the next available vertical slot.
68+
69+
:param item: the item to be added
70+
:type item: :py:class:`TTkLayoutItem`
71+
'''
6672
TTkGridLayout.addItems(self, [item], direction=TTkK.VERTICAL)
73+
6774
def addItems(self, items):
75+
'''Add layout items stacked vertically.
76+
77+
:param items: the items to be added
78+
:type items: list[:py:class:`TTkLayoutItem`]
79+
'''
6880
TTkGridLayout.addItems(self, items, direction=TTkK.VERTICAL)
81+
6982
def addWidget(self, widget):
83+
'''Add a widget on the next available vertical slot.
84+
85+
:param widget: the widget to be added
86+
:type widget: :py:class:`TTkWidget`
87+
'''
7088
TTkGridLayout.addWidgets(self, [widget], direction=TTkK.VERTICAL)
89+
7190
def addWidgets(self, widgets):
91+
'''Add widgets stacked vertically.
92+
93+
:param widgets: the widgets to be added
94+
:type widgets: list[:py:class:`TTkWidget`]
95+
'''
7296
TTkGridLayout.addWidgets(self, widgets, direction=TTkK.VERTICAL)

0 commit comments

Comments
Β (0)