Re: [pygtk] delete selection

2003-08-14 Thread Grzegorz Adam Hankiewicz
On 2003-08-05, Yang Zheng [EMAIL PROTECTED] wrote:
 Can I not delete iterator like this?

Hmmm... can't say what you do wrong, but here's my deletion code,
maybe it helps you:

   selection = self.list_view.get_selection()
   model, iter, = selection.get_selected()
   if iter:
  path = model.get_path(iter)
  model.remove(iter)
  selection.select_path(path)
  if not selection.path_is_selected(path):
 row = path[0]-1
 if row = 0:
selection.select_path((row,))

-- 
 Please don't send me private copies of your public answers. Thanks.
___
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] PyObject properties?

2003-06-28 Thread Grzegorz Adam Hankiewicz
On 2003-06-27, John Ehresman [EMAIL PROTECTED] wrote:
 Is there any way to declare a property type as a generic Python
 object?  I want to define a property that may be set to a list
 of tuples.  I realize that this wouldn't be too useful to C code,
 but I'm writing both the get/set functions in and the code that
 uses the property in Python.  I tried using gobject.TYPE_OBJECT,
 but that requires the object to derive from GObject, which a
 Python list does not.

Did you try with gobject.TYPE_PYOBJECT?

-- 
 Please don't send me private copies of your public answers. Thanks.
___
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] Selecting a row doesn't set keyboard focus

2003-06-08 Thread Grzegorz Adam Hankiewicz
On 2003-06-07, Grzegorz Adam Hankiewicz [EMAIL PROTECTED] wrote:
 I'm capturing the keyboard events of a TreeView to delete rows with
 keys. This works fine, and I also manage to select the next row after
 deletion or the previous one if the deleted row was the last one.
 
 However, the keyboard focus (a dotted rectangle) seems to be lost,
 so while I've selected the fifth row, pressing down once will select
 the second row. How can I solve this incoherency between selected
 row and widget keyboard focus?

This example illustrates the problem. Select with your cursor keys
one of the entries in the middle of the list and press your delete
key. The item will be deleted and the next one will be automatically
selected. But if you press your down key the second element of the
list will be selected, ignoring the previous selection.

--
 Please don't send me private copies of your public answers. Thanks.
# -*- mode:Python; tab-width: 3 -*-
print __name__

import gtk
import gobject

class Resources(gtk.Window):

   def __init__(self):
  super(Resources, self).__init__(gtk.WINDOW_TOPLEVEL)
  self.counter = 1
  self.connect(delete_event, lambda widget, event: 0)
  self.connect(destroy, lambda x: gtk.main_quit())

  scrolled_window = gtk.ScrolledWindow()
  self.add(scrolled_window)
  scrolled_window.set_shadow_type(gtk.SHADOW_ETCHED_IN)
  scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
  scrolled_window.set_size_request(400, 250)

  self.data = [One, Two, Three, Four, Five] * 5
  model = self.update_model(gtk.ListStore(gobject.TYPE_STRING))

  self.list_view = list_view = gtk.TreeView(model)
  scrolled_window.add(list_view)
  list_view.set_rules_hint(1)
  list_view.add_events(gtk.gdk.KEY_PRESS)
  list_view.connect(key_press_event, self.keyboard_event)
  list_view.add_events(gtk.gdk.BUTTON_PRESS)
  list_view.append_column(gtk.TreeViewColumn('blah',
 gtk.CellRendererText(), text = 0))
  
  self.show_all()

   def keyboard_event(self, widget, event):
  if gtk.gdk.keyval_name(event.keyval) == Delete:
 self.delete_resource()
  elif gtk.gdk.keyval_name(event.keyval) == Insert:
 self.new_resource()

   def update_model(self, model):
  model.clear()
  self.data.sort()
  for item in self.data: model.set(model.append(), 0, item)
  return model

   def new_resource(self, *args):
  while 1:
 self.counter += 1
 id = item%02d % self.counter
 if not id in self.data: break
  self.data.append(id)
  self.update_model(self.list_view.get_model())

   # this function should somehow set correctly the keyboard focus
   def delete_resource(self, *args):
  selection = self.list_view.get_selection()
  model, iter, = selection.get_selected()
  if iter:
 path = model.get_path(iter)
 del self.data[path[0]]
 model.remove(iter)
 selection.select_path(path)
 if not selection.path_is_selected(path):
