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


Python gtk.RESPONSE_CANCEL属性代码示例

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


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

示例1: quit

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import RESPONSE_CANCEL [as 别名]
def quit(self, widget, event=None):
		"""Asks if user would like to save file before quitting, then quits the program."""
		if self.toSave:
			if self.oneConfigFile:
				response = gtk.RESPONSE_YES
			else:
				dialog = gtk.Dialog("Save config?", self, gtk.DIALOG_MODAL, (gtk.STOCK_YES, gtk.RESPONSE_YES, gtk.STOCK_NO, gtk.RESPONSE_NO, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
				dialog.get_content_area().add(gtk.Label("Save config before quitting?"))
				dialog.get_content_area().set_size_request(300, 100)
				dialog.show_all()
				response = dialog.run()
				dialog.destroy()

			if response == gtk.RESPONSE_CANCEL:
				return True							# Return True to stop it quitting when we hit "Cancel"
			elif response == gtk.RESPONSE_NO:
				gtk.main_quit()
			elif response == gtk.RESPONSE_YES:
				self.save()
				gtk.main_quit()
		else:
			gtk.main_quit() 
开发者ID:milisarge,项目名称:malfs-milis,代码行数:24,代码来源:tintwizard.py

示例2: on_open

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import RESPONSE_CANCEL [as 别名]
def on_open(self, action):
        chooser = gtk.FileChooserDialog(title="Open dot File",
                                        action=gtk.FILE_CHOOSER_ACTION_OPEN,
                                        buttons=(gtk.STOCK_CANCEL,
                                                 gtk.RESPONSE_CANCEL,
                                                 gtk.STOCK_OPEN,
                                                 gtk.RESPONSE_OK))
        chooser.set_default_response(gtk.RESPONSE_OK)
        filter = gtk.FileFilter()
        filter.set_name("Graphviz dot files")
        filter.add_pattern("*.dot")
        chooser.add_filter(filter)
        filter = gtk.FileFilter()
        filter.set_name("All files")
        filter.add_pattern("*")
        chooser.add_filter(filter)
        if chooser.run() == gtk.RESPONSE_OK:
            filename = chooser.get_filename()
            chooser.destroy()
            self.open_file(filename)
        else:
            chooser.destroy() 
开发者ID:krintoxi,项目名称:NoobSec-Toolkit,代码行数:24,代码来源:xdot.py

示例3: on_open

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import RESPONSE_CANCEL [as 别名]
def on_open(self, action):
        chooser = gtk.FileChooserDialog(title="Open dot File",
                                        action=gtk.FILE_CHOOSER_ACTION_OPEN,
                                        buttons=(gtk.STOCK_CANCEL,
                                                 gtk.RESPONSE_CANCEL,
                                                 gtk.STOCK_OPEN,
                                                 gtk.RESPONSE_OK))
        chooser.set_default_response(gtk.RESPONSE_OK)
        chooser.set_current_folder(self.last_open_dir)
        filter = gtk.FileFilter()
        filter.set_name("Graphviz dot files")
        filter.add_pattern("*.dot")
        chooser.add_filter(filter)
        filter = gtk.FileFilter()
        filter.set_name("All files")
        filter.add_pattern("*")
        chooser.add_filter(filter)
        if chooser.run() == gtk.RESPONSE_OK:
            filename = chooser.get_filename()
            self.last_open_dir = chooser.get_current_folder()
            chooser.destroy()
            self.open_file(filename)
        else:
            chooser.destroy() 
开发者ID:ym2011,项目名称:POC-EXP,代码行数:26,代码来源:xdot.py

示例4: show_open_dialog

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import RESPONSE_CANCEL [as 别名]
def show_open_dialog(parent, title, action):        
    dlg = gtk.FileChooserDialog(title=title, parent=parent, action=action)
    dlg.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
    
    dlg.add_button(gtk.STOCK_SAVE if action==gtk.FILE_CHOOSER_ACTION_SAVE else gtk.STOCK_OPEN, gtk.RESPONSE_OK)        
    dlg.set_do_overwrite_confirmation(True)        
    if not hasattr(parent,'lastPath'):
        parent.lastPath = os.path.expanduser("~")
    dlg.set_current_folder( parent.lastPath )
    
    if dlg.run() == gtk.RESPONSE_OK:
        filename = dlg.get_filename()
        parent.lastPath = os.path.dirname(filename)
    else:
        filename = None
    dlg.destroy()
    return filename 
开发者ID:mjun,项目名称:gnome-connection-manager,代码行数:19,代码来源:gnome_connection_manager.py

示例5: show_save_buffer

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import RESPONSE_CANCEL [as 别名]
def show_save_buffer(self, terminal):        
        dlg = gtk.FileChooserDialog(title=_("Guardar como"), parent=self.wMain, action=gtk.FILE_CHOOSER_ACTION_SAVE)
        dlg.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
        dlg.add_button(gtk.STOCK_SAVE, gtk.RESPONSE_OK)        
        dlg.set_do_overwrite_confirmation(True)
        dlg.set_current_name( os.path.basename("gcm-buffer-%s.txt" % (time.strftime("%Y%m%d%H%M%S")) ))
        if not hasattr(self,'lastPath'):
            self.lastPath = os.path.expanduser("~")
        dlg.set_current_folder( self.lastPath )
        
        if dlg.run() == gtk.RESPONSE_OK:
            filename = dlg.get_filename()
            self.lastPath = os.path.dirname(filename)            
    
            try:              
                buff = terminal.get_text_range(0, 0, terminal.get_property('scrollback-lines')-1, terminal.get_column_count()-1, lambda *args: True, None, None ).strip()                
                f = open(filename, "w")
                f.write(buff)
                f.close()
            except:                
                dlg.destroy()
                msgbox("%s: %s" % (_("No se puede abrir archivo para escritura"), filename) )
                return
            
        dlg.destroy() 
开发者ID:mjun,项目名称:gnome-connection-manager,代码行数:27,代码来源:gnome_connection_manager.py

示例6: chooseFile

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import RESPONSE_CANCEL [as 别名]
def chooseFile(self, default_dir=None,
                   filter_patterns=None):
        dialog = gtk.FileChooserDialog(
            title="Open File",
            parent=self._win,
            action=gtk.FILE_CHOOSER_ACTION_OPEN,
            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                     gtk.STOCK_OPEN, gtk.RESPONSE_OK))

        dialog.set_default_response(gtk.RESPONSE_OK)

        patterns = self._str_to_obj(filter_patterns) or {"xml": "XML Files"}
        for pattern in patterns:
            file_filter = gtk.FileFilter()
            file_filter.set_name(patterns[pattern])
            file_filter.add_pattern('*.{}'.format(pattern))
            dialog.add_filter(file_filter)

        if default_dir is not None:
            dialog.set_current_folder(os.path.expanduser(default_dir))

        path = ""

        response = dialog.run()
        if response == gtk.RESPONSE_OK:
            path = dialog.get_filename()
        elif response == gtk.RESPONSE_CANCEL:
            self.error("No files selected.")

        dialog.destroy()

        return path 
开发者ID:KanoComputing,项目名称:kano-toolset,代码行数:34,代码来源:webapp.py

示例7: filedialog

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import RESPONSE_CANCEL [as 别名]
def filedialog(self, title=None, default_filename=None):
        chooser = gtk.FileChooserDialog(title=title, parent=self.window,
                                        action=gtk.FILE_CHOOSER_ACTION_OPEN,
                                        buttons=(
                                            gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN,
                                            gtk.RESPONSE_OK))
        chooser.resize(700, 500)
        if default_filename:
            chooser.set_filename(os.path.abspath(default_filename))
        filename = None
        response = chooser.run()
        if response == gtk.RESPONSE_OK:
            filename = chooser.get_filename()
        chooser.destroy()
        return filename 
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:17,代码来源:step_editor.py

示例8: openFile

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import RESPONSE_CANCEL [as 别名]
def openFile(self, widget=None, default=False):
		"""Reads from a config file. If default=True, open the tint2 default config."""
		self.new()

		if not default:
			chooser = gtk.FileChooserDialog("Open Config File", self, gtk.FILE_CHOOSER_ACTION_OPEN, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK))
			chooser.set_default_response(gtk.RESPONSE_OK)

			if self.curDir != None:
				chooser.set_current_folder(self.curDir)

			chooserFilter = gtk.FileFilter()
			chooserFilter.set_name("All files")
			chooserFilter.add_pattern("*")
			chooser.add_filter(chooserFilter)
			chooser.show()

			response = chooser.run()

			if response == gtk.RESPONSE_OK:
				self.filename = chooser.get_filename()
				self.curDir = os.path.dirname(self.filename)
			else:
				chooser.destroy()
				return

			chooser.destroy()
		else:
			self.filename = os.path.expandvars("$HOME/.config/tint2/tint2rc")
			self.curDir = os.path.expandvars("$HOME/.config/tint2")

		self.readTint2Config()
		self.generateConfig()
		self.updateStatusBar() 
