首页 > 解决方案 > Python & Tkinter:从 tkinter scrolledtext 解析文本并获取按钮以运行开始解析过程的定义

问题描述

我目前有一个工作脚本,可以从文本文件中解析文本数据。

我没有使用文本文件,而是对使用 Tkinter 滚动文本而不是文本文件来保存数据感兴趣。然后,我想要一个 Tkinter 按钮,它可以运行解析函数并解析数据,就像我使用文本文件中的数据运行解析脚本时通常所做的那样。

当我尝试将我的工作脚本转换为定义以通过 tkinter 按钮运行时,我遇到了本地和全局变量的问题。作为一个简单的修复,我改为将我的工作脚本直接添加到包含 tkinter 代码的新代码中。然后将工作脚本设置为一个循环,该循环将在按下 tkinter 按钮时被激活,该按钮调用一个简单地更改布尔值的新定义。更改后的布尔值假设使工作脚本然后运行。

我认为这会起作用,但事实并非如此。如果有人可以(1)帮助我理解如何正确运行我的工作脚本作为通过 tkinter 按钮调用的定义,或者(2)帮助我修复我的“修复”,其中工作脚本没有转换为定义,但是循环举行,我将不胜感激!

请参阅下面的脚本的“简单修复”版本:(请参阅@Mike - 当前脚本下面的 SMT 帖子 - 我通过了字数限制尝试将旧脚本和新的可测试 .txt 文件添加到此帖子中)

下面是一个可测试的 .txt 文件。(更新)

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 msdfgsdfgsd@sdgsdfgs.org:
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 | 

标签: pythontkinterglobal-variablestext-parsinglocal-variables

解决方案


这里发生了很多事情,很多事情需要改变。

  1. mainloop()在您关闭应用程序之前,您的代码将无法工作。因此,让我们将您的解析代码移动到旨在更新 onWork 的函数中。

  2. 您可以使用循环生成大部分标签和输入字段。这将有助于减少行数并使内容更易于阅读。使用条目字段列表,您可以使用列表 + 索引值来获取所需内容。

  3. 你有很多代码什么都不做,或者从来没有被调用过。我已经从示例中删除了所有内容。

  4. oneCountries可能应该是您导入的单独文件中的列表。如果您遵循 PEP8 行长度规则,您最终会在代码中添加一堆行。

  5. 除了一些小事情之外,我在您的解析代码中没有太大变化,因为我没有任何数据要测试,所以我无法按原样编写更好的版本。也就是说,我可以看到有很多地方可能会出错。你所有的 if 条件都有问题。例如,您使用循环值运行一个循环,line然后运行具有相同值的子循环,line这将导致事情在到达下一个 if 之前被覆盖。或者,如果语句失败,则您没有 else 条件,if因此您的其余代码可能会在没有定义这些变量的情况下失败。因此,如果您可以提供一些示例文件数据,我可以更新该部分。

  6. 您有几个未使用的导入。尽量保持你的导入简洁明了。

删除所有未使用的代码并重新编写其他代码后,您的示例从 320 行变为 140+。重写代码如下。如果您有任何问题,请告诉我:

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()

推荐阅读