def remove_task(self, ev, task): ev.stopPropagation() text = "Confirm deletion of: " + task.desc ret = confirm(text) if ret: del doc[task.id] self.kanban.remove_task(task.id)
def run(withTests): window.pythonTests.clear() window.cleanAll() import smartpy smartpy.defaultVerifyMessage = None smartpy.sp.types.unknownIds = 0 code = window.editor.getValue() changes = syntaxChanges() for change in changes: if change[0] in code: if window.inBrowser: message = ( "Warning: syntax change: %s -> %s" % (change[0], change[1]) + "\n\nMigrate Syntax to adapt your script automatically?\n\nOther changes:\n" + "\n".join("%s -> %s" % (change[0], change[1]) for change in changes)) from browser import confirm if confirm(message): for ch in changes: code = code.replace(ch[0], ch[1]) window.editor.setValue(code) break else: print( "Warning: syntax change: %s -> %s. You can use the editor to adapt it." % (change[0], change[1])) code = adaptBlocks(code) env = context.copy() exec(code, env) window.cleanAll() for test in window.pythonTests: window.addButton(test.name, test.f) if withTests and test.is_default: test.eval() if withTests and len(window.pythonTests) == 0: html = "" for c in env: if "$" in c: continue if hasattr(env[c], "collectMessages"): html += ( "There is a sp.Contract class '%s' but no test is defined.\n\nPlease add a test such as:\n%s" % (str(c), testTemplate % (c, c))) if html: alert(html)
def exists(evt): if evt.target.result: # A script of the same name already exists replace = confirm("A script called " + new_name + " already exists. Overwrite ?") if replace: # Replace existing script tx = db.transaction("scripts", "readwrite") store = tx.objectStore("scripts") data = {"name": new_name, "content": editor.getValue()} req = store.put(data) @bind(req, "success") def replaced(evt): # Now delete script with old name req = store.delete(old_name) @bind(req, "success") def removed(evt): del open_files[old_name] if not new_name in open_files: open_files[new_name] = { "content": editor.getValue(), "cursor": [0, 0] } update_filebrowser(new_name) else: # New script tx = db.transaction("scripts", "readwrite") store = tx.objectStore("scripts") data = {"name": new_name, "content": editor.getValue()} req = store.put(data) @bind(req, "success") def created(evt): del open_files[old_name] open_files[new_name] = {"content": "", "cursor": [0, 0]} update_filebrowser(new_name)
def onsavebutton(self, event): filename = self.fileinput.value if filename == "": alert("No name given for the file") return if self.defaultextension: ext = "." + self.defaultextension if filename[-4:] != ext: filename += ext self.path.append(filename) filepath = "/".join(self.path) if filename in self.folderlist: self.getfilelist(filepath) else: if filename in self.filelist: response = confirm("File exists. Overwrite?") if response is False: self.path.pop() return self.savefile(filepath, self.filetosave) self.filename = filename self.path.pop() self.hide() self.returnaction(filename)
def trash(evt): """Delete a file.""" current = filebrowser.select_one(".current") if current is None: return name = current.text if not name: return name = name.rstrip("*") msg = _("confirm_delete", "Do you want to delete\nfile {} ?") resp = confirm(msg.format(name)) if not resp: return db = request.result tx = db.transaction("scripts", "readwrite") store = tx.objectStore("scripts") cursor = store.openCursor() store.delete(name) def ok(evt): alert(_("file_deleted", "File deleted")) _remove(name) cursor.bind("success", ok)
kanban.add_task(task.id, 'Waiting QA', 4, 0) kanban.add_task("step6", 'Project D', 1, 100) # ---------------------------------------------------------- kanban = KanbanModel(counter=1, schema_revision=SCHEMA_REVISION, steps_colors=STEPS_COLORS, tasks_colors=TASKS_COLORS) copyright = """ Copyright (c) 2013-2014, Pedro Rodriguez [email protected] All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ ret = confirm( "Click OK to accept condition of use\n\n" + copyright ) if ret: init_demo(kanban) kanban_view = KanbanView(kanban) kanban_view.load() else: doc.open("about:blank")
def confirm_dialog(self, title, message): return confirm(title+'\n'+message)
def question_dialog(self, title, message): return confirm(title+'\n'+message)