开发者ID:milisarge,项目名称:malfs-milis,代码行数:36,代码来源:tintwizard.py

示例9: saveAs

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import RESPONSE_CANCEL [as 别名]
def saveAs(self, widget=None, event=None):
		"""Prompts the user to select a file and then saves the generated config file."""
		self.generateConfig()

		chooser = gtk.FileChooserDialog("Save Config File As...", self, gtk.FILE_CHOOSER_ACTION_SAVE, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE, gtk.RESPONSE_OK))
		chooser.set_default_response(gtk.RESPONSE_OK)

		if self.curDir != None:
			chooser.set_current_folder(self.curDir)

		chooserFilter = gtk.FileFilter()
		chooserFilter.set_name("All files")
		chooserFilter.add_pattern("*")
		chooser.add_filter(chooserFilter)
		chooser.show()

		response = chooser.run()

		if response == gtk.RESPONSE_OK:
			self.filename = chooser.get_filename()

			if os.path.exists(self.filename):
				overwrite = confirmDialog(self, "This file already exists. Overwrite this file?")

				if overwrite == gtk.RESPONSE_YES:
					self.writeFile()
					chooser.destroy()
					return True
				else:
					self.filename = None
					chooser.destroy()
					return False
			else:
				self.writeFile()
				chooser.destroy()
				return True
		else:
			self.filename = None
			chooser.destroy()
			return False 
