PyGTK + Glade = weird problem

2006-02-24 Thread sapo
Hi all, i ve started learning pygtk with glade, i m just making some
test stuff. but i got some problems with simple things.

I designed 2 windows on glade, then exported it and loaded in the
python script, the second window is hidden by default, then i wrote a
function to show it up, ok it shows, them i wrote another function to
hide it.. ok it hides...

But in the second time i show the window.. the window appear EMPTY,
with just the title and NOTHING inside..

This is well explained here:

http://ubuntuforums.org/showthread.php?p=768219

Hope someone can help me, i tried irc, forums, googled a lot.. but
nothing solves my problem, even rewriting the code by hand results on
the same thing!

thanx for any help

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyGTK + Glade = weird problem

2006-02-24 Thread sapo
Man, you saved my day.

I spent all day writing and rewriting stuff, i asked several times on
the #python channel on irc.freenode.org, asked in the ubuntuforums,
asked all people i know that uses python.. and nobody solved it.

And it was a very simple and stupid thing!

thanx a lot it worked perfectly!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyGTK + Glade = weird problem

2006-02-24 Thread sapo
Anyway, now i tried in my glade app and i m getting this error when i
try to show the window:

GtkWarning: gtk_paint_flat_box: assertion `style->depth ==
gdk_drawable_get_depth (window)' failed

here is the code:

class main:
def __init__(self):
self.principal = gtk.glade.XML("scc.glade")
self.w_cadcli = self.principal.get_widget("w_cadcli")
dic = {"on_principal_destroy" : self.DestroyFunction,
   "on_sair_activate" : self.DestroyFunction,
   "on_w_cadcli_destroy" : self.show_hide_window,
   "on_cadcli_activate" : self.show_hide_window}
self.principal.signal_autoconnect(dic)
principal = self.principal.get_widget("principal")
gtk.main()

def DestroyFunction(self,*args):
gtk.main_quit()

def show_hide_window(self,obj,event=None):
#if the second window is open hide it, if dont show it
if self.w_cadcli.get_property("visible") == True:
self.w_cadcli.hide()
else:
self.w_cadcli.show()
return True

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyGTK + Glade = weird problem

2006-02-25 Thread sapo
Finally solved this stuff, the problem wasnt with glade, the problem
was that i was using the "destroy" event in glade, i just changed the
"destroy" to "delete-event" and it worked like a charm.

thanx :)

-- 
http://mail.python.org/mailman/listinfo/python-list


Editable lists in pygtk - Editing wrong cell

2006-02-25 Thread sapo
Hi all, i m trying to make an editable list with a toggle button, it
shows up and i can edit the list.. but its editing the wrong cell!

If i click on the toggle button on the first cell it sets FALSE on the
last cell of that row, if i change the text of the last cell if changes
another cell text... here is my code:

tree = self.principal.get_widget("file_list")
list = gtk.ListStore(str, str)
#Permite selecionar os arquivos
toggle = gtk.CellRendererToggle()
toggle.set_property('activatable', True)
tree.insert_column_with_attributes(-1, "Convert?", toggle)
toggle.connect('toggled', self.Select, tree)
#permite editar a lista
renderer = gtk.CellRendererText()
renderer.set_property( 'editable', True )
renderer.connect('edited', self.Edit, list)
tree.insert_column_with_attributes(-1, "Artist", renderer, text=0)
tree.insert_column_with_attributes(-1, "Song", renderer, text=1)
tree.set_model(list)

  def Select(self,cell,path,model):
model[path][1] = not model[path][1]
return
  def Edit(self, cell, path, new_text, model):
model[path][0] = new_text

What's wrong with it? i m following this example:
http://pygtk.org/pygtk2tutorial/sec-CellRenderers.html#EditableTextCells

thanx in advance

-- 
http://mail.python.org/mailman/listinfo/python-list


Toggle button in a ListStore in pygtk, i cant make it work!

2006-03-12 Thread sapo
This is my code:

def list(self):
tree = self.principal.get_widget("list")
self.list = gtk.ListStore(bool,str)
self.options = [1,"programa1"]

renderer1 = gtk.CellRendererToggle()
renderer1.set_property('activatable', True)
renderer1.connect( 'toggled', self.selection, self.list)
tree.insert_column_with_attributes(0, "Select",renderer1)

renderer2 = gtk.CellRendererText()
tree.insert_column_with_attributes(1,"Install",renderer2, 
text=1)
self.list.append(self.options)
tree.set_model(self.list)

def selection( self, cell, path, model ):
model[path][0] = not model[path][0]
return

It shows up but the toggle button isnt working! what is wrong with
this?

I m following this example:

http://pygtk.org/pygtk2tutorial/sec-CellRenderers.html#sec-EditableActivatableProgram

Thanx for any help!

-- 
http://mail.python.org/mailman/listinfo/python-list