Re: [pygtk] How to get widget size?

2000-08-28 Thread acano

On Mon, 28 Aug 2000 11:16:28 -0400, Matt Wilson [EMAIL PROTECTED] wrote:
 call the widget's "size_allocation()" method.  This will only give you
 good data after the allocation step has been done for the widget.

Isn't that only for setting the size?

I'd assumed that pygtk didn't have something like this
widget-allocation.width/height/x/y

and have been using a little C binding to get this.

 
 Matt
 
 On Mon, Aug 28, 2000 at 03:42:11PM +0200, Martin Grimme wrote:
  Hello,
  
  I want to get the current size of a container widget (like GtkHBox or GtkLayout).
  Is there any possibility to get these values at runtime?
  
  I can get the size of a window by using the configure-event, but this doesn't seem
  to work for other widgets...
  
  Please help me!
  
  Bye,
  Martin Grimme
  
  
  ___
  pygtk mailing list   [EMAIL PROTECTED]
  http://www.daa.com.au/mailman/listinfo/pygtk
 
 ___
 pygtk mailing list   [EMAIL PROTECTED]
 http://www.daa.com.au/mailman/listinfo/pygtk
 


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



Re: [pygtk] Style

2000-08-24 Thread acano

On Thu, 24 Aug 2000 11:45:16 +0200, Javi Roman [EMAIL PROTECTED] wrote:
 After of fighting much I have managed to control the progress bar 
 (thanks to the people that helped me). Now I have the following 
 problem: I want to change the color of the bar. I have tried all 
 type of combinations of styles and I have not obtained it.
 Since I can do it? 
 
 mycolor = 'blue' # for instance
 
   self.progress = GtkProgressBar ()
   style = self.progress.get_style ().copy ()
   color = self.progress.get_colormap().alloc(mycolor)
   style.base[STATE_ACTIVE] = color
   self.progress.set_style (style) 
 
 
 So what´s the suitable combination to change the color of the bar?
 
 ___
 pygtk mailing list   [EMAIL PROTECTED]
 http://www.daa.com.au/mailman/listinfo/pygtk
 

When in doubt:

style = self.progress.get_style().copy ()
color = self.progress.get_colormap().alloc (mycolor)
for i in range (5):
style.bg[i] = mycolor
style.fg[i] = mycolor
style.base[i] = mycolor
self.progress.set_style (style)


After a process of elimination it turns out that
style.bg[STATE_PRELIGHT] = mycolor 
seemed to change it... go figure.


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



Re: [pygtk] I need help about progress bar.

2000-08-22 Thread acano

On Tue, 22 Aug 2000 11:23:47 +0200, Javi Roman [EMAIL PROTECTED] wrote:
 Profit not to understand the operation of the progress bar. 
 Somebody to indicate to me as it would be the code to
 implement the following thing: Simply I want that when 
 pressing "button2" the progress bar is increased in a 10% for example. 
 
 --- BEGIN-CODE
 
 def create_progress_bar():
   win = GtkDialog()
   win.set_position (WIN_POS_CENTER)
   win.set_policy(FALSE, FALSE, TRUE)
   win.set_title("Progress Bar")
 
   vbox = GtkVBox(spacing=5)
   vbox.set_border_width(10)
   win.vbox.pack_start(vbox)
 
   label = GtkLabel("Undating ...")
   label.set_alignment(0, 0.5)
   vbox.pack_start(label, expand=FALSE)
 
   pbar = GtkProgressBar()
   pbar.set_usize(225, 20)
   vbox.pack_start(pbar)

You need a "static" variable holding the update value so that
the bar keeps exapanding.  Ugly hack:

update_val = 0.10
pbar.set_data ("update_val", update_val)

def updateBar(_button2, pbar=pbar): 
update_val = pbar.get_data ("update_val")
pbar.update(update_val) 
update_val = update_val + 0.10
pbar.set_data ("update_val", update_val)
 
   def updateBar(_button2, pbar=pbar): # bad code
   pbar.update(0.15)   # bad code
   
   button = GtkButton("close")
   button2 = GtkButton("Update") 
   button.connect("clicked", win.destroy)
   button2.connect("clicked", updateBar)
   win.action_area.pack_start(button)
   win.action_area.pack_start(button2)
   button.set_flags(CAN_DEFAULT)
   button.grab_default()
   win.show_all()
 
 END-CODE
 
 Sincerely:  thank you very much
 
 ___
 pygtk mailing list   [EMAIL PROTECTED]
 http://www.daa.com.au/mailman/listinfo/pygtk
 


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



Re: [pygtk] cschtml

2000-08-05 Thread acano

On Sat, 05 Aug 2000 01:55:53 +0200, Tom Cato Amundsen [EMAIL PROTECTED] wrote:
 Has anyone on this list considered making python bindings
 for cschtml, http://www.cscmail.net/cschtml? It is the
 (IMO wrongly named) GtkHTML widget ported to Gtk, without
 depending on all the gnome libs.
 
 Tom Cato
 
 ___
 pygtk mailing list   [EMAIL PROTECTED]
 http://www.daa.com.au/mailman/listinfo/pygtk
 

