Automatic generation system of oral arithmetic in python (GUI interface programming)

Posted by mgason on Mon, 24 Jan 2022 07:47:22 +0100

preface:

Thank you, brother Li. It's really strong. I'll give you a compliment

1 GUI interface programming

1.1 problem description
Topic selection: oral arithmetic question generation system
Design GUI interface to realize oral arithmetic problem generation system, including but not limited to the following functions.
(1) Oral arithmetic: the questions are displayed on the interface (division must be integer division). You can display the questions one at a time or one by one. The user inputs the calculation results through the input box. The system can display the wrong questions and count the correct rate.
(2) Print: generate the title into the word document "oral calculation. docx".
(3) You can choose the number of questions generated by oral arithmetic and printing, the rows and columns when printing, and the number of operators.
1.2 design description
Including but not limited to:
(1) Functions to be designed, implementation ideas and knowledge to be used
1, Functions and implementation ideas of each module of the project:
1. the first mock exam module is the title bar module, which indicates that the users are welcome to the oral processing system.
The implementation idea is to use the frame box model in tkinter, then apply an Entry function to place the text content, and use the grid function to adjust the style (cooperate with padx and pady to adjust the width and height margins to make the whole look neat and comfortable.

2. the second module is "file" and "print" for menu bar.
You can choose to close the filling in in the file, and the GUI interface disappears. Or click the print button to display the following two functions: print to word or print the specified topic to word. Select according to user needs, and insert a picture description here

3. in the third module, there are five types of questions, including addition, subtraction, multiplication, division and mixed questions. Users can select the corresponding radio boxes according to their own needs. You can select Start generation, and all the twelve questions will appear directly on the interface. If you click generate one by one, you can do it one by one. At the same time, each question can switch the answer question type, and make the corresponding question type according to your own shortcomings, which is very conducive to the actual question making.

4. The fourth module is the user's answer area: I have prepared a total of 12 questions, and then use the grid function to neatly prevent them in this lableFrame. I use the label label in the question box and the Entry label in the answer box. That is, the title is not modifiable, it is generated in the background, and the answer is entered by yourself, which meets the actual development requirements.

5. In the fifth module, I have prepared 12 check boxes for users to select and print the specified topic. Users can check the topic they want to print according to their own needs, and then click print the specified topic to word in the upper left corner of the interface to print successfully. The first three topics in the first line of the topic specify the first three check boxes below, and so on, the third topics in the second line of the topic specify the fourth to sixth check boxes, and so on

6. The sixth module is the answer submission module for the user. When the answer is finished, the user can click to submit the answer, and the system will score for this, and the results will be calculated in the next score module (that is, the seventh module). The subsequent examination time is convenient for the user to master the answer time. When the user clicks the start generation button, the current time will be automatically generated, It will be displayed on the page after accumulating one hour as the examination time.

7. The seventh module is the score column module. After the user submits the answer, the system will score this, 10 points for each question, a total of 120 points, and then calculate the corresponding accuracy. When you click the print error report later, the system will print the wrong question into word.

8. The eighth module is the error topic reporting module. The system will count the number of error topics and display the corresponding error topic number on it

Screenshot of the overall project;

2, Knowledge required for the project
1. tkinter library is used in the project, which is also the most important library for GUI programming.
The following is the tutorial I learned in csdn for this big assignment:
https://blog.csdn.net/RNG_uzi_/article/details/89792518?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522162495353716780265439340%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=162495353716780265439340&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2allfirst_rank_v2~rank_v29-2-89792518.pc_search_result_cache&utm_term=tkinter%E5%BA%93%E7%95%8C%E9%9D%A2%E8%AE%BE%E8%AE%A1&spm=1018.2226.3001.4187
2. Secondly, I used the knowledge of finding prime numbers and composite numbers in python. Because the division problem must be integer division, my idea is to find all composite numbers within 100, then divide each composite number, and display the two numbers on the interface when finding the divisor.
3. I used a lot of list traversal knowledge. At the same time, I also reviewed the list knowledge in class and learned how to traverse the list quickly. I can use subscript traversal:

Or use traversal or iterators:

(2) Description of the calling Library
1.Tkinter Library:
Tkinter module (TK interface) is the interface of Python's standard Tk GUI toolkit TK and Tkinter can be used on most Unix platforms, as well as Windows and Macintosh systems. Tk8. The subsequent versions of 0 can realize the local window style and run well on most platforms.
GUI programming is equivalent to children building blocks. Where should each block be placed and how large each block is displayed, that is, the size and location need to be managed, and the layout manager is responsible for managing the size and location of each component. In addition, when the user resizes the window, the layout manager will automatically adjust the size and position of each component in the window.
2.datetime class:
Datetime class through datetime Datetime (year, month, day, hour, minute, second, microsecond, tzinfo) creates an object, and the attribute value of the corresponding object is obtained through similar methods.

datetime.datetime.now(): get the detailed time information of the current time
datetime.datetime.combine(date, time): pass in date and time objects and combine the two information to generate corresponding datetime objects.
timestamp(): convert datetime object into timestamp object (floating point number, calculated from 1970-1-1 00:00:00 UTC+0:00)
3.Random class:

(3) Functions and functions defined and called
Functions are defined in this GUI programming,

  1. Where the main function_ main_ For the entire function entry, call the run function
  2. The run function is the framework design function of the GUI interface. After the overall framework interface is designed through Frame and lableFrame, the grid function (similar to the front-end css style adjustment method) is used to modify the overall layout to make the page beautiful.
  3. The create function (i.e. topic generation function) is defined. After clicking the start generation button, the command calls the create function. After obtaining the topic type selected by the user through the global variable (obtained by using the get method in tk.stringVar), and then generating the corresponding topic by using the Random library, the final set method is injected into the interface. I have a total of 12 topics, so I use the for loop for sequential injection, so I don't need to write 12 set methods, which greatly improves the code cleanliness and code efficiency of the page.
  4. The create2 function (i.e. generating topic functions one by one) is defined, which is basically the same idea as the create function, but the difference is that it is not injected into the interface in turn. I defined a global variable, and then every time I click the generate one by one button, the global int variable will be added with one to represent the title number of the next topic I want to inject, then splice my prefix string constant, use the eval function, and finally inject with the set method.
  5. The submit function (topic submission function) is defined. When all 12 questions are answered, you can click Submit. At the same time, I define a global variable error outside the function_ List, the function uses global reference, and then traverses 12 questions. If the answer is correct, the number of correct answers will be increased by 1. If the answer is wrong, the question number of the wrong question will be recorded, and the append method will be added to error_list, and finally display the correct rate, wrong title number and other information
  6. The Print function (Title printing function) is defined. First get the file, if not, create one, then use the get method to get 12 titles, and then output the Print stream to the file.
  7. The Print2 function (designated Title printing function) is defined. First, the file is obtained, if not, one is created, and then the user selects the title in the check box to print the specified title into the file
  8. Print3 function (error topic printing function) is defined. First, get the file, if not, create one, and then output the user's wrong topic to the file according to the previous system statistics

1.3 implementation code
1.3.1 create main window

1.3.2 page design (layout of Frame)
1. Menu in the upper left corner

2. Frame design (and grid function layout) from top to bottom:

3. Corresponding implementation code of each framework:
title:

Answer type:

Select a print title:

Answer area:

Submit answer:

Performance report:

Error topic report:

last:

4.create function (detailed explanation of all topic generation functions)
Q is used for the answer type_ Type. This function refers to the global variable (using the global method). At the same time, it uses the datetime class to obtain the current time, sets the specified format with the striftime method, and sets the examination time to one hour. It is accumulated to the current time and calculated and displayed on the interface.
Then according to Q_ The get method of type obtains the answer type selected by the user, generates the corresponding question, and uses random RandInt method randomly generates, then splices strings to generate questions, splices a new variable with eval method, and uses set method to generate questions on the interface.

In the division method, I use the composite number to find the divisor. Once found, I break out of the loop and display the data on the page. First, type all the composite numbers into the list

5.create2 function (generating functions one by one, detailed explanation)
The idea is basically the same as that of the create function, except that the for loop is not injected into the interface, but is is is used_ List global variable, record the number of topics we generated, and then continue to generate the next one.

When all the questions are generated, click the generate one by one button, and the system will pop up to prompt that all the questions are generated.

6. Topic submission function (submit)
First, use the eval method to splice the string, and then use the get method to obtain each question and its answer. If the answer is correct, add one to the correct number, otherwise record the wrong question number in error_ In the list, the score, correct rate and wrong question number will be displayed after the final answer is submitted.

7. Title printing function
First, use the open method to open the corresponding file. If the file does not exist, create one, then obtain the corresponding topics in turn, and output them to the file using the write output stream

8. Specify the title printing function (Print2):

9. Error Title printing function (Print3)

Finally, the code:

import sys
import tkinter as tk

import tkinter.messagebox
import pickle

import random
import datetime
# Step 1: instantiate the object and create a window
window = tk.Tk()
# Step 2, name the visualization of the window
window.title('Gao Xiang's oral arithmetic generation system')
# Step 3: set the window size (length * width)
window.geometry('600x500')

q_type = tk.StringVar()
question1 = tk.StringVar()
question2 = tk.StringVar()
question3 = tk.StringVar()
question4 = tk.StringVar()
question5 = tk.StringVar()
question6 = tk.StringVar()
question7 = tk.StringVar()
question8 = tk.StringVar()
question9 = tk.StringVar()
question10 = tk.StringVar()
question11 = tk.StringVar()
question12 = tk.StringVar()
answer1=tk.StringVar()
answer2=tk.StringVar()
answer3=tk.StringVar()
answer4=tk.StringVar()
answer5=tk.StringVar()
answer6=tk.StringVar()
answer7=tk.StringVar()
answer8=tk.StringVar()
answer9=tk.StringVar()
answer10=tk.StringVar()
answer11=tk.StringVar()
answer12=tk.StringVar()
grade=tk.StringVar()
grades=tk.StringVar()
error=tk.StringVar()
errors=tk.StringVar()
gg1=tk.StringVar()
gg2=tk.StringVar()
gg3=tk.StringVar()
gg4=tk.StringVar()
gg5=tk.StringVar()
gg6=tk.StringVar()
gg7=tk.StringVar()
gg8=tk.StringVar()
gg9=tk.StringVar()
gg10=tk.StringVar()
gg11=tk.StringVar()
gg12=tk.StringVar()

Date=tk.StringVar()
Is_List=1
list = []
for i in range(4, 100):
    for j in range(2, i):
        if (i % j == 0):
            list.append(i)
            break
print((list))


def create():
    global q_type
    Date.set((datetime.datetime.now().strftime("%m-%d %H:%M"))+"Examination to"+(datetime.datetime.now()+datetime.timedelta(hours=1)).strftime("%m-%d %H:%M"))

    if (q_type.get() == 'jia'):

        for i in range(1, 13):
            first = random.randint(1, 100)
            second = random.randint(1, 100)
            result = str(first) + '+' + str(second) + '='
            qq = eval("question" + str(i))
            qq.set(result)
    elif (q_type.get() == 'jian'):
        for i in range(1, 13):
            first = random.randint(1, 100)
            second = random.randint(1, 100)
            result = str(first) + '-' + str(second) + '='
            qq = eval("question" + str(i))
            qq.set(result)
    elif (q_type.get() == 'cheng'):
        for i in range(1, 13):
            first = random.randint(1, 100)
            second = random.randint(1, 100)
            result = str(first) + '*' + str(second) + '='
            qq = eval("question" + str(i))
            qq.set(result)
    elif (q_type.get() == 'chu'):
        for k in range(1, 13):
            suiji = random.randint(1, 72)
            for i in range(2,list[suiji]):
                #print(list[suiji])
                if list[suiji] % i == 0:
                    j = list[suiji] / i
                    break
            result = str(list[suiji]) + '/' + '{:g}'.format(j) + '='
            qq = eval("question" + str(k))
            qq.set(result)
    else:
        for i in range(1, 5):
            first = random.randint(1, 100)
            second = random.randint(1, 100)
            result = str(first) + '*' + str(second) + '='
            qq = eval("question" + str(i))
            qq.set(result)
        for i in range(5, 10):
            first = random.randint(1, 100)
            second = random.randint(1, 100)
            result = str(first) + '+' + str(second) + '='
            qq = eval("question" + str(i))
            qq.set(result)
        for i in range(10, 13):
            first = random.randint(1, 100)
            second = random.randint(1, 100)
            result = str(first) + '-' + str(second) + '='
            qq = eval("question" + str(i))
            qq.set(result)

            # first = random.randint(1, 100)
            # second = random.randint(1, 100)
            # result = str(first) + '-' + str(second) + '='
        # qq = eval("question" + str(i))
        # qq.set(result)
def reply():#Define a function to generate pop-up windows multiple times
    tk.messagebox.showwarning(title='Tips', message='All the questions have been finished~')
def create2():
    Date.set((datetime.datetime.now().strftime("%m-%d %H:%M"))+"Examination to"+(datetime.datetime.now()+datetime.timedelta(hours=1)).strftime("%m-%d %H:%M"))
    global Is_List
    if(Is_List>12):
        reply()

    if (q_type.get() == 'jia'):
        # print('1')
        first = random.randint(1, 100)
        second = random.randint(1, 100)
        result = str(first) + '+' + str(second) + '='
        qq = eval("question" + str(Is_List))
        qq.set(result)
        Is_List+=1
    elif (q_type.get() == 'jian'):
        first = random.randint(1, 100)
        second = random.randint(1, 100)
        result = str(first) + '-' + str(second) + '='
        qq = eval("question" + str(Is_List))
        qq.set(result)
        Is_List += 1
    elif (q_type.get() == 'cheng'):
        first = random.randint(1, 100)
        second = random.randint(1, 100)
        result = str(first) + '*' + str(second) + '='
        qq = eval("question" + str(Is_List))
        qq.set(result)
        Is_List += 1
    elif (q_type.get() == 'chu'):
        suiji = random.randint(1, 72)
        for i in range(2, list[suiji]):
            # print(list[suiji])
            if list[suiji] % i == 0:
                j = list[suiji] / i
                break
        result = str(list[suiji]) + '/' + '{:g}'.format(j) + '='
        qq = eval("question" + str(Is_List))
        qq.set(result)
    else:
        first = random.randint(1, 100)
        second = random.randint(1, 100)
        result = str(first) + '+' + str(second) + '='
        qq = eval("question" + str(Is_List))
        qq.set(result)
        Is_List += 1
right_list=[]
error_list=[]

def submit():

    global error_list
    error_list.clear()
    true=0
    for i in range(1,13):
        an=eval("answer"+str(i))
        qu=eval("question"+str(i))
        ans=an.get()
        qus=qu.get()
        qus_list=qus.split('=')
        quse=str(eval(qus_list[0]))
        if quse==ans:
            true+=1
        else:
            error_list.append(i)

    sum = ''
    for i in error_list:
        sum = '{} {}'.format(sum, i)
    error.set(len(error_list))
    errors.set(sum)
    grade.set(true*10)
    grades.set(str((round(true/12,2))*100)+"%")


def click():
    print("Click once")
def Print():
    #File name entered
    file_name='gx Oral arithmetic exercises.docx'
    file=open(file_name,'w')
    Write=''


    for i in range(1,13):
        quest=eval("question"+str(i))
        Write=quest.get()+'\n'
        print(Write)
        file.write(Write)
    file.close()

def Print2():
    file_name = 'gx Assigned oral arithmetic exercises.docx'
    file = open(file_name, 'w')
    Write_str = ''

    for i in range(1, 13):
        gx = eval("gg" + str(i))
        if gx.get()==1:
            quest = eval("question" + str(i))
            Write_str = quest.get() + '\n'
            print(Write_str)
            file.write(Write_str)
    file.close()
def Print3():
    global error_list
    file_name = 'gx Wrong oral arithmetic exercise Report.docx'
    file = open(file_name, 'w')
    Write_str = ''

    for i in range(13):
        if error_list[i]!=0:
            Write_str = eval("qustion"+str(error_list[i])).get() + '\n'
            file.write(Write_str)
    file.close()

menubar = tk.Menu(window)
window.config(menu=menubar)
filemenu = tk.Menu(menubar, tearoff=0)
filemenu2 = tk.Menu(menubar, tearoff=0)
menubar.add_cascade(label='file', menu=filemenu)
menubar.add_cascade(label='Print', menu=filemenu2)
filemenu.add_command(label='Sign in', command=click())
filemenu.add_command(label='Close fill', command=window.quit)
filemenu2.add_cascade(label="output word",command=Print)
filemenu2.add_cascade(label="Specify topic output word",command=Print2)
# Place frame

# Title Module
frame1 = tk.Frame(window, bg='MediumTurquoise', bd=4)
# Answer type
frame2 = tk.LabelFrame(window, text='Answer type', padx=5, pady=1, bd=5)
# Answer area
frame5 = tk.Frame(window, bg='LightSkyBlue', bd=40, height=280)
# Select print title
frame8 = tk.LabelFrame(window, text='Select print title', pady=1, bg='LightSeaGreen', bd=5)
#Submit answers
frame7 = tk.LabelFrame(window, text='Submit answers', pady=1, bg='LightGreen', bd=5)
#Achievement report
frame4 = tk.LabelFrame(window, text='Score (12 questions in total, 10 points for each question, out of 120 points)', pady=1, bg='LightSeaGreen', bd=5)
#Error report
frame6 = tk.LabelFrame(window, text='Error report', pady=5, bg='LightYellow', bd=5)


frame1.grid(row=0, pady=10, sticky=tk.W + tk.E)
frame2.grid(row=1, padx=5, sticky=tk.W)
frame4.grid(row=5, pady=10, sticky=tk.W + tk.E)
frame5.grid(row=2, pady=10, sticky=tk.W + tk.E)
frame6.grid(row=6, pady=10, sticky=tk.W + tk.E)
frame7.grid(row=4, pady=10, sticky=tk.W + tk.E)
frame8.grid(row=3, pady=10, sticky=tk.W+tk.E)

g1 = tk.Checkbutton(frame8, text="1",textvariable=gg1).grid(row=1, column=0, padx=2)
g2 = tk.Checkbutton(frame8, text="2",textvariable=gg2 ).grid(row=1, column=1, padx=2)
g3 = tk.Checkbutton(frame8, text="3",textvariable=gg3 ).grid(row=1, column=2, padx=2)
g4 = tk.Checkbutton(frame8, text="4" ,textvariable=gg4).grid(row=1, column=3, padx=2)
g5 = tk.Checkbutton(frame8, text="5",textvariable=gg5 ).grid(row=1, column=4, padx=2)
g6 = tk.Checkbutton(frame8, text="6" ,textvariable=gg6).grid(row=1, column=5, padx=2)
g7 = tk.Checkbutton(frame8, text="7",textvariable=gg7 ).grid(row=1, column=6, padx=2)
g8 = tk.Checkbutton(frame8, text="8",textvariable=gg8 ).grid(row=1, column=7, padx=2)
g9 = tk.Checkbutton(frame8, text="9" ,textvariable=gg9).grid(row=1, column=8, padx=2)
g10 = tk.Checkbutton(frame8, text="10",textvariable=gg10 ).grid(row=1, column=9, padx=2)
g11 = tk.Checkbutton(frame8, text="11",textvariable=gg11 ).grid(row=1, column=10, padx=2)
g12 = tk.Checkbutton(frame8, text="12",textvariable=gg12 ).grid(row=1, column=11, padx=2)




colors = ['red', 'green', 'light blue', 'yellow']

tk.Label(frame5, width=10, bg='Honeydew', text='1+3=', textvariable=question1).grid(row=0, column=0,padx=5, pady=10)
tk.Entry(frame5, font="Arial 12", width=3, bg='White',textvariable=answer1).grid(row=0, column=1, padx=5,pady=10)

tk.Label(frame5, width=10, bg='Honeydew', text='1+3=', textvariable=question2).grid(row=0, column=2, padx=5, pady=10)
tk.Entry(frame5, font="Arial 12", width=3, bg='White',textvariable=answer2).grid(row=0, column=3, padx=5, pady=10)

tk.Label(frame5, width=10, bg='Honeydew', text='1+3=', textvariable=question3).grid(row=0, column=4, padx=5, pady=10)
tk.Entry(frame5, font="Arial 12", width=3, bg='White',textvariable=answer3).grid(row=0, column=5, padx=5, pady=10)

tk.Label(frame5, width=10, bg='Honeydew', text='1+3=', textvariable=question4).grid(row=1, column=0, padx=5, pady=10)
tk.Entry(frame5, font="Arial 12", width=3, bg='White',textvariable=answer4).grid(row=1, column=1, padx=5, pady=10)
tk.Label(frame5, width=10, bg='Honeydew', text='1+3=', textvariable=question5).grid(row=1, column=2, padx=5, pady=10)
tk.Entry(frame5, font="Arial 12", width=3,bg='White',textvariable=answer5).grid(row=1, column=3, padx=5, pady=10)
tk.Label(frame5, width=10,bg='Honeydew', text='1+3=', textvariable=question6).grid(row=1, column=4, padx=5, pady=10)
tk.Entry(frame5, font="Arial 12", width=3, bg='White',textvariable=answer6).grid(row=1, column=5, padx=5, pady=10)

tk.Label(frame5, width=10, bg='Honeydew', text='1+3=', textvariable=question7).grid(row=2, column=0, padx=5, pady=10)
tk.Entry(frame5, font="Arial 12", width=3, bg='White',textvariable=answer7).grid(row=2, column=1, padx=5, pady=10)
tk.Label(frame5, width=10, bg='Honeydew', text='1+3=', textvariable=question8).grid(row=2, column=2, padx=5, pady=10)
tk.Entry(frame5, font="Arial 12", width=3, bg='White',textvariable=answer8).grid(row=2, column=3, padx=5, pady=10)
tk.Label(frame5, width=10, bg='Honeydew', text='1+3=', textvariable=question9).grid(row=2, column=4, padx=5, pady=10)
tk.Entry(frame5, font="Arial 12", width=3, bg='White',textvariable=answer9).grid(row=2, column=5, padx=5, pady=10)

tk.Label(frame5, width=10, bg='Honeydew', text='1+3=', textvariable=question10).grid(row=3, column=0, padx=5, pady=10)
tk.Entry(frame5, font="Arial 12", width=3, bg='White',textvariable=answer10).grid(row=3, column=1, padx=5, pady=10)
tk.Label(frame5, width=10, bg='Honeydew', text='1+3=', textvariable=question11).grid(row=3, column=2, padx=5, pady=10)
tk.Entry(frame5, font="Arial 12", width=3, bg='White',textvariable=answer11).grid(row=3, column=3, padx=5, pady=10)
tk.Label(frame5, width=10, bg='Honeydew', text='1+3=', textvariable=question12).grid(row=3, column=4, padx=5, pady=10)
tk.Entry(frame5, font="Arial 12", width=3, bg='White',textvariable=answer12).grid(row=3, column=5, padx=5, pady=10)


# Place label -- frame1
name1 = tk.Label(frame1, text="Welcome to the oral arithmetic generation system", bd=10, font=('Arial 12 bold'), width=15, height=2, bg='MediumTurquoise',
                 anchor="center")

name1.grid(row=0, column=100, padx=150, sticky=tk.E)

# Place lable2--frame2
r1 = tk.Radiobutton(frame2, text="Mixed topic", value="flex", variable=q_type).grid(row=1, column=0, padx=5)
r2 = tk.Radiobutton(frame2, text="addition", value="jia", variable=q_type).grid(row=1, column=1, padx=5)
r3 = tk.Radiobutton(frame2, text="subtraction", value="jian", variable=q_type).grid(row=1, column=2, padx=5)
r4 = tk.Radiobutton(frame2, text="multiplication", value="cheng", variable=q_type).grid(row=1, column=3, padx=5)
r5 = tk.Radiobutton(frame2, text="division", value="chu", variable=q_type).grid(row=1, column=4, padx=5)
r6 = tk.Button(frame2, text="Generate one by one", bg='DeepSkyBlue', command=create2).grid(row=2, column=1, padx=6)
r7 = tk.Button(frame2, text="Start build", bg='DeepSkyBlue', command=create).grid(row=2, column=2, padx=6)

score = tk.Label(frame4, bg='MintCream', text='achievement:').grid(row=0, column=2, padx=8, pady=2)
score_entry = tk.Entry(frame4, bg='Honeydew', bd=6, width=10, textvariable=grade).grid(row=0, column=3, padx=2)
score2 = tk.Label(frame4, bg='MintCream', text='Accuracy:').grid(row=0, column=4, padx=8, pady=12)
score2_entry = tk.Entry(frame4, bg='Honeydew', bd=6, width=10, textvariable=grades).grid(row=0, column=5, padx=2)
r7 = tk.Button(frame4, text="Print error report", bg='red').grid(row=0, column=6, padx=6)

score = tk.Label(frame6, bg='MintCream', text='Number of wrong questions:').grid(row=0, column=2, padx=8, pady=2)
score_entry = tk.Entry(frame6, bg='Honeydew', bd=6, width=5,textvariable=error).grid(row=0, column=3, padx=2)
score2 = tk.Label(frame6, bg='MintCream', text='Wrong question number').grid(row=0, column=4, padx=8, pady=12)
score2_entry = tk.Entry(frame6, bg='Honeydew', bd=6, width=30,textvariable=errors).grid(row=0, column=5, padx=2)

r6 = tk.Button(frame7, text="Submit answers", bg='MediumSpringGreen',command=submit).grid(row=0, column=1, padx=6)

time = tk.Label(frame7, bg='MintCream', text='The examination time is:').grid(row=0, column=2, padx=8, pady=12)
time_entry = tk.Label(frame7, bg='Honeydew', bd=6, width=30,textvariable=Date).grid(row=0, column=3, padx=2)

window.mainloop()

ending:
There are bug s in my print2 and 3 methods and other problems

Topics: Python GUI Tkinter