Python gtk 模块,BUTTONS_OK 实例源码

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

项目:epoptes    作者:Epoptes    | 项目源码 | 文件源码
def disconnected(self, daemon):
        self.mainwin.set_sensitive(False)
        # If the reactor is not running at this point it means that we were
        # closed normally.
        if not reactor.running:
            return
        self.save_settings()
        msg = _("Lost connection with the epoptes service.")
        msg += "\n\n" + _("Make sure the service is running and then restart epoptes.")
        dlg = gtk.MessageDialog(type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK,
                                 message_format=msg)
        dlg.set_title(_('Service connection error'))
        dlg.run()
        dlg.destroy()
        reactor.stop()


    # AMP callbacks
项目:autoinjection    作者:ChengWiLL    | 项目源码 | 文件源码
def run_filter(self, dotcode):
        if not self.filter:
            return dotcode
        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)
        sys.stderr.write(error)
        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 None
        return xdotcode
项目:autoinjection    作者:ChengWiLL    | 项目源码 | 文件源码
def set_dotcode(self, dotcode, filename=None):
        self.openfilename = None
        if isinstance(dotcode, unicode):
            dotcode = dotcode.encode('utf8')
        xdotcode = self.run_filter(dotcode)
        if xdotcode is None:
            return False
        try:
            self.set_xdotcode(xdotcode)
        except ParseError as 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:
            if filename is None:
                self.last_mtime = None
            else:
                self.last_mtime = os.stat(filename).st_mtime
            self.openfilename = filename
            return True
项目:mgr.p2p.proxy    作者:tomusdrw    | 项目源码 | 文件源码
def connectionLost(self, reason):
        if len(self.buffer) == 0:
             dialog = gtk.MessageDialog(self, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                                        gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
                                        "An error occurred; file could not be retrieved.")
             dialog.run()
             dialog.destroy()
             return

        fd = gtk.FileChooserDialog(title=None, action=gtk.FILE_CHOOSER_ACTION_SAVE,
                                   buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_SAVE,gtk.RESPONSE_OK))
        fd.set_default_response(gtk.RESPONSE_OK)
        fd.set_current_name(self.filename)
        response = fd.run()
        if response == gtk.RESPONSE_OK:
            destfilename = fd.get_filename()
            f = open(destfilename, 'w')
            f.write(self.buffer)
            f.close()
        fd.destroy()
项目:landport    作者:land-pack    | 项目源码 | 文件源码
def run_filter(self, dotcode):
        if not self.filter:
            return dotcode
        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)
        sys.stderr.write(error)
        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 None
        return xdotcode
项目:landport    作者:land-pack    | 项目源码 | 文件源码
def set_dotcode(self, dotcode, filename=None):
        self.openfilename = None
        if isinstance(dotcode, unicode):
            dotcode = dotcode.encode('utf8')
        xdotcode = self.run_filter(dotcode)
        if xdotcode is None:
            return False
        try:
            self.set_xdotcode(xdotcode)
        except ParseError as 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:
            if filename is None:
                self.last_mtime = None
            else:
                self.last_mtime = os.stat(filename).st_mtime
            self.openfilename = filename
            return True
项目:Helix    作者:3lackrush    | 项目源码 | 文件源码
def run_filter(self, dotcode):
        if not self.filter:
            return dotcode
        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)
        sys.stderr.write(error)
        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 None
        return xdotcode
项目:Helix    作者:3lackrush    | 项目源码 | 文件源码
def set_dotcode(self, dotcode, filename=None):
        self.openfilename = None
        if isinstance(dotcode, unicode):
            dotcode = dotcode.encode('utf8')
        xdotcode = self.run_filter(dotcode)
        if xdotcode is None:
            return False
        try:
            self.set_xdotcode(xdotcode)
        except ParseError as 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:
            if filename is None:
                self.last_mtime = None
            else:
                self.last_mtime = os.stat(filename).st_mtime
            self.openfilename = filename
            return True
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def do_live_warning(self, radio):
        d = gtk.MessageDialog(parent=self, buttons=gtk.BUTTONS_OK)
        d.set_markup("<big><b>" + _("Note:") + "</b></big>")
        msg = _("The {vendor} {model} operates in <b>live mode</b>. "
                "This means that any changes you make are immediately sent "
                "to the radio. Because of this, you cannot perform the "
                "<u>Save</u> or <u>Upload</u> operations. If you wish to "
                "edit the contents offline, please <u>Export</u> to a CSV "
                "file, using the <b>File menu</b>.")
        msg = msg.format(vendor=radio.VENDOR, model=radio.MODEL)
        d.format_secondary_markup(msg)

        again = gtk.CheckButton(_("Don't show this again"))
        again.show()
        d.vbox.pack_start(again, 0, 0, 0)
        d.run()
        CONF.set_bool("live_mode", again.get_active(), "noconfirm")
        d.destroy()
