Re: [pygtk] Re: right clicking on a GtkTreeStore row

2003-09-30 Thread James Henstridge
On 29/09/2003 11:51 PM, Christian Reis wrote:

On Mon, Sep 29, 2003 at 04:49:49PM +0100, Stephen Kennedy wrote:
 

On Mon, 2003-09-29 at 16:01, Christian Reis wrote:
   

On Thu, Sep 25, 2003 at 10:57:23AM +0100, Stephen Kennedy wrote:
 

   path, col, cellx, celly = treeview.get_path_at_pos(
int(event.x), int(event.y) )
   

Question: Aren't event.x and event.y always integers?
 

Actually in pygtk-2.0.0 they're floats. I found this out when
upgrading to python2.3 - it gives warnings when passing floats
to c functions taking an integer.
   

We have subpixel resolutions now?
 

Some input devices give subpixel accuracy, such as some graphics tablets 
(which might also give tilt and pressure information about the 
pointer).  GTK 1.2 was the same.

James.

--
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] TreeView column expanding

2003-09-30 Thread Christian Reis
On Tue, Sep 30, 2003 at 02:25:10PM -0400, Michael McLay wrote:
> The following works as a replacment for what you are trying to do
> 
> col = gtk.TreeViewColumn (hdrs[i])
> col.pack_start (r, expand=gtk.FALSE)
>   col.add_attribute(r, 'text', i)
> renderers[i].set_property ('editable', 1)

Can you do something like set_child_packing() to change the packing of
a renderer that was already packed? 

That would avoid needing the separate pack_start() call, if it
exists/existed.

Take care,
--
Christian Reis | http://async.com.br/~kiko/ | [+55 16] 261 2331
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] TreeView column expanding

2003-09-30 Thread Michael McLay

On Tuesday 30 September 2003 01:05 pm, Theodore A. Roth wrote:
> Hi,
>
> I have built up an app using glade-2 and it loads and runs fine using
> gtk.glade. One of my widgets is a TreeView using a ListStore and I'm
> having a bit of trouble figuring out how to make all the columns
> # the model and the BOOLEAN in column 1.
> col = gtk.TreeViewColumn (hdrs[i], renderers[i],
>   text=i+2, editable=1)

> # This is obviously wrong.
> col.pack_start (renderers[i], expand=gtk.TRUE)

You are inserting the renderer and several properties into the column using 
the column constructor. Later you are using pack_start to reinsert the same 
renderer into the column. The pack_start method is to be used to insert 
multiple renderers into the same column, for instance, if you want to insert 
an icon and some text into the same cell.

The following works as a replacment for what you are trying to do

col = gtk.TreeViewColumn (hdrs[i])
col.pack_start (r, expand=gtk.FALSE)
col.add_attribute(r, 'text', i)
renderers[i].set_property ('editable', 1)

The attached example is a works.



import gtk, gtk.glade, gobject

class ListView:
def __init__ (self, view, model, hdrs, renderers, sel_cb):
self.view = view
view.set_model (model)
	view.set_headers_visible (gtk.TRUE)
for i in xrange (len (hdrs)):
# Set text to i+2 to skip over the PYOBJECT in column 0 of
# the model and the BOOLEAN in column 1.
col = gtk.TreeViewColumn (hdrs[i],)# renderers[i],text=i)
   #text=i+2, editable=1)
col.set_resizable (gtk.TRUE)
col.set_alignment (0.50)
view.append_column (col)

# This is obviously wrong.
	r = renderers[i]
col.pack_start (r, expand=gtk.FALSE)
	col.add_attribute(r, 'text', i)
renderers[i].set_property ('editable', 1)
renderers[i].set_property ('xalign', 0.50)
#renderers[i].set_property ('font-desc', font_fixed)


view.show()

sel = view.get_selection ()
sel.set_mode ('single')
sel.connect ('changed', sel_cb)


types = [ gobject.TYPE_STRING ] * 10
renderers = [ gtk.CellRendererText () ] * 10
hdrs  = [ 'Address', 'Name',
  'Bit 7', 'Bit 6', 'Bit 5', 'Bit 4',
  'Bit 3', 'Bit 2', 'Bit 1', 'Bit 0' ]


class App:

def __init__(self):
	self.gui = gtk.glade.XML("project8.glade")
	dic = {"on_treeview1_select_cursor_row":
		 self.on_treeview1_select_cursor_row
		}
	self.gui.signal_autoconnect(dic)
