Python tkinter.messagebox 模块,askokcancel() 实例源码

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

项目:PyZWare    作者:Z-WavePublic    | 项目源码 | 文件源码
def device_inclusion(Button):
    zwareGlobals.debugData.insert(INSERT,"Including device to the network....\n")
    Button['state'] = 'disabled'
    result = messagebox.askokcancel("Include Device","Initiate your device and select \"OK\" to add it to the network\n")
    if result == 1:
        zwareGlobals.debugData.focus_force()
        r = zware.zw_add_remove(2)
        zware.zw_net_comp(2)
        zwareGlobals.debugData.insert(INSERT,"Device has been successfully added to the network\n")
        poll_node_list(True)
        enable_disable_binary_switch()
    else:
        zwareGlobals.debugData.focus_force()
        zwareGlobals.debugData.insert(INSERT,"Device Inclusion cancelled\n")
    zwareGlobals.debugData.see(END)
    Button['state'] = 'normal'
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def close(self):
        "Extend EditorWindow.close()"
        if self.executing:
            response = tkMessageBox.askokcancel(
                "Kill?",
                "The program is still running!\n Do you want to kill it?",
                default="ok",
                parent=self.text)
            if response is False:
                return "cancel"
        if self.reading:
            self.top.quit()
        self.canceled = True
        self.closing = True
        # Wait for poll_subprocess() rescheduling to stop
        self.text.after(2 * self.pollinterval, self.close2)
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def main():
    # ?????????,?????Tkinter????????Tk??.??????withdraw()??????
    tk = tkinter.Tk()
    tk.withdraw()  # ?????

    print(dir(mb))

    # ??,?????????,??ok,????????????.??????????????,??????????.
    # ??,???Cancel?,??????None
    mb.showinfo("Title", "Your message here")
    mb.showerror("An Error", "Oops!")
    mb.showwarning("Title", "This may not work...")
    mb.askyesno("Title", "Do you love me?")
    mb.askokcancel("Title", "Are you well?")
    mb.askquestion("Title", "How are you?")
    mb.askretrycancel("Title", "Go again?")
    mb.askyesnocancel("Title", "Are you well?")
项目:SceneDensity    作者:ImOmid    | 项目源码 | 文件源码
def okBox(self, title, message):
        self.topLevel.update_idletasks()
        return MessageBox.askokcancel(title, message)
项目:PyZWare    作者:Z-WavePublic    | 项目源码 | 文件源码
def device_exclusion(Button):
    zwareGlobals.debugData.insert(INSERT,"Excluding device from the network....\n")
    Button['state'] = 'disabled'
    result = messagebox.askokcancel("Exclude Device","Initiate your device and select \"OK\" to remove it from the network\n")
    if result == 1:
        zwareGlobals.debugData.focus_force()
        r = zware.zw_add_remove(3)
        zware.zw_net_comp(3)
        zwareGlobals.debugData.insert(INSERT,"Device has been successfully removed from the network\n")
        poll_node_list(True)
        enable_disable_binary_switch()
    else:
        zwareGlobals.debugData.focus_force()
        zwareGlobals.debugData.insert(INSERT,"Device Exclusion cancelled\n")
    zwareGlobals.debugData.see(END)
    Button['state'] = 'normal'

