[pygtk] GtkWindow bring to front

Steve McClure smcclure@racemi.com
22 Oct 2002 11:48:59 -0400


--=-o4b0flcyK9cMpIm8jDCM
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On Tue, 2002-10-22 at 11:16, LDC - Pablo Endres Lozada wrote:
>=20
>=20
> 	Thanks for all your answers guys you've been really helpfull!!
>=20
> 	Here come the question.  Is there a way to bring a window to=20
> 	front?

I use this showDialog method when I want to update the dialog. My
dialogs use the map event to trigger loading of contents. The last bit
of checking the MAPPED flag and calling _raise is what you are
interested in.

    def showDialog(self, dialog, title =3D None):
        if type(dialog) =3D=3D types.StringType:
            d =3D self.wtree.get_widget(dialog)
        else:
            d =3D dialog

        if title:
            d.set_title(title)

        if d is None:
            sl =3D traceback.extract_stack()
            frame =3D sl[-2]
            msg =3D 'No dialog named %s, fix line %d of %s!' % (dialog,
frame[1], frame[0])
            mwsdialogs.mwsErrorDialog(msg, modal=3D1)
            raise KeyError, msg

        if d.flags(gtk.MAPPED) =3D=3D 0:
            d.show()
        else:
            d.get_window()._raise()
            # call map again so dialogs will refresh their contents
            return d.emit('map', d)


> 	  And question two:
> 	supose you define two windows with libglade and save them in
> 	the same file. if I start the app like this
>=20
> 	self.widgets =3D libglade.GladeXML("Gui.glade",=20
> "MainWindow")=09
>=20
> 	how do I acces Window2 to show it?
> 	I tryed self.widgets.get_widget("Window22)

That is the method you what to use but you have to make sure you
uniquely, and correctly, name each widget you might want to access
directly.  Also, note that when you specify the root, in your case,
"MainWindow", only that widget hierarchy is created.  I don't specify a
root and just import the whole glade file, otherwise you will have to
instantiate multiple GladeXML objects with different roots.

> 	but it doesn't work.
>=20
> 	Thanks in advance
>=20
> --=20
> 		Muchas personas creen que piensan,
> 		cuando en realidad s=F3lo est=E1n reordenando sus
> 		prejuicios.
> 					- William James
> =20
>        .-----------------------------------------------------------------=
.
>       /  .-.               Pablo Endres Lozada                        .-.=
  \
>      |  /   \       Laboratorio Docente de Computacion              /   \=
  |
>      | |\_.  |                USB - Venezuela                      |    /=
| |
>      |\|  | /|                                                     |\  | =
|/|
>      | `---' |               epablo@ldc.usb.ve                     | `---=
' |
>      |       |                                                     |     =
  |=20
>      |       |-----------------------------------------------------|     =
  |
>      \       |                                                     |     =
  /
>       \     /                                                       \    =
 /
>        `---'                                                         `---=
'
>=20
> _______________________________________________
> pygtk mailing list   pygtk@daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
--=20
Steve McClure			430 10th St NW
Racemi				Suite N-210
http://www.racemi.com		Atlanta, GA 30318
smcclure@racemi.com		voice/fax: 404-892-5850

--=-o4b0flcyK9cMpIm8jDCM
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQA9tXNrwt58YtoWR6kRAjW+AKDZvoPcYJI3Rbqdgnsj+jW1yZjiigCguf4M
8l2+1zZMkpBBLg1edCx5r/Y=
=P3YC
-----END PGP SIGNATURE-----

--=-o4b0flcyK9cMpIm8jDCM--