Python gtk 模块,MESSAGE_ERROR 实例源码

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

项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def _ebFailedLogin(self, reason):
        if isinstance(reason, failure.Failure):
            reason = reason.value
        self.statusMsg(reason)
        if isinstance(reason, (unicode, str)):
            text = reason
        else:
            text = unicode(reason)
        msg = gtk.MessageDialog(self._loginDialog,
                                gtk.DIALOG_DESTROY_WITH_PARENT,
                                gtk.MESSAGE_ERROR,
                                gtk.BUTTONS_CLOSE,
                                text)
        msg.show_all()
        msg.connect("response", lambda *a: msg.destroy())

        # hostname not found
        # host unreachable
        # connection refused
        # authentication failed
        # no such service
        # no such perspective
        # internal server error
项目: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
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def _ebFailedLogin(self, reason):
        if isinstance(reason, failure.Failure):
            reason = reason.value
        self.statusMsg(reason)
        if isinstance(reason, (unicode, str)):
            text = reason
        else:
            text = unicode(reason)
        msg = gtk.MessageDialog(self._loginDialog,
                                gtk.DIALOG_DESTROY_WITH_PARENT,
                                gtk.MESSAGE_ERROR,
                                gtk.BUTTONS_CLOSE,
                                text)
        msg.show_all()
        msg.connect("response", lambda *a: msg.destroy())

        # hostname not found
        # host unreachable
        # connection refused
        # authentication failed
        # no such service
        # no such perspective
        # internal server error
项目: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
项目: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()

  # ??????? ??????? ??????????? ???? ? ??????????
项目:hardened-centos7-kickstart    作者:fcaviggia    | 项目源码 | 文件源码
def lvm_check(self,args):
        self.lvm = self.root_partition.get_value_as_int()+self.home_partition.get_value_as_int()+self.tmp_partition.get_value_as_int()+self.var_partition.get_value_as_int()+self.log_partition.get_value_as_int()+self.audit_partition.get_value_as_int()+self.swap_partition.get_value_as_int()+self.www_partition.get_value_as_int()+self.opt_partition.get_value_as_int()
        self.partition_used.set_label(str(self.lvm)+'%')
        if int(self.lvm) > 100:
            self.MessageBox(self.window,"<b>Verify that LVM configuration is not over 100%!</b>",gtk.MESSAGE_ERROR)
            return False
        else:
            return True


    # Display Message Box (e.g. Help Screen, Warning Screen, etc.)
项目:colorize    作者:BruXy    | 项目源码 | 文件源码
def python_colorize(image, layer):
    """Colorize plugin"""
    image.disable_undo()
    print(image, layer)
    colorize.check_api_key()

    # 1. Save actual image to GIMP TEMP direcotry as PNG
    bw_photo = save_tmp_file(image, layer, image.filename)
    print("Temp file saved in: " + bw_photo)
    gimpfu.gimp.progress_init("Uploading image for processing.")

    # 2. Upload file to the server
#    gui_message(
#        "Image is being processed at <u>{0}</u>.\nIt may take a while.".format(colorize.URL), 
#        gtk.MESSAGE_INFO
#    )
# TODO: information window that data are uploaded. 
    download_url =  colorize.upload_image(bw_photo)
    if download_url == '': # if empty => error
        gui_message(colorize.ALG_API_ERR, gtk.MESSAGE_ERROR)
        gimpfu.gimp.quit()
    else:
        print("download_url: " + download_url)

    # 3. Download it from the server
    if download_url:
         color_photo = colorize.download_image(download_url, bw_photo)

    # 4. Display result as a new image
    if color_photo:
        gimpfu.gimp.Display(
            gimpfu.pdb.file_png_load(color_photo, color_photo)
        )
        gimpfu.gimp.progress_init("Colorized data received...")

    image.enable_undo()


####################
# Plug-in register #
####################
项目: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)
项目:epoptes    作者:Epoptes    | 项目源码 | 文件源码
def error_message(self, msg):
        msgdlg = self.get('msgdlg')
        msgdlg.set_property("message-type", gtk.MESSAGE_ERROR)
        msgdlg.set_transient_for(self.dlg)
        msgdlg.set_title(_("Error"))
        msgdlg.set_markup(msg)
        msgdlg.show_all()
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def show_error_message(parent_window, msg):
    alert = gtk.MessageDialog(parent_window, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR,
                              gtk.BUTTONS_CLOSE, msg)
    alert.run()
    alert.destroy()
项目: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()
项目: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
项目:lfde    作者:mv-code    | 项目源码 | 文件源码
def gui_message_box(self, message):
        dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, \
                gtk.BUTTONS_NONE, message)
        dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
        dialog.run()
        dialog.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()
