python类MessageDialog()的实例源码

gimp_colorize.py 文件源码 项目:colorize 作者: BruXy 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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()
gtk2util.py 文件源码 项目:hostapd-mana 作者: adde88 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
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
gui.py 文件源码 项目:epoptes 作者: Epoptes 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
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
xdot.py 文件源码 项目:autoinjection 作者: ChengWiLL 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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
xdot.py 文件源码 项目:autoinjection 作者: ChengWiLL 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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
gtk2util.py 文件源码 项目:sslstrip-hsts-openwrt 作者: adde88 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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
fileshare.py 文件源码 项目:mgr.p2p.proxy 作者: tomusdrw 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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()
xdot.py 文件源码 项目:landport 作者: land-pack 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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
xdot.py 文件源码 项目:landport 作者: land-pack 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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
xdot.py 文件源码 项目:Helix 作者: 3lackrush 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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
xdot.py 文件源码 项目:Helix 作者: 3lackrush 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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
mainapp.py 文件源码 项目:chirp_fork 作者: mach327 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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()
mainapp.py 文件源码 项目:chirp_fork 作者: mach327 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def do_toggle_report(self, action):
        if not action.get_active():
            d = gtk.MessageDialog(buttons=gtk.BUTTONS_YES_NO, parent=self)
            markup = "<b><big>" + _("Reporting is disabled") + "</big></b>"
            d.set_markup(markup)
            msg = _("The reporting feature of CHIRP is designed to help "
                    "<u>improve quality</u> by allowing the authors to focus "
                    "on the radio drivers used most often and errors "
                    "experienced by the users. The reports contain no "
                    "identifying information and are used only for "
                    "statistical purposes by the authors. Your privacy is "
                    "extremely important, but <u>please consider leaving "
                    "this feature enabled to help make CHIRP better!</u>\n\n"
                    "<b>Are you sure you want to disable this feature?</b>")
            d.format_secondary_markup(msg.replace("\n", "\r\n"))
            r = d.run()
            d.destroy()
            if r == gtk.RESPONSE_NO:
                action.set_active(not action.get_active())

        conf = config.get()
        conf.set_bool("no_report", not action.get_active())
id_photo.py 文件源码 项目:id_photo 作者: aeifn 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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.py 文件源码 项目:id_photo 作者: aeifn 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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()

  # ??????? ??????? ??????????? ???? "? ?????????"
menu.py 文件源码 项目:hardened-centos7-kickstart 作者: fcaviggia 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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
gimp_colorize.py 文件源码 项目:colorize 作者: BruXy 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def gui_message(text, message_type):
    """Gtk dialog for error message display"""
    message = gtk.MessageDialog(type=message_type, buttons=gtk.BUTTONS_CLOSE)
    message.set_markup(text)
    message.run()
    message.destroy()
    while gtk.events_pending():
        gtk.main_iteration()
core.py 文件源码 项目:ns3-rdma 作者: bobzhuyb 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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
Main-Window.py 文件源码 项目:Web-Stalker 作者: Dylan-halls 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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)
Main-Window.py 文件源码 项目:Web-Stalker 作者: Dylan-halls 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
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()
Synchronous_execution.py 文件源码 项目:tools 作者: denglouping 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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
gui.py 文件源码 项目:ecel 作者: ARL-UTEP-OC 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def show_alert_message(parent_window, msg):
    alert = gtk.MessageDialog(parent_window, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO,
                              gtk.BUTTONS_CLOSE, msg)
    alert.run()
    alert.destroy()
gui.py 文件源码 项目:ecel 作者: ARL-UTEP-OC 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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()
main_gui.py 文件源码 项目:ecel 作者: ARL-UTEP-OC 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def parse_all(self, event):
        for collector in self.engine.collectors:
            collector.parser.parse()
#        alert = gtk.MessageDialog(self, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO,
#                                       gtk.BUTTONS_CLOSE, "Parsing complete")
#        alert.run()
#        alert.destroy()
main_gui.py 文件源码 项目:ecel 作者: ARL-UTEP-OC 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def show_confirmation_dialog(self, msg):
        dialog = gtk.MessageDialog(self, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO,
                                      gtk.BUTTONS_YES_NO, msg)
        response = dialog.run()
        dialog.destroy()

        if response == gtk.RESPONSE_YES:
            return True

        return False
micropi.py 文件源码 项目:Micro-Pi 作者: Bottersnike 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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
micropi.py 文件源码 项目:Micro-Pi 作者: Bottersnike 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def ask(query, parent=None):
    dia = gtk.MessageDialog(parent, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, query)
    dia.show()
    rtn=dia.run()
    dia.destroy()
    return rtn == gtk.RESPONSE_YES
micropi.py 文件源码 项目:Micro-Pi 作者: Bottersnike 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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
micropi.py 文件源码 项目:Micro-Pi 作者: Bottersnike 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def ask(self, query):
        dia = gtk.MessageDialog(self.window, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, query)
        dia.show()
        rtn=dia.run()
        dia.destroy()
        return rtn == gtk.RESPONSE_YES
ui.py 文件源码 项目:barbieri-playground 作者: barbieri 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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()


问题


面经


文章

微信
公众号

扫码关注公众号