def setup_treeview (self, widget_name, types, hdrs, renderers, sel_cb):
self.model = model = gtk.ListStore (*types)
view2  = self.gui.get_widget (widget_name)
view = ListView (view2, model, hdrs, renderers, sel_cb)
	return view

def insert_row (self, data):
"""Also adds the python object, 'data' to the store in the first
column. Set the value of the boolean to TRUE so we can edit the
cells later.
"""
iter = self.model.append()
	self.model.set(iter,0,'a',1,'b',2,'c')
##args = [0, data, 1, gtk.TRUE]
##for i in range (len (data)):
##args.extend ([i+2, data[i]])
##	print "args", args
##self.model.set (iter, *args)

def on_treeview1_select_cursor_row(self, *obj):
	print "selected", obj

a = App()
print a.setup_treeview('treeview1',types,hdrs,renderers,
		   a.on_treeview1_select_cursor_row)
a.insert_row(['a','b','c'])
a.insert_row(['a','b','c'])
gtk.main()


project8.glade
Description: application/glade
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


[pygtk] auto editable gtk.TreeView

2003-09-30 Thread Lorenzo Gil Sanchez
Hi,

I'm trying to create an auto editable gtk.TreeView. What I mean with 'auto' is that 
you don't have to press the 'Enter' key when you are on a particular cell to make it 
editable. Just moving around the cells should make them editable (think in widgets 
like the ones used in spreadsheet programs).

There are two steps to make this possible with gtk.TreeView:

1. When the cursor moves you have to make the new cell editable
2. When we go out of a editable cell we need to move the cursor to the next cell. Here 
'next' depends on the key the user presses to go out of the editable cell.

I'm currently working on step 1 and I was succesfull with a small demo in C. The funny 
thing is that exactly the same code in Python doesn't work. I'll attach both codes and 
I'll try to explain what I think is happening:

What I do is connect_after the 'move-cursor' signal of the gtk.TreeView to a callback. 
In this callback I retrieve the current cursor and call treeview.set_cursor(path, 
column, start_editing=gtk.TRUE), which should make that cell editable if we trust the 
API doc. Note: I use the connect_after and not the connect method because the default 
signal handler is the one which actually move the cursor and if our callback is called 
first we would be working with the old cursor.

The commented line in the Python code is a nasty hack that make it works. It simply 
add a timeout that set the cursor, instead of setting the cursor in the 'move-cursor' 
callback. You can uncomment it to see what I mean.

I suppose this is a bug in PyGTK (since the C code works) but I'm not sure so I want 
some comments before filling a bug report.

By the way, any clue to implement step 2 is greatly welcomed :)

Regards

Lorenzo


editable-treeview.c
Description: Binary data
import pygtk
pygtk.require('2.0')
import gtk
import gobject
def move_cursor(treeview, step, count):
path, column = treeview.get_cursor()
treeview.set_cursor(path, column, gtk.TRUE)
#gobject.timeout_add(100, lambda t, p, c: t.set_cursor(p, c, gtk.TRUE),
#treeview, path, column)
def test():
window = gtk.Window()
window.connect('destroy', lambda e: gtk.main_quit())
window.set_default_size(300,300)

model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_INT,
  gobject.TYPE_BOOLEAN)
model.append(['foo1', 23, gtk.TRUE])
model.append(['foo2', 24, gtk.TRUE])
model.append(['foo3', 25, gtk.TRUE])
treeView = gtk.TreeView(model)
treeView.connect_after('move-cursor', move_cursor)
renderer = gtk.CellRendererText()
column = gtk.TreeViewColumn('column 1', renderer, text=0, editable=2)
column.set_flags(gtk.CAN_FOCUS)
treeView.append_column(column)
renderer = gtk.CellRendererText()
column = gtk.TreeViewColumn('column 2', renderer, text=1, editable=2)
column.set_flags(gtk.CAN_FOCUS)
treeView.append_column(column)
treeView.show()
window.add(treeView)
window.show()
gtk.main()
if __name__ == '__main__':
test()

-7d3126720140
Content-Disposition: form-data; name="x"

22
-7d3126720140
Content-Disposition: form-data; name="y"

4
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


[pygtk] TreeView column expanding

2003-09-30 Thread Theodore A. Roth
Hi,

