0

I am running through the excellent PyGtk tutorial and tracking it in what I thought was the most up-to-date PyGtk API reference. The tutorial has a topic on the Switch widget but there seems to be no corresponding entry in the PyGtk reference. (There is an entry in the C-language GTK reference, but I was hoping to stay in Python land.)

This makes me wonder if I am somehow missing a more recent PyGtk API reference? The versions are a potential source of confusion, but it seems as if PyGtk is at version 2.x, the underlying Gtk is at 3.x and the tutorial uses Python v3.

Any thoughts on where I should look for PyGtk API documentation for the Switch widget?

Thanks in advance.

WesR
  • 1,292
  • 1
  • 18
  • 30
  • 2
    At the tutorial you referenced, there's a link for Gtk3 documentation (Python-specific reference): https://lazka.github.io/pgi-docs/#Gtk-3.0/classes/Switch.html#Gtk.Switch – AndreLDM May 08 '17 at 19:52
  • In the words of a famous literary figure -- DOH! – WesR May 09 '17 at 03:13
  • Thanks. This is the answer I needed. If you provide it as a response I will check the the checkmark. I had actually looked at that, but it seemed so abstract I failed to recognize it was Python-specific. Your response encouraged me to look more closely. – WesR May 09 '17 at 03:31

3 Answers3

1

GtkSwitch appeared on Gtk+ 3.0 so probably you won't be able to use it from PyGtk (which uses Gtk+ 2.0), for Gtk+ 3.0 you should use PyGObject:

PyGObject is a Python module that enables developers to access GObject-based libraries such as GTK+ within Python. It exclusively supports GTK+ version 3 or later. If you want to use GTK+ 2 in your application, use PyGTK, instead.

José Fonte
  • 4,016
  • 2
  • 16
  • 28
  • 1
    Thanks for catching my misstatement. The tutorial I referenced was, of course, based on PyGObject, not PyGTK. – WesR May 09 '17 at 03:31
  • PyGtk and PyGObject are distinct implementations. I think you were confused and GtkSwitch it's only available on PyGObject. Good luck. – José Fonte May 09 '17 at 13:05
0

PyGTK is for GTK+2. PyGObject is what you need for GTK+3.

Read GObject Gtk, Gnome, Gtk+, Gl, Gtk2, Gtk3...I don't understand? to understand those differences.

For GtkSwitch, the official GtkSwitch documentation clearly states it's available since GTK+3.0.

Community
  • 1
  • 1
liberforce
  • 11,189
  • 37
  • 48
0

As Answered by AndreLDM the api refrence is here lazka.github.io/pgi-docs/#Gtk-3.0/classes/

For more info than covered in above link see the gnome developer manual for gtk+ in C - https://developer.gnome.org/gtk3/stable/

Gtk+ is made in C so see (C!) the gnome developer manual above explaining the C functions. Also see the source code from gnome git - https://git.gnome.org//browse/

So first see the C documentation, code and then see the api documentation for pygobject (or your preferred language GbObject binding - c++, vala, haskell.gi and others)

Cheers!

P.S - Gnome is an umbrella project to build awesome gnome desktop. The Gnome Project contains libraries like the gtk+ toolkit to make widgets on desktop. Gtk was first written to make the gimp image editing tool which is awesome too.

mrtechmaker
  • 1,769
  • 12
  • 11