-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial implementation of ScrolledFrame * Fixes to ScrolledFrame
- Loading branch information
Showing
5 changed files
with
514 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"""Demo grid container with scrollbars""" | ||
|
||
from guitk import * | ||
|
||
|
||
class Grid(Window): | ||
def config(self): | ||
self.title = "Grid Demo" | ||
with VLayout(): | ||
with HGrid( | ||
4, | ||
vspacing=0, | ||
hspacing=(0, 20), | ||
vscrollbar=True, | ||
autohide_scrollbars=True, | ||
) as self.vgrid: | ||
for i in range(25): | ||
Button(f"HGrid {i}") | ||
HSeparator() | ||
with HStack(expand=False): | ||
Button("Add") | ||
Button("Remove") | ||
HSeparator() | ||
Label("", key="status") | ||
|
||
@on("Add") | ||
def on_add(self): | ||
"""Add a widget""" | ||
button_count = len(self.vgrid) | ||
self.vgrid.append(Button(f"HGrid {button_count}")) | ||
|
||
@on("Remove") | ||
def on_remove(self): | ||
"""Remove a widget""" | ||
if len(self.vgrid): | ||
self.vgrid.pop() | ||
|
||
@on(event_type=EventType.ButtonPress) | ||
def on_button_press(self, event): | ||
"""Update status label""" | ||
self.get("status").value = f"Button {event.widget.value} pressed" | ||
|
||
|
||
if __name__ == "__main__": | ||
Grid().run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.