row = path[0]-1
if row = 0:
   selection.select_path((row,))
 
if __name__ == __main__:
   Resources()
   gtk.main()
___
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] How do I abort a drag and drop?

2003-06-08 Thread Grzegorz Adam Hankiewicz
I presume that I must catch the drag_begin signal and process it in
such a way that the drag is interrupted. The function processing the
signal seems to be documented as returning void, I can put return
true|false but it doesn't have any effect on the drag operation.

I've read the documentation of gdk_drag_abort() and tried to mimic
it with pygtk, but it doesn't have any effect:

   def begin_drag(self, widget, context):
  context.drag_abort(long(0))
  return 0

The function gets called, but the drag operation still goes
on. Suggestions?

-- 
 Please don't send me private copies of your public answers. Thanks.
___
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] Selecting a row doesn't set keyboard focus

2003-06-07 Thread Grzegorz Adam Hankiewicz
Hi.

I'm capturing the keyboard events of a TreeView to delete rows with
keys. This works fine, and I also manage to select the next row after
deletion or the previous one if the deleted row was the last one.

However, the keyboard focus (a dotted rectangle) seems to be lost,
so while I've selected the fifth row, pressing down once will select
the second row. How can I solve this incoherency between selected
row and widget keyboard focus?

-- 
 Please don't send me private copies of your public answers. Thanks.
___
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] Python binding of Pango should accept 'None' as anargument.

2003-04-03 Thread Grzegorz Adam Hankiewicz
On 2003-04-02, Alif Wahid [EMAIL PROTECTED] wrote:
 [...]  You see in Pango some functions are passed a NULL pointer
 to specify default behaviour. This doesn't seem to be the case in
 the Python binding, in other words we can't pass a None type object
 to achieve the same feat without generating unnecessary exceptions
 about the wrong type. In particular the method get_metrics(...) of
 a pango.Font derivative doesn't accept the None object and spews
 up a TypeError exception instead. On the other hand in the C API
 passing a NULL pointer to the same function simply means to do
 the default thing (that is to load metrics for the entire font,
 not language dependent). So as you can see Python binding should
 follow the same sort of Pango API conventions.  [...]

Maybe this case should be handled with something similar to the
following recipe?

 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/68205

It createas a Null class which avoids rasing TypeError and such (or
so the recipe claims).  The idea would be to differentiate None,
which could be passed in from a previous function if something
went wrong, and this should still be treated like a mistake. Null
instead is like saying see, I wan't you to use NULL in the C code,
and I'm showing that I didn't pass you None by accident.

-- 
 Please don't send me private copies of your public answers. Thanks.
___
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] Adjusting a TreeView padding to the other elements of anHBox

2003-03-31 Thread Grzegorz Adam Hankiewicz
On 2003-03-30, John Finlay [EMAIL PROTECTED] wrote:
 I'm attaching an example which demonstrates this, built up from John
 Finlay's tutorial and pygtk's demo (for the TreeView part). The
 expected behaviour of the example is to display a button and a
 list with three items with the same spacing, but the border of the
 TreeView stays invariable. Is this a bug? Is this a feature?
  
 Looks like a feature :-)

Where should I document this feature?

-- 
 Please don't send me private copies of your public answers. Thanks.
___
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] Adjusting a TreeView padding to the other elements of anHBox

2003-03-30 Thread Grzegorz Adam Hankiewicz
On 2003-02-23, Grzegorz Adam Hankiewicz [EMAIL PROTECTED] wrote:
 I have a VBox which contains a few buttons and a TreeView. For
 the buttons I call set_border_width(), but this doesn't have any
 effect on the TreeView.

I'm attaching an example which demonstrates this, built up from John
Finlay's tutorial and pygtk's demo (for the TreeView part). The
expected behaviour of the example is to display a button and a
list with three items with the same spacing, but the border of the
TreeView stays invariable. Is this a bug? Is this a feature?

I'm using Python 2.2.1 and PyGTK from CVS.
#!/usr/bin/env python

import gtk, gobject

