On Mon, 2004-09-27 at 21:40 +0200, Luca Manini wrote:
> Erik> After that you can change them whenever you need.
>
> I've seen a "expose" event that can be useful.
> More interesting is the gobject.idle_add function.
> The problem is that the callback is not called when the app GOES
> idle, but WHILE it is IDLE (ok, may be it goes WORKING because of
> the callback and then goes IDLE again...).
>
> Still searching....
I'm not sure if I understand what your problem is. You want to set the
sensitivity of a menu item based on some criteria? One way you would do
this is something like this (simplified example, you would need some
code to set up the app etc, but you should get the idea):
class App:
def __init__(self):
# set up the application, use whatever code you need
self.setup_ui()
# connect a callback to the File/Open menu item
menuitem = self.itemfactory.get_widget("/File/Open")
menuitem.connect("activate", self.cb_open)
def cb_open(self, widget, data = None):
self.load("myfile")
# set the state of File/Save based on if it can be
# modified or not
menuitem = self.itemfactory,get_widget("/File/Save")
if can_modify_file == True:
menuitem.set_sensitive(gtk.TRUE)
else:
menuitem.set_sensitive(gtk.FALSE)
def run(self):
# run the gtk mainloop
gtk.main()
# run the application
app = App()
app.run()
--
Erik Grinaker <[EMAIL PROTECTED]>
"We act as though comfort and luxury were the chief requirements of
life, when all that we need to make us happy is something to be
enthusiastic about."
-- Albert Einstein
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/