Re: [pygtk] get_active() of CheckButton added to ScrolledWindow

2009-01-20 Thread Walter Leibbrandt
Hi,

Firstly, on a conceptual note, "self.window" is not really an accurate 
name for the glade.XML object created. It does not represent any one 
window, but rather the whole GUI (windows and widgets) created in Glade. 
You can see the glade.XML object as a factory object, taking the XML 
output from the Glade UI designer ("check.glade" in your case) as input 
and giving you the constructed widgets as output.

Having said that, there is no way for the glade.XML object to know about 
widgets that were created at run-time and not specified in its input XML 
and that is why self.window.get_widget("test") returns None. Also the 
string you passed as argument to gtk.CheckButton() is the button's label 
and not it's name. The difference is that the label is the string that 
is displayed on the button and the name is used as an internal string 
identifier for the widget.

The most common way to achieve what you are trying to do here, is to 
keep a reference to all new, custom-created widgets. So if you replace 
"button = gtk.CheckButton('test')" with "self.button = 
gtk.CheckButton('test')", you can simply do "state = 
self.button.get_active()" in your "button2_clicked()" event handler.

HTH

Walter

Daniel Roesler wrote:
> Howdy all,
>
> I'm just learning pygtk and glade, and I have a question about
> accessing widgets that were added during an called function. In my
> example, I have two buttons. The first button that adds a checkbox to
> a scrolled window area. The second button prints the activity status
> (True/False) of the checkbox.
>
> The first button works fine. However, when I push button two, python
> says "AttributeError: 'NoneType' object has no attribute
> 'get_active'". Obviously, this means that I'm not reaching the
> checkbox widget correctly.
>
> So my question, how can I get properties of a widget added after the
> initial glade file was loaded?
>
> Here's my program, and I've attached my glade file. Thanks all!
> ---
> import pygtk
> import gtk
> import gtk.glade
>
> class app_gui:
>   def __init__(self):
> self.window = gtk.glade.XML("check.glade")
> dic = { "on_button1_clicked" : self.button1_clicked,
> "on_button2_clicked" : self.button2_clicked,
> "on_window1_destroy" : (gtk.main_quit) }
> self.window.signal_autoconnect(dic)
> return
>
>   def button1_clicked(self,widget):
> button = gtk.CheckButton("test")
> self.window.get_widget("scrolledwindow1").add_with_viewport(button)
> button.show()
> return
>
>   def button2_clicked(self,widget):
> status = self.window.get_widget("test").get_active()
> print status
> return
>
> app=app_gui()
> gtk.main()
> ---
>
> Avast!
> Daniel Roesler
> diaf...@gmail.com
>   
> 
>
> ___
> pygtk mailing list   pygtk@daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/

-- 
Walter Leibbrandt  http://translate.org.za/blogs/walter
Software Developer  +27 12 460 1095 (w)
Translate.org.za

Recent blogs:
* Virtaal's MVCisation
http://www.translate.org.za/blogs/walter/en/content/virtaals-mvcisation
* Things that changed the way I code
* Switching from Subversion to git


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


[pygtk] get_active() of CheckButton added to ScrolledWindow

2009-01-20 Thread Daniel Roesler
Howdy all,

I'm just learning pygtk and glade, and I have a question about
accessing widgets that were added during an called function. In my
example, I have two buttons. The first button that adds a checkbox to
a scrolled window area. The second button prints the activity status
(True/False) of the checkbox.

The first button works fine. However, when I push button two, python
says "AttributeError: 'NoneType' object has no attribute
'get_active'". Obviously, this means that I'm not reaching the
checkbox widget correctly.

So my question, how can I get properties of a widget added after the
initial glade file was loaded?

Here's my program, and I've attached my glade file. Thanks all!
---
import pygtk
import gtk
import gtk.glade

class app_gui:
  def __init__(self):
