def on_import_clicked(self, widget): dialog = Gtk.FileChooserDialog("Please choose a file", self, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) self.add_filters(dialog) response = dialog.run() if response == Gtk.ResponseType.OK: filename = dialog.get_filename() track = GpxTrack(self.view, self.trackstore) try: track.import_file(filename) except: print "Import error, could not find %s" % filename else: track.show() track.go_to() self.sidebartogglebutton.set_active(True) elif response == Gtk.ResponseType.CANCEL: print "Cancel clicked" dialog.destroy()
def on_import_clicked(self, widget): dialog = Gtk.FileChooserDialog(_("Open file"), self, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) self.add_filters(dialog) response = dialog.run() if response == Gtk.ResponseType.OK: filename = dialog.get_filename() track = GpxTrack(self.view, self.trackstore) try: track.import_file(filename) except: print(_("Import error: Could not find %(file)s" % {'file': filename})) else: track.show() track.go_to() self.sidebartogglebutton.set_active(True) elif response == Gtk.ResponseType.CANCEL: pass dialog.destroy()
def on_drag_data_received(self, window, context, x, y, data, info, time): filename = data.get_text().strip() track = GpxTrack(self.view, self.trackstore) try: track.import_file(filename) except: print "Import error, could not find %s" % filename else: track.show() track.go_to() self.sidebartogglebutton.set_active(True)