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


Python Gtk.STOCK_CANCEL属性代码示例

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


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

示例1: on_folder_clicked

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_CANCEL [as 别名]
def on_folder_clicked(self):
        Gtk.Window.__init__(self, title=_("Change working directory"))
        dialog = Gtk.FileChooserDialog(_("Choose directory"),
                                       self,
                                       Gtk.FileChooserAction.SELECT_FOLDER,
                                       (Gtk.STOCK_CANCEL,
                                        Gtk.ResponseType.CANCEL,
                                        _("Apply"),
                                        Gtk.ResponseType.OK,
                                        )
                                       )
        dialog.set_default_size(800, 400)
        response = dialog.run()
        if response == Gtk.ResponseType.OK:
            self.selectedfolder = dialog.get_filename()
        elif response == Gtk.ResponseType.CANCEL:
            self.selectedfolder = cli.stdir

        dialog.destroy() 
开发者ID:encarsia,项目名称:gpt,代码行数:21,代码来源:modules.py

示例2: run_quick_open

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_CANCEL [as 别名]
def run_quick_open(self):
		"""
		Display a dialog asking a user which file should be opened. The
		value of target_path in the returned dictionary is an absolute path.

		:return: A dictionary with target_uri and target_path keys representing the path chosen.
		:rtype: dict
		"""
		self.set_action(Gtk.FileChooserAction.OPEN)
		self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
		self.add_button(Gtk.STOCK_OPEN, Gtk.ResponseType.ACCEPT)
		self.show_all()
		response = self.run()
		if response == Gtk.ResponseType.CANCEL:
			return None
		target_path = self.get_filename()
		if not os.access(target_path, os.R_OK):
			gui_utilities.show_dialog_error('Permissions Error', self.parent, 'Can not read the selected file.')
			return None
		target_uri = self.get_uri()
		return {'target_uri': target_uri, 'target_path': target_path} 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:23,代码来源:extras.py

示例3: run_quick_select_directory

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_CANCEL [as 别名]
def run_quick_select_directory(self):
		"""
		Display a dialog which asks the user to select a directory to use. The
		value of target_path in the returned dictionary is an absolute path.

		:return: A dictionary with target_uri and target_path keys representing the path chosen.
		:rtype: dict
		"""
		self.set_action(Gtk.FileChooserAction.SELECT_FOLDER)
		self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
		self.add_button(Gtk.STOCK_OPEN, Gtk.ResponseType.ACCEPT)
		self.show_all()
		response = self.run()
		if response == Gtk.ResponseType.CANCEL:
			return None
		target_uri = self.get_uri()
		target_path = self.get_filename()
		return {'target_uri': target_uri, 'target_path': target_path} 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:20,代码来源:extras.py

示例4: __select_file

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_CANCEL [as 别名]
def __select_file(self, obj):
        """
        Call back function to handle the open button press
        """

        my_action = Gtk.FileChooserAction.SAVE

        dialog = Gtk.FileChooserDialog('lxml',
                                       action=my_action,
                                       buttons=(Gtk.STOCK_CANCEL,
                                                Gtk.ResponseType.CANCEL,
                                                Gtk.STOCK_OPEN,
                                                Gtk.ResponseType.OK))

        name = os.path.basename(self.entry.get_text())
        dialog.set_current_name(name)
        dialog.set_current_folder(self.__base_path)
        dialog.present()
        status = dialog.run()
        if status == Gtk.ResponseType.OK:
            self.set_filename(dialog.get_filename())
        dialog.destroy() 
开发者ID:gramps-project,项目名称:addons-source,代码行数:24,代码来源:lxmlGramplet.py

