Python tkMessageBox 模块,askquestion() 实例源码

我们从Python开源项目中,提取了以下20个代码示例,用于说明如何使用tkMessageBox.askquestion()

项目:PYEdit    作者:Congren    | 项目源码 | 文件源码
def specialSeven(event):
    #gets only the mp3 audio file of the video
    canvas = event.widget.canvas
    try:
        clip = AudioFileClip(canvas.message)
        title = 'Get Audio'
        message = 'Would you like to retrieve the audio file for this video?'
        answer = tkMessageBox.askquestion(title,message)
        if answer == 'yes':
            name = 'new-'+os.path.basename(canvas.message)
            name2 = name.replace('.mp4','.mp3')
            clip.to_audiofile(name2)
            canvas.message = 'new-'+canvas.display
            canvas.display = 'new-'+canvas.display
    except:
        canvas.condition=4
        canvas.create_text(250,10,text='Please Try Again')
        redrawAll(canvas)
项目:PYEdit    作者:Congren    | 项目源码 | 文件源码
def editSeven(event):
    canvas = event.widget.canvas
    try:
        title = 'Remove Audio'
        message = "Would you like to remove the audio?"
        answer = tkMessageBox.askquestion(title=title,message=message)
        if answer == 'yes':
            video=VideoFileClip(canvas.message)
            audioless=video.without_audio()
            name = 'new-'+os.path.basename(canvas.message)
            audioless.write_videofile(name)
            canvas.message = 'new-'+canvas.display
            canvas.display = 'new-'+canvas.display
    except:
        canvas.create_text(250,10,text='Please Try Again')
        redrawAll(canvas)
项目:SceneDensity    作者:ImOmid    | 项目源码 | 文件源码
def questionBox(self, title, message):
        self.topLevel.update_idletasks()
        return MessageBox.askquestion(title, message)
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def do_lose_action(real=False):
    # Cause the game to lose.
    answer = tkMessageBox.askquestion('GAME OVER', 'Do you want to try again?')
    graph.after_cancel(frame_handle if real else blink_handle)
    graph.delete(ALL)
    if answer == 'yes':
        initialise()
    else:
        high_score_table()

################################################################################

# VECTOR MATHEMATICS CLASS
项目:Cryptokey_Generator    作者:8BitCookie    | 项目源码 | 文件源码
def questionBox(self, title, message):
        self.topLevel.update_idletasks()
        return MessageBox.askquestion(title, message)
项目:nao_slam_amcl    作者:hu7241    | 项目源码 | 文件源码
def MsgBox(title, text, style):
    box = [
        msg.showinfo,       msg.showwarning,    msg.showerror,
        msg.askquestion,    msg.askyesno,       msg.askokcancel,        msg.askretrycancel,
    ];
    tk.Tk().withdraw(); #Hide Main Window.
    if style in range(7):
        return box[style](title, text)
项目:nao_slam_amcl    作者:hu7241    | 项目源码 | 文件源码
def MsgBox(title, text, style):
    box = [
        msg.showinfo,       msg.showwarning,    msg.showerror,
        msg.askquestion,    msg.askyesno,       msg.askokcancel,        msg.askretrycancel,
    ];
    tk.Tk().withdraw(); #Hide Main Window.
    if style in range(7):
        return box[style](title, text)
项目:SPGL    作者:wynand1004    | 项目源码 | 文件源码
def ask_question(self, title, message):
        return messagebox.askquestion(title, message)
项目:SPGL    作者:wynand1004    | 项目源码 | 文件源码
def ask_question(self, title, message):
        return messagebox.askquestion(title, message)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def loop(self):
        """This is an explict replacement for _tkinter mainloop()
        It lets you catch keyboard interrupts easier, and avoids
        the 20 msec. dead sleep() which burns a constant CPU."""
        while self.exit < 0:
            # There are 2 whiles here. The outer one lets you continue
            # after a ^C interrupt.
            try:
                # This is the replacement for _tkinter mainloop()
                # It blocks waiting for the next Tcl event using select.
                while self.exit < 0:
                    self.root.tk.dooneevent(TCL_ALL_EVENTS)
            except SystemExit:
                # Tkinter uses SystemExit to exit
                #print 'Exit'
                self.exit = 1
                return
            except KeyboardInterrupt:
                if tkMessageBox.askquestion ('Interrupt', 'Really Quit?') == 'yes':
                    # self.tk.eval('exit')
                    self.exit = 1
                    return
                continue
            except:
                # Otherwise it's some other error - be nice and say why
                t, v, tb = sys.exc_info()
                text = ""
                for line in traceback.format_exception(t,v,tb):
                    text += line + '\n'
                try: tkMessageBox.showerror ('Error', text)
                except: pass
                self.exit = 1
                raise SystemExit, 1
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def _WriteSlaveAddress(self, id):
        q = tkMessageBox.askquestion('Address update','Are you sure you want to change address?', parent=self.frame)
        if q == 'yes':
            status = pijuice.config.SetAddress(id+1, self.slaveAddr[id].get())
            if status['error'] != 'NO_ERROR':
                #self.slaveAddr[id].set(status['error'])
                tkMessageBox.showerror('Address update', status['error'], parent=self.frame)
            else:
                tkMessageBox.showinfo('Address update', "Success!", parent=self.frame)
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def _WriteSlaveAddress(self, id):
        q = tkMessageBox.askquestion('Address update','Are you sure you want to change address?', parent=self.frame)
        if q == 'yes':
            status = pijuice.config.SetAddress(id+1, self.slaveAddr[id].get())
            if status['error'] != 'NO_ERROR':
                #self.slaveAddr[id].set(status['error'])
                tkMessageBox.showerror('Address update', status['error'], parent=self.frame)
            else:
                tkMessageBox.showinfo('Address update', "Success!", parent=self.frame)
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def _WriteSlaveAddress(self, id):
        q = tkMessageBox.askquestion('Address update','Are you sure you want to change address?', parent=self.frame)
        if q == 'yes':
            status = pijuice.config.SetAddress(id+1, self.slaveAddr[id].get())
            if status['error'] != 'NO_ERROR':
                #self.slaveAddr[id].set(status['error'])
                tkMessageBox.showerror('Address update', status['error'], parent=self.frame)
            else:
                tkMessageBox.showinfo('Address update', "Success!", parent=self.frame)
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def _WriteSlaveAddress(self, id):
        q = tkMessageBox.askquestion('Address update','Are you sure you want to change address?', parent=self.frame)
        if q == 'yes':
            status = pijuice.config.SetAddress(id+1, self.slaveAddr[id].get())
            if status['error'] != 'NO_ERROR':
                #self.slaveAddr[id].set(status['error'])
                tkMessageBox.showerror('Address update', status['error'], parent=self.frame)
            else:
                tkMessageBox.showinfo('Address update', "Success!", parent=self.frame)
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def _WriteSlaveAddress(self, id):
        q = tkMessageBox.askquestion('Address update','Are you sure you want to change address?', parent=self.frame)
        if q == 'yes':
            status = pijuice.config.SetAddress(id+1, self.slaveAddr[id].get())
            if status['error'] != 'NO_ERROR':
                #self.slaveAddr[id].set(status['error'])
                tkMessageBox.showerror('Address update', status['error'], parent=self.frame)
            else:
                tkMessageBox.showinfo('Address update', "Success!", parent=self.frame)