class Test_window:

   def clicked_button1(self, widget):
  print Button pressed

   def delete_event(self, widget, event, data = None):
  return 0

   def __init__(self):
  # create the new window
  self.window = window = gtk.Window(gtk.WINDOW_TOPLEVEL)
  window.set_title(Welcome window)
  window.set_border_width(10)

  # delete handler to exit GTK
  window.connect(delete_event, self.delete_event)
  window.connect('destroy', lambda w: gtk.main_quit())

  # create a box to package interface elements inside
  self.box1 = box1 = gtk.VBox(0, 0)
  window.add(box1)

  # create a button
  self.button1 = button1 = gtk.Button(Create)
  box1.pack_start(button1, 1, 1, 0)
  button1.connect(clicked, self.clicked_button1)
  button1.set_border_width(5)
  button1.show()

  # create a list
  store = gtk.ListStore(gobject.TYPE_STRING)
  for entry in [One item, Anoter, Oh, and this one]:
 store.set(store.append(), 0, entry)

  self.list = list = gtk.TreeView(store)
  box1.pack_start(list)
  # the following line seems to be ignored
  list.set_border_width(50)
  list.set_rules_hint(1)
  list.set_headers_visible(0)

  column = gtk.TreeViewColumn('Description',
 gtk.CellRendererText(), text=0)
  list.append_column(column)
  list.show()

  # show elements
  box1.show()
  window.show()
  
if __name__ == '__main__':
   Test_window = Test_window()
   gtk.main()
___
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] Translating PyGTK programs

2002-11-23 Thread Grzegorz Adam Hankiewicz
Hi.

Last time I checked the faq said something strange about not using
gettext, using intl, then using again gettext :-? So I took an
example from the pygtk directory and started hacking it until I
managed to get it working with python's gettext module. The example
is attached.

Can somebody check if this is ok? I see that the FAQ has been
updated, but looks like it focuses on the C part of gettext, and
this smaller example might be easier to understand for newbies. Feel
free to put it in the faq or some cvs directory.

I was also wondering if you need help with PyGTK's web page, I do
web maintaining for other free software. I'm not in the side of
graphic design and such (I browse with elinks), I focus on having
content updated.



translating_interfaces.tar.bz2
Description: Binary data


Re: [pygtk] Is there a prebuilt runtime for windows?

2002-10-07 Thread Grzegorz Adam Hankiewicz

On Mon, Oct 07, 2002 at 02:35:36PM +0200, Cedric Gustin wrote:
libiconv-1.7-w32.bin.zip
 
 I don't know why Tor Lillqvist is changing its library dependencies
 all the time. A few weeks, the port of iconv that was recommended (and
 the one I'm currently using whenbuilding pygtk on win32) was the one
 provided by the gnuwin32 project
 
 http://sourceforge.net/project/showfiles.php?group_id=23617release_id=41715
 
 which seems to extract itself into the right directory (./bin and ./lib). 
 Strange.

True. Then maybe an explicit link for libiconv should be made to avoid
Tor's package?
___
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] Is there a prebuilt runtime for windows?

2002-10-05 Thread Grzegorz Adam Hankiewicz

On Fri, Oct 04, 2002 at 12:05:38AM +0200, Grzegorz Adam Hankiewicz wrote:
   Thank you very much. BTW, some names have changed, and the win32 gtk
   page says you need libjpeg-6b, zlib, freetype2, tiff and libpng too,
   or is that only for gimp?

I've tried now, and if you mindlessly follow the instructions it won't
work. First if all, the list of packages at this moment is:

   libiconv-1.7-w32.bin.zip
   libintl-0.10.40-tml-20020904.zip
   glib-2.0.6-20020802.zip
   gtk+-2.0.6-20020921.zip
   atk-1.0.3-20020821.zip
   pango-1.0.4-20020921.zip

After installation pygtk doesn't work because some DLL import failed:

 import gtk, gtk.glade
Traceback (most recent call last):
  File pyshell#0, line 1, in ?
import gtk, gtk.glade
  File C:\PYTHON22\Lib\site-packages\pygtk\gtk\__init__.py, line 14, in ?
import gobject
ImportError: DLL load failed: No se puede hallar uno de los archivos de biblioteca 
necesarios para ejecutar esta aplicaciĆ³n.
 

