diff --git a/pyproject.toml b/pyproject.toml index 0ea13bd..db001a5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "ScrollableContainers" -version = "2.1.0" +version = "2.1.1" authors = [ { name = "Vishal Pankaj Chandratreya" }, ] diff --git a/src/ScrollableContainers/_qt5.py b/src/ScrollableContainers/_qt5.py index 2cfe5ea..e4fd846 100644 --- a/src/ScrollableContainers/_qt5.py +++ b/src/ScrollableContainers/_qt5.py @@ -18,7 +18,11 @@ def __init__(self, *args, **kwargs): container = QWidget() self.setWidget(container) vbox = QVBoxLayout(container) - self.area = QWidget() - vbox.addWidget(self.area, alignment=Qt.AlignHCenter) + self._area = QWidget() + vbox.addWidget(self._area, alignment=Qt.AlignHCenter) vbox.addStretch() self.setWidgetResizable(True) + + @property + def area(self): + return self._area diff --git a/src/ScrollableContainers/_qt6.py b/src/ScrollableContainers/_qt6.py index fc599ce..b01d508 100644 --- a/src/ScrollableContainers/_qt6.py +++ b/src/ScrollableContainers/_qt6.py @@ -18,7 +18,11 @@ def __init__(self, *args, **kwargs): container = QWidget() self.setWidget(container) vbox = QVBoxLayout(container) - self.area = QWidget() - vbox.addWidget(self.area, alignment=Qt.AlignmentFlag.AlignHCenter) + self._area = QWidget() + vbox.addWidget(self._area, alignment=Qt.AlignmentFlag.AlignHCenter) vbox.addStretch() self.setWidgetResizable(True) + + @property + def area(self): + return self._area diff --git a/src/ScrollableContainers/_tk.py b/src/ScrollableContainers/_tk.py index a73268a..6a96b67 100644 --- a/src/ScrollableContainers/_tk.py +++ b/src/ScrollableContainers/_tk.py @@ -42,10 +42,10 @@ def __init__(self, *args, **kwargs): self.grid_rowconfigure(0, weight=1) self.grid_columnconfigure(0, weight=1) - self.frame = ttk.Frame(self._canvas) - self._window = self._canvas.create_window((0, 0), window=self.frame, anchor=tk.NW) - self.frame.bind("", self._on_frame_configure) - self._on_frame_expose_id = self.frame.bind("", self._on_frame_expose) + self._frame = ttk.Frame(self._canvas) + self._window = self._canvas.create_window((0, 0), window=self._frame, anchor=tk.NW) + self._frame.bind("", self._on_frame_configure) + self._on_frame_expose_id = self._frame.bind("", self._on_frame_expose) # Initially, the vertical scrollbar is a hair below its topmost # position. Move it to said position. No harm in doing the equivalent @@ -53,6 +53,10 @@ def __init__(self, *args, **kwargs): self._canvas.xview_moveto(0.0) self._canvas.yview_moveto(0.0) + @property + def frame(self): + return self._frame + def _show_scrollbars(self): """ Move the horizontal and vertical scrollbars above the scrollable @@ -120,7 +124,7 @@ def _xview(self, *args, width: int | None = None): # function with a negative argument. I don't know if this hack is # supported (because the Tcl/Tk manual pages say that it must be a # fraction between 0 and 1), but it works! - self._canvas.xview_moveto((1 - width / self.frame.winfo_width()) / 2) + self._canvas.xview_moveto((1 - width / self._frame.winfo_width()) / 2) def _yview(self, *args): """ @@ -169,7 +173,7 @@ def _on_frame_expose(self, _event: tk.Event | None = None): :param _event: Expose event. """ self._on_frame_configure() - self.frame.unbind("", self._on_frame_expose_id) + self._frame.unbind("", self._on_frame_expose_id) def _on_canvas_enter(self, _event: tk.Event | None = None): """ diff --git a/src/ScrollableContainers/_wx.py b/src/ScrollableContainers/_wx.py index b3e1b2c..ca179a7 100644 --- a/src/ScrollableContainers/_wx.py +++ b/src/ScrollableContainers/_wx.py @@ -17,6 +17,10 @@ def __init__(self, *args, **kwargs): # According to the documentation, a sizer is required to calculate the # minimum virtual size of the panel. vbox = wx.BoxSizer(wx.VERTICAL) - self.panel = wx.Panel(self) - vbox.Add(self.panel, flag=wx.ALIGN_CENTRE) + self._panel = wx.Panel(self) + vbox.Add(self._panel, flag=wx.ALIGN_CENTRE) self.SetSizer(vbox) + + @property + def panel(self): + return self._panel