Python gi.repository.Gtk 模块,STOCK_SAVE 实例源码

我们从Python开源项目中,提取了以下20个代码示例,用于说明如何使用gi.repository.Gtk.STOCK_SAVE

项目:sbrick-controller    作者:wintersandroid    | 项目源码 | 文件源码
def on_save_as_configuration(self, action, param):
        dialog = Gtk.FileChooserDialog("Save Configuration As...", self.window,
                                       Gtk.FileChooserAction.SAVE,
                                       (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                                        Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
        dialog.set_filename(self.configFile)

        self.add_filters(dialog)

        response = dialog.run()
        if response == Gtk.ResponseType.OK:
            self.configFile = dialog.get_filename()
            self.save_configuration(self.configFile)

        dialog.destroy()

    # noinspection PyUnusedLocal
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def __init__(self, filename=None):
        self.m_instance_number = EditorDialogBase.instance_counter
        EditorDialogBase.instance_counter += 1
        self.m_filename = filename
        self.m_savetime = time.time()
        self.connect('delete_event', self.on_delete_event)
        self.g_ui_manager = Gtk.UIManager()
        accelgroup = self.g_ui_manager.get_accel_group()
        self.add_accel_group(accelgroup)

        self.g_actiongroup = Gtk.ActionGroup('')
        self.g_actiongroup.add_actions([
         ('Close', Gtk.STOCK_CLOSE, None, None, None, self.close_window),
         ('Save', Gtk.STOCK_SAVE, None, None, None, self.on_save),
         ('SaveAs', Gtk.STOCK_SAVE_AS, None, None, None, self.on_save_as),
         ('New', Gtk.STOCK_NEW, None, None, None, self.new_file),
         ('Open', Gtk.STOCK_OPEN, None, None, None, self.on_open),
         ('Help', Gtk.STOCK_HELP, None, None, None, self.on_show_help),
        ])
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def file_save_cb(self, *v):
        self.store_data_from_ui()
        if self.m_P.m_filename is None:
            dialog = Gtk.FileChooserDialog(_("Save..."), self,
                                   Gtk.FileChooserAction.SAVE,
                                   (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                                    Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
            dialog.set_default_response(Gtk.ResponseType.OK)

            if dialog.run() == Gtk.ResponseType.OK:
                self.m_P.m_filename = gu.decode_filename(dialog.get_filename())
            dialog.destroy()

        if self.m_P.m_filename:
            self.update_appwin()
            self.save_file()
项目:Remarkable    作者:jamiemcg    | 项目源码 | 文件源码
def save_as(self, widget):
        self.window.set_sensitive(False)
        chooser = Gtk.FileChooserDialog(title=None, action=Gtk.FileChooserAction.SAVE, buttons=(
            Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
        chooser.set_do_overwrite_confirmation(True)
        title = self.name.split("/")[-1]
        chooser.set_title("Save As: " + title)
        response = chooser.run()
        if response == Gtk.ResponseType.OK:
            file = open(chooser.get_filename(), 'w')
            self.name = chooser.get_filename()
            text = self.text_buffer.get_text(self.text_buffer.get_start_iter(), self.text_buffer.get_end_iter(), False)
            file.write(text)
            file.close()
            self.text_buffer.set_modified(False)
            title = self.name.split("/")[-1]
            self.window.set_title("Remarkable: " + title)
        elif response == Gtk.ResponseType.CANCEL:
            pass
        chooser.destroy()
        self.window.set_sensitive(True)
项目:poseidon    作者:sidus-dev    | 项目源码 | 文件源码
def force_save(self, content, name):

        d = Gtk.FileChooserDialog("{}: {}".format(_("Save as"), name), self,
            Gtk.FileChooserAction.SAVE,
            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
             Gtk.STOCK_SAVE, Gtk.ResponseType.OK))

        d.set_current_name(name)
        d.set_default_size(int(width), int(height))
        response = d.run()

        if response == Gtk.ResponseType.OK:

            if os.path.exists(d.get_filename()):
                if self.do_decision(name): pass
                else:
                    d.destroy()
                    return True

            with open(d.get_filename(), 'w') as f:
                f.write(content)
                f.close()

        d.destroy()
项目:plotcommander    作者:FilipDominec    | 项目源码 | 文件源码
def __init__(self):
        super(CellRendererFadeWindow, self).__init__(title="CellRendererFade Example")

        self.set_default_size(200, 200)
        self.liststore = Gtk.ListStore(str, str)
        self.liststore.append(["New", Gtk.STOCK_NEW])
        self.liststore.append(["Open", Gtk.STOCK_OPEN])
        self.liststore.append(["Save", Gtk.STOCK_SAVE])

        treeview = Gtk.TreeView(model=self.liststore)
        renderer_text = Gtk.CellRendererText()
        column_text = Gtk.TreeViewColumn("Text", renderer_text, text=0)
        treeview.append_column(column_text)

        renderer_pixbuf = CellRenderFade(param=0.001)
        column_pixbuf = Gtk.TreeViewColumn("Image", renderer_pixbuf, stock_id=1)
        treeview.append_column(column_pixbuf)
        self.add(treeview)
项目:yt-browser    作者:juanfgs    | 项目源码 | 文件源码
def on_download_clicked(self,button,video_data):
        """ Show the file dialog """
        file_chooser_dialog = Gtk.FileChooserDialog("Elegir donde guardar el video", self.window, Gtk.FileChooserAction.SAVE,
                                                    (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                                                     Gtk.STOCK_SAVE, Gtk.ResponseType.OK))

        file_chooser_dialog.set_current_name(video_data["title"])



        if file_chooser_dialog.run() == Gtk.ResponseType.OK:
            filename = file_chooser_dialog.get_filename()

            row  = button.get_parent().get_parent()

            # for widget in button.get_parent().get_children():
            #     if widget.__class__.__name__ == 'Button':
            #         widget.destroy()
            video_iter = self.add_video_to_queue(video_data)
            self.video_list.show_all()
            file_chooser_dialog.destroy()

            if video_data["action"] == "convert": #add postprocessing if convert was pressed
                self.backend.convert(True)

            self.download_video_thread(video_data["video_id"], filename,video_iter)
        else:
            file_chooser_dialog.destroy()
项目:aniwall    作者:worron    | 项目源码 | 文件源码
def __init__(self, parent, title, action=Gtk.FileChooserAction.SAVE, action_button=Gtk.STOCK_SAVE):
        self.parent = parent
        self.title = title
        self.action = action
        self.action_button = action_button
        self.homedir = os.path.expanduser("~")
项目:Dict-O-nator    作者:theawless    | 项目源码 | 文件源码
def __init__(self, window: Gtk.Window):

        """Constructor.

        :param window: current window to set as parent.
        """
        self.owner = window
        self.file_chooser = Gtk.FileChooserDialog("Save file", window, Gtk.FileChooserAction.SAVE, (
            Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
        # Sets whether we get the overwrite confirmation
        self.file_chooser.set_do_overwrite_confirmation(True)
        self.save_possible = False
项目:pyspc    作者:carlosqsilva    | 项目源码 | 文件源码
def on_save_clicked(self, widget):
        dialog = Gtk.FileChooserDialog("Please choose a filename to save", self,
                                       Gtk.FileChooserAction.SAVE,
                                       (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                                        Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
        dialog.set_current_name("Untitled.png")
        dialog.set_do_overwrite_confirmation(True)
        response = dialog.run()
        if response == Gtk.ResponseType.OK:
            self.graph.save(dialog.get_filename(), dpi=600)

        dialog.destroy()
项目:simbuto    作者:nobodyinperson    | 项目源码 | 文件源码
def saveas_dialog(self, *args):
        # create a dialog
        dialog = Gtk.FileChooserDialog(
            _("Please select a saving destination"), # title
            self("main_applicationwindow"), # parent
            Gtk.FileChooserAction.SAVE, # Action
            # Buttons (obviously not possible with glade!?)
            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
            Gtk.STOCK_SAVE, Gtk.ResponseType.OK)
            )

        # add the filter
        dialog.add_filter(self.simbuto_filefilter)

        response = dialog.run() # run the dialog
        if response == Gtk.ResponseType.OK: # file selected
            filename = dialog.get_filename()
            self.logger.debug(_("File '{}' selected").format(filename))
            if not filename.endswith(".simbuto"):
                filename = "{}.simbuto".format(filename)
            # save
            self.save_current_budget_to_file(filename)
        elif response == Gtk.ResponseType.CANCEL: # cancelled
            self.logger.debug(_("File selection cancelled"))
        else: # something else
            self.logger.debug(_("File selection dialog was closed"))

        dialog.destroy() # destroy the dialog, we don't need it anymore
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def file_save_as_cb(self, *v):
        self.store_data_from_ui()
        dialog = Gtk.FileChooserDialog(_("Save as..."), self,
                                  Gtk.FileChooserAction.SAVE,
                                   (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                                    Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
        dialog.set_default_response(Gtk.ResponseType.OK)

        if dialog.run() == Gtk.ResponseType.OK:
            self.m_P.m_filename = gu.decode_filename(dialog.get_filename())
            self.save_file()
        dialog.destroy()
项目:ez_gpg    作者:sgnn7    | 项目源码 | 文件源码
def get_save_filename(window, filename, title="Save..."):
        dialog = Gtk.FileChooserDialog(title,
                                       window,
                                       Gtk.FileChooserAction.SAVE,
                                       (Gtk.STOCK_CANCEL,
                                        Gtk.ResponseType.CANCEL,
                                        Gtk.STOCK_SAVE,
                                        Gtk.ResponseType.ACCEPT))

        dialog.set_default_response(Gtk.ResponseType.OK)
        dialog.set_do_overwrite_confirmation(True)
        dialog.set_current_name(filename)
        UiUtils._set_save_keyfile_filter(dialog)

        response = dialog.run()

        filename = None
        armor = True
        if response == Gtk.ResponseType.ACCEPT:
            filename = dialog.get_filename()

            if dialog.get_filter().get_name() == 'Encoded key':
                armor = False

            # Suffix the filename
            if not (filename.endswith('.asc') or filename.endswith('.gpg')):
                suffix = '.asc'
                if not armor:
                    suffix = '.gpg'

                filename += suffix

            print("Filename chosen as:", filename)

        dialog.destroy()
        return filename, armor
项目:PyFlowChart    作者:steelcowboy    | 项目源码 | 文件源码
def create_save_as_dialog(self):
        """Returns a Save As dialog object."""
        return Gtk.FileChooserDialog("Save as...", self,
                Gtk.FileChooserAction.SAVE,
                (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                 Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
项目:poseidon    作者:sidus-dev    | 项目源码 | 文件源码
def save(self, name, download, url):

        d = Gtk.FileChooserDialog("{}: {}".format(_("Save as"), name), self,
            Gtk.FileChooserAction.SAVE,
            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
             Gtk.STOCK_SAVE, Gtk.ResponseType.ACCEPT))

        d.set_current_name(name)
        d.set_default_size(int(width), int(height))
        response = d.run()

        if response == Gtk.ResponseType.ACCEPT:

            f = rtags(d.get_filename())

            if os.path.exists(f):
                if self.do_decision(f): download.set_allow_overwrite(True)
                else:
                    download.cancel()
                    d.destroy()
                    return True

            download.set_destination("file://{}".format(f))

        elif response == Gtk.ResponseType.CANCEL\
        or response == Gtk.ResponseType.DELETE_EVENT: download.cancel()

        d.destroy()
项目:hubangl    作者:soonum    | 项目源码 | 文件源码
def _build_menu_new(self, menu_bar):
        """
        Build the whole New menu item.
        """
        menu_item = self._build_menu_item("New", menu_bar)
        self.dropmenu_new = Gtk.Menu()
        menu_item.set_submenu(self.dropmenu_new)
        self.subitem_new_session = self._build_menu_item(
            "New Session", self.dropmenu_new,
            image=Gtk.STOCK_NEW
        )
        self.subitem_save_configuration = self._build_menu_item(
            "Save configuration", self.dropmenu_new,
            image=Gtk.STOCK_SAVE, callback=self.on_save_clicked
        )
        self.subitem_load_configuration = self._build_menu_item(
            "Load Configuration", self.dropmenu_new,
            image=Gtk.STOCK_FILE, callback=self.on_load_clicked
        )
        self.subitem_recent_session = self._build_menu_item(
            "Recent Session", self.dropmenu_new,
            image=Gtk.STOCK_REVERT_TO_SAVED
        )
        self.subitem_preferences = self._build_menu_item(
            "Preferences", self.dropmenu_new,
            image=Gtk.STOCK_PREFERENCES
        )
        self._build_separatormenuitem(self.dropmenu_new)
        self.subitem_quit = self._build_menu_item(
            "Quit", self.dropmenu_new,
            image=Gtk.STOCK_QUIT, callback=Gtk.main_quit
        )

        return menu_item
项目:hubangl    作者:soonum    | 项目源码 | 文件源码
def on_save_clicked(self, widget):
        file_save_dialog = Gtk.FileChooserDialog(
                title="Save Session",
                action=Gtk.FileChooserAction.SAVE,
                buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                         Gtk.STOCK_SAVE, Gtk.ResponseType.ACCEPT)
        )
        file_save_dialog.set_icon_from_file(self.images.logo_favicon_path)
        file_save_dialog.set_current_name("Untilted.huba")
        file_save_dialog.set_do_overwrite_confirmation(True)
        file_save_dialog.set_modal(True)
        file_save_dialog.connect("response", self.on_save_response)
        file_save_dialog.run()
项目:gstation-edit    作者:fengalin    | 项目源码 | 文件源码
def run_file_chooser(self, action, proposed_name=None):
        folder = None
        if self.config.has_section('Import-Export'):
            folder = self.config.get('Import-Export', 'folder')

        title = 'Import'
        stock_ok = Gtk.STOCK_OPEN
        if action == Gtk.FileChooserAction.SAVE:
            stock_ok = Gtk.STOCK_SAVE
            title = 'Export'

        file_chooser = Gtk.FileChooserDialog(
                title, self.gtk_window, action,
                (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                 stock_ok, Gtk.ResponseType.OK)
            )
        filter_sysex = Gtk.FileFilter()
        filter_sysex.set_name('Sysex files (.syx)')
        filter_sysex.add_pattern('*.syx')
        file_chooser.add_filter(filter_sysex)

        if Gtk.FileChooserAction.SAVE:
            file_chooser.set_do_overwrite_confirmation(True)

        if folder:
            file_chooser.set_current_folder(folder)
        if proposed_name:
            file_chooser.set_current_name('%s.syx'%(proposed_name))

        result = file_chooser.run()
        if result == Gtk.ResponseType.OK:
            filename = file_chooser.get_filename()
            if not self.config.has_section('Import-Export'):
                self.config.add_section('Import-Export')
            self.config.set('Import-Export', 'folder', path.dirname(filename))

        return (result, file_chooser)
项目:PyFlowChart    作者:steelcowboy    | 项目源码 | 文件源码
def __init__(self, parent, courses, user):
        Gtk.Dialog.__init__(self, "Preferences", parent,
            0, (Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
        self.set_size_request(400, -1)
        self.planned_ges = courses  

        self.ge_list = [
                'A1', 'A2', 'A3', 
                'B1', 'B2', 'B3', 'B4', 'B5', 'B6', 
                'C1', 'C2', 'C3', 'C4', 'C5', 
                'D1', 'D2', 'D3', 'D4/E', 'D5', 
                'F'
                ]

        self.ge_length = len(self.ge_list)

        self.notebook = Gtk.Notebook()
        self.box = self.get_content_area()
        self.box.add(self.notebook)

        self.user = Gtk.Grid()
        self.user.set_column_homogeneous(True)
        self.user.attach(Gtk.Label("Year:"), 0, 0, 1, 1)

        self.year_selector = Gtk.ComboBoxText()
        self.user.attach(self.year_selector, 1, 0, 1, 1)
        for x in range(1,7):
            self.year_selector.append_text(str(x))
        self.year_selector.set_active(user['year']-1)

        self.user.attach(Gtk.Label("Years to display:"), 0, 1, 1, 1)
        self.display_years_selector = Gtk.ComboBoxText()
        self.user.attach(self.display_years_selector, 1, 1, 1, 1)
        for x in range(1,7):
            self.display_years_selector.append_text(str(x))
        self.display_years_selector.set_active(user['display_years']-1)

        self.notebook.append_page(self.user, Gtk.Label("User Info"))

        self.ges = Gtk.Grid()
        self.ges.set_column_homogeneous(True)

        for pos, ge in enumerate(self.ge_list):
            self.ges.attach(Gtk.Label(ge), 0, pos, 1, 1)
            if ge in self.planned_ges:
                self.ges.attach(editable_label(self.planned_ges[ge]), 1, pos, 1, 1)
            else:
                self.ges.attach(editable_label(), 1, pos, 1, 1)

        self.notebook.append_page(self.ges, Gtk.Label("GEs"))

        self.show_all()
项目:MTTT    作者:roxana-lafuente    | 项目源码 | 文件源码
def make_table_interface(self):
          self.back_button = Gtk.Button("Back")
          self.tables_content[self.get_menu_grid].add(self.back_button)
          self.next_button = Gtk.Button("Next")
          self.tables_content[self.get_menu_grid].attach_next_to(self.next_button, self.back_button, Gtk.PositionType.RIGHT, 1, 1)
          self.reduce_rows_translation_table = Gtk.Button("- rows")
          self.tables_content[self.get_menu_grid].attach_next_to(self.reduce_rows_translation_table, self.back_button, Gtk.PositionType.TOP, 1, 10)
          self.increase_rows_translation_table = Gtk.Button("+ rows")
          self.tables_content[self.get_menu_grid].attach_next_to(self.increase_rows_translation_table, self.next_button, Gtk.PositionType.TOP, 1, 10)
          self.tables_content[self.get_menu_grid].set_column_spacing(10)

          self.increase_rows_translation_table.connect("clicked", self._increase_table_rows)
          self.reduce_rows_translation_table.connect("clicked", self._reduce_table_rows)
          self.back_button.connect("clicked", self._back_in_table)
          self.next_button.connect("clicked", self._next_in_table)

          if self.table_type == "translation_table":
            #Add save buttons
            self.REC_button = Gtk.CheckButton.new_with_label("Autosave")
            self.tables_content[self.get_menu_grid].attach_next_to(self.REC_button, self.increase_rows_translation_table, Gtk.PositionType.RIGHT, 1, 50)

            self.save_post_editing_changes_button = Gtk.Button()
            self.save_post_editing_changes_button.set_image(Gtk.Image(stock=Gtk.STOCK_SAVE))
            self.save_post_editing_changes_button.set_label("Save changes")
            self.save_post_editing_changes_button.connect("clicked", self.save_callback_function)
            self.tables_content[self.get_menu_grid].attach(self.save_post_editing_changes_button, 3, 0, 1 ,1)
            self.save_post_editing_changes_button.hide()



            self.deletions_statistics_button = Gtk.Button()
            self.deletions_statistics_button.set_label("deletions stats")
            self.deletions_statistics_button.connect("clicked", self.stats_callback_function, "deletions")
            self.tables_content[self.get_menu_grid].attach_next_to(self.deletions_statistics_button, self.save_post_editing_changes_button, Gtk.PositionType.TOP, 1, 1)
            self.deletions_statistics_button.hide()

            self.insertions_statistics_button = Gtk.Button()
            self.insertions_statistics_button.set_label("insertions stats")
            self.insertions_statistics_button.connect("clicked", self.stats_callback_function, "insertions")
            self.tables_content[self.get_menu_grid].attach_next_to(self.insertions_statistics_button, self.deletions_statistics_button, Gtk.PositionType.TOP, 1, 1)
            self.insertions_statistics_button.hide()

            self.time_statistics_button = Gtk.Button()
            self.time_statistics_button.set_label("time spent per segment")
            self.time_statistics_button.connect("clicked", self.stats_callback_function, "time_per_segment")
            self.tables_content[self.get_menu_grid].attach_next_to(self.time_statistics_button, self.insertions_statistics_button, Gtk.PositionType.TOP, 1, 1)
            self.time_statistics_button.hide()

            self.statistics_button = Gtk.Button()
            self.statistics_button.set_label("statistics")
            self.statistics_button.connect("clicked", self.stats_callback_function, "statistics_in_general")
            self.tables_content[self.get_menu_grid].attach_next_to(self.statistics_button, self.time_statistics_button, Gtk.PositionType.TOP, 1, 1)
            self.statistics_button.hide()