##
#\addtogroup poll_network
#@{
#\section polling Network Polling
#The client polls the network both automatically in the background as well as on user prompt with the "Node Details" button. On polling succesfully the client displays a list of nodes along with all available endpoints connected to them. It also displays a list of all the Command Classes supported by each endpoint. This is achieved using:<br>1. The Client queries for available nodes using the <b>zwnet_get_node_list</b> web api.<br>2. On succesfully retrieving the node list the client queries for available endpoints for each node using the <b>zwnet_get_ep_list</b> web api.<br>3. Subsequently for each endpoint it will query for the supporting command classes using the <b>zwnet_get_if_list</b> web api. Once all data has been retrieved it will either be a:)Be displayed to the user if they had clicked on the "Node Details" button or b:)Be used for further background polling of devices.
#\section tracking Tracking Devices
#The client will constantly be polling the network for tracking devices and their state values. In the present version this support is provided for Binary Switches, Binary Sensors and Multilevel Sensors. For example whenever a binary switch is added or removed from a network the client will display this information to the user. This is achieved using the polling web-apis mentioned above along with identifying the binary switch using it's interface id.
#@}
项目:sc8pr    作者:dmaccarthy    | 项目源码 | 文件源码
def __init__(self, response=str, text="", title=None, accept=0, **options):
        if response is bool:
            self.dialog = [askyesno, askokcancel, askretrycancel][accept]
        else: self.dialog = {None:showinfo, str:askstring, int:askinteger, float:askfloat,
            0:askopenfilename, 1:asksaveasfilename, 2:askdirectory}[response]
        self.options = options.copy()
        if "initialdir" in options:
            self.options["initialdir"] = abspath(options["initialdir"])
        if type(response) is int:
            self.args = tuple()
            if title: self.options["title"] = title
        else:
            if title is None:
                title = "Info" if response is None else "Confirm" if response is bool else "Input"
            self.args = title, text
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def quit(self):
        if askokcancel('Verify exit', 'Really quit?'):
            self._root().destroy()

################################################################################
项目:Cryptokey_Generator    作者:8BitCookie    | 项目源码 | 文件源码
def okBox(self, title, message):
        self.topLevel.update_idletasks()
        return MessageBox.askokcancel(title, message)
项目:Physics-2.0    作者:rschwa6308    | 项目源码 | 文件源码
def submit(self, chosen, chosen2):
        new_bodies, dims, num, mass_r = [], self.dims, self.num.get(), self.findEntries('mass_r')
        if chosen == "Gradient":
            colors = (self.color1ValTrue, self.color2ValTrue)
            if chosen2 == "Density":
                densities = self.findEntries('densities')
                new_bodies = Gradient(dims, num, mass_r, colors).preset('Density', densities)
            else:
                new_bodies = Gradient(dims, num, mass_r, colors).preset('Diffusion')
        else:
            dist_r, density = self.findEntries('dist_r'), self.density.get()
            if chosen2 == "Cluster":
                new_bodies = System(dims, num, mass_r, dist_r, density).preset('Cluster')
            else:
                star_density, star_mass = self.star_density.get(), self.star_mass.get()
                if chosen2 == "Binary":
                    star_mass2 = self.star_mass2.get()
                    new_bodies = System(dims, num, mass_r, dist_r, density).preset('Binary', (star_mass, star_mass2),
                                                                                   star_density)
                else:
                    circular = self.circular.get()
                    new_bodies = System(dims, num, mass_r, dist_r, density).preset('Unary', star_mass, star_density,
                                                                                   circular)
        if not self.bodies or messagebox.askokcancel("Discard Changes", "Are you sure you want to discard changes?"):
            self.bodies[:] = new_bodies
            for window in self.parent.properties_windows:
                window.destroy()
            self.parent.properties_windows = []
            self.parent.name.set("Unnamed Simulation")
            self.parent.filename = ''
项目:Physics-2.0    作者:rschwa6308    | 项目源码 | 文件源码
def open_file(self):
        filename = filedialog.askopenfilename()
        if filename and (
            not self.bodies or messagebox.askokcancel("Discard Changes", "Are you sure you want to discard changes?")):
            self.filename = filename
            self.name.set(os.path.split(filename)[-1])
            for window in self.properties_windows:
                window.destroy()
            self.properties_windows = []
            with open(filename) as file:
                self.bodies[:] = generate_bodies(load_save(self, file))
项目:Physics-2.0    作者:rschwa6308    | 项目源码 | 文件源码
def delete_body(self):
        if messagebox.askokcancel("Delete Body", 'Are you sure you want to delete "{}"?'.format(self.body.name)):
            self.bodies.remove(self.body)
            self.destroy()
项目:spe2fits    作者:jerryjiahaha    | 项目源码 | 文件源码
def on_closing(app):
    if messagebox.askokcancel("Quit", "Do you want to quit?"):
        app.cleanup()
    sleep(0.2)
    print("exit")
    os._exit(1)
