Search code examples
pythontkinterglobal-variablestext-parsinglocal-variables

Python & Tkinter: parsing text from tkinter scrolledtext and getting button to run definition which begins parsing process


I currently have a working script which parses text data from a text file.

Instead of using a text file, I am interested in using a Tkinter scrolledtext to hold the data instead of a text file. I would then like to have a Tkinter button which would run the parsing function and parse the data as it normally would do when I run the parsing script with the data from a text file.

I ran into a problem of local and global variables when I tried to convert my working script into a definition to run via a tkinter button. As a simple fix, I instead added my working script directly to the new code which contained the tkinter code. The working script was then set into a loop that would be activated when the tkinter button was pressed which called a new definition that simply changed a boolean. The changed boolean value was suppose to make the working script then run.

I thought that this would work, but it doesn't. If someone could (1) help me understand either how to properly run my working script as a definition called through a tkinter button or (2) to help me fix my "fix" in which the working script is not converted into a definition, but held within a loop, I would be very grateful!

Please see below for the "simple fix" version of the script: (please see @Mike - SMT post below for current script - I passed the word limit trying to add both the old script and the new testable .txt file into this post)

Below is a testable .txt file. (updated)

asdfasdfasdfasd asdf™
BLAH asdfasdf asdff 
asdfasdfsadf & asdfasd
asdf
asd asdf

 asdff
 asdfaf
 asdfasd
 asdfasd 
asdff asdfasdf / asdfasdf asdfas asdfasdf asdfasdf / asdfa asdf BLAH-2020-02-0001 asdffd




    asdf asdf asdff asdf asdf asdfas asdf asdfas asdf asdfast asdfdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfsdfasdfasd asdfasd sdfas df asdfas df  ffffffasdfasd asdfasdfasd      asdfasdfasdfasdfasdfasdfsdfsdf  asdfasdfasdfasdf asdfasdfasdfsdf asdf asdf asdff asdf asdf asdfas asdf asdfas asdf asdfast asdfdfasdfasdfasdf asdf asdf asdff asdf asdf asdfas asdf asdfas asdf asdfast asdfdfasdfasdfasdf Read More ...



asdfasdf sa








as asdff asdff
Adf f asdf



BLAH-2020-02-0001

Submitted: 29-Feb-2020; Last Updated: 03-Mar-2020; 12314 days, 112314 hours in review

Title Title Title Title Title Title


bob, blah (proxy) (contact); bob2, blah2; bob3, blah3; bob4, blah4


Short Report


asdff - asdffasdf asdf sdf asdff asdfas:  


dfgsdfg fg (Due 10-Mar-2020)

fg: sdf Agsdfgs
sdfg: sdgfsd sdfg, BLAH
ADM: sdfgg, sdfgsd (proxy)

   HTML    PDF     Supplemental Files   Original Files     Abstract     Cover Letter     External Searches   





- sdfg sdfgg sdfgsdf


Date Submitted:

29-Feb-2020

Admin:

sdfgg, sdfgsd  AU REV VIEW ADM PROD 
proxy   
Date to Admin:

29-Feb-2020

Admin:

 Admin  
Date to Admin:

03-Mar-2020

sdfgg-sdf-sdgfsd:

sdfgsdg sdfgg, BLAH  AU REV DE EIC ADM VIEW PROD    
Date to sdfgg-gsd-sdfg:

03-Mar-2020





- sdfgsd sdfgsdf sdgg


sdfgs dfgsdg  dfgsdfgdfg  asdf asdf asdff asdf asdf asdfas asdf asdfas asdf asdfast asdfdfasdfasdfasdfasdf asdf asdff asdf asdf asdfas asdf asdfas asdf asdfast asdfdfasdfasdfasdfasdf asdf asdff asdf asdf asdfas asdf asdfas asdf asdfast asdfdfasdfasdfasdfasdf asdf asdff asdf asdf asdfas asdf asdfas asdf asdfast asdfdfasdfasdfasdf