(python-cschtml)
http://freshmeat.net/appindex/2000/07/03/962622187.html


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



RE : [pygtk] gdk-pixbuf bindings

2000-08-03 Thread acano

On Thu, 03 Aug 2000 15:04:13 +0200 (MEST), [EMAIL PROTECTED] wrote:
 Fine ! Just two (three) questions : 
 1/ Will it be eventually part of standard pygtk/pygnome distro ?

No, pygtk will have its own, correct, version :)

 2/ Is / Will GdkPixBuf CanvasItem supported ?

Nope, I've never used the gnome canvas and I didn't know what
to do with the gdk-pixbuf canvas item.

 3/ Rpms / x86 binairies ?

Sorry, I don't know how to do autoconf/automake/rpms/etc... :(
All that's there is the code, some examples/tests, and a Makefile.


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


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



[pygtk] gdk-pixbuf bindings

2000-08-01 Thread acano


I made python/pygtk bindings for gdk-pixbuf.  It's the first time
I've worked with the Python C-API, so... it probably sucks badly, :)
but should be good enough if you just want to play around.

http://users.systec.com/acano/pygdkpixbuf.tar.gz


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



Re: [pygtk] RE: Loading PNGs

2000-07-31 Thread acano

On Mon, 31 Jul 2000 10:29:55 +0200, Javi Roman [EMAIL PROTECTED] wrote:
  I have the following code:
 
  from gtk import *
 
  rcfile = """
  pixmap_path "/home"
  style "back" {
 bg_pixmap[NORMAL] = "image.xpm"
  }
  widget "*mystyle" style "back"
  """
 
  Everything works correctly. But the load of the image is very slow,
  therefore I have tried to use the following thing:
 
  from gtk import *
 
  rcfile = """
  pixmap_path "/home"
  style "back" {
 bg_pixmap[NORMAL] = "image.png"
  }
  widget "*mystyle" style "back"
  """
 
  It does not load the PNG image, why?.
  In other programs I have seen that they load PNG images without
  problems.

Note: I don't know much about the gtk rc stuff.

I think what you've seen the other programs use is a gtk-theme-engine,
not the "regular" rc parsing.  

I've never gotten that crap to work, you have to do some garbage like
this (example doesn't work):

#!/usr/bin/python
from gtk import *

rcfile = """
pixmap_path "/home/mnt/acano/src/pygtk/rcfile"
module_path "/usr/lib/gtk/themes/engines"
style "back" {
#bg_pixmap[NORMAL] = "image.png"
engine "pixmap" {
image {
function= BOX
recolorable = TRUE
detail  = "button"
state   = NORMAL
shadow  = IN
file= "image.png"
border  = { 3, 3, 3, 3 }
stretch = TRUE

}
}
}

widget "main window.*GtkButton*" style "back"
#class "GtkWidget" style "default"

#widget "*mybutton" style "back"
#widget "*mystyle" style "back"
"""

rc_parse_string (rcfile)
win = GtkWindow ()
win.connect ("destroy", mainquit)
#win.set_name ("mystyle")
win.set_usize (200, 200)

button = GtkButton ("test")
#button.set_name ("mytest")
win.add (button)

win.show_all ()
mainloop ()



 
 
 
  I have received silence by answer. It is that I have asked a
 triviality?
 
 ___
 pygtk mailing list   [EMAIL PROTECTED]
 http://www.daa.com.au/mailman/listinfo/pygtk
 
 


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



Re: [pygtk] PyGtk drag n drop and reparenting

2000-07-18 Thread acano

On Tue, 18 Jul 2000 09:29:47 +0200, MOULET Xavier FTRD/DMR/ISS 
[EMAIL PROTECTED] wrote:
 Hello everybody. As I told in my last email, I spennt another night on this
 and could not find what was causing any trouble. The following program
 should let me drag a node over another, and then the dragged node becomes a
 child of the other one. drag_data_set were methods of my node object, which
 led to many segfaults. Now, I placed them away but I still have problems.
 
 I pass a string to look up at which node is passed, as you can only pass
 strings in a drag data I think. My problem is, the dragged data disappears,
 the other ones remain as they were and a gtk warning appears. What do I
 wrong ? can someone cast some light on me ?
 
 -- Beginning of the "program"
 
 
 # Sample gnome-python prog
 
 # Imports
 from gtk import *
 import GDK
 import GTK
 
   
 def drag_data_get (widget,context,data,info,time,user) :
   data.set(data.target,123,user)
 
 def drag_data_rec (widget,context,x,y,data,info,time,user) :
   if user == data.data :
   # drags over myself : do nothing
   widget.drag_finish(context,FALSE,FALSE,time)
   else :  
   noeud = app.nodes[data.data]   # Look up the dragged
 (incoming) node
   noeud.gtknode.drag_finish(context,TRUE,TRUE,time)
 
   me = app.nodes[user] # who has it been dragged to ? (whoami
 ?)
   
   # if no tree, create one
   if me.subtree==None :
   me.subtree = GtkTree()
   me.subtree.show()
   noeud.gtknode.set_subtree(me.subtree)
   
   noeud.gtknode.reparent(me.subtree)
   noeud.gtknode.show()

