Re: [pygtk] Change background of selected cell in a TreeView

2009-06-29 Thread Noam Yorav-Raphael
Thanks! However, the link you sent me explains how to change the
background of cells when they are not selected. At least on my system,
the cells have the same (ubuntu orange) background when selected. I'm
looking for a way to change that color.

2009/6/29 Alessandro Dentella :
> On Mon, Jun 29, 2009 at 08:15:19PM +0300, Noam Yorav-Raphael wrote:
>> Hello,
>>
>> TreeViews usually highlight the background of the selected cell. I
>> would like to change that color to white (the background of unselected
>> cells), so that a border would be drawn around the cell but its
>> background won't change.
>>
>> I tried using treeview.modify_bg(gtk.STATE_SELECTED,
>> gdk.color_parse('white')), but it had no effect.
>>
>> Do you have any idea how to do it?
>
> I think this explains what you need:
>
>  http://faq.pygtk.org/index.py?req=show&file=faq13.031.htp
>
> It works for me.
>
> sandro
> *:-)
> ___
> pygtk mailing list   pygtk@daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/
>
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Re: [pygtk] GPollFD/GSource wrappers [was: Re: iosource]

2009-06-29 Thread Martin Schulze
I've got it working!

gobject.Source is not functional - you must derive your own class and
define the functions prepare, check and dispatch. See attached example.

If this is actually intended, the error that's being raised should be a
NotImplementedError. Btw, there doesn't seem to be any documentation
around for the GSource/GPollFD wrappers. (Who cares, as long as it works
- and pygobject/pygtk really rocks ;-) )

Regards,

  Martin




Am Montag, den 29.06.2009, 22:59 +0200 schrieb Martin Schulze:
> Sorry, it should read the "GSource/GPollFD wrappers", not "GIOSource
> wrapper". Also, I should add that I'm using the Linux versions
> 2.16.1/2.14.1 and the Windows versions 2.14.2/2.12.1 of pygobject/pygtk.
> 
> Still, the problem remains unchanged ...
> 
> Regards,
> 
>   Martin
> 
> 
> 
> Am Sonntag, den 28.06.2009, 23:33 +0200 schrieb Martin Schulze:
> > Hello,
> > 
> > I have a problem with the GIOSource wrapper. In the attached test
> > program I'm using either
> > 
> > a) gobject.io_add_watch() or
> > 
> > b) gobject.iosource.add_poll_fd() and gobject.iosource.attach()
> > 
> > to listen on a pipe in the glib main context with the following result:
> > 
> > a) works like a charm (see the dialog being updated every second).
> > 
> > b) just produces the endlessly repeated error output
> > 
> > AttributeError: prepare
> > AttributeError: check
> > 
> > Use "use_poll_fd={False/True}" to switch between a) and b).
> > Can someone guess what's going wrong?
> > 
> > Best Regards,
> > 
> >   Martin
> > 
> > 
> > P.S.: Background: version b) helps me to port the program to win32. I
> > have already implemented an overlapping i/o version of
> > _multiprocessing.PipeConnection (in python using pywin32). I just need
> > to hook the win32 event handle into the glib main context like in
> > version b) of attached code ...
> > 
> > ___
> > pygtk mailing list   pygtk@daa.com.au
> > http://www.daa.com.au/mailman/listinfo/pygtk
> > Read the PyGTK FAQ: http://faq.pygtk.org/
> 
> ___
> pygtk mailing list   pygtk@daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/
#! /usr/bin/env python

import time

import multiprocessing

import gtk
import glib
import gobject



# ---
# background process
# ---

def client (conn_client):
while True:
if conn_client.poll(1):
break
t = time.localtime()
msg = str(t.tm_year) + '-' + str(t.tm_mon) + '-' + str(t.tm_mday) + ', ' + str(t.tm_hour) + ':' + str(t.tm_min) + ':' + str(t.tm_sec)
conn_client.send_bytes(msg)



# ---
# SourceFD
# ---

class SourceFD (gobject.Source):

def __init__(self, fd, callback, check):
gobject.Source.__init__(self)
self.add_poll(fd)
self.fd = fd
self.__callback = callback
self.__check = check

def prepare(self):
return ((self.__check)(), -1)

def check(self):
return (self.__check)()

def dispatch(self, *args, **kw):
return (self.__callback)(*args, **kw)



# ---
# dialog
# ---

class ServerDialog (gtk.Dialog):

def __init__(self, conn_server):
gtk.Dialog.__init__(self, title="Hello World", buttons=(gtk.STOCK_CLOSE,gtk.RESPONSE_ACCEPT))
self.label  = gtk.Label("Last Messages:\nN/A")
self.get_content_area().pack_start(self.label)
self.conn_server = conn_server

def destroy(self):
self.label = None
self.conn_server = None
gtk.Dialog.destroy(self)