示例5: choose_file

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_CANCEL [as 别名]
def choose_file(self):
        """ Let user choose a file to save and return its path """
        chooser = Gtk.NativeFileChooser(
            title=_("Choose where to save your list"),
            parent=self.export_dialog,
            action=Gtk.FileChooserAction.SAVE,
            buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                     Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
        chooser.set_do_overwrite_confirmation(True)
        chooser.set_default_response(Gtk.ResponseType.OK)
        chooser.set_current_folder(get_desktop_dir())
        response = chooser.run()
        filename = chooser.get_filename()
        chooser.destroy()
        if response == Gtk.ResponseType.OK:
            return filename
        else:
            return None

# Preferences methods ######################################################### 
开发者ID:getting-things-gnome,项目名称:gtg,代码行数:22,代码来源:export.py

示例6: on_import_click

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_CANCEL [as 别名]
def on_import_click(self, widget):
        fcd = Gtk.FileChooserDialog(
                      'Select a colorscheme', self.parent,
                      Gtk.FileChooserAction.OPEN,
                      (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                       Gtk.STOCK_OPEN, Gtk.ResponseType.OK))

        filter = Gtk.FileFilter()
        filter.set_name("JSON colorscheme")
        filter.add_mime_type("application/json")
        fcd.add_filter(filter)
        response = fcd.run()

        if response == Gtk.ResponseType.OK:
            self.color_list = color.get_color_list(fcd.get_filename(), True)
            self.render_buttons()
            self.render_sample()
        fcd.destroy() 
开发者ID:deviantfero,项目名称:wpgtk,代码行数:20,代码来源:color_grid.py

示例7: _config_chooser_dialog

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_CANCEL [as 别名]
def _config_chooser_dialog(self, title_text, description):
        """Dialog to select which config shall be exported

        :param title_text: Title text
        :param description: Description
        """
        dialog = Gtk.Dialog(title_text, self.view["preferences_window"],
                            flags=0, buttons=
                            (Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,
                             Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))
        label = Gtk.Label(label=description)
        label.set_padding(xpad=10, ypad=10)
        dialog.vbox.pack_start(label, True, True, 0)
        label.show()
        self._gui_checkbox = Gtk.CheckButton(label="GUI Config")
        dialog.vbox.pack_start(self._gui_checkbox, True, True, 0)
        self._gui_checkbox.show()
        self._core_checkbox = Gtk.CheckButton(label="Core Config")
        self._core_checkbox.show()
        dialog.vbox.pack_start(self._core_checkbox, True, True, 0)
        response = dialog.run()
        dialog.destroy()
        return response 
开发者ID:DLR-RM,项目名称:RAFCON,代码行数:25,代码来源:preferences_window.py

示例8: __show_file_chooser

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_CANCEL [as 别名]
def __show_file_chooser(self, button):
        """ Tworzenie dialogu wyboru pliku obrazu
        """
        dialog = Gtk.FileChooserDialog("Please choose a file", self, Gtk.FileChooserAction.OPEN, (
              Gtk.STOCK_CANCEL
            , Gtk.ResponseType.CANCEL
            , Gtk.STOCK_OPEN
            , Gtk.ResponseType.OK
        ))

        filters = {
            "application/x-cd-image": "CD/DVD image"
        }
        for key, val in filters.items():
            filter_text = Gtk.FileFilter()
            filter_text.set_name(val)
            filter_text.add_mime_type(key)
            dialog.add_filter(filter_text)

        response = dialog.run()
        if response == Gtk.ResponseType.OK:
            self.path.set_text(dialog.get_filename())
        elif response == Gtk.ResponseType.CANCEL:
            print("Cancel clicked")
        dialog.destroy() 
开发者ID:Mati365,项目名称:pyWinUSB,代码行数:27,代码来源:window.py

示例9: bruter_open_user_file

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_CANCEL [as 别名]
def bruter_open_user_file(self ,widget):
		dialog = Gtk.FileChooserDialog("Please choose a file", None,
			Gtk.FileChooserAction.OPEN,
			(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
			 Gtk.STOCK_OPEN, Gtk.ResponseType.OK))

		file_filters.add_filter_txt(dialog)

		response = dialog.run()
		if response == Gtk.ResponseType.OK:
			file_selected = dialog.get_filename()
			self.bruter_user_wl_path.set_text(file_selected)
		elif response == Gtk.ResponseType.CANCEL:
			dialog.destroy()

		dialog.destroy() 
开发者ID:r3vn,项目名称:badKarma,代码行数:18,代码来源:bruter.py

示例10: bruter_open_pass_file

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_CANCEL [as 别名]
def bruter_open_pass_file(self ,widget):
		dialog = Gtk.FileChooserDialog("Please choose a file", None,
			Gtk.FileChooserAction.OPEN,
			(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
			 Gtk.STOCK_OPEN, Gtk.ResponseType.OK))

		file_filters.add_filter_txt(dialog)

		response = dialog.run()
		if response == Gtk.ResponseType.OK:
			file_selected = dialog.get_filename()
			self.bruter_pass_wl_path.set_text(file_selected)
		elif response == Gtk.ResponseType.CANCEL:
			dialog.destroy()

		dialog.destroy() 
开发者ID:r3vn,项目名称:badKarma,代码行数:18,代码来源:bruter.py

示例11: save_file_as

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_CANCEL [as 别名]
def save_file_as(self, widget):
		""" save the project's sqlite database """

		dialog = Gtk.FileChooserDialog("Please choose a filename", None,
			Gtk.FileChooserAction.SAVE,
			(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
			 Gtk.STOCK_SAVE, Gtk.ResponseType.OK))


		dialog.set_filename("project")
		file_filters.add_filter_database(dialog)

		response = dialog.run()
		if response == Gtk.ResponseType.OK:
			file_selected = dialog.get_filename()
			try:
				shutil.copy(self.engine.database.db_loc, file_selected)
			except: pass
			
		elif response == Gtk.ResponseType.CANCEL:
			dialog.destroy()

		dialog.destroy() 
开发者ID:r3vn,项目名称:badKarma,代码行数:25,代码来源:main.py

示例12: file_chooser_save_action

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_CANCEL [as 别名]
def file_chooser_save_action(self, on_success):
        """
        Opens the file chooser and runs on_success upon completion of valid file choice.

        :param on_success: A function to run upon selection of a filename. Takes 2
            parameters: The instance of the application (App) and the chosen filename. This
            gets run immediately in the same thread.
        :return: None
        """
        dialog = Gtk.FileChooserDialog("Save file", self.window,
                                       Gtk.FileChooserAction.SAVE,
                                       (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                                        Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
        dialog.set_current_name("Untitled")
        response = dialog.run()
        if response == Gtk.ResponseType.OK:
            filename = dialog.get_filename()
            dialog.destroy()
            on_success(self, filename)
        elif response == Gtk.ResponseType.CANCEL:
            self.info("Save cancelled.")  # print("Cancel clicked")
            dialog.destroy() 
开发者ID:Denvi,项目名称:FlatCAM,代码行数:24,代码来源:FlatCAMApp.py

示例13: on_reset_menu_clicked

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_CANCEL [as 别名]
def on_reset_menu_clicked(self, button):
        self.popover.hide()
        def __confirmation_dialog_response(widget, response_id):
            if response_id == Gtk.ResponseType.OK:
                utility.reset_config()
                self.config = Config()
                # Remove breaks from the container
                self.box_short_breaks.foreach(lambda element: self.box_short_breaks.remove(element))
                self.box_long_breaks.foreach(lambda element: self.box_long_breaks.remove(element))
                # Remove plugins from the container
                self.box_plugins.foreach(lambda element: self.box_plugins.remove(element))
                # Initialize again
                self.__initialize(self.config)
            widget.destroy()

        messagedialog = Gtk.MessageDialog(parent=self.window,
                                          flags=Gtk.DialogFlags.MODAL,
                                          type=Gtk.MessageType.WARNING,
                                          buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                                                   _("Reset"), Gtk.ResponseType.OK),
                                          message_format=_("Are you sure you want to reset all settings to default?"))
        messagedialog.connect("response", __confirmation_dialog_response)
        messagedialog.format_secondary_text(_("You can't undo this action."))
        messagedialog.show() 
开发者ID:slgobinath,项目名称:SafeEyes,代码行数:26,代码来源:settings_dialog.py

示例14: __delete_break

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_CANCEL [as 别名]
def __delete_break(self, break_config, is_short, on_remove):
        """
        Remove the break after a confirmation.
        """

        def __confirmation_dialog_response(widget, response_id):
            if response_id == Gtk.ResponseType.OK:
                if is_short:
                    self.config.get('short_breaks').remove(break_config)
                else:
                    self.config.get('long_breaks').remove(break_config)
                on_remove()
            widget.destroy()

        messagedialog = Gtk.MessageDialog(parent=self.window,
                                          flags=Gtk.DialogFlags.MODAL,
                                          type=Gtk.MessageType.WARNING,
                                          buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                                                   _("Delete"), Gtk.ResponseType.OK),
                                          message_format=_("Are you sure you want to delete this break?"))
        messagedialog.connect("response", __confirmation_dialog_response)
        messagedialog.format_secondary_text(_("You can't undo this action."))
        messagedialog.show() 
开发者ID:slgobinath,项目名称:SafeEyes,代码行数:25,代码来源:settings_dialog.py

示例15: select_image

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_CANCEL [as 别名]
def select_image(self, button):
        """
        Show a file chooser dialog and let the user to select an image.
        """
        dialog = Gtk.FileChooserDialog(_('Please select an image'), self.window, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK))

        png_filter = Gtk.FileFilter()
        png_filter.set_name("PNG files")
        png_filter.add_mime_type("image/png")
        png_filter.add_pattern("*.png")
        dialog.add_filter(png_filter)

        response = dialog.run()
        if response == Gtk.ResponseType.OK:
            self.break_config['image'] = dialog.get_filename()
            pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(self.break_config['image'], 16, 16, True)
            self.img_break.set_from_pixbuf(pixbuf)
        elif response == Gtk.ResponseType.CANCEL:
            self.break_config.pop('image', None)
            self.img_break.set_from_stock('gtk-missing-image', Gtk.IconSize.BUTTON)

        dialog.destroy() 
开发者ID:slgobinath,项目名称:SafeEyes,代码行数:24,代码来源:settings_dialog.py


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