开发者ID:milisarge,项目名称:malfs-milis,代码行数:42,代码来源:tintwizard.py

示例10: _get_export_file_name

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import RESPONSE_CANCEL [as 别名]
def _get_export_file_name(self):
        sel = gtk.FileChooserDialog("Save...", self.canvas.get_toplevel(),
                                    gtk.FILE_CHOOSER_ACTION_SAVE,
                                    (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                     gtk.STOCK_SAVE, gtk.RESPONSE_OK))
        sel.set_default_response(gtk.RESPONSE_OK)
        sel.set_local_only(True)
        sel.set_do_overwrite_confirmation(True)
        sel.set_current_name("Unnamed.pdf")

        filter = gtk.FileFilter()
        filter.set_name("Embedded PostScript")
        filter.add_mime_type("image/x-eps")
        sel.add_filter(filter)

        filter = gtk.FileFilter()
        filter.set_name("Portable Document Graphics")
        filter.add_mime_type("application/pdf")
        sel.add_filter(filter)

        filter = gtk.FileFilter()
        filter.set_name("Scalable Vector Graphics")
        filter.add_mime_type("image/svg+xml")
        sel.add_filter(filter)

        resp = sel.run()
        if resp != gtk.RESPONSE_OK:
            sel.destroy()
            return None
        
        file_name = sel.get_filename()
        sel.destroy()
        return file_name 
开发者ID:ntu-dsi-dcn,项目名称:ntu-dsi-dcn,代码行数:35,代码来源:core.py

