Jicksy John
Jicksy John

Reputation: 169

Adding browse function to button -Python

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.

Upvotes: 0

Views: 58

Answers (1)

Zaur Nasibov
Zaur Nasibov

Reputation: 22659

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()

Upvotes: 1

Related Questions