项目:DnD    作者:the-nick-of-time    | 项目源码 | 文件源码
def startup_end(self):
        self.name = self.charactername['Character Name?']
        self.container.title(self.name)
        path = 'character/' + h.clean(self.name) + '.character'
        self.filename = iface.JSONInterface.OBJECTSPATH + path
        if (os.path.exists(iface.JSONInterface.OBJECTSPATH + path)):
            ok = messagebox.askokcancel(message='You are overwriting an '
                                        'existing file. Continue?')
            if (not ok):
                self.container.destroy()

        f = open(self.filename, 'w')
        f.close()
        ######
        self.basic = BasicInfoSelector(self.f, self.race_features,
                                       self.class_features)
        self.abils = AbilitySelector(self.f)
        self.skills = SkillSelector(self.f)
        ######
        self.draw_static()
        self.container.deiconify()

    # def select_features(self):
    #     self.data['name'] = self.name
    #     self.data.update(self.basic.export())
    #     classes = cm.ClassMap(self.data['level'])
    #     classjf = classes[0].record
    #     self.features = FeaturesAtLevel(self.f, classjf, 1)
    #     self.draw_dynamic()
项目:SPGL    作者:wynand1004    | 项目源码 | 文件源码
def ask_ok_cancel(self, title, message):
        return messagebox.askokcancel(title, message)
项目:SPGL    作者:wynand1004    | 项目源码 | 文件源码
def ask_ok_cancel(self, title, message):
        return messagebox.askokcancel(title, message)
项目:persianDooz    作者:FONQRI    | 项目源码 | 文件源码
def on_closing():
    if messagebox.askokcancel("Quit", "Do you want to quit?"):
        root.destroy()
        sys.exit()
项目:persianDooz    作者:FONQRI    | 项目源码 | 文件源码
def TwoPlayerMood():

    global turn


    c = board()
    def on_closing():
        if messagebox.askokcancel("Quit", "Do you want to quit?"):
            board.root.destroy()
            sys.exit()

    board.root.protocol("WM_DELETE_WINDOW", on_closing)
    def make():
        global v
        v = Taw(turn,c)
    make()
    def right(event):
        v.moveRight()

    c.root.bind('<KeyPress-Right>',right)

    def left(event):
        v.moveLeft()

    c.root.bind('<KeyPress-Left>',left)
    def down(event):
        if v.row==0:
            v.moveDown()
            if v.done == 1:
                v.done= 0
                make()
        else :
            pass
    c.root.bind('<KeyPress-Down>',down)

#************************artificial intelligence*************************************************************
项目:persianDooz    作者:FONQRI    | 项目源码 | 文件源码
def SinglePlayerMood():
    global turn
    if turn == 1:
        c = board()
        def on_closing():
            if messagebox.askokcancel("Quit", "Do you want to quit?"):
                board.root.destroy()
                sys.exit()

        board.root.protocol("WM_DELETE_WINDOW", on_closing)

        make(c)
        def right(event):
            v.moveRight()

        c.root.bind('<KeyPress-Right>',right)

        def left(event):
            v.moveLeft()

        c.root.bind('<KeyPress-Left>',left)


        def down(event):
            if v.row==0:
                v.moveDown()
                if v.done == 1:
                    v.done= 0
                    make(c)
                    ai=AI(c,v)
            else :
                pass
        c.root.bind('<KeyPress-Down>',down)
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def ask_save_dialog(self):
        msg = "Source Must Be Saved\n" + 5*' ' + "OK to Save?"
        confirm = tkMessageBox.askokcancel(title="Save Before Run or Check",
                                           message=msg,
                                           default=tkMessageBox.OK,
                                           master=self.editwin.text)
        return confirm
项目:PyLaz    作者:LAPIS-Lazurite    | 项目源码 | 文件源码
def on_closing():
    if start_flag == False:
        if messagebox.askokcancel("Quit", "Do you want to quit??"):
            root.destroy()
    else:
        print("please stop gateway")

## Gateway Process
项目:qal    作者:OptimalBPM    | 项目源码 | 文件源码
def on_commit_merge(self, *args):
        if askokcancel(title="Warning: committing merge", message="This will commit actual changes to the destination, "
                                                                  "do you want to proceed?") is True:
            self.do_merge(_commit=True)
