python类BUTTONS_OK的实例源码

xdot.py 文件源码 项目:Eagle 作者: magerx 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def set_dotcode(self, dotcode, filename='<stdin>'):
        if isinstance(dotcode, unicode):
            dotcode = dotcode.encode('utf8')
        p = subprocess.Popen(
            [self.filter, '-Txdot'],
            stdin=subprocess.PIPE,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            shell=False,
            universal_newlines=True
        )
        xdotcode, error = p.communicate(dotcode)
        if p.returncode != 0:
            dialog = gtk.MessageDialog(type=gtk.MESSAGE_ERROR,
                                       message_format=error,
                                       buttons=gtk.BUTTONS_OK)
            dialog.set_title('Dot Viewer')
            dialog.run()
            dialog.destroy()
            return False
        try:
            self.set_xdotcode(xdotcode)
        except ParseError, ex:
            dialog = gtk.MessageDialog(type=gtk.MESSAGE_ERROR,
                                       message_format=str(ex),
                                       buttons=gtk.BUTTONS_OK)
            dialog.set_title('Dot Viewer')
            dialog.run()
            dialog.destroy()
            return False
        else:
            self.openfilename = filename
            return True
xdot.py 文件源码 项目:Eagle 作者: magerx 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def open_file(self, filename):
        try:
            fp = file(filename, 'rt')
            self.set_dotcode(fp.read(), filename)
            fp.close()
        except IOError, ex:
            dlg = gtk.MessageDialog(type=gtk.MESSAGE_ERROR,
                                    message_format=str(ex),
                                    buttons=gtk.BUTTONS_OK)
            dlg.set_title('Dot Viewer')
            dlg.run()
            dlg.destroy()
xdot.py 文件源码 项目:landport 作者: land-pack 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def open_file(self, filename):
        try:
            fp = file(filename, 'rt')
            self.set_dotcode(fp.read(), filename)
            fp.close()
        except IOError as ex:
            dlg = gtk.MessageDialog(type=gtk.MESSAGE_ERROR,
                                    message_format=str(ex),
                                    buttons=gtk.BUTTONS_OK)
            dlg.set_title(self.base_title)
            dlg.run()
            dlg.destroy()
xdot.py 文件源码 项目:Helix 作者: 3lackrush 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def open_file(self, filename):
        try:
            fp = file(filename, 'rt')
            self.set_dotcode(fp.read(), filename)
            fp.close()
        except IOError as ex:
            dlg = gtk.MessageDialog(type=gtk.MESSAGE_ERROR,
                                    message_format=str(ex),
                                    buttons=gtk.BUTTONS_OK)
            dlg.set_title(self.base_title)
            dlg.run()
            dlg.destroy()
gutils.py 文件源码 项目:griffith 作者: Strit 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def error(msg, parent=None):
    dialog = gtk.MessageDialog(parent,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, msg)
    dialog.set_skip_taskbar_hint(False)
    dialog.run()
    dialog.destroy()
gutils.py 文件源码 项目:griffith 作者: Strit 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def urllib_error(msg, parent=None):
    dialog = gtk.MessageDialog(parent,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, msg)
    dialog.set_skip_taskbar_hint(False)
    dialog.run()
    dialog.destroy()
gutils.py 文件源码 项目:griffith 作者: Strit 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def warning(msg, parent=None):
    if mac:
        macutils.createAlert(msg)
    else:
        dialog = gtk.MessageDialog(parent,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            gtk.MESSAGE_WARNING, gtk.BUTTONS_OK, msg)
        dialog.set_skip_taskbar_hint(False)
        dialog.run()
        dialog.destroy()
gutils.py 文件源码 项目:griffith 作者: Strit 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def info(msg, parent=None):
    if mac:
        macutils.createAlert(msg)
    else:
        dialog = gtk.MessageDialog(parent,
                gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                gtk.MESSAGE_INFO, gtk.BUTTONS_OK, msg)
        dialog.set_skip_taskbar_hint(False)
        dialog.run()
        dialog.destroy()