self.window = gtk.glade.XML("check.glade")
dic = { "on_button1_clicked" : self.button1_clicked,
"on_button2_clicked" : self.button2_clicked,
"on_window1_destroy" : (gtk.main_quit) }
self.window.signal_autoconnect(dic)
return

  def button1_clicked(self,widget):
button = gtk.CheckButton("test")
self.window.get_widget("scrolledwindow1").add_with_viewport(button)
button.show()
return

  def button2_clicked(self,widget):
status = self.window.get_widget("test").get_active()
print status
return

app=app_gui()
gtk.main()
---

Avast!
Daniel Roesler
diaf...@gmail.com


check.glade
Description: application/glade
___
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] Tooltips on comboBox

2009-01-20 Thread Alessandro Dentella
On Sun, Jan 18, 2009 at 11:31:57PM +0100, Alessandro Dentella wrote:
> hi,
> 
>   I  have been googling around for a while but I can't see if there is any
>   possibility to set tooltips for combobox entries.
> 

>   Is it any possible?

in my attempt to get tooltips I see that as I click on the arrow and the
popup appears, the tooltip disappears.

It seems the popup is a different gtk.Widget, and I should connect to that
one to attach tooltips. Is that correct? and in case how can I have that
widget?

I tried to connect to 'add' signal but it's never triggered. I see the 
ComboBox has a child: a CellView, but if I understand correctly CellView
only displayes *one* line and moreover I was not able to add a tooltip
anyhow.

Can somebody clearify widh is the way a ComboBox pops a menu and how Ican
get to it's components to set a ooltip?

thanks
sandro
*:-)







import gtk
import datetime

class Test(object):

def __init__(self):
self.w = gtk.Window()
self.v = gtk.VBox()
self.c = gtk.ComboBox()
self.c = gtk.combo_box_new_text()
#print self.c, type(self.c)

for i in "= > < >= <= ~ ~!".split():
self.c.append_text(i)

self.c.set_property('has-tooltip', True)
self.c.connect('query-tooltip', self.on_query_tooltip)

self.w.add(self.v)
self.v.add(self.c)

self.w.show_all()

def on_query_tooltip(self, widget,  x, y, keyboard_mode, tooltip):
print widget, x, y, keyboard_mode, tooltip
tooltip.set_text(datetime.datetime.now().strftime('%M:%S'))
return True


if __name__ == '__main__':

t = Test()
gtk.main()
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/


[pygtk] Adding Validation in TreeView: how to use 'edited' cb and stop any other processing?

2009-01-20 Thread Alessandro Dentella
Hi,

   I'm trying to add validation in a TreeView. 

   Connecting to cell's 'edited'  signal I can trigger validation on a cell
   input and if the field is not valid I reset it to previous value. That's
   not ideal, since the invalid value must be completely reentered while I'd
   like to leave it there.

   really It's pretty easy to do exacly what I want trapping a Tab on the
   editable, but that's junst *one* way to travel throught data (albeith
   very common).
   
   What I was not able to do is to prevent from moving from that cell, from
   within the 'edited' callback. I don't know how to stop any further
   processing of possible precedent events (click on other cell or DonwArrow
   or Tab...)

   Any hints?

   TIA
   sandro



-- 
Sandro Dentella  *:-)
http://sqlkit.argolinux.orgSQLkit home page - PyGTK/python/sqlalchemy
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/


[pygtk] Multi gtk.EventBox and gtk.Image cause artefacts

2009-01-20 Thread MATTHIEU CADET

Hi everybody!

I'm trying to write a tool in PyGtk that shows user lot of images in a Window,
each images must be "clickable", so i've put all of them into a gtk.EventBox.

The problem now for me is, when the number of images is more than about 45
EventBox shown in the main Window, i got some strange artefacts near to the
last image has been show.

How can i fix those artefacts from EventBox ? and keep my images clickable ?

Here the link to my code;glade and image :

http://www.filefactory.com/file/a02c6df/n/multi_eventbox_example_zip

Please if someone can help me on this.


Thanks a lot.

Maty.


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