473,396 Members | 1,779 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,396 software developers and data experts.

treeview / pygtk problem

Hi list,

I am quite new to Python and try to learn Python with a small pygtk
program. I am facing a problem which I am unable to solve for myself.
I think I have read the documentation and some samples, but however
I cannot find my mistake, so hopefully someone can help me with a
short hint. This is a small sample application which demonstrates
my problem:

import gtk as g
import gobject

window = g.Window ()
window.connect ('delete_event', g.mainquit)
scrolledwin = g.ScrolledWindow ()
renderer = g.CellRendererText ()
col1 = g.TreeViewColumn ("col 1", renderer, text=1)
col2 = g.TreeViewColumn ("col 2", renderer, text=1)
model = g.ListStore (gobject.TYPE_STRING, gobject.TYPE_STRING)
view = g.TreeView ()
view.set_model (model)
view.set_headers_visible (1)
view.append_column(col1)
view.append_column(col2)

scrolledwin.add (view)
window.add (scrolledwin)
window.show_all ()

iter = model.append ()
# -- Problem -- #
model.set (iter, 0, "foo", 1, "bar")
# ------------- #
g.mainloop ()

I thought, with the marked model.set... I can set the first row in my
treeview to col1 = foo and col2 = bar. But, if I execute the script
the 2 columns are set to bar.

Where is my mistake? I am using Python 2.2.2 on RedHat 9.

Thanks,

Andre
Jul 18 '05 #1
3 2250
On Thu, 2003-07-10 at 11:53, Andre Lerche wrote:
Hi list,

I am quite new to Python and try to learn Python with a small pygtk
program. I am facing a problem which I am unable to solve for myself.
I think I have read the documentation and some samples, but however
I cannot find my mistake, so hopefully someone can help me with a
short hint. This is a small sample application which demonstrates
my problem:

import gtk as g
import gobject

window = g.Window ()
window.connect ('delete_event', g.mainquit)
scrolledwin = g.ScrolledWindow ()
renderer = g.CellRendererText ()
col1 = g.TreeViewColumn ("col 1", renderer, text=1)
col2 = g.TreeViewColumn ("col 2", renderer, text=1)

----^
That's your problem right there: text= expects a sequence from 0 to n.
So try:

col1 = g.TreeViewColumn ("col 1", renderer, text=0)
col2 = g.TreeViewColumn ("col 2", renderer, text=1)

That should solve your problem!

-Tim
ti*@gerla.net
Jul 18 '05 #2
Hi Tim,

Tim Gerla <ti*@gerla.net> wrote in message news:<ma**********************************@python. org>...
On Thu, 2003-07-10 at 11:53, Andre Lerche wrote:
Hi list, [...] renderer = g.CellRendererText ()
col1 = g.TreeViewColumn ("col 1", renderer, text=1)
col2 = g.TreeViewColumn ("col 2", renderer, text=1)

----^
That's your problem right there: text= expects a sequence from 0 to n.
So try:

col1 = g.TreeViewColumn ("col 1", renderer, text=0)
col2 = g.TreeViewColumn ("col 2", renderer, text=1)

That should solve your problem!

-Tim
ti*@gerla.net


Yes, this has solved my problem, I was really to dumb.

Thanks,

Andre
Jul 18 '05 #3
In article <ea*************************@posting.google.com> , Andre Lerche
wrote:
col1 = g.TreeViewColumn ("col 1", renderer, text=0)
col2 = g.TreeViewColumn ("col 2", renderer, text=1)

That should solve your problem!

-Tim
ti*@gerla.net


Yes, this has solved my problem, I was really to dumb.


Hardly; this API is quite obscure.

Dave Cook
Jul 18 '05 #4

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

Similar topics

0
by: Franck Pommereau | last post by:
Hi all, I'm building a PyGTK interface in which I would like that no widget would be able to get the focus (and so to be activated by pressing the Return key). For this purpose, for each widget,...
0
by: manatlan | last post by:
Hello, I'm new to pygtk (but i know wxpython very well) I'm trying to play with this example : http://www.pygtk.org/pygtk2tutorial/sec-CellRenderers.html#filelistingfig (the code is here :...
2
by: JUAN ERNESTO FLORES BELTRAN | last post by:
Hi you all, I am developping a python application which connects to a database (postresql) and displays the query results on a treeview. In adittion to displaying the info i do need to implement...
0
by: Chris Johnson | last post by:
Good morning. I have recently begun a project using PyGTK, and part of my planned interface has a gtk.TreeView showing a portion of the filesystem. Now, rather than load the entire FS structure...
0
by: Fabian Braennstroem | last post by:
Hi, I am just testing pygtk/glade out and wonder, if I am able to change the keybindings. E.g. the treeview searches by default for the entries beginning with the typed keystroke; moving to the...
2
by: cypher543 | last post by:
I have a TreeView and a ToolButton. The ToolButton should only be active if the user has selected an item in the TreeView. What signal should I use to achieve this? Thanks, David
1
by: Guillermo Heizenreder | last post by:
Hi list I'm developing a application for learn pygkt, and I need to know when a user selected or clicked one determinate row of my TreeView for shot another signal . Study the tutorial I began...
0
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...
1
micmast
by: micmast | last post by:
Ey all, I'm currently working on an application that uses the pygtk libraries to create windows and widgets. I have a HBOX (2 boxes) in the middle and in the left one I have a treeview, in the...
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: 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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
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...

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.