项目:BeachedWhale    作者:southpaw5271    | 项目源码 | 文件源码
def okBox(self, title, message):
        self.topLevel.update_idletasks()
        return MessageBox.askokcancel(title, message)
项目:FFT-spectrum-analyzer    作者:ariquezada    | 项目源码 | 文件源码
def on_closing(self):
        if (self.f_saved==False):
            if messagebox.askokcancel("Quit", "Sampled data not saved. Do you wanto to quit?"):
                root.destroy()
        else:
            root.destroy()
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def close(self):
        "Extend EditorWindow.close()"
        if self.executing:
            response = tkMessageBox.askokcancel(
                "Kill?",
                "Your program is still running!\n Do you want to kill it?",
                default="ok",
                parent=self.text)
            if response is False:
                return "cancel"
        self.stop_readline()
        self.canceled = True
        self.closing = True
        return EditorWindow.close(self)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def ask_save_dialog(self):
        msg = "Source Must Be Saved\n" + 5*' ' + "OK to Save?"
        confirm = tkMessageBox.askokcancel(title="Save Before Run or Check",
                                           message=msg,
                                           default=tkMessageBox.OK,
                                           parent=self.editwin.text)
        return confirm
项目:pynpuzzle    作者:mahdavipanah    | 项目源码 | 文件源码
def save_file_cmd(puzzle_frame, parent):
    """
    Input's save to file button click handler

    puzzle_frame : The puzzle frame which it's puzzle will be saved to file
    parent : The parent window of the puzzle_frame
             This is used for showing the 'save as file' dialog so it can be showed on top of the window.
    """
    # Check if puzzle frame has a valid input, and if not, ask the user if he's sure he wants to save the puzzle
    lst = is_input_puzzle_valid(puzzle_frame)
    if not lst:
        if not messagebox.askokcancel("Input not valid",
                                      "Input puzzle is not valid, are you sure to save it as a file?",
                                      parent=parent):
            return

    # Open the 'save as file' dialog
    file_name = filedialog.asksaveasfilename(title="Choose a file to save puzzle", parent=parent)
    # Check if user has selected a file
    if not file_name:
        return

    # Generate file's content
    len_sqrt = int(math.sqrt(len(lst)))
    file_lines = []
    for i in range(0, len(lst), 3):
        line_nums = []
        for j in range(0, len_sqrt):
            line_nums.append(str(lst[i + j]))
        file_lines.append(' '.join(line_nums))

    try:
        with open(file_name, 'w') as file:
            file.write('\n'.join(file_lines))
    except:
        messagebox.showerror("Error saving to file",
                             "Some problem happened while saving puzzle to the file.",
                             parent=parent)


# Save to file button widgget
项目:drc-sim    作者:rolandoislas    | 项目源码 | 文件源码
def button_clicked(self, event):
        if self.getting_psk:
            messagebox.showerror("Running", "A pairing attempt is already im progress.")
            return
        number = str(event.widget.number)
        LoggerGui.debug("A suit button was clicked")  # Don't log numbers as the code can be derived from that
        code = self.entry_pair_code.get()
        code += number
        self.set_code_text(code)
        wii_u_interface = self.dropdown_wii_u.get()
        if not wii_u_interface:
            messagebox.showerror("No Interface", "An interface must be selected.")
            self.activate()
            return
        try:
            InterfaceUtil.get_mac(wii_u_interface)
        except ValueError:
            messagebox.showerror("Interface Error", "The selected Interface is no longer available.")
            self.activate()
            return
        if InterfaceUtil.is_managed_by_network_manager(wii_u_interface):
            set_unmanaged = messagebox.askokcancel(
                "Managed Interface", "This interface is managed by Network Manager. To use it with DRC Sim it needs "
                                     "to be set to unmanaged. Network Manager will not be able to control the interface"
                                     " after this.\nSet %s to unmanaged?" % wii_u_interface)
            if set_unmanaged:
                InterfaceUtil.set_unmanaged_by_network_manager(wii_u_interface)
            else:
                messagebox.showerror("Managed Interface", "Selected Wii U interface is managed by Network Manager.")
                self.activate()
                return
        if len(code) == 4:
            self.getting_psk = True
            self.set_code_text("")
            self.get_psk(code, wii_u_interface)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def close(self):
        "Extend EditorWindow.close()"
        if self.executing:
            response = tkMessageBox.askokcancel(
                "Kill?",
                "The program is still running!\n Do you want to kill it?",
                default="ok",
                parent=self.text)
            if response is False:
                return "cancel"
        self.stop_readline()
        self.canceled = True
        self.closing = True
        return EditorWindow.close(self)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def ask_save_dialog(self):
        msg = "Source Must Be Saved\n" + 5*' ' + "OK to Save?"
        confirm = tkMessageBox.askokcancel(title="Save Before Run or Check",
                                           message=msg,
                                           default=tkMessageBox.OK,
                                           master=self.editwin.text)
        return confirm