项目:id_photo    作者:aeifn    | 项目源码 | 文件源码
def show_error_msg(self, msg):
    errdialog = gtk.MessageDialog(None, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, str(msg))
    errdialog.set_position(gtk.WIN_POS_CENTER_ALWAYS)
    errdialog.show_all()
    response_err = errdialog.run()
    if response_err == gtk.RESPONSE_OK:
      errdialog.hide()
      errdialog.destroy()

  # ??????? ??????? ??????????? ???? ? ??????????
项目:id_photo    作者:aeifn    | 项目源码 | 文件源码
def info(self, msg):
    infodialog = gtk.MessageDialog(None, 0, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, str(msg))
    infodialog.set_position(gtk.WIN_POS_CENTER_ALWAYS)
    infodialog.show_all()
    response_info= infodialog.run()
    if response_info == gtk.RESPONSE_OK:
      infodialog.hide()
      infodialog.destroy()

  # ??????? ??????? ??????????? ???? "? ?????????"
项目:hardened-centos7-kickstart    作者:fcaviggia    | 项目源码 | 文件源码
def MessageBox(self,parent,text,type=gtk.MESSAGE_INFO):
                message = gtk.MessageDialog(parent,0,type,gtk.BUTTONS_OK)
        message.set_markup(text)    
        response = message.run()
        if response == gtk.RESPONSE_OK:
            message.destroy()


    # Get Password
项目:ns3-rdma    作者:bobzhuyb    | 项目源码 | 文件源码
def update_view_timeout(self):
        #print "view: update_view_timeout called at real time ", time.time()

        # while the simulator is busy, run the gtk event loop
        while not self.simulation.lock.acquire(False):
            while gtk.events_pending():
                gtk.main_iteration()
        pause_messages = self.simulation.pause_messages
        self.simulation.pause_messages = []
        try:
            self.update_view()
            self.simulation.target_time = ns.core.Simulator.Now ().GetSeconds () + self.sample_period
            #print "view: target time set to %f" % self.simulation.target_time
        finally:
            self.simulation.lock.release()

        if pause_messages:
            #print pause_messages
            dialog = gtk.MessageDialog(parent=self.window, flags=0, type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_OK,
                                       message_format='\n'.join(pause_messages))
            dialog.connect("response", lambda d, r: d.destroy())
            dialog.show()
            self.play_button.set_active(False)

        # if we're paused, stop the update timer
        if not self.play_button.get_active():
            self._update_timeout_id = None
            return False

        #print "view: self.simulation.go.set()"
        self.simulation.go.set()
        #print "view: done."
        return True
项目:Web-Stalker    作者:Dylan-halls    | 项目源码 | 文件源码
def open_window(self, url):
      url = address_bar.get_text()
      for letter in url:
          if '.' not in url:
               a = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR, gtk.BUTTONS_CANCEL)
               a.set_markup("<big><b>WTF!?!? Thats not even a website?</b></big>")
               a.run()
               return
      if 'http://' not in url:
           w = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK)
           w.set_markup("<big><b>**mumble, mumble** Force to change {} to {}</b></big>".format(url, 'http://'+url+'/'))
           w.run()
           url = 'http://'+url+'/'
      os.system('python Web-Window.py '+url)
项目:Web-Stalker    作者:Dylan-halls    | 项目源码 | 文件源码
def saver(self, text):
      file_name = save_bar.get_text()
      start_iter = textbuffer.get_start_iter()
      end_iter = textbuffer.get_end_iter()
      file_data = textbuffer.get_text(start_iter, end_iter, True)  
      with open('Reports/'+file_name, 'w') as file:
         file.write(file_data)
         file.close()
      done = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO, gtk.BUTTONS_OK)
      done.set_markup("<big><b>File {} Has Been Saved</b></big>".format(file_name))
      done.run()
项目:tools    作者:denglouping    | 项目源码 | 文件源码
def show_message(message,title):
    message_dialog = gtk.MessageDialog(None, 0, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, None);
    message_dialog.set_markup(message);
    message_dialog.set_title(title)
    message_dialog.run();

#?????dialog
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def message(message, parent=None):
    dia = gtk.MessageDialog(parent, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, message)
    dia.show()
    dia.run()
    dia.destroy()
    return False
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def askFolder(query, prompt=None, parent=None):
    if prompt:
        dia = FolderDialog(parent, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK, query, default_value=prompt)
    else:
        dia = FolderDialog(parent, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK, query)
    dia.show()
    rtn=dia.run()
    dia.destroy()
    return rtn
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def message(self, message):
        dia = gtk.MessageDialog(self.window, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, message)
        dia.show()
        dia.run()
        dia.destroy()
        return False
项目:barbieri-playground    作者:barbieri    | 项目源码 | 文件源码
def show_error(parent, msg):
    d = gtk.MessageDialog(parent,
                          DEF_DIALOG_FLAGS,
                          gtk.MESSAGE_ERROR,
                          gtk.BUTTONS_OK,
                          msg)
    d.show_all()
    d.run()
    d.hide()
    d.destroy()
