在Python Gtk3中关闭主窗口时关闭辅助窗口

时间:2019-06-10 19:46:17

标签: python gtk

我有GUI应用程序,通过单击主窗口上的按钮,我可以在其中生成辅助Gtk窗口。在第二个窗口出现之后,如果用户单击关闭按钮,则窗口将隐藏。现在我要做的是:当用户关闭主窗口时关闭辅助窗口。

class GenerateClicked(Gtk.Window):
def __init__(self):

    Gtk.Window.__init__(self, title="Generated BOM")
    self.set_border_width(10)
    self.set_default_size(900, 1000)
    self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)

    # box_pass = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
    renderer_text = Gtk.CellRendererText()

    column_tag = Gtk.TreeViewColumn("Tags", renderer_text, text=0)
    bom_tree_view.append_column(column_tag)

    column_location = Gtk.TreeViewColumn("Location", renderer_text, text=1)
    bom_tree_view.append_column(column_location)

    column_Enumber = Gtk.TreeViewColumn("Part Number", renderer_text, text=2)
    bom_tree_view.append_column(column_Enumber)

    column_cost = Gtk.TreeViewColumn("Cost", renderer_text, text=3)
    bom_tree_view.append_column(column_cost)

    column_qty = Gtk.TreeViewColumn("Quantity", renderer_text, text=4)
    bom_tree_view.append_column(column_qty)

    column_catalog = Gtk.TreeViewColumn("Catalogue", renderer_text, text=5)
    bom_tree_view.append_column(column_catalog)

    column_mfg = Gtk.TreeViewColumn("Manufacturer", renderer_text, text=6)
    bom_tree_view.append_column(column_mfg)

    column_desc = Gtk.TreeViewColumn("Description", renderer_text, text=7)
    bom_tree_view.append_column(column_desc)

    self.scrolled = Gtk.ScrolledWindow()
    self.scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
    self.scrolled.add(bom_tree_view)
    self.add(self.scrolled)

    self.connect("delete-event", self.hide_window)
    self.show_all()
    Gtk.main_quit()
    Gtk.main()

0 个答案:

没有答案