Skip to content

Commit 821f87f

Browse files
committed
add Grid Object
1 parent 9c1818e commit 821f87f

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,4 @@ cython_debug/
159159
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160160
#.idea/
161161
poetry.lock
162+
htagui/swipers2.py

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,20 @@ self <= ui.Button("p1", _onclick = lambda ev: v.go( Tag.div("p1") ))
373373
self <= ui.Button("p2", _onclick = lambda ev: v.go( Tag.div("p2") ))
374374
self <= v
375375
```
376+
## Object Grid
377+
378+
signature : Grid(format,vformat="auto",gap="1px",**a)
379+
380+
A simple grid container
381+
382+
example:
383+
```python
384+
385+
g = Grid("1fr 1fr 2fr")
386+
g <= Tag.div( "2colums",_style="grid-column:1 / 3")
387+
g <= Tag.div( "1column")
388+
389+
```
376390

377391

378392
## utilities methods

htagui/all.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from .splitters import HSplit, VSplit
1717
from .ifields import IText,ITextarea,IRange,IBool,ISelect,IRadios
1818
from .fileupload import FileUpload
19-
from .containers import VScroll,VScrollPager, View
19+
from .containers import VScroll,VScrollPager, View, Grid
2020
from .sortables import Sortable
2121
from .swipers import Swiper
2222
from .javascripts import JSKEYABLE
@@ -34,5 +34,5 @@ def ui(self):
3434

3535
# Swiper not inluded by default !!!!!
3636

37-
ALL=[JSKEYABLE, App,Form,Tabs,Dialog,HSplit,VSplit,IText,ITextarea,IRange,IBool,ISelect,IRadios,FileUpload,Sortable,VScroll,VScrollPager,View]
37+
ALL=[JSKEYABLE, App,Form,Tabs,Dialog,HSplit,VSplit,IText,ITextarea,IRange,IBool,ISelect,IRadios,FileUpload,Sortable,VScroll,VScrollPager,View,Grid]
3838
FULL=ALL+[Swiper] # Swiper not inluded by default !!!!! (coz +170ko)

htagui/containers.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,14 @@ def go(self,tag,anchor=None):
9696
self._refs[f'#{anchor}'] = tag
9797
self.call( f"document.location=`#{anchor}`")
9898

99+
class Grid(Tag.div):
100+
"""
101+
g = Grid("2fr 1fr 1fr")
102+
g <= Tag.div( "2colums",_style="grid-column:1 / 3")
103+
g <= Tag.div( "1column")
104+
"""
105+
def init(self,format,vformat="auto",gap="1px",**a): # format= "2fr 1fr 1fr"
106+
self["style"].set("display","grid")
107+
self["style"].set("grid-template-columns",format)
108+
self["style"].set("grid-template-rows",vformat)
109+
self["style"].set("gap",gap)

0 commit comments

Comments
 (0)