I have built up an app using glade-2 and it loads and runs fine using
gtk.glade. One of my widgets is a TreeView using a ListStore and I'm
having a bit of trouble figuring out how to make all the columns
expand.

Google hasn't turned up a solution and the PyGTK FAQ Entry 13.19
gives a hint as such:

   Another thing to note is that renderers use the normal GTK packing
   mechanism. If you want one renderer to expand and take up any extra
   space (or `compete' for it if more than one cell has expand=TRUE),
   pack it with expand=TRUE, and vice-versa.

I not sure how to perform the packing of the column so I can set
expand to TRUE.

Here's what I've got so far:

class ListView:
def __init__ (self, view, model, hdrs, renderers, sel_cb):
self.view = view
view.set_model (model)

view.set_headers_visible (gtk.TRUE)
for i in xrange (len (hdrs)):
# Set text to i+2 to skip over the PYOBJECT in column 0 of
# the model and the BOOLEAN in column 1.
col = gtk.TreeViewColumn (hdrs[i], renderers[i],
  text=i+2, editable=1)
renderers[i].set_property ('xalign', 0.50)
renderers[i].set_property ('font-desc', font_fixed)
col.set_resizable (gtk.TRUE)
col.set_alignment (0.50)

# This is obviously wrong.
col.pack_start (renderers[i], expand=gtk.TRUE)

view.append_column (col)

view.show()

sel = view.get_selection ()
sel.set_mode ('single')
sel.connect ('changed', sel_cb)

Elsewhere, I define the following and pass them to the ListView init
method:

types = [ gobject.TYPE_STRING ] * 10
renderers = [ gtk.CellRendererText () ] * 10
hdrs  = [ 'Address', 'Name',
  'Bit 7', 'Bit 6', 'Bit 5', 'Bit 4',
  'Bit 3', 'Bit 2', 'Bit 1', 'Bit 0' ]

And the view is instantiated with this:

def setup_treeview (self, widget_name, types, hdrs, renderers, sel_cb):
model = ListModel (*types)
view  = self.wTree.get_widget (widget_name)
view = ListView (view, model.store, hdrs, renderers, sel_cb)

The problem code is:

# This is obviously wrong.
col.pack_start (renderers[i], expand=gtk.TRUE)

which generates quite a few of these:

(gui.py:26663): Gtk-CRITICAL **: file gtktreeviewcolumn.c: line 1234
(gtk_tree_view_column_pack_start): assertion `!
gtk_tree_view_column_get_cell_info (tree_column, cell)' failed

>From reading the docs, I kinda think that my call to col.pack_start()
is not the right approach as it seems to expect a specific cell, not a
renderer instance.

Just in cases it's of interest, here's how I'm adding my data to the
list store model:

   def insert_row (self, data):
"""Also adds the python object, 'data' to the store in the first
column. Set the value of the boolean to TRUE so we can edit the
cells later.
"""
iter = self.store.append ()
args = [0, data, 1, gtk.TRUE]
for i in range (len (data)):
args.extend ([i+2, data[i]])
self.store.set (iter, *args)

I'm using the current 2.2.x gtk+ libs.

Any insight into how to do this is appreciated.


Thanks.

Ted Roth
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


[pygtk] [PyORBit] "#pragma prefix" module names

2003-09-30 Thread dvilla

Hello:

When I use a "prefix" in my .idl...

File hello.idl:

  #pragma prefix "example"

  module hello_mod {
interface hello {
  void puts(in string str);
};
  };

 ...the module name that I must import is "example"

  import ORBit

  ORBit.load_typelib('./hello_module.so')

  import CORBA, example


But, when the prefix contains a dot...

  #pragma prefix "example.org"


 ... What is the name of the module??

  import ORBit

  ORBit.load_typelib('./hello_module.so')

  import CORBA, ?


Thanks in advance,
David


___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


[pygtk] GnomeEntry and events

2003-09-30 Thread Igor Stroh
Hi all,

I'm looking for an event that's fired by a GnomeEntry widget when an
entry is selected from the history list. Something like
'selection_changed' from GtkCombo->GtkList. I mean I could connect the
'changed' signal to the widget, but then it would be fired each time the
user types something into the Entry...
I searched for this topic on the net, and the only hit was an archived
posting from this list dated to April(?) 2001 with no reply.

TIA,
Igor
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/