Как поднять окно, которое свернуто или закрыто с помощью PyGObject?

Я использовал ответ, приведенный в PyGTK FAQ, но, похоже, он не работает с PyGObject. Для удобства приведен тестовый пример, который работает с PyGTK, а затем переведенная версия, которая не работает с PyGObject.

Версия PyGTK:

import gtk

def raise_window(widget, w2):
    w2.window.show()

w1 = gtk.Window()
w1.set_title('Main window')
w2 = gtk.Window()
w2.set_title('Other window')

b = gtk.Button('Move something on top of the other window.\nOr, minimize the'
               'other window.\nThen, click this button to raise the other'
               'window to the front')
b.connect('clicked', raise_window, w2)

w1.add(b)

w1.show_all()
w2.show_all()

w1.connect('destroy', gtk.main_quit)
gtk.main()

Версия PyGObject:

from gi.repository import Gtk

def raise_window(widget, w2):
    w2.window.show()

w1 = Gtk.Window()
w1.set_title('Main window')
w2 = Gtk.Window()
w2.set_title('Other window')

b = Gtk.Button('Move something on top of the other window.\nOr, minimize the'
               'other window.\nThen, click this button to raise the other'
               'window to the front')
b.connect('clicked', raise_window, w2)

w1.add(b)

w1.show_all()
w2.show_all()

w1.connect('destroy', Gtk.main_quit)
Gtk.main()

Когда я нажимаю кнопку в версии PyGObject, другое окно не поднимается, и я получаю эту ошибку:

Traceback (most recent call last):
  File "test4.py", line 4, in raise_window
    w2.window.show()
AttributeError: 'Window' object has no attribute 'window'

Так что, я полагаю, должен быть какой-то другой способ получить Gdk.window в PyGObject?

Или есть какой-то другой/лучший способ достижения той же цели?

Есть идеи?

5
задан dumbmatter 29 January 2012 в 15:50
поделиться