문제

I have a button in my code:

self.add_bt = Gtk.Button()
self.add_bt.set_label(_("Choose from computer"))


vbox.pack_start(self.add_bt, False, False, 0)

I want to include FileChooser function on clicking this button.

dlg = Gtk.FileChooserDialog()
dlg.show()

What I am trying to do is, on clicking the button labelled "Choose from computer" I want the browse window to open. Then get the added file included in place of current image.

도움이 되었습니까?

해결책

Do you mean something like:

self.add_bt.connect("clicked", self.on_add_bt_clicked)

def on_add_bt_clicked(self, button):
    dlg = Gtk.FileChooserDialog()
    dlg.show()
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top