- sdfgsdn sdfgsd




sdfgsdgsd fg

sdfgsdg sdfgsd

sdfgs sdgsdg

sdfgsdg dfgsd & sdgg

sdfgsd
sdgsd


BLAH-2020-02-0001

Title Title Title Title Title sdfg 

29-Feb-2020





- asdfasd-asdfasdf asdfa


asdfas - Manuscript type:

Short Report

Title:

Title Title Title Title Title blah

Manuscript ID:

BLAH-2020-02-0001

Funding Information:

sdfgsdfg sdfg sdgsdfgsdfg

Submitting Author:


    bob, bob  (proxy)

primary affiliation
Dr.
place place place 123
123 place place place
China

Authors & Institutions:



Dr. name name
place place place 123
123 place place place
China


Dr. name name
place place place 123
123 place place place
China


Dr. name name
place place place 123
123 place place place
China


Dr. name name
place place place 123
123 place place place
China


Dr. name name
place place place 123
123 place place place
China

Dr. name name
place place place 123
123 place place place
China


Dr. name name
place place place 123
123 place place place
China


Dr. name name
place place place 123
123 place place place
Australia


Dr. name name
place place place 123
123 place place place
South Korea

Contact Author (populates the ##PROLE_AUTHOR_..## e-mail tags):


Dr. name name
place place place 123
123 place place place
Japan

Running Head:

Title Title Title Title blah blah

Discipline:

Dis Type blah blah

Keywords:

asdf asdf, asdfas, asdf asdfa, Tasdfsdf, asdfasasdf

Additional Keywords:

asdfas 

Author Recommended Reviewers:

person 1
person 2

Author Opposed Reviewers:

Author's Cover Letter:

dear person,
blah blah blah
cover letter
blahb blah blah
blah blah blah

sincerely,
person

If you have been invited to submit an article for a supplement, please select the title of the supplement:


Manuscript Details - Metadata (Please use numbers only)
Content Information
 Number of words (excluding the title page, abstract, references, acknowledgements, and wording for tables and figures):    
1761

 Number of manuscript pages:    
12

 Number of tables (use 0 for none): 
2

Illustration Information
 Total number of figures (use 0 for none):  
2

 Number of colour figures (use 0 for none): 
0



Publication Charge
 zsasdf sdf asdf as dfa sdfasdfasdf asdfas df asdf as df as dfdfasdfasdfasd zsasdf sdf asdf as dfa sdfasdfasdf asdfas df asdf as df as dfdfasdfasdfasdzsasdf sdf asdf as dfa sdfasdfasdf asdfas df asdf as df as dfdfasdfasdfasdzsasdf sdf asdf as dfa sdfasdfasdf asdfas df asdf as df as dfdfasdfasdfasd

zsasdf sdf asdf as dfa sdfasdfasdf asdfas df asdf as df as dfdfasdfasdfasdzsasdf sdf asdf as dfa sdfasdfasdf asdfas df asdf as df as dfdfasdfasdfasdzsasdf sdf asdf as dfa sdfasdfasdf asdfas df asdf as df as dfdfasdfasdfasdzsasdf sdf asdf as dfa sdfasdfasdf asdfas df asdf as df as dfdfasdfasdfasd zsasdf sdf asdf as dfa sdfasdfasdf asdfas df asdf as df as dfdfasdfasdfasd
Supplement articles: please select the option "I believe a third-party will pay..." below, and enter AAA as the code (stands for "BLAH Supplement Sponsor").

If your manuscript is accepted, you will be given the option of paying by credit card or invoice. If you believe that payment for your article is covered by a society, institutional or funding agency arrangement, please let us know using the form below.

Not sure if payment for your article could be covered by your institution or funding agency? Use our Institute/Funder Policy Finder tool to check: http://sdfgsdfgsdgsdgsdg.html

Who Will Pay


I accept responsibility for paying the publication charge on this article.

If your manuscript is accepted, you will be able to pay by credit card, invoice, or pro forma.

(Please see the “Discounts That May Apply” section for a list of institutions and funding agencies that have agreed to cover a portion of the publication fees.)


I believe a third-party will pay the publication charge for this article.

Some institutions and funding agencies have agreed to be invoiced directly and pay the sdfgsd sdfgsdfgsd sdfgsdg article publication charge (sdfgs) for their affiliated researchers. To check your eligibility, go to http://www.sdfgsdfg and find the affiliated institution or funder of the corresponding author, then copy the code and paste it here.
    Please enter institution code here:

    Please enter your funder and grant / project number if your institution requires this information in order to pay the APC:



I request a waiver of the publication charge for this article.

We offer a complete or partial fee waiver on a case-by-case basis for individual autdfghdfh dfhdfhdfhdfghdfhdfghdfhdfgdfh gfhdfhdfhdf dfghdfh (internal use)

Discounts That May Apply

Please select from the drop-down menus below for all discounts you wish to claim. Please note that the single, highest discount will apply.
Society Membership Discount
If the Corresponding Author is a member of the asdfasdf fasdf asdf asdasdf and wishes to request a discount (as applicable), please select it from the list below.
If the Corresponding Author is not an dsfgs dgfsdgsd sdfgsdgfishes to apply before submitting, the membership application form is available at: www.sdfgsdfgsdfg. To qualify for the discount, please supply your membership number during original submission. The discount will not be applied if you become a member after original submission, or if you suspend your membership before acceptance of your manuscript.
Please enter the society membership ID number of the corresponding author so we can verify your membership. If you don't know your membership ID you can request this from [email protected]:
For office use only:  dfasdf asdffdasasdf asdf
 asdfasdfasdf asdfasdf
The institutions or funding agencies listed below have agreed to cover a portion of the article publication charges in sdfgsd gsdgsdgfsdfgsdfgsdg for their affiliated researchers. If you are a corresponding author affiliated with one of the organizations listed, please select it from the list below:
Other Discount
If you have received another type of discount code, such as a promotional discount code via e-mail or brochure, please enter it below:
Eligibility for institutional payment via asdf asfasdfasdfasdfasdfas is based on the date of submission of an article. If your institution ceases to have an active account/partnership arrangement prior to completion of the article submission process, your article will not be eligible for institutional/funder payment.


Submission Information - Confirm the following:
 Confirm that the manuscript has been submitted solely to this journal and is not published, in press, or submitted elsewhere.  




Conflict of Interest
wer wert wet wet wetwert wet wert we requires that all authors disclose any potential sources of conflict of interest. Any interest or relationship, financial or otherwise, that might be perceived as influencing an author’s objectivity is considered a potential source of conflict of interest. These must be disclosed when directly relevant or indirectly related to the work that the authors describe in their manuscript. Potential sources of conflict of interest include but are not limited to patent or stock ownership, membership of a company board of directors, membership of an advisory board or committee for a company, and consultancy for or receipt of speaker’s fees from a company. The existence of a conflict of interest does not preclude publication in this journal.

If the authors have no conflict of interest to declare, they must also state this at submission. It is the responsibility of the corresponding author to review this policy with all authors and to collectively list in the cover letter (if applicable) to the Editor-in-Chief, in the manuscript (in the footnotes, Conflict of Interest or Acknowledgments section), and in the online submission system ALL pertinent commercial and other relationships.
 Do you or any of your co-authors have a conflict of interest to declare?
No

Confirm that you have stated this conflict of interest in the footnotes, Conflict of Interest or Acknowledgments section of your manuscript as required by the Journal (see the Instructions to Authors).


Provide details and include this information below.


Previously Submitted to  sdfgsdfgsdfgsdfgsdfgsdfgsdfg
 Has this manuscript previously
- been submitted via  sdfgsdfgsdfgsdfsdfgsdfgsdfg previous submission site and is now being submitted either for final acceptance or after revision
- been submitted via the  sdfgsdfgsdfgsdgfsdf sdgfsdfg website and received a revision decision [revised papers should be submitted as “revisions” and not as “new” papers]
- been submitted to  sdfgsdfgsdfgsdgsdfgsdfgsdfcted?
If either of the above is true please answer "Yes". 
No

If yes, please state previous sdfg sdfg sdgfsdgsdfgsdfgsdfgsd:


Open Access Agreement
 Confirm that all authors of this submission have read and understood the journal's policy concerning the completion of the Open Access Agreement. This form will be requested if your paper is accepted. Further information can be found in the journal's Author Guidelines.  




Supporting Information
 We allow submission of "Sdfhdfggh dfh". Go to https://dfgsdgf sdgsdfgsdfgdfgsd.html to access the fgh dfhdfh guidelines for the submission of Supporting Information. If you wish to submit Supporting Information, please select the file designation “Supporting Information for review and publication” when uploading your files. Please note that we would encourage you, where possible and appropriate, to include such information in an Appendix in your main document instead of designating it as Supporting Information.

Does your submission include any supporting information files for publication?


Yes



No



 Ethics
 Please insert your ethical statement below. This should include approval by any ethical boards and your consent or consent waiver procedure. If your article does not require an ethical statement (for example if it is a review), please state this. Your ethical statement should also be included in your methods section.
The case we reported are consent for the study.



 Dates of data collection
 Please state the dates between which your data was collected. Literature reviews should list when the review was completed and the dates of the literature reviewed. This information should also be included in the methods section of your main article and abstract.
 sdfgsdfgsdgsd gsdfgsdgsdfgsdgsdgfsdgfsdgsdgsdfg sdf sdfg sdfgsdfgsd.







- Plagiarism Check iThenticate User Guide


Crossref Similarity Check logo  
Overall Similarity Index Percentage: 25%

Report complete. View the Originality Report.





- Forward to Viewing


Viewing



- Forward to Admin


 fgjgfj, fgjgh  (assign a different person)



- Admin Checklist (Date Completed: 03-Mar-2020 )


Is the submission complete, are all files submitted in an acceptable format and is the manuscript ready for review? 


 Has the author requested a fee waiver? 


Have all co-author names been uploaded by the submitting author?    


Is the manuscript within the scope of/suitable for the journal? 


Does the manuscript main document include keywords? 


If the author has claimed a society membership discount, has membership been verified and society discount code provided (Manuscript Information tab>Author-Supplied Data>Edit This Information)?   


Supplement articles only: Has author selected "BLAH Supplement Sponsor" as their funder? Is manuscript on list of expected supplemental articles? If yes, copy Supplement Title into "Comments to Payment Administrator" below. If no, unsubmit paper and ask author to select another payment option.  




Comments to Payment Administrator:







- Export History 


Export Method

Date Exported

History

Remove

Batch:
Submitted ms export

03-Mar-2020

Exported to file blah-2020-02-0001-20200303110924.zip
Successfully uploaded blah-2020-02-0001-20200303110924.zip via FTP file to sdfgsdfg.com.





Assign to Batch:


Export Now:




- Editor-in-Chief List


Order

Name

Status

History

Remove




 Editorial Office, BLAH
(assign a different person)



Assigned (03-Mar-2020)





- EIC Decision


Make a Decision


Accept


Minor Revision


Major Revision


Reject


Reject without Review

Decision comments (internal use only):



Reviews






- Assign to Issue


Not assigned to issue.

Assign to:






- Companion Papers


Manuscript ID

Manuscript Title

Date Submitted

Author

Status

Delete

Type






- Flag This Manuscript



Leave this manuscript unflagged

      Accepted Manuscript             Plagiarism check needed

      .R2             
                  Resubmission
                  .R1
      TDA with Reports            TDA without Reports






- Notes


Note Title

Updated By

Updated On

Edit

Delete

This document has no notes.





dfghdfhdfhd fgh dfhdfgh
df hdfhdfghdfhdfhdfghdfhdf
dfhdfghdfghdfghdfgh
dfhdfghdfhdfhdfhd

 @dfghdfhdfh  |   dfghdfh dfhdfhh  |   dfhdf dfhdfh  |   dfhdf df dfhdf

 Admin: dfghdfhdf dfhdfhh | 

Solution

  • There is a lot going on here and a lot that needs to be changed.

    1. Your code after mainloop() wont work until you close the application. So instead lets move your parsing code into the function that was meant to update onWork.

    2. You can generate most of your label and entry fields using a loop. This will help reduce lines and make things easier to read. With list of entry fields you can use the list + index values to get what you need.

    3. You had a lot of code that did nothing or was never called. I have removed all that from the example.

    4. oneCountries should probably be a list in a separate file that you import. If you follow PEP8 line length rules you end up adding a bunch of lines to your code.

    5. I have not changed much in your parsing code except for a few small things as I do not have any data to test so I cannot write up a better version as is. That said I can see there are a lot of places things can go wrong. All your if condition have issues. For example you run a loop with the loop value of line then you run sub loops with the same value of line this will cause things to overwrite before it reaches the next if. Or you do not have an else condition if the if statement fails so it is possible for the rest of your code to fail without those variables being defined. So if you can provide some example file data I can update that portion.

    6. You had several imports you were not using. Try to keep your imports clean and concise.

    With all the unused code removed and other code reworked your example went from 320 lines to 140+. Reworked code below. Let me know if you have any questions:

    import tkinter as tk
    from tkinter import scrolledtext
    from itertools import islice
    import re
    
    
    def click_work():
        print('clicked!!')
        print('do work is now in the function!!')
        the_file = txt1.get('1.0', 'end-1c').split('\n')
        print(the_file)
        for line in the_file:
            line = line.strip()
            # print(line)
            if re.match(r'Blah-2020'.upper(), line.upper()):
                print('the_id', line)
                the_id = line  # had to rename due to "id" being a built in function.
            if re.match(r'Submitted: ', line):
                date = line
                for line1 in islice(the_file, 2):
                    title = line1
                for line2 in islice(the_file, 3):
                    authors = line2
                for line3 in islice(the_file, 3):
                    ms_type = line3
                for line4 in islice(the_file, 3):
                    extra_data = line4
    
            if line.startswith('Submitting Author:'):
                country_parsing = True
            elif line.startswith('Running Head:'):
                country_parsing = False
            else:
                country_parsing = False
    
            print(country_parsing)
            if country_parsing:
                for d in countries:
                    if d in line:
                        my_other_list.append(d)
    
            if line.startswith('Author\'s Cover Letter:'):
                cover_letter_parsing = True
            elif line.startswith('If you have been invited to submit an article for a supplement, '
                                 'please select the title of the supplement:'):
                cover_letter_parsing = False
            else:
                cover_letter_parsing = False
    
            if cover_letter_parsing:
                cover_letter.append(line)
    
            if re.match(r'Discipline:', line):
                for sub_line in islice(the_file, 2):
                    discipline = sub_line
            # print(line)
            # print(r'Overall Similarity Index Percentage:' in line)
            if r'Overall Similarity Index Percentage:' in line:
                ithenticate = line
    
        # note several lines will error if a condition was not met previously.
        # so if I were you I would write in some default values just in case match fails.
        ithenticate = float(re.sub('%', '', ithenticate.split(':')[1])) / 100
        first_author = authors.split(',')[0]
        date = date.split(':')[1].split(';')[0].strip(' ')
        id_short = re.sub('Blah'.upper(), '', the_id.upper())
        countries_without_duplicates = list(dict.fromkeys(my_other_list))
        cover_letter.pop(0)
        countrry = ', '.join(countries_without_duplicates)
    
        results = [authors, first_author, the_id, date, ms_type, discipline, ithenticate,
                   id_short, extra_data, my_other_list[0], my_other_list[-1], countrry]
    
        for ndex, entry in enumerate(entry_list3):
            if ndex < len(results):
                entry.delete(0, 'end')
                entry.insert(0, results[ndex])
    
        print("@@@@@@@@@@\n@@@@@@@@@@\n@@@@@@@@@@\n")
        print("All Authors: " + authors)
        print("First Author: " + first_author)
        print("\nMS ID: " + the_id)
        print("\nMS Title: " + title)
        print("Submission date: " + date)
        print("MS type: " + ms_type)
        print("Discipline: " + discipline)
        print("iThenticate: " + str(ithenticate))
        print("MS ID (short version): " + id_short)
        print("Extra info: " + extra_data)
        print("First Author's Country: " + my_other_list[0])
        print("Last  Author's Country: " + my_other_list[-1])
        print("All Author's Countries (w/o duplicates): " + countrry)
    
    oneCountries = "Afghanistan, Albania, Algeria, Andorra, Angola, Antigua & Deps, Argentina, Armenia, Australia, Austria, Azerbaijan, Bahamas, Bahrain, Bangladesh, Barbados, Belarus, Belgium, Belize, Benin, Bhutan, Bolivia, Bosnia Herzegovina, Botswana, Brazil, Brunei, Bulgaria, Burkina, Burma, Burundi, Cambodia, Cameroon, Canada, Cape Verde, Central African Rep, Chad, Chile, China, Republic of China, Colombia, Comoros, Democratic Republic of the Congo, Republic of the Congo, Costa Rica, Côte d’Ivoire, Ivory Coast, Republic of Côte d'Ivoire, Croatia, Cuba, Cyprus, Czech Republic, Danzig, Denmark, Djibouti, Dominica, Dominican Republic, East Timor, Ecuador, Egypt, El Salvador, Equatorial Guinea, Eritrea, Estonia, Ethiopia, Fiji, Finland, France, Gabon, Gaza Strip, The Gambia, Georgia, Germany, Ghana, Greece, Grenada, Guatemala, Guinea, Guinea-Bissau, Guyana, Haiti, Holy Roman Empire, Honduras, Hungary, Iceland, India, Indonesia, Iran, Iraq, Republic of Ireland, Israel, Italy, Ivory Coast, Jamaica, Japan, Jonathanland, Jordan, Kazakhstan, Kenya, Kiribati, North Korea, South Korea, Kosovo, Kuwait, Kyrgyzstan, Laos, Latvia, Lebanon, Lesotho, Liberia, Libya, Liechtenstein, Lithuania, Luxembourg, Macedonia, Madagascar, Malawi, Malaysia, Maldives, Mali, Malta, Marshall Islands, Mauritania, Mauritius, Mexico, Micronesia, Moldova, Monaco, Mongolia, Montenegro, Morocco, Mount Athos, Mozambique, Namibia, Nauru, Nepal, Newfoundland, Netherlands, New Zealand, Nicaragua, Niger, Nigeria, Norway, Oman, Ottoman Empire, Pakistan, Palau, Panama, Papua New Guinea, Paraguay, Peru, Philippines, Poland, Portugal, Prussia, Qatar, Romania, Rome, Russian Federation, Rwanda, St Kitts & Nevis, St Lucia, Saint Vincent & the Grenadines, Samoa, San Marino, Sao Tome & Principe, Saudi Arabia, Senegal, Serbia, Seychelles, Sierra Leone, Singapore, Slovakia, Slovenia, Solomon Islands, Somalia, South Africa, Spain, Sri Lanka, Sudan, Suriname, Swaziland, Sweden, Switzerland, Syria, Tajikistan, Tanzania, Thailand, Togo, Tonga, Trinidad & Tobago, Tunisia, Turkey, Turkmenistan, Tuvalu, Uganda, Ukraine, United Arab Emirates, United Kingdom, United States, Uruguay, Uzbekistan, Vanuatu, Vatican City, Venezuela, Vietnam, Yemen, Zambia, Zimbabwe"
    
    lbl_list = ['Authors: ', '1st Author: ', 'MS ID: ', 'MS Title: ', 'Sub. Date: ',
                'MS Type: ', 'Discipline: ', 'iThenticate: ', 'Extra Info: ',
                '1st Au Country: ', 'Last Au Country: ', 'All Au Country: ', 'COI parameters: ']
    
    window = tk.Tk()
    window.geometry('225x225')
    window.title('Title Here')
    entry_list1 = []  # you can use these list to get the data from entry fields
    entry_list2 = []  # you can use these list to get the data from entry fields
    entry_list3 = []  # you can use these list to get the data from entry fields
    bool_list = []   # you can use this list to get the data from bool vars
    
    tk.Label(window, text='Add Copy&Paste text here', font=('Arial Bold', 10)).grid(column=0, row=0, sticky='w')
    txt1 = scrolledtext.ScrolledText(window, height=0, width=25)
    txt1.grid(column=0, row=1)
    txt1.insert('insert', 'Paste the text here...')
    
    tk.Button(window, text='Analyze the text', bg='white', fg='green',
              command=click_work).grid(column=0, row=4, sticky='w')
    
    tk.Label(window, text='Did you download the files yet?').grid(column=0, row=5, sticky='w')
    rad1 = tk.Radiobutton(window, text='yes', value=1)
    rad2 = tk.Radiobutton(window, text='no', value=0)
    rad1.grid(column=0, row=6, sticky='w')
    rad2.grid(column=0, row=6)
    
    tk.Label(window, text='Files:').grid(column=0, row=8, sticky='w')
    
    
    for i in range(9, 15):
        tk.Label(window, text='{})'.format(i)).grid(column=0, row=9, sticky='w')
        entry_list1.append(tk.Entry(window, width=25, state='disabled'))
        entry_list1[-1].grid(column=0, row=i)
        tk.Label(window, text='~~>', font=('Arial Bold', 10)).grid(column=0, row=i, sticky='e')
        entry_list2.append(tk.Entry(window, width=25))
        entry_list2[-1].grid(column=1, row=i, sticky='w')
        bool_list.append(tk.BooleanVar())
        bool_list[-1].set(True)
        tk.Checkbutton(window, var=bool_list[-1]).grid(column=1, row=9, sticky='e')
    
    for ndex, value in enumerate(lbl_list):
        if ndex == 0:
            sticky1 = 'se'
            sticky2 = 's'
        else:
            sticky1 = 'ne'
            sticky2 = 'n'
        tk.Label(window, text=value).grid(column=2, row=ndex+1, sticky=sticky1)
        entry_list3.append(tk.Entry(window, width=55))
        entry_list3[-1].grid(column=3, row=ndex+1, sticky=sticky2)
        bool_list.append(tk.BooleanVar())
        bool_list[-1].set(True)
        tk.Checkbutton(window, var=bool_list[-1]).grid(column=4, row=ndex+1, sticky=sticky2)
    
    cb_list = ['Title Page', 'Abstract', 'Ethics', 'Consent', 'Contribution', 'COI', 'Funding', 'Cover Letter']
    for ndex, value in enumerate(cb_list):
        tk.Checkbutton(window, text=value).grid(column=0, row=ndex+16, sticky='w')
    
    countries = oneCountries.split(', ')
    my_other_list = []
    directory = 'C:/Users/me/Desktop/'
    path = 'C:/Users/me/Desktop/read.txt'
    cover_letter = []
    window.mainloop()