473,382 Members | 1,791 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.

Read from .glade

Hello,

I've got the following problem: I've got a Userinterface that is made
in Glade, so i've got a
..glade file. What I want is to get the id's of every widget from the
class GtkEntry from a given window.

The glade file is like

<?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="TEVOinvoeren">
<property name="visible">True</property>
<property name="title" translatable="yes">Tevo - Invoeren</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</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>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>

<child>

<widget class="GtkWindow" id="TEVOklanttoevoegen">
<property name="visible">True</property>
<property name="title" translatable="yes">window1</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</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>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<signal name="destroy" handler="on_TEVOklanttoevoegen_destroy"
last_modification_time="Wed, 06 Sep 2006 08:51:33 GMT"/>

<child>
<widget class="GtkFixed" id="fixed10">
<property name="visible">True</property>

<child>
<widget class="GtkEntry" id="entry_cnaam">
<property name="width_request">184</property>
<property name="height_request">16</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="x">88</property>
<property name="y">88</property>
</packing>
</child>

.....

Kind regards,

Ralf Brand

Sep 6 '06 #1
1 1471

On Wednesday, September 06, 2006, at 10:36AM, <ra*********@gmail.comwrote:
>Hello,

I've got the following problem: I've got a Userinterface that is made
in Glade, so i've got a
.glade file. What I want is to get the id's of every widget from the
class GtkEntry from a given window.

The glade file is like

<?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="TEVOinvoeren">
<snip rest of glade xml file>
>Kind regards,

Ralf Brand

You want to use one of the XML processing libraries. The simplest (and should be fine for this use) is dom.

Here is some code I wrote as part of GladeGen - see http://www.linuxjournal.com/article/7421
that you should be able to easily extract the piece you need:

doc = xml.dom.minidom.parse(self.glade_file)

# look for widgets and get their widget type and name
for node in doc.getElementsByTagName('widget'):
widget = str(node.getAttribute('class'))
name = str(node.getAttribute('id'))
if self.top_window is None and widget == 'GtkWindow':
self.top_window = name

# if the widget type is in list of widgets user specified
# in config file, include it in the list

if widget in GladeGenConfig.include_widget_types:
# (widget type, name)
# ('GtkWindow', 'window1')
self.widgets.append((widget, name))
HTH,
Dave

Sep 6 '06 #2

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): -------------------------...
1
by: Will Ware | last post by:
In July there was a thread about problems on Red Hat 9 with PyGTK not playing nice with Glade. I was tinkering with this a little bit tonight, starting with the code I found in this article:...
8
by: p.kosina | last post by:
Does there exist any python plug-in (or something like that) for Glade 2.0.1. win32 port? I cant find any or links are unavailable. Thanks Pavel
2
by: John Doe | last post by:
Hi, does anyone have a website that covers gtk.glade? Thanks in advance. Dan
6
by: Doug | last post by:
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...
0
by: Terry Hancock | last post by:
I've run into something a little odd on my Debian-installed Python 2.3. I have deb packages "python2.3", "python-gtk2", and "python2.3-glade2" installed on this machine. Among other things,...
4
by: feo | last post by:
Hi, i'm interesting in use glade in windows. Could somebody help me? i've installed but i don't know how obtain an .exe, in linux its easy, but in windows i don't know. thanks and sorry for my...
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:...
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: 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: 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
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...

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.