当前位置: 首页>>代码示例>>Python>>正文


Python Gtk.STOCK_SAVE_AS属性代码示例

本文整理汇总了Python中gi.repository.Gtk.STOCK_SAVE_AS属性的典型用法代码示例。如果您正苦于以下问题:Python Gtk.STOCK_SAVE_AS属性的具体用法?Python Gtk.STOCK_SAVE_AS怎么用?Python Gtk.STOCK_SAVE_AS使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在gi.repository.Gtk的用法示例。


在下文中一共展示了Gtk.STOCK_SAVE_AS属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_toolbuttons

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_SAVE_AS [as 别名]
def create_toolbuttons(self):
        self.import_button = Gtk.ToolButton.new_from_stock(Gtk.STOCK_CONVERT)
        self.import_button.set_tooltip_text(_("Import PGN file"))
        self.import_button.connect("clicked", self.on_import_clicked)

        self.save_as_button = Gtk.ToolButton.new_from_stock(Gtk.STOCK_SAVE_AS)
        self.save_as_button.set_tooltip_text(_("Save to PGN file as..."))
        self.save_as_button.connect("clicked", self.on_save_as_clicked) 
开发者ID:pychess,项目名称:pychess,代码行数:10,代码来源:__init__.py

示例2: _on_export_config

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_SAVE_AS [as 别名]
def _on_export_config(self, *args):
        """Callback method the the export button was clicked

        Shows dialogs allowing to export the configurations into separate files
        """
        response = self._config_chooser_dialog("Export configuration",
                                               "Please select the configuration file(s) to be exported:")
        if response == Gtk.ResponseType.REJECT:
            return

        def handle_export(dialog_text, path, config_m):
            chooser = Gtk.FileChooserDialog(dialog_text, None,
                                            Gtk.FileChooserAction.SAVE,
                                            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                                             Gtk.STOCK_SAVE_AS, Gtk.ResponseType.ACCEPT))
            chooser.set_current_folder(path)
            response = chooser.run()
            if response == Gtk.ResponseType.ACCEPT:
                config_file = chooser.get_filename()
                if not config_file:
                    logger.error("Configuration could not be exported! Invalid file name!")
                else:
                    if ".yaml" not in config_file:
                        config_file += ".yaml"
                    if config_m.preliminary_config:
                        logger.warning("There are changes in the configuration that have not yet been applied. These "
                                    "changes will not be exported.")
                    self._last_path = dirname(config_file)
                    config_dict = config_m.as_dict()
                    config_copy = yaml_configuration.config.DefaultConfig(str(config_dict))
                    config_copy.config_file_path = config_file
                    config_copy.path = self._last_path
                    try:
                        config_copy.save_configuration()
                        logger.info("Configuration exported to {}" .format(config_file))
                    except IOError:
                        logger.error("Cannot open file '{}' for writing".format(config_file))
            elif response == Gtk.ResponseType.CANCEL:
                logger.warning("Export Config canceled!")
            chooser.destroy()

        if self._core_checkbox.get_active():
            handle_export("Select file for core configuration", self._last_path, self.core_config_model)

        if self._gui_checkbox.get_active():
            handle_export("Select file for GUI configuration.", self._last_path, self.gui_config_model) 
开发者ID:DLR-RM,项目名称:RAFCON,代码行数:48,代码来源:preferences_window.py


注:本文中的gi.repository.Gtk.STOCK_SAVE_AS属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。