File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed
src/Library/demos/Color Dialog Expand file tree Collapse file tree 1 file changed +46
-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+ from gi .repository import Gdk , Gio , Gtk
5+ import workbench
6+
7+
8+ color_dialog_button = workbench .builder .get_object ("color_dialog_button" )
9+ custom_button = workbench .builder .get_object ("custom_button" )
10+
11+ color = Gdk .RGBA ()
12+ color .parse ("red" )
13+
14+ dialog_standard = Gtk .ColorDialog (
15+ title = "Select a color" ,
16+ modal = True ,
17+ with_alpha = True ,
18+ )
19+
20+ color_dialog_button .set_dialog (dialog_standard )
21+ color_dialog_button .set_rgba (color )
22+
23+ color_dialog_button .connect (
24+ "notify::rgba" ,
25+ lambda * _ : print (
26+ f"Color Dialog Button: The color selected is { color_dialog_button .get_rgba ().to_string ()} " ,
27+ ),
28+ )
29+
30+ dialog_custom = Gtk .ColorDialog (
31+ title = "Select a color" ,
32+ modal = True ,
33+ with_alpha = False ,
34+ )
35+
36+
37+ def on_color_selected (_dialog , _result ):
38+ color = _dialog .choose_rgba_finish (_result )
39+ print (f"Custom Button: The color selected is { color .to_string ()} " )
40+
41+
42+ def on_clicked (_button ):
43+ dialog_custom .choose_rgba (workbench .window , None , None , on_color_selected )
44+
45+
46+ custom_button .connect ("clicked" , on_clicked )
You can’t perform that action at this time.
0 commit comments