项目: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()
项目: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()
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def show_error_text(msg, text, parent=None):
    d = gtk.MessageDialog(buttons=gtk.BUTTONS_OK, parent=parent,
                          type=gtk.MESSAGE_ERROR)
    d.set_property("text", msg)

    _add_text(d, text)
    if not parent:
        d.set_position(gtk.WIN_POS_CENTER_ALWAYS)

    d.set_size_request(600, 400)
    d.run()
    d.destroy()
项目:hardened-centos7-kickstart    作者:fcaviggia    | 项目源码 | 文件源码
def check_network(self,widget,event=None):

        self.network_error = 0

        if self.dhcp.get_active() == True:
            self.dhcp.set_label("DHCP")
            self.ip.set_sensitive(False)
            self.netmask.set_sensitive(False)
            self.gateway.set_sensitive(False)
            self.dns1.set_sensitive(False)
            self.dns2.set_sensitive(False)
        else:
            self.dhcp.set_label("Static IP")
            self.ip.set_sensitive(True)
            self.netmask.set_sensitive(True)
            self.gateway.set_sensitive(True)
            self.dns1.set_sensitive(True)
            self.dns2.set_sensitive(True)

            if self.verify.check_ip(self.ip.get_text()) == False:
                self.MessageBox(self.window,"<b>Invalid IP Address!</b>",gtk.MESSAGE_ERROR)
                self.network_error = 1
                if self.verify.check_ip(self.netmask.get_text()) == False:
                self.MessageBox(self.window,"<b>Invalid Netmask!</b>",gtk.MESSAGE_ERROR)
                self.network_error = 1
            if self.verify.check_ip(self.gateway.get_text()) == False:
                self.MessageBox(self.window,"<b>Invalid Gateway!</b>",gtk.MESSAGE_ERROR)
                self.network_error = 1
            if self.verify.check_ip(self.dns1.get_text()) == False:
                self.MessageBox(self.window,"<b>Invalid DNS1 Address!</b>",gtk.MESSAGE_ERROR)
                self.network_error = 1
            if self.verify.check_ip(self.dns2.get_text()) == False:
                self.MessageBox(self.window,"<b>Invalid DNS2 Address!</b>",gtk.MESSAGE_ERROR)
                self.network_error = 1

        if self.network_error == 1:
            self.network_dialog.set_response_sensitive(gtk.RESPONSE_ACCEPT,False)
            return False    
        else:
            self.network_dialog.set_response_sensitive(gtk.RESPONSE_ACCEPT,True)
            return True


        # Appply Configurations to Kickstart File
项目:ns3-rdma    作者:bobzhuyb    | 项目源码 | 文件源码
def _take_screenshot(self, dummy_button):
        #print "Cheese!"
        file_name = self._get_export_file_name()
        if file_name is None:
            return

        # figure out the correct bounding box for what is visible on screen
        x1 = self._scrolled_window.get_hadjustment().value
        y1 = self._scrolled_window.get_vadjustment().value
        x2 = x1 + self._scrolled_window.get_hadjustment().page_size
        y2 = y1 + self._scrolled_window.get_vadjustment().page_size
        bounds = goocanvas.Bounds()
        bounds.x1, bounds.y1 = self.canvas.convert_from_pixels(x1, y1)
        bounds.x2, bounds.y2 = self.canvas.convert_from_pixels(x2, y2)
        dest_width = bounds.x2 - bounds.x1
        dest_height = bounds.y2 - bounds.y1
        #print bounds.x1, bounds.y1, " -> ", bounds.x2, bounds.y2

        dummy, extension = os.path.splitext(file_name)
        extension = extension.lower()
        if extension == '.eps':
            surface = cairo.PSSurface(file_name, dest_width, dest_height)
        elif extension == '.pdf':
            surface = cairo.PDFSurface(file_name, dest_width, dest_height)
        elif extension == '.svg':
            surface = cairo.SVGSurface(file_name, dest_width, dest_height)
        else:
            dialog = gtk.MessageDialog(parent  = self.canvas.get_toplevel(),
                               flags   = gtk.DIALOG_DESTROY_WITH_PARENT,
                               type    = gtk.MESSAGE_ERROR,
                               buttons = gtk.BUTTONS_OK,
                               message_format = "Unknown extension '%s' (valid extensions are '.eps', '.svg', and '.pdf')"
                                                          % (extension,))
            dialog.run()
            dialog.destroy()
            return

        # draw the canvas to a printing context
        cr = cairo.Context(surface)
        cr.translate(-bounds.x1, -bounds.y1)
        self.canvas.render(cr, bounds, self.zoom.value)
        cr.show_page()
        surface.finish()