[pygtk] gnome application

2003-12-12 Thread doug . blanding

I would like to write a gnome application using gnome-python (without glade) but I havn't been able to find any examples or documentation showing how to do it. I can only find examples from a couple years ago, showing how it used to be done the old way with the earlier version of pygtk and with the deprecated  from foo import *  statements. The reason I want to go through this without glade is to have a better understanding of what is going on under the hood. Can anyone point me to some example code or documentation showing how to do this? 

--Doug Blanding___
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] gnome application

2003-12-12 Thread doug . blanding

On Fri, 2003-12-12 at 14:21, [EMAIL PROTECTED] wrote:
 I would like to write a gnome application using gnome-python (without
 glade) but I havn't been able to find any examples or documentation
 showing how to do it. I can only find examples from a couple years
 ago, showing how it used to be done the old way with the earlier
 version of pygtk and with the deprecated  from foo import * 
 statements. The reason I want to go through this without glade is to
 have a better understanding of what is going on under the hood. Can
 anyone point me to some example code or documentation showing how to
 do this? 
 
 --Doug Blanding

Get pygtk tarball and have a look at the example dir (esp pygtk-demo).

Regards,
Xavier Ordoquy.

Xavier-
Thanks for your suggestion. You are right. There is an example there called appwindow.py which builds an application window pretty much like what I want, complete with menubar, toolbar and statusbar. But I am thinking there is a call to gnomeui.App (or something like that) which creates the application window automatically (complete with menubar, toolbar and statusbar). According to some old documentation I read, you used to be able to do this. But now with pygtk2 and the new python-gnome, I haven't seen any examples or documentation to show how to do it.
--Doug Blanding

___
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] gnome application

2003-12-12 Thread Xavier Ordoquy

 Thanks for your suggestion. You are right. There is an example there
 called appwindow.py which builds an application window pretty much
 like what I want, complete with menubar, toolbar and statusbar. But I
 am thinking there is a call to gnomeui.App (or something like that)
 which creates the application window automatically (complete with
 menubar, toolbar and statusbar). According to some old documentation I
 read, you used to be able to do this. But now with pygtk2 and the new
 python-gnome, I haven't seen any examples or documentation to show how
 to do it.
 --Doug Blanding

Well, gnome windows are usually avoided by most developpers. You should
consider using bonobo windows instead.
In gnome-python tarball, it's in examples/bonobo/bonoboui

Regards,
Xavier Ordoquy.


___
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] gnome application

2003-12-12 Thread doug . blanding

 Thanks for your suggestion. You are right. There is an example there
 called appwindow.py which builds an application window pretty much
 like what I want, complete with menubar, toolbar and statusbar. But I
 am thinking there is a call to gnomeui.App (or something like that)
 which creates the application window automatically (complete with
 menubar, toolbar and statusbar). According to some old documentation I
 read, you used to be able to do this. But now with pygtk2 and the new
 python-gnome, I haven't seen any examples or documentation to show how
 to do it.
 --Doug Blanding

 Well, gnome windows are usually avoided by most developpers. You should
 consider using bonobo windows instead.
 In gnome-python tarball, it's in examples/bonobo/bonoboui

 Regards,
 Xavier Ordoquy.

Oh, OK. Thanks, I didn't know that.
I have tried the bonoboui example and played with it a little. It certainly seems to provide a nice UI. I guess I was just afraid of it because I don't know anything about bonobo (what it is or why I need it).
I suppose I'll just need to learn more about bonobo windows. Thanks.

--Doug Blanding

___
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] gnome application

2003-12-12 Thread Murray . Cumming
 Well, gnome windows are usually avoided by most developpers. 
 You should consider using bonobo windows instead. In 
 gnome-python tarball, it's in examples/bonobo/bonoboui

No, I think that most people are trying to use BonoboUI as little as
possible. The new menu and toolbar APIs in GTK+ 2.4 are meant to replace
- The old GTK+ menus and toolbars
- The libgnomeui menus and toolbar
- The libbonoboui menus and toolbars.

This is all my opinion, but I think you should just use libbonoboui if you
want to create an embeddable GUI component, or us libbonobo if you want to
do some difficult multi-threading interprocess-communication stuff.

Murray Cumming
www.murrayc.com
[EMAIL PROTECTED]
___
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[2]: [pygtk] High CPU problem example