项目:SFC_models    作者:brianr747    | 项目源码 | 文件源码
def install_examples(): # pragma: no cover
    """
    Pops up windows to allow the user to choose a directory for installation
    of sfc_models examples.

    Uses tkinter, which is installed in base Python (modern versions).
    :return:
    """
    if not mbox.askokcancel(title='sfc_models Example Installation',
                            message=validate_str):
        return
    target = fdog.askdirectory(title='Choose directory to for sfc_models examples installation')
    if target == () or target == '':
        return
    install_example_scripts.install(target)
项目:More-I-O    作者:koltafrickenfer    | 项目源码 | 文件源码
def onClosing(self):
    if messagebox.askokcancel("Quit","do you want to Quit?"):
      self.master.destroy()
      self.master.quit()
项目:More-I-O    作者:koltafrickenfer    | 项目源码 | 文件源码
def onClosing(self):
        if messagebox.askokcancel("Quit","do you want to Quit?"):
            for child in multiprocessing.active_children():
                kill_proc_tree(child.pid)
            if self.running:
                killFCEUX()
                self.master.destroy()
                self.master.quit()
项目:CTPrivAPI    作者:doubleelforbes    | 项目源码 | 文件源码
def canceltrade():
    global privapi
    global orders
    if len(orders) > 0:
        if window.lstorders.curselection():
            selectedorder = window.lstorders.get(window.lstorders.curselection())
            orderid = str(orders[selectedorder].OrderId)
            warning = messagebox.askokcancel("############ WARNING!! ############",
                                             "You have requested a cancel on order no: " + orderid)
            if warning:
                ttype = "Trade"
                debugout("Requesting Cancellation of order no. " + orderid)
                response = privapi.canceltrade(ttype, orderid)
                if isinstance(response, str):
                    debugout(response)
                else:
                    orderstr = "Cancel Order ID: " + orderid + " Submitted! "
                    if len(response) > 0:
                        orderstr = orderstr + "Cancelled Order ID's: "
                        for corder in response:
                            orderstr = orderstr + str(corder) + ", "
                    debugout(orderstr)
                getorders()
            else:
                debugout("User cancelled order: " + orderid + " cancellation after warning.")
        else:
            debugout("ERROR! - No Order Selected!")
    else:
        debugout("ERROR! - No Orders Found! Please try again.")
        getorders()


# Cancel All trades for a TradePair via TradePairId
项目:CTPrivAPI    作者:doubleelforbes    | 项目源码 | 文件源码
def canceltradepair():
    global privapi
    global orders
    if len(orders) > 0:
        if window.lstorders.curselection():
            selectedorder = window.lstorders.get(window.lstorders.curselection())
            tradepairid = str(orders[selectedorder].TradePairId)
            marketname = orders[selectedorder].Market
            warning = messagebox.askokcancel("############ WARNING!! ############",
                                             "You have requested a cancel on ALL " + marketname + " orders.")
            if warning:
                ttype = "TradePair"
                debugout("Requesting Cancellation of all " + marketname + " trades...")
                response = privapi.canceltrade(ttype, tradepairid)
                if isinstance(response, str):
                    debugout(response)
                else:
                    orderstr = marketname + " TradePair Cancel Submitted! "
                    if len(response) > 0:
                        orderstr = orderstr + "Cancelled Order ID's: "
                        for corder in response:
                            orderstr = orderstr + str(corder) + ", "
                    debugout(orderstr)
                getorders()
            else:
                debugout("User cancelled All " + tradepairid + " cancellation after warning.")
        else:
            debugout("ERROR! - No Order Selected!")
    else:
        debugout("ERROR! - No Orders Found! Please try again.")
        getorders()


