473,487 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

PyGTK Notebook button_press_event connection

Hi all!

I have an application that uses a gtk.Notebook to show the content of a
GUI. Each page of it has a gtk.Label with a text that explains the
content. Each page is added to the notebook with the method
append_page(child, tab_label=None), passing a gtk.Label instance as
tab_label variable.

Now I'd like to connect to the button_press_event of the gtk.Label a
function call. I've done something like this:

<code>

notebook = gtk.Notebook()
....
child = gtk.Frame()
....
label = gtk.Label('Any text')
label.connect('button_press_event', a_function)
....
notebook.append_page(child, label)

</code>

But the button_press_event event is not intercepted (nothing happens
when I click on the tab label).

Any idea to solve this question?

Thanks

Luigi

Jan 24 '06 #1
1 3089
> <code>

notebook = gtk.Notebook()
...
child = gtk.Frame()
...
label = gtk.Label('Any text')
label.connect('button_press_event', a_function)
...
notebook.append_page(child, label)

</code>

But the button_press_event event is not intercepted (nothing happens
when I click on the tab label).


A gtk.Label does not have a gdk window (as in the windowing system of gtk+),
so it cannot listen to events. A workaround is to put it in an eventbox:

eventbox = gtk.EventBox()
eventbox.set_events(gtk.gdk.BUTTON_PRESS_MASK)
eventbox.connect('button-press-event', callback)

label = gtk.Label()
eventbox.add(label)

notebook.append_page(..., eventbox)

Perhaps you should subscribe to the PyGTK mailing list[1] though, where this
kind of question is more appropriately asked

[1]: http://www.daa.com.au/mailman/listinfo/pygtk

Johan Dahlin

Jan 24 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2470
by: F. GEIGER | last post by:
Hi again, I'd like to rename a page of a notebook. Deleting the page and adding a new one is not really an option, because the page is filled with other controls already. So I looked into...
4
2578
by: j_mckitrick | last post by:
Hi all. Here is a tiny container for one of each combo box, along with the glade file. Just 2 widgets, so hopefully not too large. How the heck do I get the selection from the ComboBox, as...
6
2019
by: Mark Mitchell | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I have a program written in python that tells me it requires PyGTK, so I DLed, ./configure, make, make install and the process seems to go ok. Some...
0
1335
by: Johan | last post by:
Hello! I'm trying to figure out how to use PYGTK to implement a rudimentary UI: I want to have an Image as the background, and then be able to put buttons (eventually icons, but buttons for...
7
6633
by: Domenique.Tilleuil | last post by:
hello, Is there an event simular to the java event onMouseOver ? I want to get the coordinates of the mouse pointer when it is over an image ( GTKImage widget) I've tried using the EventBox...
25
4250
by: TPJ | last post by:
GUI's etc: PyGtk on Windows "(...) So if someone develops mainly for X and just wants to make sure that it is not impossible to run on Windows, you can use PyGTK. (...)", July 2nd, 1999 pyGTK...
8
16699
by: JyotiC | last post by:
I want to make a stand alone gui. Whose work is to get the diff options from user and run a shell script based on them. I wanna know which one is better to use Tkinter or PyGTK, in terms of...
1
1756
by: krishnakant Mane | last post by:
hello, I will be writing some code in PyGTK to run on linux. but I want to know if there are any installers or distutils available for PyGTK on windows? I have heard that installing gimp or even...
0
1770
by: Michael Palmer | last post by:
On Sep 16, 12:30 pm, binaryjesus <coolman.gu...@gmail.comwrote: I haven't tried it myself, but I came across a blog post the other day that describes a way of building windows installers for...
0
7137
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7181
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7349
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4874
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
600
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
267
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.