Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

Python3 XApp IconChooserButton demo application

If I ever need a simple iconchooser from the XApp library.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python3
import gi
gi.require_version("Gtk","3.0")
gi.require_version("XApp","1.0")
from gi.repository import XApp, Gtk, Gdk

class MainWindow(Gtk.Window):
   def __init__(self):
      Gtk.Window.__init__(self, title="Example window")
      self.grid = Gtk.Grid()
      self.add(self.grid)
      self.button0 = XApp.IconChooserButton()
      # technically only a regular Button can use a button-press-event, not the IconChooserButton
      #self.button0.connect("button-press-event", self.on_button0_press_event)
      self.grid.add(self.button0)

   def on_button0_press_event(self, *args):
      print("Do something on the button press!")

icon = MainWindow()
icon.connect("destroy", Gtk.main_quit)
icon.show_all()
Gtk.main()

Screenshot of IconChooserDialog from XApp library demonstrating the Numix
Circle icon
theme The XApp folks (Linux Mint team) have put into their library all the functionality that previously had to be done yourself (see Tomha/python-gtk- themed-icon-chooser). Some decent Internet documentation of the XApp library is available too: http://lazka.github.io/pgi-docs/#XApp-1.0/classes/StatusIcon.html

Comments