# Cancel ALL trades
项目:CTPrivAPI    作者:doubleelforbes    | 项目源码 | 文件源码
def cancelalltrades():
    global privapi
    global orders
    if len(orders) > 0:
        warning = messagebox.askokcancel("############ WARNING!! ############",
                                         "You have requested a cancel on ALL trades!")
        if warning:
            ttype = "All"
            response = privapi.canceltrade(ttype)
            if isinstance(response, str):
                debugout(response)
            else:
                orderstr = "All Trade Cancel Submitted! "
                if len(response) > 0:
                    orderstr = orderstr + "Cancelled Order ID's: "
                    for corder in response:
                        orderstr = orderstr + str(corder) + ", "
                debugout(orderstr)
            getorders()
        else:
            debugout("User Cancelled All Trade Cancellation after warning.")
    else:
        debugout("ERROR! - No Orders Found! Please try again.")
        getorders()


# Just a way to use 2 button handlers to start the trade with a binary choice
项目:CTPrivAPI    作者:doubleelforbes    | 项目源码 | 文件源码
def tip():
    global privapi
    currency = simpledialog.askstring("Currency Required", "Please provide the currency to tip in (eg. 'DOT' or '2')")
    if currency == "":
        debugout("ERROR! - Cannot tip without a currency!")
    else:
        amount = simpledialog.askfloat("Amount Required", "Please provide an amount of " + currency + " to tip")
        activeusers = simpledialog.askinteger("Number of Users Required",
                                              "Please provide a number of active users to tip (2-100):", initialvalue=2)
        formattedamount = "{0:.8f}".format(amount)
        activeusers = str(activeusers)
        confirm = messagebox.askokcancel("Confirm Tip", "Please confirm that you want to tip the trollbox\r\n" +
                                         "Tip Details:\r\nCurrency: " + currency + "\r\nAmount: " + formattedamount +
                                         "\r\nActive Users receiving: " + activeusers)
        if confirm:
            debugout("User confirmed " + formattedamount + " " + currency + " tip, to " + activeusers + " users.")
            response = privapi.submittip(currency, amount, activeusers)
            # The API is supposed to return a string in any event, it doesn't appear to be at the moment.
            # Just as well I coded my own confirmation!!
            if isinstance(response, str):
                # In this case, the response is always a string.
                debugout(response)
            else:
                # This next line is me getting over the fact that the API returns a Nonetype!!
                pass
                # debugout(str(response) + " is a " + str(type(response)))
        else:
            debugout("User Cancelled Tip after warning.")
项目:bench_computer    作者:futureshocked    | 项目源码 | 文件源码
def on_closing(self):
    if messagebox.askokcancel("Quit", "Do you want to quit?"):
        self.pfr.init_board(  {   'value':      0, 
                              'direction':  0, 
                              'pullup':     0}, 
                          {   'value':      0, 
                              'direction':  0,    # Makes all pins outputs outputs
                              'pullup':     0})
        self.root.destroy()
项目:bench_computer    作者:futureshocked    | 项目源码 | 文件源码
def on_closing(self):
    if messagebox.askokcancel("Quit", "Do you want to quit?"):
        self.pfr.init_board(  {   'value':      0, 
                              'direction':  0, 
                              'pullup':     0}, 
                          {   'value':      0, 
                              'direction':  0,    # Makes all pins outputs outputs
                              'pullup':     0})
        self.root.destroy()
项目:bench_computer    作者:futureshocked    | 项目源码 | 文件源码
def on_closing(self):
    if messagebox.askokcancel("Quit", "Do you want to quit?"):
        self.pfr.init_board(  {   'value':      0, 
                              'direction':  0, 
                              'pullup':     0}, 
                          {   'value':      0, 
                              'direction':  0,    # Makes all pins outputs outputs
                              'pullup':     0})
        self.root.destroy()
