मैं PyGTK FAQ में दिए गए उत्तर का उपयोग कर रहा हूं, लेकिन यह PyGObject के साथ काम नहीं करता है। आपकी सुविधा के लिए, यहां एक परीक्षण केस है जो पीईजीटीके के साथ काम करता है, और उसके बाद एक अनुवादित संस्करण जो PyGObject के साथ काम नहीं करता है।मैं एक खिड़की कैसे उठा सकता हूं जो कम से कम है या 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'
तो मुझे लगता है कि PGObject में Gdk.window प्राप्त करने के लिए कोई अन्य तरीका होना चाहिए?
या क्या एक ही लक्ष्य को पूरा करने का कुछ अलग/बेहतर तरीका है?
कोई भी विचार?
अस्थायी रूप से खिड़की उठाएँ (शायद क्या आप देख रहे हैं):
def raise_window(widget, w2):
w2.present()
खिड़की स्थायी रूप से बढ़ाएं (या स्पष्ट रूप से जब तक द्वारा बदला
बहुत बढ़िया, यह पहले से ही जिस तरह से कर रहा था उससे भी अधिक सही लगता है। – dumbmatter