python类MESSAGE_ERROR的实例源码

gnome_connection_manager.py 文件源码 项目:gnome-connection-manager 作者: mjun 项目源码 文件源码 阅读 18 收藏 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 项目源码 文件源码 阅读 17 收藏 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 项目源码 文件源码 阅读 18 收藏 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()
inputdialog.py 文件源码 项目:chirp_fork 作者: mach327 项目源码 文件源码 阅读 20 收藏 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 项目源码 文件源码 阅读 16 收藏 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()
common.py 文件源码 项目:chirp_fork 作者: mach327 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
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()
menu.py 文件源码 项目:hardened-centos7-kickstart 作者: fcaviggia 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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
core.py 文件源码 项目:ns3-rdma 作者: bobzhuyb 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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()


问题


面经


文章

微信
公众号

扫码关注公众号