项目:bench_computer    作者:futureshocked    | 项目源码 | 文件源码
def on_closing(self):
    if messagebox.askokcancel("Quit", "Do you want to quit?"):
        self.pfr.init_board(  {   'value':      0, 
                              'direction':  0, 
                              'pullup':     0}, 
                          {   'value':      0, 
                              'direction':  0,    # Makes all pins outputs outputs
                              'pullup':     0})
        self.root.destroy()
项目:bench_computer    作者:futureshocked    | 项目源码 | 文件源码
def on_closing(self):
    if messagebox.askokcancel("Quit", "Do you want to quit?"):
        self.root.destroy()
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def print_window(self, event):
        confirm = tkMessageBox.askokcancel(
                  title="Print",
                  message="Print to Default Printer",
                  default=tkMessageBox.OK,
                  master=self.text)
        if not confirm:
            self.text.focus_set()
            return "break"
        tempfilename = None
        saved = self.get_saved()
        if saved:
            filename = self.filename
        # shell undo is reset after every prompt, looks saved, probably isn't
        if not saved or filename is None:
            (tfd, tempfilename) = tempfile.mkstemp(prefix='IDLE_tmp_')
            filename = tempfilename
            os.close(tfd)
            if not self.writefile(tempfilename):
                os.unlink(tempfilename)
                return "break"
        platform = os.name
        printPlatform = True
        if platform == 'posix': #posix platform
            command = idleConf.GetOption('main','General',
                                         'print-command-posix')
            command = command + " 2>&1"
        elif platform == 'nt': #win32 platform
            command = idleConf.GetOption('main','General','print-command-win')
        else: #no printing for this platform
            printPlatform = False
        if printPlatform:  #we can try to print for this platform
            command = command % filename
            pipe = os.popen(command, "r")
            # things can get ugly on NT if there is no printer available.
            output = pipe.read().strip()
            status = pipe.close()
            if status:
                output = "Printing failed (exit status 0x%x)\n" % \
                         status + output
            if output:
                output = "Printing command: %s\n" % repr(command) + output
                tkMessageBox.showerror("Print status", output, master=self.text)
        else:  #no printing for this platform
            message = "Printing is not enabled for this platform: %s" % platform
            tkMessageBox.showinfo("Print status", message, master=self.text)
        if tempfilename:
            os.unlink(tempfilename)
        return "break"
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def print_window(self, event):
        confirm = tkMessageBox.askokcancel(
                  title="Print",
                  message="Print to Default Printer",
                  default=tkMessageBox.OK,
                  parent=self.text)
        if not confirm:
            self.text.focus_set()
            return "break"
        tempfilename = None
        saved = self.get_saved()
        if saved:
            filename = self.filename
        # shell undo is reset after every prompt, looks saved, probably isn't
        if not saved or filename is None:
            (tfd, tempfilename) = tempfile.mkstemp(prefix='IDLE_tmp_')
            filename = tempfilename
            os.close(tfd)
            if not self.writefile(tempfilename):
                os.unlink(tempfilename)
                return "break"
        platform = os.name
        printPlatform = True
        if platform == 'posix': #posix platform
            command = idleConf.GetOption('main','General',
                                         'print-command-posix')
            command = command + " 2>&1"
        elif platform == 'nt': #win32 platform
            command = idleConf.GetOption('main','General','print-command-win')
        else: #no printing for this platform
            printPlatform = False
        if printPlatform:  #we can try to print for this platform
            command = command % shlex.quote(filename)
            pipe = os.popen(command, "r")
            # things can get ugly on NT if there is no printer available.
            output = pipe.read().strip()
            status = pipe.close()
            if status:
                output = "Printing failed (exit status 0x%x)\n" % \
                         status + output
            if output:
                output = "Printing command: %s\n" % repr(command) + output
                tkMessageBox.showerror("Print status", output, parent=self.text)
        else:  #no printing for this platform
            message = "Printing is not enabled for this platform: %s" % platform
            tkMessageBox.showinfo("Print status", message, parent=self.text)
        if tempfilename:
            os.unlink(tempfilename)
        return "break"