项目:BeachedWhale    作者:southpaw5271    | 项目源码 | 文件源码
def questionBox(self, title, message):
        self.topLevel.update_idletasks()
        return MessageBox.askquestion(title, message)
项目:Code-Sleep-Python    作者:prateekiiest    | 项目源码 | 文件源码
def QuitGame(self):
        self.message=tkMessageBox.askquestion("Exit","Do you want to exit ?")
        if (self.message == 'yes'):
            root.destroy()
项目:Assignment1_Python    作者:zhenmin1993    | 项目源码 | 文件源码
def quit():
    answer = tkMessageBox.askquestion('Computer Application', 'Are you sure to EXIT?')

    if answer == 'yes': 
            Login.quit
            sys.exit()
项目:PSP0201    作者:prevwong    | 项目源码 | 文件源码
def logout(name):
    result = tkMessageBox.askquestion("Logout Confirmation", "Are you sure you want to logout?", icon='warning')
    if result == 'yes':
        message = "See you again, " + name + "!"
        tkMessageBox.showinfo("Thank you", message)
        root.destroy()
        authentication.show_window()
项目:Assignment1_Python    作者:zhenmin1993    | 项目源码 | 文件源码
def write_entry_db():
    print 'Connecting to MySQL server'
    Message = 'Connecting to MySQL server'
    status = Label(topframe, text = 'Connecting to MySQL server', bd = 1, relief = SUNKEN, anchor =W)
    status.grid(row = 8, sticky=N+E+S+W, columnspan = 2)
    host =  var_host.get()
    user = var_user.get()
    passwd =  var_passwd.get()
    db =  var_dbName.get()
    port =  var_port.get()
    port = int(port)



    try:
        global conn
        global cur
        conn=MySQLdb.connect(host,user,passwd,db,port)
        cur = conn.cursor()
        Message = 'Connected to MySQL server'
        print 'Connected to MySQL server\n'
        status = Label(topframe, text = Message, bd = 1,fg = '#228B22', relief = SUNKEN, anchor =W)
        status.grid(row = 8, sticky=N+E+S+W, columnspan = 2)

        status = Label(topframe, text = 'Waiting For Table Creating...', bd = 1, relief = SUNKEN, anchor =W)
        status.grid(row = 9, sticky=N+E+S+W, columnspan = 2)

        answer = tkMessageBox.askquestion('Computer Application', 'Server Connected, creating new tables?')

        if answer == 'yes': 
            execfile("Creating_Table.py")
            status = Label(topframe, text = 'Tables Created', fg = '#228B22', bd = 1, relief = SUNKEN, \
                anchor =W)
            status.grid(row = 9, sticky=N+E+S+W, columnspan = 2)

        else: 
            execfile("Existing_Table.py")
            status = Label(topframe, text = "Tables checking, if not exist, creat new table", bd = 1, \
                 relief = SUNKEN, anchor =W)
            status.grid(row = 9, sticky=N+E+S+W, columnspan = 2)

        status = Label(topframe, text = 'Table checking passed, please input the following file names', \
            bd = 1,fg = '#228B22', relief = SUNKEN, anchor =W)
        status.grid(row = 9, sticky=N+E+S+W, columnspan = 2)


    except:
        Message = 'Connection Failed! Please Check!'
        print 'Connection Failed! Please Check!'
        status = Label(topframe, text = Message, bd = 1 , fg = 'red',relief = SUNKEN, anchor =W)
        status.grid(row = 8, sticky=N+E+S+W, columnspan = 2)