I think you might have the source and destination mixed up.

try -
# if no tree, create one
if me.subtree == None:
me.subtree = GtkTree ()
me.subtree.show ()
#noeud.gtknode.set_subtree(me.subtree)
widget.set_subtree (me.subtree) # widget is where you are
   
 # dragging to

#noeud.gtknode.reparent(me.subtree)
#noeud.gtknode.show()

# remember to remove the item you drag, that caused the
# gtk warning.
# noeud.gtknode is the item you are dragging, and 'tree' is
# the original tree you created in App.__init__()
global tree
tree.remove_item (noeud.gtknode)
me.subtree.append (noeud.gtknode)


there's also some changes to class App -

 # my main node class.
 class UI_Node :
 
def __init__ (self, label="Unknown") :
   self.label = label
 
   self.subtree = None
 
   self.gtknode = GtkTreeItem(self.label)
   self.gtknode.show()
   
   # Drag interface
   target = [('GLOOPNODE',0,-1)]
   
 self.gtknode.drag_source_set(GDK.BUTTON1_MASK,target,GDK.ACTION_COPY)
   
 self.gtknode.connect("drag_data_get",drag_data_get,self.label)
   
   # Drop interface
   
 self.gtknode.connect("drag_data_received",drag_data_rec,self.label)
   
 self.gtknode.drag_dest_set(GTK.DEST_DEFAULT_ALL,target,GDK.ACTION_COPY)
   
 class App :
   def __init__(self):
   self.window = GtkWindow();
   self.window.connect("destroy",mainquit)
 

global tree


   self.tree = GtkTree()

tree = self.tree


   self.window.add(self.tree)
   self.window.show_all()  
 
   self.nodes = {} # Nodes : a dictonnary, keys are names of
 nodes, then node is given
 
 
   def append(self,node) :
   self.nodes[node.label] = node 
   self.tree.append(node.gtknode)  
 
   def main (self) :
   self.append(UI_Node("foo1"))
   self.append(UI_Node("foo2"))
   self.append(UI_Node("foo3"))
   self.append(UI_Node("foo4"))
   
   
 if __name__ == '__main__' :
   global app
   app = App()
   app.main()
 
   mainloop()
   
 # dragging a node to another makes : 
 # Gtk-CRITICAL **: file gtkwidget.c: line 2933
 (gtk_widget_reparent_container_child): assertion `client_data != NULL'
 failed.
 # and the dragged widget disappears.
 
 ___
 pygtk mailing list   [EMAIL PROTECTED]
 http://www.daa.com.au/mailman/listinfo/pygtk
 



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



Re: [pygtk] Clist append without data

2000-07-02 Thread acano

On Sat, 01 Jul 2000 00:49:43 -0700, "Scott F. Johnston" [EMAIL PROTECTED] 
wrote:
 Does anybody have a patch to allow a GtkCList's "append" method
 to be called with "NULL" which would add the row with no data?
 
 The 0.6.6 *_wrap_gtk_clist_append requires a sequence object.
 Not passing an argument would be a good trigger for this.
 
 Also, I can't find any /good/ tutorial information on GC's
 and styles. gtk.org information is fragmentary at best.
 I can't get a bg_pixmap to appear behind the cells of my clist.
 
 TIA,
 
 S
 
 ___
 pygtk mailing list   [EMAIL PROTECTED]
 http://www.daa.com.au/mailman/listinfo/pygtk
 
 

maybe something like this:

from gtk import *

class MyCList (GtkCList):
def __init__ (self, cols=1, titles=None, _obj=None):
self.number_of_columns = cols
GtkCList.__init__ (self, cols, titles, _obj)

def append (self, values=None):
if values == None:
empty_values = []
for i in range(self.number_of_columns):
empty_values.append ("")
GtkCList.append (self, empty_values)
else:
GtkCList.append (self, values)

# testing
win = GtkWindow ()
win.connect ("destroy", mainquit)

#clist = GtkCList (3, ("ColumnOne", "ColumnTwo", "ColumnThree"))
clist = MyCList (3, ("ColumnOne", "ColumnTwo", "ColumnThree"))
clist.append (("a", "b", "c"))
clist.append (("", "", "")) # usual way
clist.append (("d", "e", "f"))
clist.append () # the way you like it :)
clist.append (("g", "h", "i"))

win.add (clist)
win.show_all ()
mainloop ()


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