# show_error()
项目:autoinjection    作者:ChengWiLL    | 项目源码 | 文件源码
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()
项目:tintwizard    作者:vanadey    | 项目源码 | 文件源码
def errorDialog(parent=None, message="An error has occured!"):
    """Creates an error dialog."""
    dialog = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, message)
    dialog.show()
    dialog.run()
    dialog.destroy()
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def show_about(self, widget):
        dialog = gtk.MessageDialog(
            None,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            gtk.MESSAGE_INFO,
            gtk.BUTTONS_OK,
            """
PiJuice battery 
level status
""")
        dialog.run()
        dialog.destroy()
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def show_about(self, widget):
        dialog = gtk.MessageDialog(
            None,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            gtk.MESSAGE_INFO,
            gtk.BUTTONS_OK,
            """
PiJuice battery 
level status
""")
        dialog.run()
        dialog.destroy()
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def show_about(self, widget):
        dialog = gtk.MessageDialog(
            None,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            gtk.MESSAGE_INFO,
            gtk.BUTTONS_OK,
            """
PiJuice battery 
level status
""")
        dialog.run()
        dialog.destroy()
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def show_about(self, widget):
        dialog = gtk.MessageDialog(
            None,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            gtk.MESSAGE_INFO,
            gtk.BUTTONS_OK,
            """
PiJuice battery 
level status
""")
        dialog.run()
        dialog.destroy()
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def show_about(self, widget):
        dialog = gtk.MessageDialog(
            None,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            gtk.MESSAGE_INFO,
            gtk.BUTTONS_OK,
            """
PiJuice battery 
level status
""")
        dialog.run()
        dialog.destroy()
项目:mgr.p2p.proxy    作者:tomusdrw    | 项目源码 | 文件源码
def downloadFile(self, treeView, path, column):
        model = treeView.get_model()
        iter = model.get_iter(path)
        filename = model.get(iter, 0)[0]
        h = hashlib.sha1()
        h.update(filename)
        key = h.digest()

        def getTargetNode(result):
            targetNodeID = result[key]
            df = self.node.findContact(targetNodeID)
            return df
        def getFile(protocol):
            if protocol != None:
                protocol.requestFile(filename, self)
        def connectToPeer(contact):
            if contact == None:
                dialog = gtk.MessageDialog(self, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                                        gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
                                        "File could not be retrieved.\nThe host that published this file is no longer on-line.")
                dialog.run()
                dialog.destroy()
            else:
                c = ClientCreator(twisted.internet.reactor, FileGetter)
                df = c.connectTCP(contact.address, contact.port)
                return df

        df = self.node.iterativeFindValue(key)
        df.addCallback(getTargetNode)
        df.addCallback(connectToPeer)
        df.addCallback(getFile)
项目:mgr.p2p.proxy    作者:tomusdrw    | 项目源码 | 文件源码
def _tupleFromStr(self, text):
        tp = None
        try:
            exec 'tp = %s' % text
            if type(tp) != tuple:
                raise Exception
        except Exception:
            dialog = gtk.MessageDialog(self, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                                       gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
                                        "Please enter a valid Python tuple,\ne.g. (1, 'abc', 3.14)")
            dialog.set_title('Error')
            dialog.run()
            dialog.destroy()
        finally:
            return tp
项目:NativeCAM    作者:FernV    | 项目源码 | 文件源码
def mess_dlg(mess, title = "NativeCAM"):
    dlg = gtk.MessageDialog(parent = None,
        flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
        type = gtk.MESSAGE_WARNING,
        buttons = gtk.BUTTONS_OK, message_format = '%s' % mess)
    dlg.set_title(title)
    dlg.set_keep_above(True)
    dlg.run()
    dlg.destroy()
项目:Eagle    作者:magerx    | 项目源码 | 文件源码
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
项目:Eagle    作者:magerx    | 项目源码 | 文件源码
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()
项目:landport    作者:land-pack    | 项目源码 | 文件源码
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()
项目:Helix    作者:3lackrush    | 项目源码 | 文件源码
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()
项目:griffith    作者:Strit    | 项目源码 | 文件源码
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()
项目:griffith    作者:Strit    | 项目源码 | 文件源码
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()
项目:griffith    作者:Strit    | 项目源码 | 文件源码
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()
项目:griffith    作者:Strit    | 项目源码 | 文件源码
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()
项目:autoscan    作者:b01u    | 项目源码 | 文件源码
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
项目:autoscan    作者:b01u    | 项目源码 | 文件源码
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    作者:mjun    | 项目源码 | 文件源码
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    作者:mjun    | 项目源码 | 文件源码
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
项目:linux-pentest-util    作者:fikr4n    | 项目源码 | 文件源码
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()
项目:wahcade    作者:sairuk    | 项目源码 | 文件源码
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
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
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()
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
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()
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
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
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
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)
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
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("----------------------------")
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
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()