xdot.py 文件源码 项目:autoscan 作者: b01u 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def set_dotcode(self, dotcode, filename='<stdin>'):
        if isinstance(dotcode, unicode):
            dotcode = dotcode.encode('utf8')
        p = subprocess.Popen(
            [self.filter, '-Txdot'],
            stdin=subprocess.PIPE,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            shell=False,
            universal_newlines=True
        )
        xdotcode, error = p.communicate(dotcode)
        if p.returncode != 0:
            dialog = gtk.MessageDialog(type=gtk.MESSAGE_ERROR,
                                       message_format=error,
                                       buttons=gtk.BUTTONS_OK)
            dialog.set_title('Dot Viewer')
            dialog.run()
            dialog.destroy()
            return False
        try:
            self.set_xdotcode(xdotcode)
        except ParseError, ex:
            dialog = gtk.MessageDialog(type=gtk.MESSAGE_ERROR,
                                       message_format=str(ex),
                                       buttons=gtk.BUTTONS_OK)
            dialog.set_title('Dot Viewer')
            dialog.run()
            dialog.destroy()
            return False
        else:
            self.openfilename = filename
            return True
xdot.py 文件源码 项目:autoscan 作者: b01u 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def open_file(self, filename):
        try:
            fp = file(filename, 'rt')
            self.set_dotcode(fp.read(), filename)
            fp.close()
        except IOError, ex:
            dlg = gtk.MessageDialog(type=gtk.MESSAGE_ERROR,
                                    message_format=str(ex),
                                    buttons=gtk.BUTTONS_OK)
            dlg.set_title('Dot Viewer')
            dlg.run()
            dlg.destroy()
gnome_connection_manager.py 文件源码 项目:gnome-connection-manager 作者: mjun 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def msgbox(text, parent=None):
    msgBox = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, text)
    msgBox.set_icon_from_file(ICON_PATH)
    msgBox.run()    
    msgBox.destroy()
gnome_connection_manager.py 文件源码 项目:gnome-connection-manager 作者: mjun 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def msg(self, text, parent):        
        self.msgBox = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, text)
        self.msgBox.set_icon_from_file(ICON_PATH)
        self.msgBox.connect('response', self.on_clicked)
        self.msgBox.show_all()      
        return False
smalictrace.py 文件源码 项目:linux-pentest-util 作者: fikr4n 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def _launch_error(self, exception, message, fatal=False):
        dlg = gtk.MessageDialog(parent=None,
            type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK, message_format=
            '%s\n\n%s' % (message, str(exception)))
        dlg.set_title('Error')
        dlg.connect('response', gtk.main_quit if fatal else lambda *x: dlg.destroy())
        dlg.show_all()
glade2.py 文件源码 项目:wahcade 作者: sairuk 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def show_msg_dialog(self, dlg_type=gtk.MESSAGE_INFO, dlg_buttons=gtk.BUTTONS_OK, msg=None):
        """display a MessageDialog"""
        mdlg = gtk.MessageDialog(type=dlg_type, buttons=dlg_buttons, message_format=msg)
        resp = mdlg.run()
        mdlg.destroy()
        #done
        return resp

    #map getitem to getattr
mainapp.py 文件源码 项目:chirp_fork 作者: mach327 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def _show_instructions(self, radio, message):
        if message is None:
            return

        if CONF.get_bool("clone_instructions", "noconfirm"):
            return

        d = gtk.MessageDialog(parent=self, buttons=gtk.BUTTONS_OK)
        d.set_markup("<big><b>" + _("{name} Instructions").format(
                     name=radio.get_name()) + "</b></big>")
        msg = _("{instructions}").format(instructions=message)
        d.format_secondary_markup(msg)

        again = gtk.CheckButton(
            _("Don't show instructions for any radio again"))
        again.show()
        again.connect("toggled", lambda action:
                      self.clonemenu.set_active(not action.get_active()))
        d.vbox.pack_start(again, 0, 0, 0)
        h_button_box = d.vbox.get_children()[2]
        try:
            ok_button = h_button_box.get_children()[0]
            ok_button.grab_default()
            ok_button.grab_focus()
        except AttributeError:
            # don't grab focus on GTK+ 2.0
            pass
        d.run()
        d.destroy()