2003-12-12 Thread Alejandro David Weil
Hi!

I'm not sure what's your problem but I had have one of your problems:

The create_pango_layout is not supposed to be called all the time..
For that, my class caches the layout:

class Message:
def __init__(self, msg):
 We are expecting unicode message strings 
self.msg = msg.encode('utf-8')
# create a font description
self.font_desc = pango.FontDescription('Serif 8')

def _make_layout (self, widget):
global wrapmode, wrapwidth
# create a layout for your drawing area
self.layout = widget.create_pango_layout(self.msg)
self.layout.set_wrap(wrapmode)
self.layout.set_width(wrapwidth)
# tell the layout which font description to use
self.layout.set_font_description(self.font_desc)

def _make_cache(self, gc):
 This method doesn't seems to be fundamental, but..  
global depth
#self.image = string.join(self.mx*3*self.my*['\0'],)
#self.image = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, 
self.mx, self.my)
self.image = gtk.gdk.Pixmap(None, self.mx, self.my, depth)

self.gc = gc
colormap = gc.get_colormap()
white = colormap.alloc_color('white')
yellow = colormap.alloc_color('yellow')
black = colormap.alloc_color('black')

gc.set_rgb_fg_color (yellow)
self.image.draw_rectangle(gc, gtk.TRUE, 0,0, self.mx-1, self.my-1)
gc.set_rgb_fg_color (black)
self.image.draw_rectangle(gc, gtk.FALSE,0,0, self.mx-1, self.my-1)
gc.set_rgb_fg_color (black)

# draw the text with the draw_layout method
self.image.draw_layout(self.gc, Message.BORDER_SIZE, 
Message.BORDER_SIZE, self.layout)

def drawon(self, atx, aty, widget=None, gc=None):
if not self.widget:
if not widget or not gc:
return
else:
self._make_layout(widget)
self.widget = widget
self._make_cache(gc)

# draw the text with the draw_layout method
#widget.window.draw_layout(gc, atx, aty, self.layout)
#self.image.render_to_drawable (widget.window, gc, 0, 0, atx,aty, 
self.mx, self.my, gtk.gdk.RGB_DITHER_MAX, 0, 0)
widget.window.draw_drawable(self.gc, self.image, 0, 0, atx, aty, 
self.mx, self.my)


This creates the layout and dumps it, with a frame into a pixmap that's
later used to be draw anytime.

I removed some code, but that should be enough.
It's from the class Message of IMFish(.sourceforge.net) :-)

Also, i think that you should setup what font do you want
to use, in other place, than the expose-cb!

Seeya!

-Original Message-
From: Jean-Baptiste Cazier [EMAIL PROTECTED]
To: Gustavo J. A. M. Carneiro [EMAIL PROTECTED]
Date: Fri, 12 Dec 2003 17:38:46 +
Subject: Re: [pygtk] High CPU problem example

Hello Gustavo !

Thanks for your answer.
Your solution works fine for my simplified problem. It also pin-point the source of 
my troubles.
But in order to solve my original problem I need a further tip:
Indeed If I actually draw something based on the modified font by adding the line
area.window.draw_layout(self.gc, 10, 10, 
 self.area.create_pango_layout(TEXT))
Nothing is drawn at all if moved to the area_realize_cb routine.

In my real area_expose_cb routine I draw many things with various fonts that are 
set-up in other windows
For example I call draw_axes_s which uses 2 types of fonts.

def draw_axes_s(self, xo, yo, xs, ys ):
   Draw axis and write down the labels on the screen

  win=self.area.window
  mini=self.Cld.mini
  maxi=self.Cld.maxi
  mindist=self.Cld.mindist
  markers=self.Cld.markers
  location=self.Cld.location
  f_mrkX=markers[0][0]
  l_mrkX=markers[0][len(markers[0])-1]
  f_mrkY=markers[1][0]
  l_mrkY=markers[1][len(markers[1])-1]
  
 xsize=min(max(float(xs)/(maxi[0]-mini[0])*mindist[0]*.9,self.min_size),self.max_size)
  
 ysize=min(max(float(ys)/(maxi[1]-mini[1])*mindist[1]*.9,self.min_size),self.max_size)
#  Draw the lines
  self.gc.foreground =self.area.get_colormap().alloc_color(black)
  win.draw_line(self.gc, xo, yo, xo+xs, yo)
  win.draw_line(self.gc, xo, yo, xo, yo-ys)
  #Draw ticks
  for m in markers[0]:
col=(location[0][m]-mini[0])/(maxi[0]-mini[0])
win.draw_line(self.gc, xsize/2+xo+col*(xs-xsize), 
 yo,xsize/2+xo+col*(xs-xsize),yo+3 )
  for m in markers[1]:
col=(location[1][m]-mini[1])/(maxi[1]-mini[1])
win.draw_line(self.gc, xo,-ysize/2+yo-col*(ys-ysize), xo-3, 
 

RE: [pygtk] gnome application

2003-12-12 Thread doug . blanding

 Well, gnome windows are usually avoided by most developpers. 
 You should consider using bonobo windows instead. In 
 gnome-python tarball, it's in examples/bonobo/bonoboui

 No, I think that most people are trying to use BonoboUI as little as
 possible. The new menu and toolbar APIs in GTK+ 2.4 are meant to replace
 - The old GTK+ menus and toolbars
 - The libgnomeui menus and toolbar
 - The libbonoboui menus and toolbars.

 This is all my opinion, but I think you should just use libbonoboui if you
 want to create an embeddable GUI component, or us libbonobo if you want to
 do some difficult multi-threading interprocess-communication stuff.

OK, but now I still have my original question.
Can an application window be built using a call to gnomeui.App which will automagically give me the consistent and slick look and feel of a Gnome Application (menubar, dockable toolbar, etc) using a simple command or two like in the bonoboui example? (And if so, can anyone point me to some documentation or example code showing how?)

I also now have another question: What is it that most developpers know that causes them to want to avoid Gnome windows? Maybe if I knew that, I wouldn't be asking the first question.
--Doug Blanding

___
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] gnome application

2003-12-12 Thread Xavier Ordoquy
On Fri, 2003-12-12 at 18:55, [EMAIL PROTECTED] wrote:
 I also now have another question: What is it that most developpers
 know that causes them to want to avoid Gnome windows? Maybe if I knew
 that, I wouldn't be asking the first question.
 --Doug Blanding

For what I can see gnumeric, planner (ex mrproject), evolution, abiword,
nautilus, ghex, file-roller and a couple of other apps uses that bonobo
window. Some uses bonobo for embedding but not all.

Now, I missed that improvement in gtk 2.4 so that may make sense to
think about it twice.


___
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] gnome application

2003-12-12 Thread Gustavo J. A. M. Carneiro
A Sex, 2003-12-12 às 15:20, [EMAIL PROTECTED] escreveu:
  Well, gnome windows are usually avoided by most developpers. 
  You should consider using bonobo windows instead. In 
  gnome-python tarball, it's in examples/bonobo/bonoboui
 
 No, I think that most people are trying to use BonoboUI as little as
 possible. The new menu and toolbar APIs in GTK+ 2.4 are meant to replace
 - The old GTK+ menus and toolbars
 - The libgnomeui menus and toolbar
 - The libbonoboui menus and toolbars.
 
 This is all my opinion, but I think you should just use libbonoboui if you
 want to create an embeddable GUI component, or us libbonobo if you want to
 do some difficult multi-threading interprocess-communication stuff.

  You are correct. However, pygtk doesn't yet wrap the new gtk+ 2.4 menu
APIs, so the better choice right now is still bonoboui.

  Regards.

-- 
Gustavo J. A. M. Carneiro
[EMAIL PROTECTED] [EMAIL PROTECTED]

___
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] gnome application

2003-12-12 Thread Siegmund Fuhringer
hi

there is a good tutorial for pygtk2 at:
http://www.moeraki.com/pygtktutorial/pygtk2tutorial/

but i don't know any for gnome-python


lg / sifu

On Fri, Dec 12, 2003 at 08:21:43AM -0500, [EMAIL PROTECTED] wrote:
 
 I would like to write a gnome application using gnome-python (without
 glade) but I havn't been able to find any examples or documentation
 showing how to do it. I can only find examples from a couple years ago,
 showing how it used to be done the old way with the earlier version of
 pygtk and with the deprecated  from foo import *  statements. The
 reason I want to go through this without glade is to have a better
 understanding of what is going on under the hood. Can anyone point me
 to some example code or documentation showing how to do this?
 
 --Doug Blanding

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



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