473,545 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ScrolledWindo w ()
renderer = g.CellRendererT ext ()
col1 = g.TreeViewColum n ("col 1", renderer, text=1)
col2 = g.TreeViewColum n ("col 2", renderer, text=1)
model = g.ListStore (gobject.TYPE_S TRING, gobject.TYPE_ST RING)
view = g.TreeView ()
view.set_model (model)
view.set_header s_visible (1)
view.append_col umn(col1)
view.append_col umn(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 2256
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.ScrolledWindo w ()
renderer = g.CellRendererT ext ()
col1 = g.TreeViewColum n ("col 1", renderer, text=1)
col2 = g.TreeViewColum n ("col 2", renderer, text=1)

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

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

That should solve your problem!

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

Tim Gerla <ti*@gerla.ne t> wrote in message news:<ma******* *************** ************@py thon.org>...
On Thu, 2003-07-10 at 11:53, Andre Lerche wrote:
Hi list, [...] renderer = g.CellRendererT ext ()
col1 = g.TreeViewColum n ("col 1", renderer, text=1)
col2 = g.TreeViewColum n ("col 2", renderer, text=1)

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

col1 = g.TreeViewColum n ("col 1", renderer, text=0)
col2 = g.TreeViewColum n ("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************ *************@p osting.google.c om>, Andre Lerche
wrote:
col1 = g.TreeViewColum n ("col 1", renderer, text=0)
col2 = g.TreeViewColum n ("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
2103
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, I do: widget.set_property("can-focus", gtk.FALSE) My problem is a TreeView which has a clickable column, it get the default focus and I did...
0
1280
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 : http://www.pygtk.org/pygtk2tutorial/examples/filelisting.py) I'd like to be able to use a virtual list (like wx.ListCtrl in mode LC_VIRTUAL) ...
2
3084
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 filtering facility for all the columns of the treestore/liststore model in order to allow the user an easy search method to find the desired...
0
1247
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 into the tree right from the beginning, I made a lazy tree by adding blank children to rows representing directories, and connected a call to fill...
0
1158
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 next row works as usual with the Down key. Now I would like to change the key bindings to e.g. 'j' to move to the next row (just like in vim) and...
2
1420
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
3735
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 to see the explanation that I see in the chapter 14.7. TreeView Signal and found one in particular "select-cursor-row", but I don't understood how...
0
1773
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 pyGTK applications at http://unpythonic.blogspot.com/2007/07/pygtk-py2exe-and-inno-setup-for-single.html
1
2945
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 right the rest (drawingarea, entries, labels, notebooks, ...). But, as usual, the big hbox is divided exactly in the middle and I was wondering if it is...
0
7487
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7420
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7934
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7446
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7778
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3459
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1908
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1033
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
731
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.