The problem is in the libiconv-1.7-w32.bin.zip file, which doesn't
uncompress correctly into the %gtkdir% tree structure, instead, it
creates a libiconv-1.7-w32.bin directory.  So I manually copied the dll
files to ../lib, and the exe to ../bin, and then everything worked and
I could run my pygtk2 examples without problems.

Please update this into the faq.
___
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] Is there a prebuilt runtime for windows?

2002-10-03 Thread Grzegorz Adam Hankiewicz

On Wed, Oct 02, 2002 at 07:13:44PM -0300, Christian Reis wrote:
  that, but I guess I'll find out). Now, where's pygtk for win32? If it
  Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
 
 Take care,

Thank you very much. BTW, some names have changed, and the win32 gtk
page says you need libjpeg-6b, zlib, freetype2, tiff and libpng too,
or is that only for gimp?

PD: Love steps 5 and 10.
___
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] Is there a prebuilt runtime for windows?

2002-10-03 Thread Grzegorz Adam Hankiewicz

On Thu, Oct 03, 2002 at 06:48:41PM -0300, Christian Reis wrote:
  Thank you very much. BTW, some names have changed, and the win32 gtk
  page says you need libjpeg-6b, zlib, freetype2, tiff and libpng too,
  or is that only for gimp?
 
 FAQ 21.12 is for PyGTK2, mind you, not PyGTK-0, which is why some of the
 requirements are different. Which version are you using?

PyGTK2. According to the page those requeriments come from GTK2.0 for
windows.
___
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] Is there a prebuilt runtime for windows?

2002-09-27 Thread Grzegorz Adam Hankiewicz

Hi.

One thing I forgot: while my development platform is linux, I will have
to eventually deploy the programs in windows platforms. So I am looking
for an easy to install .exe file which I could install everywhere and
after that all my pygtk code could run without problems. Does such a
thing exist?
___
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] Want to start with pygtk, but automake gets in the way

2002-09-26 Thread Grzegorz Adam Hankiewicz

Hi.

I'm a fresh new programmer who would like to get started learning pygtk
for gtk 2.0 under gnu/linux.  So I checked out the cvs code of pygtk
and made sure to get all the required developement debian packages
(libpango1.0-dev, libgtk2.0-dev, etc). Missing is the automake package,
since debian includes 1.5, but autogen.sh looks for version 1.6.

No problem, I installed the source version and now autogen.sh continues,
but drops lot's of warnings:

I am going to run ./configure with no arguments - if you wish
to pass any to it, please specify them on the ./autogen.sh command line.
WARNING: aclocal's directory is /usr/local/share/aclocal, but...
 no file /usr/local/share/aclocal/glib-2.0.m4
 You may see fatal macro warnings below.
 If these files are installed in /some/dir, set the ACLOCAL_FLAGS
 environment variable to -I /some/dir, or install
 /usr/local/share/aclocal/glib-2.0.m4.

WARNING: aclocal's directory is /usr/local/share/aclocal, but...
 no file /usr/local/share/aclocal/gtk-2.0.m4
...blah blah blah...

Now, I have these files, but they are installed in another place:

[gregorio:37] [~/cvs/libs/pygtk]$ locate glib-2.0.m4
/usr/share/aclocal/glib-2.0.m4
[gregorio:38] [~/cvs/libs/pygtk]$ locate gtk-2.0.m4
/usr/share/aclocal/gtk-2.0.m4
[gregorio:39] [~/cvs/libs/pygtk]$ locate gettext.m4
/home/gregorio/instalacion_manual/mutt-1.4/m4/gettext.m4
/mnt/g/cvs/progs/source-navigator-support/gettext.m4
/usr/share/aclocal/gettext.m4
/usr/share/aclocal/glib-gettext.m4

So, looks like automake is looking for the .m4 files only in the
/usr/local/share/aclocal/, when all the packages are in another place. I
expected to force automake look there, but without success: the strange
info manual doesn't seem to tell anything about path configuration (unless
it's about where to put installed files by the generated makefiles).

I guess I will have to make some symlinks, but before I do so, does
somebody know if there's a way to tell automake where to look for
.m4 files?
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/