示例11: on_save_changes_clicked

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import RESPONSE_CANCEL [as 别名]
def on_save_changes_clicked(self, *args):
        """send updated handlers dictionary to server, call the callback if supplied"""
        settings = self.collect_dialog_settings()
        handler_id = self.handler_name_combo_entry.child.get_text().strip()
        if not handler_id:
            dialog = InfoDialog("Identifier Required",
                                "The Handler requires a Name.",
                                modal=True)
            dialog.run()
            dialog.destroy()
            return
        if handler_id in self.handlers:
            buttons = (gtk.STOCK_CANCEL,
                       gtk.RESPONSE_CANCEL,
                       gtk.STOCK_OK,
                       gtk.RESPONSE_OK,)

            dialog = ResponseDialog("Overwrite?",
                                    "Overwrite the profile named {0}? "
                                    "Auto-sort rules that use this handler will "
                                    "be affected.".format(handler_id),
                                    buttons=buttons)
            response = dialog.run()
            dialog.destroy()
            if response != gtk.RESPONSE_OK:
                return
        self.handlers[handler_id] = settings
        self.window.destroy()
        if self.cb:
            self.cb(handler_id, self.handlers) 
开发者ID:Laharah,项目名称:deluge-FileBotTool,代码行数:32,代码来源:handler_editor.py

示例12: __init__

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import RESPONSE_CANCEL [as 别名]
def __init__(self, title, message, parent=None, modal=True, buttons=None):
        if not buttons:
            buttons = (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT, gtk.STOCK_CANCEL,
                       gtk.RESPONSE_CANCEL)
        modal = gtk.DIALOG_MODAL if modal else 0
        super(self.__class__, self).__init__(title, parent, modal, buttons)
        self.message = message
        label = gtk.Label(message)
        self.get_content_area().add(label)
        self.set_gravity(gtk.gdk.GRAVITY_CENTER)
        self.set_position(gtk.WIN_POS_CENTER)
        self.show_all() 
开发者ID:Laharah,项目名称:deluge-FileBotTool,代码行数:14,代码来源:user_messenger.py

示例13: askOpenFileGtk

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import RESPONSE_CANCEL [as 别名]
def askOpenFileGtk(title, suffixes, initialDir):
    fls = []
    def run_dlg():
        chooser = gtk.FileChooserDialog(title,
                                        None, gtk.FILE_CHOOSER_ACTION_SAVE,
                                        (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                        gtk.STOCK_OPEN, gtk.RESPONSE_OK))
    
        chooser.set_default_response(gtk.RESPONSE_OK)
        chooser.set_current_folder(initialDir)
        chooser.set_current_name("world")  # For some reason the Windows isn't closing if this line ins missing or the parameter is ""

        # Add custom Filter
        file_filter = gtk.FileFilter()
        file_filter.set_name(_("Levels and Schematics"))
        for suffix in suffixes:
            file_filter.add_pattern("*." + suffix)
        chooser.add_filter(file_filter)

        # Add "All files" Filter
        file_filter = gtk.FileFilter()
        file_filter.set_name("All files")
        file_filter.add_pattern("*")
        chooser.add_filter(file_filter)

        response = chooser.run()
        if response == gtk.RESPONSE_OK:
            fls.append(chooser.get_filename())
        else:
            fls.append(None)
        chooser.destroy()
        gtk.main_quit()

    gtk.idle_add(run_dlg)
    gtk.main()

    return fls[0] 
开发者ID:mcgreentn,项目名称:GDMC,代码行数:39,代码来源:mcplatform.py

示例14: _on_loginDialog_response

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import RESPONSE_CANCEL [as 别名]
def _on_loginDialog_response(self, widget, response):
        handlers = {gtk.RESPONSE_NONE: self._windowClosed,
                   gtk.RESPONSE_DELETE_EVENT: self._windowClosed,
                   gtk.RESPONSE_OK: self._doLogin,
                   gtk.RESPONSE_CANCEL: self._cancelled}
        handler = handlers.get(response)
        if handler is not None:
            handler()
        else:
            log.msg("Unexpected dialog response %r from %s" % (response,
                                                               widget)) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:13,代码来源:gtk2util.py


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