Skip to content

Commit 1da6c6d

Browse files
authored
Library: Port 'Tooltip' to Python (#729)
1 parent d2aad79 commit 1da6c6d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/Library/demos/Tooltip/main.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import gi
2+
3+
gi.require_version("Gtk", "4.0")
4+
from gi.repository import Gtk
5+
import workbench
6+
7+
button: Gtk.Button = workbench.builder.get_object("button")
8+
9+
10+
def on_query_tooltip(button, x, y, mode, tooltip):
11+
custom_tooltip = Gtk.Box(spacing=6)
12+
label = Gtk.Label(label="This is a custom tooltip")
13+
icon = Gtk.Image(icon_name="penguin-alt-symbolic")
14+
custom_tooltip.append(label)
15+
custom_tooltip.append(icon)
16+
17+
tooltip.set_custom(custom_tooltip)
18+
return True
19+
20+
21+
button.connect("query-tooltip", on_query_tooltip)

0 commit comments

Comments
 (0)