11"""box-backgrounds example for pyinkcli."""
22
3- from pyinkcli import Box , Text , render , useApp , useInput
3+ from pyinkcli import Box , Text , render
44
55
66def box_backgrounds_example ():
7- app = useApp ()
8-
9- def on_input (char , key ):
10- if char == "q" or (key .ctrl and char == "c" ):
11- app .exit ()
12-
13- useInput (on_input )
14-
157 return Box (
168 Text ("Box Background Examples:" , bold = True ),
17- Text ("1. Standard red background (10x3):" ),
9+ Box ( Text ("1. Standard red background (10x3):" ) ),
1810 Box (Text ("Hello" ), backgroundColor = "red" , width = 10 , height = 3 , alignSelf = "flex-start" ),
19- Text ("2. Blue background with border (12x4):" ),
11+ Box ( Text ("2. Blue background with border (12x4):" ) ),
2012 Box (
2113 Text ("Border" ),
2214 backgroundColor = "blue" ,
@@ -25,7 +17,7 @@ def on_input(char, key):
2517 height = 4 ,
2618 alignSelf = "flex-start" ,
2719 ),
28- Text ("3. Green background with padding (14x4):" ),
20+ Box ( Text ("3. Green background with padding (14x4):" ) ),
2921 Box (
3022 Text ("Padding" ),
3123 backgroundColor = "green" ,
@@ -34,7 +26,7 @@ def on_input(char, key):
3426 height = 4 ,
3527 alignSelf = "flex-start" ,
3628 ),
37- Text ("4. Yellow background with center alignment (16x3):" ),
29+ Box ( Text ("4. Yellow background with center alignment (16x3):" ) ),
3830 Box (
3931 Text ("Centered" ),
4032 backgroundColor = "yellow" ,
@@ -43,7 +35,7 @@ def on_input(char, key):
4335 justifyContent = "center" ,
4436 alignSelf = "flex-start" ,
4537 ),
46- Text ("5. Magenta background, column layout (12x5):" ),
38+ Box ( Text ("5. Magenta background, column layout (12x5):" ) ),
4739 Box (
4840 Text ("Line 1" ),
4941 Text ("Line 2" ),
@@ -53,45 +45,47 @@ def on_input(char, key):
5345 height = 5 ,
5446 alignSelf = "flex-start" ,
5547 ),
56- Text ("6. Hex color background #FF8800 (10x3):" ),
48+ Box ( Text ("6. Hex color background #FF8800 (10x3):" ) ),
5749 Box (
5850 Text ("Hex" ),
5951 backgroundColor = "#FF8800" ,
6052 width = 10 ,
6153 height = 3 ,
6254 alignSelf = "flex-start" ,
6355 ),
64- Text ("7. RGB background rgb(0,255,0) (10x3):" ),
56+ Box ( Text ("7. RGB background rgb(0,255,0) (10x3):" ) ),
6557 Box (
6658 Text ("RGB" ),
6759 backgroundColor = "rgb(0,255,0)" ,
6860 width = 10 ,
6961 height = 3 ,
7062 alignSelf = "flex-start" ,
7163 ),
72- Text ("8. Text inheritance test:" ),
64+ Box ( Text ("8. Text inheritance test:" ) ),
7365 Box (
7466 Text ("Inherited " ),
7567 Text ("Override " , backgroundColor = "red" ),
7668 Text ("Back to inherited" ),
7769 backgroundColor = "cyan" ,
7870 alignSelf = "flex-start" ,
7971 ),
80- Text ("9. Nested background inheritance:" ),
72+ Box ( Text ("9. Nested background inheritance:" ) ),
8173 Box (
82- Text ("Outer " ),
74+ Text ("Outer: " ),
8375 Box (
84- Text ("Inner " ),
76+ Text ("Inner: " ),
8577 Text ("Deep" , backgroundColor = "red" ),
8678 backgroundColor = "yellow" ,
8779 ),
8880 backgroundColor = "blue" ,
8981 alignSelf = "flex-start" ,
9082 ),
91- Text ("Press 'q' to exit." , dimColor = True ),
83+ Box (
84+ Text ("Press Ctrl+C to exit" ),
85+ marginTop = 1 ,
86+ ),
9287 flexDirection = "column" ,
9388 gap = 1 ,
94- padding = 1 ,
9589 )
9690
9791
0 commit comments