473,382 Members | 1,093 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,382 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 2880
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'''
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.