(*args)
| 52 | |
| 53 | |
| 54 | def programSelect(*args): |
| 55 | global CURRENT_SELECTED_INDEX, programListbox, descTextarea, undoChangesBtnSV, undoChangesButton |
| 56 | # If, for some reason, nothing is currently selected in the listbox of programs, do nothing: |
| 57 | if len(programListbox.curselection()) == 0: |
| 58 | return |
| 59 | |
| 60 | i = CURRENT_SELECTED_INDEX = programListbox.curselection()[0] |
| 61 | |
| 62 | descTextarea.configure(state='normal') |
| 63 | descTextarea.delete('1.0', END) |
| 64 | filename = os.path.join(FOLDER_OF_THIS_FILE, PROGRAMS[i]['filename']) |
| 65 | |
| 66 | # Pygame games need to have their cwd changed to pygame_games/ |
| 67 | if 'Pygame' in PROGRAMS[i]['desc']: |
| 68 | os.chdir(os.path.join(FOLDER_OF_THIS_FILE, 'pygame_games')) |
| 69 | else: |
| 70 | os.chdir(FOLDER_OF_THIS_FILE) |
| 71 | |
| 72 | # Set the text in the text box to the program name and description: |
| 73 | programNameInListbox = PROGRAMS[i]['name'] |
| 74 | text = programNameInListbox + '\n\n' + PROGRAMS[i]['desc'] + '\n' |
| 75 | descTextarea.insert(INSERT, text) |
| 76 | descTextarea.configure(state='disabled') |
| 77 | |
| 78 | # Get the adler32 hash of the .py file: |
| 79 | fileObj = open(filename, encoding='utf-8') |
| 80 | fileHash = zlib.adler32(fileObj.read().encode('utf-8')) |
| 81 | fileObj.close() |
| 82 | |
| 83 | # Check if the .py file on disk is different from the original file (based on the hash): |
| 84 | sourceFileIsChanged = fileHash != PROGRAMS[i]['hash'] |
| 85 | if sourceFileIsChanged: |
| 86 | undoChangesBtnSV.set('Undo Changes') |
| 87 | undoChangesButton.config(state='normal') |
| 88 | else: |
| 89 | undoChangesBtnSV.set('File is Unchanged') |
| 90 | undoChangesButton.config(state='disabled') |
| 91 | |
| 92 | |
| 93 | def runClick(*args): |
nothing calls this directly
no outgoing calls
no test coverage detected