python类askokcancel()的实例源码

zwareClient.py 文件源码 项目:PyZWare 作者: Z-WavePublic 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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'
PyShell.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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)
test_tkinter.py 文件源码 项目:Mac-Python-3.X 作者: L1nwatch 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
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?")
appjar.py 文件源码 项目:SceneDensity 作者: ImOmid 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def okBox(self, title, message):
        self.topLevel.update_idletasks()
        return MessageBox.askokcancel(title, message)
zwareClient.py 文件源码 项目:PyZWare 作者: Z-WavePublic 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
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.
#@}
tkdialog.py 文件源码 项目:sc8pr 作者: dmaccarthy 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
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
recipe-578569.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def quit(self):
        if askokcancel('Verify exit', 'Really quit?'):
            self._root().destroy()

################################################################################
appjar.py 文件源码 项目:Cryptokey_Generator 作者: 8BitCookie 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def okBox(self, title, message):
        self.topLevel.update_idletasks()
        return MessageBox.askokcancel(title, message)
tkinter_windows.py 文件源码 项目:Physics-2.0 作者: rschwa6308 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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 = ''
tkinter_windows.py 文件源码 项目:Physics-2.0 作者: rschwa6308 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
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))
tkinter_windows.py 文件源码 项目:Physics-2.0 作者: rschwa6308 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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()
spe2fitsGUI.py 文件源码 项目:spe2fits 作者: jerryjiahaha 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def on_closing(app):
    if messagebox.askokcancel("Quit", "Do you want to quit?"):
        app.cleanup()
    sleep(0.2)
    print("exit")
    os._exit(1)
character_creator.py 文件源码 项目:DnD 作者: the-nick-of-time 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
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.py 文件源码 项目:SPGL 作者: wynand1004 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def ask_ok_cancel(self, title, message):
        return messagebox.askokcancel(title, message)
spgl.py 文件源码 项目:SPGL 作者: wynand1004 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def ask_ok_cancel(self, title, message):
        return messagebox.askokcancel(title, message)
Dooz.py 文件源码 项目:persianDooz 作者: FONQRI 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def on_closing():
    if messagebox.askokcancel("Quit", "Do you want to quit?"):
        root.destroy()
        sys.exit()
Dooz.py 文件源码 项目:persianDooz 作者: FONQRI 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
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*************************************************************
Dooz.py 文件源码 项目:persianDooz 作者: FONQRI 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
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)
ScriptBinding.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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
gateway.py 文件源码 项目:PyLaz 作者: LAPIS-Lazurite 项目源码 文件源码 阅读 45 收藏 0 点赞 0 评论 0
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
main_tk_replicator.py 文件源码 项目:qal 作者: OptimalBPM 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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)
appjar.py 文件源码 项目:BeachedWhale 作者: southpaw5271 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def okBox(self, title, message):
        self.topLevel.update_idletasks()
        return MessageBox.askokcancel(title, message)
fft_spectrum_gui_3can_py3_01.py 文件源码 项目:FFT-spectrum-analyzer 作者: ariquezada 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
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()
PyShell.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
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)
ScriptBinding.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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.py 文件源码 项目:pynpuzzle 作者: mahdavipanah 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
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
frame_get_key.py 文件源码 项目:drc-sim 作者: rolandoislas 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
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)
PyShell.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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)
ScriptBinding.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
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
install_examples.py 文件源码 项目:SFC_models 作者: brianr747 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
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)


问题


面经


文章

微信
公众号

扫码关注公众号