项目:drc-sim    作者:rolandoislas    | 项目源码 | 文件源码
def start_server(self, event=None):
        """
        Try to start wpa_supplicant and connect to a Wii U.
        :param event: Determines if this was a user initiated start.
        :return: None
        """
        if event:
            LoggerGui.debug("User clicked start server button")
        LoggerGui.debug("Start server called")
        if self.label_backend_status["text"] != DrcSimC.STOPPED and \
                (self.label_wpa_status["text"] not in (WpaSupplicant.DISCONNECTED, WpaSupplicant.TERMINATED)):
            messagebox.showerror("Running", "Server is already running")
            return
        if not os.path.exists(constants.PATH_CONF_CONNECT):
            messagebox.showerror("Auth Error",
                                 "No auth details found. Use the \"Get Key\" tab to pair with a Wii U.")
            self.activate()
            return
        self.normal_interface = self.dropdown_normal_interface.get()
        self.wii_u_interface = self.dropdown_wiiu_interface.get()
        if not self.normal_interface or not self.wii_u_interface:
            messagebox.showerror("Interface Error", "Two interfaces need to be selected.")
            self.activate()
            return
        if self.normal_interface == self.wii_u_interface:
            messagebox.showerror("Interface Error", "The selected normal and Wii U interfaces must be different.")
            self.activate()
            return
        try:
            InterfaceUtil.get_mac(self.normal_interface)
            InterfaceUtil.get_mac(self.wii_u_interface)
        except ValueError:
            messagebox.showerror("Interface Error", "The selected Interface is no longer available.")
            self.activate()
            return
        if InterfaceUtil.is_managed_by_network_manager(self.wii_u_interface):
            set_unmanaged = messagebox.askokcancel(
                "Managed Interface", "This interface is managed by Network Manager. To use it with DRC Sim it needs "
                                     "to be set to unmanaged. Network Manager will not be able to control the interface"
                                     " after this.\nSet %s to unmanaged?" % self.wii_u_interface)
            if set_unmanaged:
                InterfaceUtil.set_unmanaged_by_network_manager(self.wii_u_interface)
            else:
                messagebox.showerror("Managed Interface", "Selected Wii U interface is managed by Network Manager.")
                self.activate()
                return
        LoggerGui.debug("Starting wpa supplicant")
        self.wpa_supplicant = WpaSupplicant()
        self.wpa_supplicant.add_status_change_listener(self.wpa_status_changed)
        self.wpa_supplicant.connect(constants.PATH_CONF_CONNECT, self.wii_u_interface)
        self.label_backend_status.config(text="WAITING")
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def print_window(self, event):
        confirm = tkMessageBox.askokcancel(
                  title="Print",
                  message="Print to Default Printer",
                  default=tkMessageBox.OK,
                  master=self.text)
        if not confirm:
            self.text.focus_set()
            return "break"
        tempfilename = None
        saved = self.get_saved()
        if saved:
            filename = self.filename
        # shell undo is reset after every prompt, looks saved, probably isn't
        if not saved or filename is None:
            (tfd, tempfilename) = tempfile.mkstemp(prefix='IDLE_tmp_')
            filename = tempfilename
            os.close(tfd)
            if not self.writefile(tempfilename):
                os.unlink(tempfilename)
                return "break"
        platform = os.name
        printPlatform = True
        if platform == 'posix': #posix platform
            command = idleConf.GetOption('main','General',
                                         'print-command-posix')
            command = command + " 2>&1"
        elif platform == 'nt': #win32 platform
            command = idleConf.GetOption('main','General','print-command-win')
        else: #no printing for this platform
            printPlatform = False
        if printPlatform:  #we can try to print for this platform
            command = command % shlex.quote(filename)
            pipe = os.popen(command, "r")
            # things can get ugly on NT if there is no printer available.
            output = pipe.read().strip()
            status = pipe.close()
            if status:
                output = "Printing failed (exit status 0x%x)\n" % \
                         status + output
            if output:
                output = "Printing command: %s\n" % repr(command) + output
                tkMessageBox.showerror("Print status", output, master=self.text)
        else:  #no printing for this platform
            message = "Printing is not enabled for this platform: %s" % platform
            tkMessageBox.showinfo("Print status", message, master=self.text)
        if tempfilename:
            os.unlink(tempfilename)
        return "break"