File tree Expand file tree Collapse file tree 5 files changed +55
-20
lines changed
Expand file tree Collapse file tree 5 files changed +55
-20
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,17 @@ class History(ft.Column):
5252 """
5353
5454 def __init__ (self ):
55- super ().__init__ ([ft .TextField (label = "Type a message..." )])
55+
56+ super ().__init__ (
57+ [ft .TextField (label = "Type a message..." )],
58+ # when we send several prompts the text goes down
59+ # so make the column scrollable, and always at the bottom
60+ scroll = ft .ScrollMode .AUTO ,
61+ auto_scroll = True ,
62+ # see https://stackoverflow.com/questions/77172817/items-not-scrolling-in-flet-gui
63+ # required for scroll to work properly
64+ expand = True ,
65+ )
5666
5767 # insert material - prompt or answer - to allow for different styles
5868 def add_prompt (self , message ):
@@ -102,7 +112,11 @@ def __init__(self, page):
102112 )
103113 super ().__init__ (
104114 [header , row , self .history ],
105- horizontal_alignment = ft .CrossAxisAlignment .CENTER )
115+ horizontal_alignment = ft .CrossAxisAlignment .CENTER ,
116+ # same as above, the history column needs to know
117+ # it is expected to take all the vertical space
118+ expand = True ,
119+ )
106120
107121
108122 def submit (self , event ):
Original file line number Diff line number Diff line change @@ -53,12 +53,15 @@ class History(ft.Column):
5353 # need to pass the app object so we can invoke its submit method
5454 def __init__ (self , app ):
5555 self .app = app
56- super ().__init__ ([
57- ft .TextField (
56+ super ().__init__ (
57+ [ ft .TextField (
5858 label = "Type a message..." ,
5959 on_submit = lambda event : self .app .submit (event ),
60- )
61- ])
60+ )],
61+ scroll = ft .ScrollMode .AUTO ,
62+ auto_scroll = True ,
63+ expand = True ,
64+ )
6265
6366 # insert material - prompt or answer - to allow for different styles
6467 def add_prompt (self , message ):
@@ -110,7 +113,9 @@ def __init__(self, page):
110113 )
111114 super ().__init__ (
112115 [header , row , self .history ],
113- horizontal_alignment = ft .CrossAxisAlignment .CENTER )
116+ horizontal_alignment = ft .CrossAxisAlignment .CENTER ,
117+ expand = True ,
118+ )
114119 # a local attribute to prevent multiple submissions
115120 self .disabled = False
116121
Original file line number Diff line number Diff line change @@ -51,12 +51,15 @@ class History(ft.Column):
5151 # need to pass the app object so we can invoke its submit method
5252 def __init__ (self , app ):
5353 self .app = app
54- super ().__init__ ([
55- ft .TextField (
54+ super ().__init__ (
55+ [ ft .TextField (
5656 label = "Type a message..." ,
5757 on_submit = lambda event : self .app .submit (event ),
58- )
59- ])
58+ )],
59+ scroll = ft .ScrollMode .AUTO ,
60+ auto_scroll = True ,
61+ expand = True ,
62+ )
6063
6164 # insert material - prompt or answer - to allow for different styles
6265 def add_prompt (self , message ):
@@ -108,7 +111,9 @@ def __init__(self, page):
108111 )
109112 super ().__init__ (
110113 [header , row , self .history ],
111- horizontal_alignment = ft .CrossAxisAlignment .CENTER )
114+ horizontal_alignment = ft .CrossAxisAlignment .CENTER ,
115+ expand = True ,
116+ )
112117 # a local attribute to prevent multiple submissions
113118 self .disabled = False
114119
Original file line number Diff line number Diff line change @@ -53,13 +53,16 @@ class History(ft.Column):
5353
5454 def __init__ (self , app ):
5555 self .app = app
56- super ().__init__ ([
57- ft .TextField (
56+ super ().__init__ (
57+ [ ft .TextField (
5858 label = "Type a message..." ,
5959 on_submit = lambda event : self .app .submit (event ),
6060 fill_color = "lightgrey" ,
61+ )],
62+ scroll = ft .ScrollMode .AUTO ,
63+ auto_scroll = True ,
64+ expand = True ,
6165 )
62- ])
6366
6467 # insert material - prompt or answer - to allow for different styles
6568 def add_prompt (self , message ):
@@ -113,7 +116,9 @@ def __init__(self, page):
113116 )
114117 super ().__init__ (
115118 [header , row , self .history ],
116- horizontal_alignment = ft .CrossAxisAlignment .CENTER )
119+ horizontal_alignment = ft .CrossAxisAlignment .CENTER ,
120+ expand = True ,
121+ )
117122 # a local attribute to prevent multiple submissions
118123 self .disabled = False
119124
Original file line number Diff line number Diff line change @@ -46,13 +46,16 @@ class History(ft.Column):
4646
4747 def __init__ (self , app ):
4848 self .app = app
49- super ().__init__ ([
50- ft .TextField (
49+ super ().__init__ (
50+ [ ft .TextField (
5151 label = "Type a message..." ,
5252 on_submit = lambda event : self .app .submit (event ),
5353 fill_color = "lightgrey" ,
54+ )],
55+ scroll = ft .ScrollMode .AUTO ,
56+ auto_scroll = True ,
57+ expand = True ,
5458 )
55- ])
5659
5760 # insert material - prompt or answer - to allow for different styles
5861 def add_prompt (self , message ):
@@ -107,7 +110,10 @@ def __init__(self, page):
107110 )
108111 super ().__init__ (
109112 [header , row , self .history ],
110- horizontal_alignment = ft .CrossAxisAlignment .CENTER )
113+ horizontal_alignment = ft .CrossAxisAlignment .CENTER ,
114+ expand = True ,
115+ )
116+ # xxx somehow I need to move this here because after __init__ self.page is .. None !?!
111117 self .page = page
112118 # a local attribute to prevent multiple submissions
113119 self .disabled = False
You can’t perform that action at this time.
0 commit comments