0
任何人都可以告诉我如何我可以有一个偏好弹出居中集中在父窗口,即使移动父窗口?谢谢:)有一个弹出窗口居中居中父 - Glade,GTK,Python
任何人都可以告诉我如何我可以有一个偏好弹出居中集中在父窗口,即使移动父窗口?谢谢:)有一个弹出窗口居中居中父 - Glade,GTK,Python
这是一个很简单的例子,优先窗口为中心,而移动它的母公司将移动(但将取决于窗口管理器):
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
class AppWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="Python Example")
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL,spacing=6)
self.add(box)
button1 = Gtk.Button("Information")
button1.connect("clicked", self.on_button_clicked)
box.add(button1)
treeview = Gtk.TreeView()
treeview.set_size_request(640,480)
box.add(treeview)
def on_button_clicked(self, widget):
preferences_window = Gtk.Window (Gtk.WindowType.TOPLEVEL)
preferences_window.set_title ("Preferences Window")
preferences_window.set_modal (True)
preferences_window.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
preferences_window.set_transient_for(self)
preferences_window.show_all()
preferences_window.connect("delete-event", preferences_window.destroy);
win = AppWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()