mainapp.py 文件源码 项目:chirp_fork 作者: mach327 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def _updates(self, version):
        if not version:
            return

        if version == CHIRP_VERSION:
            return

        LOG.info("Server reports version %s is available" % version)

        # Report new updates every seven days
        intv = 3600 * 24 * 7

        if CONF.is_defined("last_update_check", "state") and \
           (time.time() - CONF.get_int("last_update_check", "state")) < intv:
            return

        CONF.set_int("last_update_check", int(time.time()), "state")
        d = gtk.MessageDialog(buttons=gtk.BUTTONS_OK, parent=self,
                              type=gtk.MESSAGE_INFO)
        d.set_property("text",
                       _("A new version of CHIRP is available: " +
                         "{ver}. ".format(ver=version) +
                         "It is recommended that you upgrade, so " +
                         "go to http://chirp.danplanet.com soon!"))
        d.run()
        d.destroy()
importdialog.py 文件源码 项目:chirp_fork 作者: mach327 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def _toggle(self, rend, path, col):
        iter = self.__store.get_iter(path)
        imp, nloc = self.__store.get(iter, self.col_import, self.col_nloc)
        if not imp and self._check_for_dupe(nloc):
            d = gtk.MessageDialog(parent=self, buttons=gtk.BUTTONS_OK)
            d.set_property("text",
                           _("Location {number} is already being imported. "
                             "Choose another value for 'New Location' "
                             "before selection 'Import'").format(number=nloc))
            d.run()
            d.destroy()
        else:
            self.__store[path][col] = not imp
importdialog.py 文件源码 项目:chirp_fork 作者: mach327 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def _edited(self, rend, path, new, col):
        iter = self.__store.get_iter(path)

        if col == self.col_nloc:
            nloc, = self.__store.get(iter, self.col_nloc)

            try:
                val = int(new)
            except ValueError:
                common.show_error(_("Invalid value. Must be an integer."))
                return

            if val == nloc:
                return

            if self._check_for_dupe(val):
                d = gtk.MessageDialog(parent=self, buttons=gtk.BUTTONS_OK)
                d.set_property("text",
                               _("Location {number} is already being "
                                 "imported").format(number=val))
                d.run()
                d.destroy()
                return

            self.record_use_of(val)

        elif col == self.col_name or col == self.col_comm:
            val = str(new)

        else:
            return

        self.__store.set(iter, col, val)
inputdialog.py 文件源码 项目:chirp_fork 作者: mach327 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, exception, **args):
        gtk.MessageDialog.__init__(self, buttons=gtk.BUTTONS_OK,
                                   type=gtk.MESSAGE_ERROR, **args)
        self.set_property("text", _("An error has occurred"))
        self.format_secondary_text(str(exception))

        import traceback
        import sys
        reporting.report_exception(traceback.format_exc(limit=30))
        LOG.error("--- Exception Dialog: %s ---" % exception)
        LOG.error(traceback.format_exc(limit=100))
        LOG.error("----------------------------")
common.py 文件源码 项目:chirp_fork 作者: mach327 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def show_error(msg, parent=None):
    d = gtk.MessageDialog(buttons=gtk.BUTTONS_OK, parent=parent,
                          type=gtk.MESSAGE_ERROR)
    d.set_property("text", msg)

    if not parent:
        d.set_position(gtk.WIN_POS_CENTER_ALWAYS)

    d.run()
    d.destroy()


问题


面经


文章

微信
公众号

扫码关注公众号