Re: [pygtk] A few quickies (IMPORTANT)

2000-11-02 Thread James Henstridge

On 3 Nov 2000, Hassan Aurag wrote:

>  Hi,
> 
>  I'm writing a tool for internal use. Anyway, I build up a GtkCTree
> containing info and where to find that info in the file (the char
> positions) on a text file that I display in a GtkText. 
> 
>  The goal is to be able to click on a tree node and "jump" to its place
> in the text file. Grabbing the info and connecting to the selection
> event goes normal, but there are some problems
> 
>  I know GtkText is going to die, but for it's the only one I can use.
> Anyway, I'll shoot my quickies:
> 
> 1- For some unknown reason, insert_defaults(text) would change the
> format of my text. Do you know why and how to prevent this? As far as I
> guess, it has to do with empty spaces. And btw, there are no tabs in my
> text file. I read the file using python and it prints ok (the read text)
> on anything from terminal to emacs ... but not in the damn widget.

The other option would be to use the insert_text() method inherited from
the GtkEditable interface.  It might work better for you.

> 
> 2-When I use set_position (or the other one, can't remember) to jump, it
> jumps ok for the top parts of the file but fails miserably later. I
> think it may have to do with point 1. The crazy part is that it still
> reports the correct position and when I print that part of the string on
> Python nothing is wrong, but all is in the widget. Any help?

I don't know about this one.

> 
> 3-What is a GdkColor? How can I get red, white, black ... and turn it
> into a GdkColor?

A GdkColor represents a colour :).  You can create colours with a
GdkColormap (such as the one returned by widget.get_colormap()).  You just
call its alloc() method:
  colour = cmap.alloc("red")
or:
  colour = cmap.alloc(0x, 0, 0)

James.


___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk



Re: [pygtk] Preventing a GTK Window from being closed

2000-11-02 Thread mpj17

"Kohli, Ranjan" wrote:
> 
> Hi, I did try not connecting to the destroy signal, the consequence of that
> was that on clicking the dismiss window icon, the window still disappears.
> 
self.window.connect("delete_event", destroy_cb)
self.window.connect("destroy", destroy_cb)
def destroy_cb(self, *args):
return 1


Why, in the name of all that is good and pure, would you want to do this
|:-}?
-- 
Michael JasonSmithhttp://www.cosc.canterbury.ac.nz/~mpj17/

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk



[pygtk] A few quickies (IMPORTANT)

2000-11-02 Thread Hassan Aurag



 Hi,

 I'm writing a tool for internal use. Anyway, I build up a GtkCTree containing info and where to find that info in the file (the char positions) on a text file that I display in a GtkText. 

 The goal is to be able to click on a tree node and "jump" to its place in the text file. Grabbing the info and connecting to the selection event goes normal, but there are some problems

 I know GtkText is going to die, but for it's the only one I can use. Anyway, I'll shoot my quickies:

1- For some unknown reason, insert_defaults(text) would change the format of my text. Do you know why and how to prevent this? As far as I guess, it has to do with empty spaces. And btw, there are no tabs in my text file. I read the file using python and it prints ok (the read text) on anything from terminal to emacs ... but not in the damn widget.

2-When I use set_position (or the other one, can't remember) to jump, it jumps ok for the top parts of the file but fails miserably later. I think it may have to do with point 1. The crazy part is that it still reports the correct position and when I print that part of the string on Python nothing is wrong, but all is in the widget. Any help?

3-What is a GdkColor? How can I get red, white, black ... and turn it into a GdkColor?


Thanks a lot for reading thus far ;)
-- 
--
--
Hassan Aurag
--
CAE Electronics Ltd |   Universite de Montreal
System update specialist|   Centre de Recherches Mathematiques
++
Maximum Linux Magazine  |   Universite de Montreal
Contributing Editor |   Departement de Maths/Stat
++
EMAIL:  [EMAIL PROTECTED]
--
--

Drew's Law of Highway Biology:
The first bug to hit a clean windshield lands directly in front
of your eyes.
--



Re: [pygtk] Switching pixmaps using GtkPixmap.set()

2000-11-02 Thread Martin Grimme

> This looks like a bug in pygtk.  You should be able to fix it by editing
> generate/gtkmisc.defs, and finding the following section:
> (define-func gtk_pixmap_set
>   none
>   ((GtkPixmap pixmap)
>(GdkPixmap val)
>(GdkBitmap mask)))

> and change it to:
> (define-func gtk_pixmap_set
>   none
>   ((GtkPixmap pixmap)
>(GdkPixmap val)
>(GdkBitmap mask (null-ok

Another way without hacking into pygtk and thus making your program incompatible for
the rest of the world would be to check if Imlib returns None for the mask.
If this happens, you can create a mask by yourself:

  width, height = (img2.rgb_width, img2.rgb_height)
  mask = create_pixmap(None, width, height, 1)
  gc = mask.new_gc()
  gc.foreground = GdkColor(0, 0, 0, 0)
  draw_rectangle(mask, gc, TRUE, 0, 0, width, height)

This is the way I handle this.

Martin Grimme - http://www.pycage.de



___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk



[pygtk] Threading problem using pygtk on Win32

2000-11-02 Thread Alexandre Fayolle

Hello,

I'm using happily pygtk to develop Horn the user interface for Narval
(http://www.logilab.org). It runs very well under Linux, but I'm having
big troubles getting something under Windows. It looks like there's
something wrong with the thread support in pygtk win32 edition. I checked
Hans Breuer patch over pygtk 0.6.4 and it does look like there's a known
issue with threading in the patch, from the comments I saw. 

If we cut down to the skeletton of the app, the implementation is
something equivallent to:

--8<---
from gtk import mainloop, timeout_add
import time
import thread,Queue

queue = Queue.Queue(10)

def ping_thread():
while 1:
t = time.time()
print 'ping',t
queue.put_nowait(t)
time.sleep(0.7)


def pong():
try:
while 1:
t0 = queue.get_nowait()
t1 = time.time()
print 'pong',t1, t1-t0
except:
return 1

thread.start_new_thread(ping_thread,())
timeout_add(1000,pong)
mainloop()
-8<


This works fine under linux, but under windows (winnt4.0, runnning on a
P133), I get pongs comming with a  9 seconds lag. So my question is:
 * is it just because my NT box is waay to slow ?
 * has it something to do with lines 31-32 of the patch which state:
+#if defined (_MSC_VER)
+#undef WITH_THREAD /* no thread support on win32 yet */

In that case what would be required to implement the thread support on
win32 ? I'm not yet very familiar with the innards of the python bindings
of gtk nor with the win32 port of GTK+, but I'm ready to get my shirt wet,
since I really need this feature. Any help/suggestion welcome.

Alexandre Fayolle
-- 
http://www.logilab.com 
Narval is the first software agent available as free software (GPL).
LOGILAB, Paris (France).


___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk