def ask_if_need_to_save(self):
     if self.open_file != None:
         
         if self.modded == True:
             result = tkMessageBox.askyesnocancel("Save changes?", 
             "Save changes to "+self.open_file.name+" before quitting?")
             
             if result == True:
                 self.doSave()
                 self.root.destroy()
             elif result == False:
                 self.root.destroy()
             
         else: self.root.destroy()
     else:
         if self.modded == True:
             result = tkMessageBox.askyesnocancel("Save changes?", 
                 "Save changes before quitting?")
             
             if result == True:
                 self.doSaveAs()
                 self.root.destroy()
             elif result == False:
                 self.root.destroy()
         else: 
             self.root.destroy()
 def end(k):
     root = Tkinter.Tk()
     root.withdraw()
     if idx() == 0:
         answer = tkMessageBox.askyesnocancel(
             "Terminating", "Compute and save homography matrix H?")
         if answer is True:
             H, _ = cv2.findHomography(np.array(Lst[0]), np.array(Lst[1]))
             try:
                 os.rename(
                     fn + '.map',
                     datetime.datetime.now().strftime("%Y%m%d-%H%M") +
                     'H.map')
             except:
                 print 'error creating backup'
             with open(fn + '.map', 'w') as file:
                 json.dump(H.tolist(), file)
             print 'Matrix saved'
         elif answer is None:
             k = 0
     else:
         answer = tkMessageBox.askokcancel(
             "Warning",
             "Mapping not complete. Are you sure you want to exit?")
         if answer is not True:
             k = 0
     root.destroy()
     return k
Beispiel #3
0
    def _open_cmd(self):
        if self._dirty:
            title = "New Score"
            msg = "Save changes before opening a new score?"
            answer = askyesnocancel(title, msg)

            if answer == None:
                return
            elif answer:
                if self._filepath:
                    self._save_cmd()
                elif not self._save_as_cmd():
                    return False

        filename = askopenfilename(
            parent=self, initialdir=self._initial_dir)
        if not filename: return False

        self._initial_dir = os.path.dirname(filename)
        self._filepath = filename

        song_data = load_song(filename)
        self.set_bottombar_length(song_data['length'])
        self.set_bottombar_timesig(song_data['timesig'])
        self.piano_roll_frame.setup(song_data['notes'])

        self.set_dirty(False)
Beispiel #4
0
    def prevent_losing_changes(self):
        """
        Checks if there are unsaved changes and asks user to save or discard them
        This routine should be called whenever current config is going to be discarded

        Raises the usual 'Yes', 'No', 'Cancel' prompt.

        Return:
            - True: caller may safely drop current config state
            - False: user needs to continue work on current config ('Cancel' pressed or saving failed)
        """
        if self.config_is_changed() == True:
            self.mark_as_changed()
        if not self.unsaved_changes:
            return True
        
        if self.__silent:
            saved = self.save_config()
            return saved
        res = messagebox.askyesnocancel(
            parent=self.root,
            title='Unsaved changes',
            message='Config has unsaved changes. Do you want to save them?'
        )
        if res is None:
            return False
        elif res is False:
            return True
        # Otherwise attempt to save config and succeed only if config has been saved successfully
        saved = self.save_config()
        return saved
Beispiel #5
0
 def destroy(self):
     #check if a test is running
     if self.running.value:
         if tkMessageBox.askokcancel(
                 'Running Test',
                 'There is a test running. Stop test and quit?'):
             self.stop_command()
         else:
             return
     try:
         #Query to save logfile
         val = tkMessageBox.askyesnocancel(
             'Save', 'Do you want to save the log file for this session?')
         #cancel
         if val is None:
             return
         #yes
         elif val:
             #copy logfile to the file given by the saveas dialog
             filename = tkFileDialog.asksaveasfilename(
                 defaultextension='.txt')
             logfile = os.path.join(os.getcwd(), filename)
             shutil.copy('stdout.txt', logfile)
         #simply close and destroy the logfile
         #On windows, os.remove will fail due to a file lock from a subprocess
         #that I haven't been able to track down
         self.logfile.close()
         os.remove('stdout.txt')
         if self.proc and self.proc.is_alive():
             self.proc.terminate()
         self.quit()
     except:
         if self.proc and self.proc.is_alive():
             self.proc.terminate()
         self.quit()
Beispiel #6
0
def checkUpdateUrl(cntlr, actualUrl):    
    # get latest header file
    try:
        from arelle import WebCache, Version
        filename = os.path.basename(actualUrl)
        if filename and u"-20" in filename:
            i = filename.index(u"-20") + 1
            filenameDate = filename[i:i+10]
            versionDate = Version.version[0:10]
            if filenameDate > versionDate:
                # newer
                reply = tkMessageBox.askyesnocancel(
                            _(u"arelle\u2122 - Updater"),
                            _(u"Update {0} is available, running version is {1}.  \n\nDownload now?    \n\n(Arelle will exit before installing.)").format(
                                  filenameDate, versionDate), 
                            parent=cntlr.parent)
                if reply is None:
                    return False
                if reply:
                    thread = threading.Thread(target=lambda u=actualUrl: backgroundDownload(cntlr, u))
                    thread.daemon = True
                    thread.start()
            else:
                if filenameDate < versionDate:
                    msg = _(u"Arelle running version, {0}, is newer than the downloadable version, {1}.").format(
                              versionDate, filenameDate)
                else:
                    msg = _(u"Arelle running version, {0}, is the same as the downloadable version.").format(
                              versionDate)
                tkMessageBox.showwarning(_(u"arelle\u2122 - Updater"), msg, parent=cntlr.parent) 
                                
    except:
        pass
    
    return
Beispiel #7
0
    def low_res_dock(self):
        """
        Low res docking protocol
        This will have its own UI shortly.
        """
        print "This protocol is not set to run global docking.  Please see the rosettacommons documentation for global docking runs."

        if self.score_class.ScoreType.get()!= "interchain_cen":
            result = tkMessageBox.askyesnocancel(title="Set Docking scorefunction?", message="Docking requires the appropriate scorefunction (interchain_cen).  Temporarily set docking scorefunction?")
            if result:
                start_scorefxn = ScoreFunction()
                start_scorefxn.assign(self.score_class.score)
                low_res_scorefxn = create_score_function("interchain_cen")
            elif result==None:
                return
            else:
                low_res_scorefxn = start_scorefxn


        to_dock = tkSimpleDialog.askstring(title = "Input", prompt="Please supply two partners (ex - A_B or A_BC ).  The first will be held rigid.")
        if not to_dock: return
        to_dock = to_dock.upper()

        repack_interface = tkMessageBox.askyesno(message="Repack interface post-dock (talaris2013)?")
        low_res_mover = DockingLowRes(low_res_scorefxn, 1)
        low_res_wrapper = LowResWrapper(to_dock, repack_interface, low_res_mover, low_res_scorefxn)

        self.run_protocol(low_res_wrapper)

        if result:
            self.score_class.score.assign(start_scorefxn)
Beispiel #8
0
    def startGUI(self):
        self.root=Tk()
        self.root.title('ABRAhaM Configuration')
        self.status=Label(self.root, text='...Waiting for input...', bg='black',fg='yellow', width=100)
        self.addactbtn=Button(self.root, text='Add Account', width=50, command=self.addact)
        self.editactbtn=Button(self.root, text='Edit Account', width=50,state=DISABLED, command=self.editact)
        self.addsetbtn=Button(self.root, text='Add Preference',width=50, command=self.addset)
        self.editsetbtn=Button(self.root, text='Edit Preferences',width=50,state=DISABLED, command=self.editset)
        self.savebtn=Button(self.root, text='Save',width=50, command=self.save)
        self.cancelbtn=Button(self.root,text="Done",width=50, command=self.exit)
        Label(self.root, text="Please Select an Action to Perform", foreground='red',background='black').grid(column=0, row=0, columnspan=2, sticky='ew')

        #Build the GUI
        self.status.grid(column=0,row=5,columnspan=2)
        self.addactbtn.grid(column=0,row=2)
        self.editactbtn.grid(column=0,row=3)
        self.editsetbtn.grid(column=1,row=3)
        self.addsetbtn.grid(column=1,row=2)
        self.savebtn.grid(column=0,row=4)
        self.cancelbtn.grid(column=1,row=4)
        self.update()
        if tkMessageBox.askyesnocancel('Load Configuration Data', 'Would you like to load the data from the configuration file?'):
            self.status['text']='Reading and loading saved configuration data...'
            self.cfg=ConfigFile(self.configfile)
            self.cfg.read_config_file()
            self.update()
            self.status['text']='Configuration data loaded...waiting for input...'
        mainloop()
Beispiel #9
0
def askbool(description, message, **kwargs):
    """
    Asks a yes/no question and returns a bool.

    kwargs ignored for compatibility.
    """
    return tkmsg.askyesnocancel(description, message)
 def destroy(self):
     #check if a test is running
     if self.running.value:
         if tkMessageBox.askokcancel('Running Test', 'There is a test running. Stop test and quit?'):
             self.stop_command()
         else:
             return
     try:
         #Query to save logfile
         val = tkMessageBox.askyesnocancel('Save', 'Do you want to save the log file for this session?')
         #cancel
         if val is None:
             return
         #yes
         elif val:
             #copy logfile to the file given by the saveas dialog
             filename = tkFileDialog.asksaveasfilename(defaultextension='.txt')
             logfile = os.path.join(os.getcwd(), filename)
             shutil.copy('stdout.txt', logfile)
         #simply close and destroy the logfile
         #On windows, os.remove will fail due to a file lock from a subprocess
         #that I haven't been able to track down
         self.logfile.close()
         os.remove('stdout.txt')
         if self.proc and self.proc.is_alive():
             self.proc.terminate()
         self.quit()
     except:
         if self.proc and self.proc.is_alive():
             self.proc.terminate()
         self.quit()
    def high_res_dock(self):
        """
        Uses DockMCMProtocol for high-res docking.  Checks scorefunction for docking patch.
        """
        if self.score_class.ScoreType.get() != "docking":
            result = tkMessageBox.askyesnocancel(
                title="Set docking scorefunction?",
                message=
                "Standard docking scorefunction not set. Temporarily set scorefunction?"
            )
            if result:
                start_scorefxn = ScoreFunction()
                start_scorefxn.assign(self.score_class.score)
                self.score_class.score.assign(
                    create_score_function_ws_patch("docking", "docking_min"))
            elif result == None:
                return

        to_dock = tkSimpleDialog.askstring(
            title="Input",
            prompt=
            "Please supply two partners (ex - A_B or A_BC ).  The first will be held rigid."
        )
        to_dock = to_dock.upper()
        if not to_dock: return

        dock_mover = DockMCMProtocol(Vector1([1]), self.score_class.score,
                                     create_score_function("talaris2013"))

        original_ft = self.pose.fold_tree()
        setup_foldtree(self.pose, to_dock, Vector1([1]))
        self.run_protocol(dock_mover)
        if result:
            self.score_class.score.assign(start_scorefxn)
        self.pose.fold_tree(original_ft)
Beispiel #12
0
def MessageBox_type(title='你没给标题呀!!', message='你没给文本啊!!!!', showtype='info',**options):
    if showtype=='info':
        tkmbox.showinfo(title, message,**options)
    elif showtype=='waring':
        tkmbox.showwarning(title, message,**options)
    elif showtype=='error':
        tkmbox.showerror(title, message,**options)
    elif showtype=='question':
        tkmbox.askquestion(title, message,**options)
    elif showtype=='okcancel':
        tkmbox.askokcancel(title, message,**options)
    elif showtype=='yesno':
        tkmbox.askyesno(title, message,**options)
    elif showtype=='yesnocancel':
        tkmbox.askyesnocancel(title, message,**options) 
    elif showtype=='retrycancel':
        tkmbox.askretrycancel(title, message,**options)        
Beispiel #13
0
 def show_yes_no(self, cancel=False):
     """Display a popup with 'Yes', 'No', and optionally 'Cancel'.
     Returns True, False, or None."""
     if cancel:
         self.input = tkMessageBox.askyesnocancel(self.name, self.message)
         return
     self.input = tkMessageBox.askyesno(self.name, self.message)
     return
Beispiel #14
0
def savework():
    global root
    if tkMessageBox.askyesnocancel(
            "Quit",
            "You haven't solved the model, do you still want to terminate?"):
        root.destroy()
    else:
        print "bad mofo"
Beispiel #15
0
 def new(self):
     title = 'Save?'
     msg = 'Would you like to save your work before creating a new file?'
     answer = tkMessageBox.askyesnocancel(title=title, message=msg)
     if answer is None:
         return
     elif answer is True:
         self.save()
     self.reset()
 def onClose(self):
     if self._get() != self._savedcontent:
         ok = tkMessageBox.askyesnocancel("Save?", "Save before quit?",
                 parent=self.root)
         if ok:
             self.doSave()
         elif ok is None:
             return
     self.root.destroy()
Beispiel #17
0
    def quit_handler(self):
        # askyesnocancel returns True, False or None
        if not self._game.game_over:
	  save_response = tkMessageBox.askyesnocancel("Quit?", "Would you like to save your game?")
	  if save_response is None: #cancel
	      return
	  elif save_response: #yes (save)
	      self.db.save_game(self._game, self.difficulty)
        root.destroy()        #no (don't save) or game_over
Beispiel #18
0
 def _on_close(self):
     if self.manager.view.is_dirty():
         msg = 'Do you want to save your changes before exiting?'
         result = askyesnocancel(TITLE, msg)
         if result:
             self.manager.save_game()
         elif result is None:
             return
     self.root.destroy()
 def _on_close(self):
     if self.manager.view.is_dirty():
         msg = 'Do you want to save your changes before exiting?'
         result = askyesnocancel(TITLE, msg)
         if result == True:
             self.manager.save_game()
         elif result == None:
             return
     self.root.destroy()
Beispiel #20
0
    def create_newrecording(self):
        print "Here goes the code to create a new recording"
        # first prompt warning to delete any existing drawing exists

        reply=tkMessageBox.askyesnocancel("Erase existing canvas",\
                                          "Pressing Yes will delete the existing canvas. \n Are you sure you want to create a new recording?")
        
        if reply:
            print "going to delete existing canvas"
Beispiel #21
0
def confirm(text, title="Confirmation", confirm_type=YES_NO_CANCEL):
    if confirm_type == YES_NO_CANCEL:
        return tkMessageBox.askyesnocancel(title, text)
    elif confirm_type == YES_NO:
        return tkMessageBox.askyesno(title, text)
    elif confirm_type == OK_CANCEL:
        return tkMessageBox.askokcancel(title, text)
    else:
        raise Exception('confirm_type must be YES_NO_CANCEL, YES_NO, or OK_CANCEL')
Beispiel #22
0
    def _ehClose(self):
        if(self._dirty):
            result = askyesnocancel('Unsaved Changes', 'There are unsaved changes. Do you want to save them before closing this tab?')
            
            if(result is None):
                return
            elif(result):
                self._save()

        self._parentnotebook.forget(self)
Beispiel #23
0
 def _file_close(self):
     if self.editor.text_has_changed():
         ans = tkMessageBox.askyesnocancel(
             i18n.i18n('File not saved'),
             i18n.i18n('File has not been saved.\nSave it now?'))
         if ans == None: return False
         if ans == True:
             if not self.file_save(): return False
     self.editor.new_file()
     return True
Beispiel #24
0
 def new_command():
     """clear the text area so you can start new text"""         
     answer = tkMessageBox.askyesnocancel("New", "Do you want to save this file?")
     if answer == False:
         textbox.delete(0.0, 'end')
     elif answer == True:
         save_command()
         textbox.delete(0.0, 'end')
     else:
         pass
Beispiel #25
0
 def ps_tuichu(self):
     #退出窗体
     tuichu_return = tkmesbox.askyesnocancel(title=u'mini ps',message=u'图像经过修改,是否保存')
     if tuichu_return == True:
         self.ps_save()
         window.destroy()
     elif tuichu_return == False:
         window.destroy()
     else :
         pass
    def default_KIC(self):
        """
          LoopMover_Perturb_KIC for Low Resolution Loop Modeling
          """
        print "Please cite: Mandell DJ, Coutsias EA, Kortemme T. (2009). Sub-angstrom accuracy in protein loop reconstruction by robotics-inspired conformational sampling. Nature Methods 6(8):551-2."
        print "Additional options can be set using the options system.  Symmetry is not supported at this time."

        if self.score_class.ScoreType.get(
        ) != "cen_std" != self.score_class.ScorePatch.get() != "score4L":
            result = tkMessageBox.askyesnocancel(
                title="Set loop modeling scorefunction?",
                message=
                "Standard loop modeling scorefunction not set (cen_std/score4L patch). Temporarily set scorefunction?"
            )
            if result:
                start_scorefxn = ScoreFunction()
                start_scorefxn.assign(self.score_class.score)
                self.score_class.score.assign(
                    create_score_function_ws_patch("cen_std", "score4L"))
            elif result == None:
                return

        extend = tkMessageBox.askyesno(
            title="Extended",
            message=
            "Start with idealized bond lenghths, angles, and discard original phi/psi?"
        )
        movemap = MoveMap()
        ft = self.pose.fold_tree()
        ft_o = FoldTree()
        ft_o.assign(ft)
        ft.clear()
        #ft.simple_tree(self.pose.total_residue())
        ft, movemap, loops_object = loop_tools.InitializeLoops(
            self.pose, self.input_class.loops_as_strings, ft, movemap)
        print "Fold Tree Correct? " + repr(ft.check_fold_tree())
        self.pose.fold_tree(ft)

        #Setup extended loop to throw away initial loop structure
        if extend:
            for loop in loops_object:
                loop.set_extended(True)

        kic_mover = LoopMover_Perturb_KIC(loops_object, self.score_class.score)

        switch = SwitchResidueTypeSetMover("centroid")
        recover = ReturnSidechainMover(self.pose)
        switch.apply(self.pose)
        self.run_protocol(kic_mover)
        recover.apply(self.pose)
        ft.assign(ft_o)
        self.pose.fold_tree(ft)

        if result:
            self.score_class.score.assign(start_scorefxn)
Beispiel #27
0
 def quit(self):
     if self.settings_dirty.get() or self.project_dirty.get():
         savechanges = tkMessageBox.askyesnocancel("Save changes", "You have unsaved project changes. Do you want to save them before quitting?")
         if savechanges is None: return
         elif savechanges:
             self.noask_save_project()
         self.master.destroy()
     else:
         # write gui settings and destroy
         self.write_gconfig()
         self.master.destroy()
Beispiel #28
0
 def newfile(self, event=None):
     ''' Clears the document and asks if the user wants to save '''
     answer = tkMessageBox.askyesnocancel("", "Save your work before creating a new document?")
     if answer is not None:
         if answer is True:
             if not self.save():
                 return "break"
         self.saved = False
         self.filename = ''
         self.set_all("")
     return "break"
Beispiel #29
0
 def quit(self):
     if self.textarea.edit_modified():
         ans = askyesnocancel('Save', "file has modified,save it before exit?")
         if ans:
             self.savefile()
         elif ans == False:
             self.top.quit()
         elif ans == None:
             pass
     else:
         self.top.quit()
Beispiel #30
0
 def closeWindow(self, askToApplyChanges=True):
     """Close the window."""
     if askToApplyChanges:
         applyOnExit = tkMessageBox.askyesnocancel('Confirm exit',\
                                                   'Would you like to apply your changes before you exit?',
                                                   parent = self.top)
         if applyOnExit == None:
                 return
         elif not applyOnExit:
             self.revertChanges()
     self.top.grab_release()
     self.top.destroy()
Beispiel #31
0
 def quit(self):
     if self.settings_dirty.get() or self.project_dirty.get():
         savechanges = tkMessageBox.askyesnocancel("Save changes", "You have unsaved project changes. Do you want to save them before quitting?")
         if savechanges is None:
             return
         elif savechanges:
             self.noask_save_project()
         self.master.destroy()
     else:
         # write gui settings and destroy
         self.write_gconfig()
         self.master.destroy()
Beispiel #32
0
 def quit(self):
     if self.textarea.edit_modified():
         ans = askyesnocancel('Save',
                              "file has modified,save it before exit?")
         if ans:
             self.savefile()
         elif ans == False:
             self.top.quit()
         elif ans == None:
             pass
     else:
         self.top.quit()
    def promptSave(self):
        '''
        Tells the user that they are about to delete the current
        session, and asks them if they want to save. Returns a value
        based on the user's choice to the prompt.

        Returns:
        None: Cancel
        False: Don't Save
        True: Save
        '''
        return tkMessageBox.askyesnocancel(default=tkMessageBox.YES,icon=tkMessageBox.QUESTION,message='This will end your current session.\nWould you like to save your current session?',title='Save?')
Beispiel #34
0
 def ps_close(self):
     #关闭图片
     baocun_return = tkmesbox.askyesnocancel(title=u'mini ps',message=u'图像经过修改,是否保存')
     if baocun_return == True:
         self.ps_save()
         self.img = Image.open('test.jpg')
         self.photo_display()
     elif baocun_return ==False:
         self.img = Image.open('test.jpg')
         self.photo_display()
     else :
         pass
Beispiel #35
0
 def close(self): # ask for saving before closing
     if not self.saved:
         ok = tkMessageBox.askyesnocancel(parent=self,
                                          message="Your scratch has unsaved modifications. Do you want to save the scratch?",
                                          title="Save scratch")
         if ok == True:
             return self.save()
         elif ok == None: # cancel
             return False # close without saving
         else: # no
             return True
     return True
Beispiel #36
0
def verify_close():
    if modified:
        response = tkMessageBox.askyesnocancel(
            title="Hoodcraft",
            message=
            "You have unsaved changes. Would you like to save {0} before closing it?"
            .format(project_path if project_path else "Untitled"),
            parent=root)
        if response:
            return save()
        else:
            return response is not None
    return True
Beispiel #37
0
def ask_saving():
    #message box pops out asking user to save changes, application's killed no be the game saved or not
    if saved_light.saved_game == 1:
        answer_saving = tkMessageBox.askyesnocancel(
            "Thoughts Box", "Do you want to save any changes?")
        if answer_saving == True:
            Save_action()
            window_1.destroy()

        elif answer_saving == False:
            window_1.destroy()
    else:
        window_1.destroy()
Beispiel #38
0
 def _save_curr_game_if_needed(self):
     if self.view.is_dirty():
         msg = 'Do you want to save your changes'
         if self.filename:
             msg += ' to %s?' % self.filename
         else:
             msg += '?'
         result = askyesnocancel(TITLE, msg)
         if result == True:
             self.save_game()
         return result
     else:
         return False
Beispiel #39
0
    def _ehClose(self):
        if (self._dirty):
            result = askyesnocancel(
                'Unsaved Changes',
                'There are unsaved changes. Do you want to save them before closing this tab?'
            )

            if (result is None):
                return
            elif (result):
                self._save()

        self._parentnotebook.forget(self)
Beispiel #40
0
def ShowMessageYesNoCancel(msg, title=None):
    print(msg)
    if title is None:
        title = msg

    root = tkinter.Tk()
    root.overrideredirect(1)
    root.withdraw()
    root.attributes("-topmost", True)
    result = messagebox.askyesnocancel(title,
                                       msg)  #, icon='warning')#, parent=texto)
    root.destroy()
    return result
Beispiel #41
0
 def _save_curr_game_if_needed(self):
     if self.view.is_dirty():
         msg = 'Do you want to save your changes'
         if self.filename:
             msg += ' to %s?' % self.filename
         else:
             msg += '?'
         result = askyesnocancel(TITLE, msg)
         if result == True:
             self.save_game()
         return result
     else:
         return False
Beispiel #42
0
    def Close(self, obj):
        """fragt den Nutzer bei ungespeicherten Änderungen,
ob das Fenster geschlossen werden kann, gibt Antwort zurück"""
        Close = True
        if not self.Saved:
            if self.Autosave:
                self.Save(obj)
            else:
                tmp = askyesnocancel("Wirklich beenden?", "Möchten Sie Ihre Änderungen speichern?")
                if tmp == None:
                    Close = False
                elif tmp:
                    self.Save(obj)
        return Close
Beispiel #43
0
    def _exit_cmd(self):
        if self._dirty:
            title = "New Score"
            msg = "Save changes before exiting?"
            answer = askyesnocancel(title, msg)

            if answer == None:
                return
            elif answer:
                if self._filepath:
                    self._save_cmd()
                elif not self._save_as_cmd():
                    return False

        self.quit()
Beispiel #44
0
 def on_close(self):
     data_saved = self.host.palette_is_saved(
         self.get_colors(), self.data_type,
         self.main_frame.get_color_names())
     if data_saved == False:
         answer = tkMessageBox.askyesnocancel(
             "Save data before closing?",
             "You have unsaved changes; do you want to save them?",
             icon="question",
             parent=self)
         if answer == None:  # Cancel, do nothing
             return
         if answer == True:
             self.export_colors()
     tkinter.Toplevel.destroy(self)
Beispiel #45
0
    def done_editing_game(self):
        dosave = tkMessageBox.askyesnocancel(
            "Save?", "Do you want to save before quitting?", type=tkMessageBox.YESNOCANCEL
        )
        if dosave == False:
            self.root.destroy()
            self.play = False

        elif dosave == True:
            if self.save():
                self.root.destroy()
                self.play = False

        else:
            print "canceling."
Beispiel #46
0
 def closeWindow(self, ask_to_apply_changes=True):
     '''
     Close the top window.
     '''
     if ask_to_apply_changes:
         apply_on_exit = tkMessageBox.askyesnocancel('Confirm exit',\
                                                   'Would you like to apply these changes?',
                                                   parent = self)
         if apply_on_exit == None:
             return
         if not apply_on_exit:
             self.revert()
     self.grab_release()
     for wid in self.winfo_children():
         wid.destroy()
     self.destroy()
    def delete(self, ev=None):
        try:
            self.get()

            sql = 'DELETE FROM person where 1=1'
            if self.name.get():
                sql = sql + ' AND name like "%%%s%%"' % self.name.get()
            if self.age.get():
                sql = sql + ' AND age = %s' % self.age.get()

            if tkMessageBox.askyesnocancel('提示', '确认删除表中的记录?'):
                self.conn.execute(sql)
                self.conn.commit()
                self.refresh()
        except Exception as e:
            tkMessageBox.showinfo('提示', '删除失败:%s' % e)
    def change_paramset(self, event):
        i = self.cb_paramset.current()
        if (self.remember_paramset != i):
            resp = False
            if (self.b_save_pset['state'] == 'active'):
                resp = tkMessageBox.askyesnocancel(self.lang.save_first, self.lang.save_first_q)
            if (resp == True):
                self.save_params(index = self.remember_paramset)
                resp = False

            # Either... there were no changes, or, there were changes we didn't want to save,
            # Or, there were changes we saved and wanted to continue... resp == False for all 3.

            if (resp == False):
                self.select_parameterset()
                self.remember_paramset = i
Beispiel #49
0
 def save_if_modified(self, event=None):
     if self.editor.edit_modified():  # modified
         response = tkMessageBox.askyesnocancel(
             "Save?",
             "This document has been modified. Do you want to save changes?"
         )  # yes = True, no = False, cancel = None
         if response:  # yes/save
             result = self.file_save()
             if result == "saved":  # saved
                 return True
             else:  # save cancelled
                 return None
         else:
             return response  # None = cancel/abort, False = no/discard
     else:  # not modified
         return True
Beispiel #50
0
    def isOkToOpen(self):
        """Return if it is ok to open another slideshow. If there are unsaved
        changes a yes/no/cancel dialog will be shown."""
        if(self._dirty):
            response = askyesnocancel(lang[lng.dlgUnsavedTitle], lang[lng.dlgUnsaved], parent = self)
          
            if(response is None):
                return False
            elif(response):
                self._save()
            
            self.clear()            
        elif(self.editing):
            self.clear()

        return True
Beispiel #51
0
 def maybesave(self):
     if self.get_saved():
         return 'yes'
     else:
         message = 'Do you want to save %s before closing?' % (self.filename or 'this untitled document')
         confirm = tkMessageBox.askyesnocancel(title='Save On Close', message=message, default=tkMessageBox.YES, master=self.text)
         if confirm:
             reply = 'yes'
             self.save(None)
             if not self.get_saved():
                 reply = 'cancel'
         elif confirm is None:
             reply = 'cancel'
         else:
             reply = 'no'
         self.text.focus_set()
         return reply
Beispiel #52
0
 def maybesave(self):
     if self.get_saved():
         return 'yes'
     else:
         message = 'Do you want to save %s before closing?' % (self.filename or 'this untitled document')
         confirm = tkMessageBox.askyesnocancel(title='Save On Close', message=message, default=tkMessageBox.YES, master=self.text)
         if confirm:
             reply = 'yes'
             self.save(None)
             if not self.get_saved():
                 reply = 'cancel'
         elif confirm is None:
             reply = 'cancel'
         else:
             reply = 'no'
         self.text.focus_set()
         return reply
Beispiel #53
0
def id_option_more():
    response = tkMessageBox.askyesnocancel("Confirm", "save or not")

    if response == True:

        print("You clicked Yes")
        return "Y"

    elif response == False:

        print("You clicked No")
        return "N"

    elif response is None:
        return "C"

    print("You clicked Cancel")
Beispiel #54
0
 def open(self, skip_save=False):
     if not skip_save:
         title = 'Save?'
         msg = 'Would you like to save your work before opening a file?'
         answer = tkMessageBox.askyesnocancel(title=title, message=msg)
         if answer is None:
             return
         elif answer is True:
             self.save()
     filename = tkFileDialog.askopenfilename(
         parent=self,
     )
     if filename == '':
         return
     with open(filename) as f:
         data = yaml.load(f)
     self.data.load(data)
     self.filename = filename
Beispiel #55
0
 def maybesave(self):
     if self.get_saved():
         return "yes"
     message = "Do you want to save %s before closing?" % (self.filename or "this untitled document")
     confirm = tkMessageBox.askyesnocancel(
         title="Save On Close", message=message, default=tkMessageBox.YES, parent=self.text
     )
     if confirm:
         reply = "yes"
         self.save(None)
         if not self.get_saved():
             reply = "cancel"
     elif confirm is None:
         reply = "cancel"
     else:
         reply = "no"
     self.text.focus_set()
     return reply
Beispiel #56
0
def exitApp():
    global saved
    if not saved:
        quitmsg = tkMessageBox.askyesnocancel("Quit?", "The current file is not saved.\nSave file?")
        if quitmsg == None:
            frame.focus()
            return
        if quitmsg:
            if fileexists:
                if saveFile() != "Save Complete":
                    frame.focus()
                    return
            else:
                if saveFileAs() != "Save Complete":
                    frame.focus()
                    return
    #print "Exiting App..."
    frame.destroy()
    sys.exit()
Beispiel #57
0
    def revert_file_event(self, event):
        fname = self.io.filename
        if fname is None:
            # No file associated.
            return

        if not self.io.get_saved():
            msg = "Do you want to save a copy of %s before reverting?" % fname
            res = tkMessageBox.askyesnocancel(
                    master=self.text,
                    title="Save a copy",
                    message=msg)
            if res is None:
                # Canceled.
                return
            elif res:
                self.io.save_a_copy(event)
                # XXX Maybe it would be better to not revert the file when
                # user cancels the dialog that saves a copy of the current
                # file.

        self.io.loadfile(fname)