473,388 Members | 1,355 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Python / glade fundamentals

Hi all,
Can someone tell me why I do not get a connection between the events and
the functions in the sample below. GUI window appears OK, just no
connections seem to be made.
I am new to this so may be missing something fundamental.
Thanks,
Doug

file pgtest.glade
=================

<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">

<glade-interface>

<widget class="GtkWindow" id="page">
<property name="visible">True</property>
<property name="events">GDK_KEY_PRESS_MASK</property>
<property name="title" translatable="yes">PGtestWindow</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="default_width">640</property>
<property name="default_height">480</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">True</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<signal name="destroy_event" handler="on_page_destroy_event" last_modification_time="Thu, 16 Mar 2006 12:57:33 GMT"/>

<child>
<widget class="GtkDrawingArea" id="drawingarea1">
<property name="visible">True</property>
<property name="events">GDK_KEY_PRESS_MASK</property>
<property name="extension_events">GDK_EXTENSION_EVENTS_ALL</property>
<signal name="key_press_event" handler="on_drawingarea1_key_press_event" last_modification_time="Thu, 16 Mar 2006 10:09:36 GMT"/>
<signal name="destroy_event" handler="on_drawingarea1_destroy_event" last_modification_time="Thu, 16 Mar 2006 13:01:31 GMT"/>
</widget>
</child>
</widget>

</glade-interface>

file pgtest.py
==============
import gtk
import gtk.glade

def on_drawingarea1_key_press(widget):
print "keypress"

xml = gtk.glade.XML('pgtest.glade')
widget = xml.get_widget('drawingarea1')
#print type(xml)

xml.signal_autoconnect({
"on_drawingarea1_key_press_event": on_drawingarea1_key_press,
"on_page_destroy_event":gtk.mainquit
})

gtk.main()
Mar 16 '06 #1
6 2881
On 2006-03-16, Doug <do**@localhost.localdomain> wrote:
Can someone tell me why I do not get a connection between the events and
the functions in the sample below. GUI window appears OK, just no
connections seem to be made.
I am new to this so may be missing something fundamental.


This might be relevant:

http://www.async.com.br/faq/pygtk/in...=faq03.003.htp

Dave Cook
Mar 17 '06 #2
OK, I have solved the problem. The reference was a help. The clue is that
the events may not get passed through the parent. For reference here is
the code that worked.
It's good to finally get the basics working.
Doug

import gtk
import gtk.glade

def key_press(widget,event):
print "keypress"

xml = gtk.glade.XML('pgtest.glade')
widget = xml.get_widget('drawingarea1')

xml.signal_autoconnect({
"on_page_key_press_event": key_press,
"on_page_destroy_event": gtk.main_quit
})

gtk.main()
=======file: pgtest.glade=======

<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">

<glade-interface>

<widget class="GtkWindow" id="page">
<property name="visible">True</property>
<property name="title" translatable="yes">PGtestWindow</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="default_width">640</property>
<property name="default_height">480</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">True</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<signal name="destroy" handler="on_page_destroy_event" last_modification_time="Fri, 17 Mar
2006 12:42:42 GMT"/>
<signal name="key_press_event" handler="on_page_key_press_event" after="yes" last_modificat
ion_time="Fri, 17 Mar 2006 12:56:29 GMT"/>

<child>
<widget class="GtkDrawingArea" id="drawingarea1">
<property name="visible">True</property>
<signal name="key_press_event" handler="on_drawingarea1_key_press_event" after="yes" la
st_modification_time="Thu, 16 Mar 2006 10:09:36 GMT"/>
<signal name="destroy" handler="on_drawingarea1_destroy_event" last_modification_time="
Fri, 17 Mar 2006 12:36:08 GMT"/>
</widget>
</child>
</widget>

</glade-interface>
Mar 17 '06 #3
Hi Doug,
mabe you will find it easyer to use GladeGen to generate the
skeleton of your application rather then coding it yourself. Take a
look here: http://www.linuxjournal.com/article/7421

Cheers,
Ido Yehieli

Mar 17 '06 #4
Hi Doug,
maybe you will find it easyer to use GladeGen to generate the
skeleton of your application rather then coding it yourself. Take a
look here: http://www.linuxjournal.com/article/7421

Cheers,
Ido Yehieli

Mar 17 '06 #5
> maybe you will find it easyer to use GladeGen to generate the
skeleton of your application rather then coding it yourself. Take a
look here: http://www.linuxjournal.com/article/7421


You may also use my PyGG module: http://freshmeat.net/projects/pygg

Cheers,
Franck
Mar 20 '06 #6
Franck:
PyGG seems pretty cool, thanks for the link!

Mar 20 '06 #7

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

Similar topics

3
by: Hans Deragon | last post by:
Greetings. Total newbie to Glade here. I created an interface using glade-2 and I want to use it with my python program. Following is what I wrote (test prg): -------------------------...
9
by: Edilmar | last post by:
Hi, First of all, I'm new in Python... I have worked with manu langs and IDEs, like Delphi, VB, JBuilder, Eclipse, Borland C++, Perl, etc... Then, today I think IDEs like Delphi have a...
59
by: Hugh Macdonald | last post by:
I've recently been trying out various different GUI frameworks in Python and was wondering if I could get your input on the pros and cons of the different ones... wxPython: I love the...
5
by: somesh | last post by:
hello, I wrote a small tute for my brother to teach him python + glade, plz see, and suggest to make it more professional , In tute I discussed on Glade + Python for developing Applications too...
7
by: Madhusudan Singh | last post by:
Is there such a thing for python ? Like Qt Designer for instance ?
0
by: Doug | last post by:
I am having some fun running a program called pygps. This uses libglade and runs fine on my very old Redhat 7.? system running Python 1.5.2. I have not needed to make any changes to the import...
5
by: Kveldulv | last post by:
I made simple GUI in Glade 3 (Ubuntu 7.04) consisting of only 2 buttons. When I run 2buttonsgui.py, no GUI pops out #!/usr/bin/env python import pygtk import gtk.glade class TwoButtonsGUI:...
19
by: Sam | last post by:
A friend of mine is picking up some Python and is frustrated by Python's indentation rules (http://greatbiggary.livejournal.com/ 260460.html?thread=1835884#t1835884). Personally, I've never had...
5
by: holmes86 | last post by:
hi,everyone. I am a python newbie.and I write a python program with glade,as following: import sys import gtk import gtk.glade class TLaitSignals: '''Define TLait singals handler'''
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.