Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite layout managers, but this time sucklessly #138

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions tukaan/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from tukaan._collect import commands, widgets
from tukaan._events import BindingsMixin
from tukaan._layout import ContainerGrid, Geometry, Grid, Position, ToplevelGrid
from tukaan._mixins import GeometryMixin, VisibilityMixin, WidgetMixin
from tukaan.layouts import LayoutManagerBase
from tukaan._props import cget, config
from tukaan._tcl import Tcl
from tukaan._utils import count
Expand Down Expand Up @@ -65,17 +65,20 @@ class TkWidget(WidgetMixin, BindingsMixin, VisibilityMixin):
_tcl_class: str
_variable: Any # TODO This is set in LinkProp

grid: LayoutManagerBase

def __init__(self) -> None:
self._children = {}
self._child_type_count = collections.defaultdict(lambda: count())

for name, lm in LayoutManagerBase.layout_managers.items():
setattr(self, name, lm(self))

widgets[self._name] = self


class ToplevelBase(TkWidget, Container):
def __init__(self) -> None:
self.grid = ToplevelGrid(self)

TkWidget.__init__(self)


Expand All @@ -89,10 +92,6 @@ def __init__(self, parent: TkWidget, tooltip: str | None = None, **kwargs: Any)

TkWidget.__init__(self)

self.grid = ContainerGrid(self) if isinstance(self, Container) else Grid(self)
self.geometry = Geometry(self)
self.position = Position(self)

Tcl.call(None, self._tcl_class, self._name, *Tcl.to_tcl_args(**kwargs))

if tooltip:
Expand Down
Loading