Skip to content

Commit

Permalink
Merge pull request #21 from Mkranj/multiple_files
Browse files Browse the repository at this point in the history
Add a dialog where user can choose to process another file
  • Loading branch information
Mkranj authored Jan 12, 2023
2 parents 25e4e37 + 8b52140 commit c741e94
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions PapersCited.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# GUI elements - for the file dialog. Explicitly import the filedialog submodule.
import tkinter
from tkinter import filedialog
from tkinter import messagebox

# In the actual string, a single \ is used. But for escaping it, we need to put
# \\ inside strings. Otherwise it will append lines, causing indentation errors.
Expand Down Expand Up @@ -409,6 +410,16 @@ def preview_citations(citations, wider_citations):
print("Wider citations found:")
[print(citation) for citation in wider_citations.citations]

def dialog_process_another_file():
root = tkinter.Tk()
# Make the main window of tkinter invisible since we only need the dialog.
root.withdraw()
root.attributes("-topmost", True)
process_another_file = messagebox.askyesno(title = "Process another file?", message = "Choose another file to extract citations from?\
\nPress 'No' to end the program.")
root.destroy()
return(process_another_file)

# MAIN ----

def main():
Expand Down Expand Up @@ -441,5 +452,9 @@ def main():
preview_citations(narrower_citations, wider_citations)

if __name__ == "__main__":
main()
input("\nPress Enter to exit the program.")
continue_processing_files = True
while continue_processing_files:
main()
continue_processing_files = dialog_process_another_file()
if continue_processing_files:
print("\n-------------------\n")

0 comments on commit c741e94

Please sign in to comment.