File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
src/Library/demos/Flow Box Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ import gi
2+
3+ gi .require_version ("Gtk" , "4.0" )
4+ gi .require_version ("Adw" , "1" )
5+ from gi .repository import Adw , Gtk
6+ import workbench
7+
8+ flowbox = workbench .builder .get_object ("flowbox" )
9+
10+
11+ def add_emoji (_flowbox , unicode ):
12+ item = Adw .Bin (
13+ child = Gtk .Label (
14+ vexpand = True ,
15+ hexpand = True ,
16+ label = unicode ,
17+ css_classes = ["emoji" ],
18+ ),
19+ width_request = 100 ,
20+ height_request = 100 ,
21+ css_classes = ["card" ],
22+ )
23+ _flowbox .append (item )
24+
25+
26+ for code in range (128513 , 128591 ):
27+ add_emoji (flowbox , chr (code ))
28+
29+
30+ def on_item_selected (_flowbox , item ):
31+ # FlowBoxChild -> AdwBin -> Label
32+ emoji = item .get_child ().get_child ().get_label ()
33+ print ("Unicode:" , emoji .encode ("unicode-escape" ))
34+
35+
36+ flowbox .connect ("child-activated" , on_item_selected )
You can’t perform that action at this time.
0 commit comments