def check(self):
return self.conn_server.poll(0)

def process_message(self, *args, **kw):
msg = self.conn_server.recv_bytes()
self.label.set_text("Last Messages:\n" + msg)
return True



# ---
# main program
# ---

if __name__ == '__main__':

use_poll_fd = True   # set to True to stimulate bug

# prepare pipe
conn_server, conn_client = multiprocessing.Pipe()

# create dialog
dialog = ServerDialog(conn_server)

# attach a new io source to the main context
dialog.conn_server = conn_server
if not use_poll_fd:
io_source_server = gobject.io_add_watch(conn_server.fileno(), gobject.IO_IN, dialog.process_message)
else:
poll_fd_server = gobject.PollFD(conn_server.fileno(), gobject.IO_IN)
io_source_server = SourceFD(poll_fd_server, dialog.process_message, dialog.check)
io_source_server.attach(glib.main_context_default())

# start background process
client = multiproc

[pygtk] GPollFD/GSource wrappers [was: Re: iosource]

2009-06-29 Thread Martin Schulze
Sorry, it should read the "GSource/GPollFD wrappers", not "GIOSource
wrapper". Also, I should add that I'm using the Linux versions
2.16.1/2.14.1 and the Windows versions 2.14.2/2.12.1 of pygobject/pygtk.

Still, the problem remains unchanged ...

Regards,

  Martin



Am Sonntag, den 28.06.2009, 23:33 +0200 schrieb Martin Schulze:
> Hello,
> 
> I have a problem with the GIOSource wrapper. In the attached test
> program I'm using either
> 
> a) gobject.io_add_watch() or
> 
> b) gobject.iosource.add_poll_fd() and gobject.iosource.attach()
> 
> to listen on a pipe in the glib main context with the following result:
> 
> a) works like a charm (see the dialog being updated every second).
> 
> b) just produces the endlessly repeated error output
> 
> AttributeError: prepare
> AttributeError: check
> 
> Use "use_poll_fd={False/True}" to switch between a) and b).
> Can someone guess what's going wrong?
> 
> Best Regards,
> 
>   Martin
> 
> 
> P.S.: Background: version b) helps me to port the program to win32. I
> have already implemented an overlapping i/o version of
> _multiprocessing.PipeConnection (in python using pywin32). I just need
> to hook the win32 event handle into the glib main context like in
> version b) of attached code ...
> 
> ___
> pygtk mailing list   pygtk@daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/

___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/


Re: [pygtk] Change background of selected cell in a TreeView

2009-06-29 Thread Alessandro Dentella
On Mon, Jun 29, 2009 at 08:15:19PM +0300, Noam Yorav-Raphael wrote:
> Hello,
> 
> TreeViews usually highlight the background of the selected cell. I
> would like to change that color to white (the background of unselected
> cells), so that a border would be drawn around the cell but its
> background won't change.
> 
> I tried using treeview.modify_bg(gtk.STATE_SELECTED,
> gdk.color_parse('white')), but it had no effect.
> 
> Do you have any idea how to do it?

I think this explains what you need:

  http://faq.pygtk.org/index.py?req=show&file=faq13.031.htp

It works for me.

sandro
*:-)
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/


[pygtk] Change background of selected cell in a TreeView

2009-06-29 Thread Noam Yorav-Raphael
Hello,

TreeViews usually highlight the background of the selected cell. I
would like to change that color to white (the background of unselected
cells), so that a border would be drawn around the cell but its
background won't change.

I tried using treeview.modify_bg(gtk.STATE_SELECTED,
gdk.color_parse('white')), but it had no effect.

Do you have any idea how to do it?

If you are interested, the long story is that I write an IDE - a code
editor which can show a list of completions. If the user requested the
completion list to be shown, pressing enter will copy the selected
item to his text. But the list can also be shown automatically, after
a dot was inserted, and then I don't want Enter to do anything
special, because maybe the user didn't intend to complete from the
list at all. If the user moves around the list to select what he
wants, pressing Enter will of course copy the selected item to the
text. To distinguish between those two states, I would like to use the
selection background.

Thanks,

Noam
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/


[pygtk] gtkunixprint.enumerate_printers - Cant detect all printers.

2009-06-29 Thread Vamsi Krishna Davuluri
Hi,

I don't if i'm doing this wrong, but
I can only get the 'Print To File' gtkunixprint.Printer
Listed. Here's a sample code. Even if I return a
false from the function, all I get is a loop.
Although my gtkunixprint dialog shows all the
listed printers.

import gtkunixprint
import gtk


def function(printers, data):
print printers.get_name()
#print data


def main():
gtk.main()
return 0

if __name__ == "__main__":
gtkunixprint.enumerate_printers(function, None, True)
main()

thanks,
Vamsi
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/