Python gtk 模块,BUTTONS_OK_CANCEL 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用gtk.BUTTONS_OK_CANCEL

项目:colorize    作者:BruXy    | 项目源码 | 文件源码
def gui_ask_for_api():
    """Gtk dialog for API key insert."""
    message = gtk.MessageDialog(type=gtk.MESSAGE_QUESTION, buttons=gtk.BUTTONS_OK_CANCEL)
    message.set_markup(colorize.MSG_ASK_API.replace(colorize.URL,"<u>" + colorize.URL +"</u>"))

    entry = gtk.Entry(max=64)
    entry.set_text("Enter your API key")
    entry.show()
    message.vbox.pack_end(entry)
    entry.connect("activate", lambda _: d.response(gtk.RESPONSE_OK))
    message.set_default_response(gtk.RESPONSE_OK)
    message.run()

    api_key = entry.get_text().decode('utf8')
    fp = open(colorize.HOME + colorize.API_KEY_FILE, 'w')
    fp.write("YOUR_API_KEY={0}{1}".format(api_key, os.linesep))
    fp.close()

    # process buttong click immediately
    message.destroy()
    while gtk.events_pending():
        gtk.main_iteration()
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def askQ(query, prompt=None, parent=None):
    if prompt:
        dia = EntryDialog(parent, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, query, default_value=prompt)
    else:
        dia = EntryDialog(parent, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, query)
    dia.show()
    rtn=dia.run()
    dia.destroy()
    return rtn
项目:zim-icontags-plugin    作者:Pl-M    | 项目源码 | 文件源码
def __init__(self, window, index, uistate):

        Dialog.__init__(self, window, _('Tags Manager (IconTags plugin)'), # T: dialog title
                        buttons=gtk.BUTTONS_OK_CANCEL,
                        defaultwindowsize=(450, 400) )

        # Don't confuse with local variable 'self.uistate',
        # which is already determined for this class.
        self._window = window
        self.plugin_uistate = uistate
        self.show_pages_button = gtk.ToggleButton('Show Pages')
    self.show_pages_button.connect('toggled', self.toggle_show_pages)
        self.add_extra_button(self.show_pages_button)

        self.treeview_tags = TagsManagerTagsView(index, self.plugin_uistate['Icons for Tags'])
        self.treeview_pages = TagsManagerPagesView(index, window.ui)
        self.scrolled_widget = ScrolledWindow(self.treeview_tags)
        self.vbox.pack_start(self.scrolled_widget, True)

        self.treeview_tags.connect('row-activated', self.get_tag)

        # Enable left/right arrows to navigate between views.
        self.treeview_tags.connect('key-release-event', self.toggle_view)
        self.treeview_pages.connect('key-release-event', self.toggle_view)

        # Update if tags change.
        self.connectto_all(index, (
            ('tag-inserted', lambda *a: self.update()),
            ('tag-removed', lambda *a: self.update())
        ))

        self.show_all()
项目:zim-icontags-plugin    作者:Pl-M    | 项目源码 | 文件源码
def __init__(self, window, index, uistate):

        Dialog.__init__(self, window, _('Tags Manager (IconTags plugin)'), # T: dialog title
                        buttons=gtk.BUTTONS_OK_CANCEL,
                        defaultwindowsize=(450, 400) )

        # Don't confuse with local variable 'self.uistate',
        # which is already determined for this class.
        self._window = window
        self.plugin_uistate = uistate
        self.show_pages_button = gtk.ToggleButton('Show Pages')
        self.show_pages_button.connect('toggled', self.toggle_show_pages)
        self.add_extra_button(self.show_pages_button)

        self.treeview_tags = TagsManagerTagsView(index, self.plugin_uistate['Icons for Tags'])
        self.treeview_pages = TagsManagerPagesView(index, window.ui)
        self.scrolled_widget = ScrolledWindow(self.treeview_tags)
        self.vbox.pack_start(self.scrolled_widget, True)

        self.treeview_tags.connect('row-activated', self.get_tag)

        # Enable left/right arrows to navigate between views.
        self.treeview_tags.connect('key-release-event', self.toggle_view)
        self.treeview_pages.connect('key-release-event', self.toggle_view)

        # Update if tags change.
        self.connectto_all(index.update_iter.tags, (
            ('tag-row-inserted', lambda *a: self.update()),
            ('tag-row-deleted', lambda *a: self.update())
        ))

        self.show_all()
项目:NativeCAM    作者:FernV    | 项目源码 | 文件源码
def action_renameF(self, *arg):
        self.newnamedlg = gtk.MessageDialog(parent = None,
            flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            type = gtk.MESSAGE_QUESTION,
            buttons = gtk.BUTTONS_OK_CANCEL
        )
        old_name = self.selected_feature.get_attr('name')
        self.newnamedlg.set_markup(_('Enter new name for'))
        self.newnamedlg.format_secondary_markup(old_name)
        self.newnamedlg.set_title('NativeCAM')
        edit_entry = gtk.Entry()
        edit_entry.set_editable(True)
        edit_entry.set_text(old_name)
        edit_entry.connect('key-press-event', self.action_rename_keyhandler)
        self.newnamedlg.vbox.add(edit_entry)
        self.newnamedlg.set_keep_above(True)

        (tree_x, tree_y) = self.treeview.get_bin_window().get_origin()
        self.newnamedlg.move(tree_x, tree_y + self.click_y)

        self.newnamedlg.show_all()
        response = self.newnamedlg.run()
        if (response == gtk.RESPONSE_OK) :
            newname = edit_entry.get_text().lstrip(' ')
            if newname > '' :
                self.selected_feature.attr['name'] = newname
                self.refresh_views()
        self.newnamedlg.destroy()
项目:gnome-connection-manager    作者:mjun    | 项目源码 | 文件源码
def msgconfirm(text):
    msgBox = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, text)
    msgBox.set_icon_from_file(ICON_PATH)
    response = msgBox.run()    
    msgBox.destroy()
    return response