PyGTK Book - PyGTK, PyCario, DBus, GStreamer, Pyclutter ...

View PDF Document
Download lyx Document - usually the most up to date
https://github.com/majorsilence/pygtknotebook

Note: Everything in this book is for gtk 2.* and does not cover 3.*. This book is no longer being actively maintained as most of my work now is with mono and .net. Further development has been moved to https://github.com/majorsilence/pygtknotebook in case anyone would like to continue working on it.

I have decided to collect all of my notes and sample files as a book so I have one location to turn to when I want to remember how to do something. Basically I am using open source code to write an open source book. At the moment there is not much and it is only a very rough draft. There are many empty sections and many of my sources probably are not cited properly yet. Hopefully some day it will be in good shape.

My goal is to create a high quality PyGTK book that covers integrating PyGTK with other Linux technologies such as: GStreamer multimedia, clutter animation, cairo graphics, DBus interprocess communication, empathy instant messaging, webkit and embedded firefox. This is just a small sample of the things that I want to cover, and many of them I already do. However, this is only an incomplete first draft and will take time to finish, but I am putting it on the Internet now hoping it will be useful to someone other then myself.

I am currently writing this using lyx which is a GUI tool for latex. I find this a very easy to use tool and convenient for myself.

Send to peter@majorsilence.com all suggestions, ideas, corrections etc...

Comments

get following on Windows XP + IE7 + latest PyGTK + latest GTK+

Traceback (most recent call last):
File "H:\backup\code\enjoy-pygtk\broswer\t.py", line 166, in
gui = GUI()
File "H:\backup\code\enjoy-pygtk\broswer\t.py", line 61, in __init__
self.init_ie()
File "H:\backup\code\enjoy-pygtk\broswer\t.py", line 82, in init_ie
parentHwnd = self.container.window.handle
AttributeError: 'NoneType' object has no attribute 'handle'

http://www.majorsilence.com/pygtk_embedded_web_browsers

please fix it.

I have fixed a small error with this. You can get the latest copy from http://svn.majorsilence.com/pygtknotebook/trunk/examples/browsers/ or go through the book.

The problem was that I was calling self.init_ie() before the following:
self.win.add(self.main_vbox)
self.win.show_all()

I have that fixed in the book and the examples.

on 8.5.4
class clutter.BehaviourRotate(Behaviour)
...
get_bounds(angle_start, angle_end)
get_bounds(angle_start, angle_end)
...
I imagine you meant set_bounds for one of them.

I will change that tonight.

In 1.2.4 the line:

    label_1.set_text("Hello " + str(data))

should be indented to show that it is part of the function and the rest of the program should be indented as shown.

Hi there. I looked into this. For now if you want to see everything indented correctly you are going to need to use the book that is all in one document http://svn.majorsilence.com/pygtknotebook/trunk/pygtk-notebook-latest.ht.... This is auto generated whenever I do a change in main lyx document and is the most up to date and all indentation is shown correctly in it.

In 1.3.1 the line

button.connect("clicked", button_callback, "Button Click Me")     vbox.pack_start(button, True, True, 2)

should be cut into two lines as follows. The end of the line is being cut of in the PDF version.

button.connect("clicked", button_callback, "Button Click Me")     
vbox.pack_start(button, True, True, 2)

Fixed now. Will be uploading the new pdf and html (http://svn.majorsilence.com/pygtknotebook/trunk/pygtk-notebook-latest.html) document soon.

In 1.2.3
The line

vbox.pack_start(hbox)

is in the comments but missing from the code. It should appear right after the comment section.

Fixed.

There is a minor typo. In the line...

 It than connects the buttons when clicked to the function...

than should be then

The button_callback function need to be defined before it is used.

button.connect("clicked", button_callback, "Button Click Me")     
vbox.pack_start(button, True, True, 2)
def button_callback(widget=None, data=None):
   print "%s was clicked." % data

should be...

def button_callback(widget=None, data=None):
   print "%s was clicked." % data
button.connect("clicked", button_callback, "Button Click Me")     
vbox.pack_start(button, True, True, 2)

In the line

button2 = gtk.RadioButton(button1, label="Radio Button 3")

button2 =
should be ...
button3 =

The line

print "%s was toggled %s" % (data, ("off","on")[widget.get_active()])

should be indented to show that it is part of the button_callback function

Fixed.

the line

print "%s was clicked." % data

should be indented to show that it is part of the function.

In the clear_callback function setting text_box=None will cause an the text_box.set_text("") to fail with a NoneType error. Change text_box=None to data=None fixes it.

Change

def clear_callback(widget=None, text_box=None):
    text_box.set_text(“”)
    label.set_text(“”)
To
def clear_callback(widget=None, data=None):
    text_box.set_text(“”)
    label.set_text(“”)

I will fix those errors tonight.

Fixed.

That's so interesting to know about the new PyGTK book. I am looking forward for it and hope it will launch soon. Please give the information will it will launch. I have very weak memory power and I forgot so fast where I kept my important files and with the new PyGTK book I can arrange my files in one section. It will be easy for me to remember as well. Please update us. Thank you.

Great thanks for you book, - exporting to pdf part

Alex