Ejemplo n.º 1
0
    def __init__(self):
        self.root = tk.Tk()
        self.root.geometry('600x150')
        self.root.title('Question Page')
        self.json_obj = Json.JsonHandler()
        self.all_question = self.read_question()
        self.first_question_label = Label(self.root, text=self.all_question[i])
        self.first_question_label.pack(side=TOP)
        self.barVar = DoubleVar()
        self.barVar.set(0)
        self.max = 200
        self.option = self.json_obj.search_option(self.all_question[i])

        self.progbar1 = Progressbar(self.root,
                                    orient=HORIZONTAL,
                                    length=100,
                                    mode='determinate',
                                    variable=self.barVar,
                                    maximum=self.max)
        self.progbar1.place(x=450, y=120)

        select_option_value = partial(self.check_option, self.option['1'],
                                      self.all_question[i])
        option_label = Button(self.root,
                              text=self.option['1'],
                              width=30,
                              justify=RIGHT,
                              command=select_option_value)
        option_label.place(x=350, y=40)

        select_option_value = partial(self.check_option, self.option['2'],
                                      self.all_question[i])
        option_label = Button(self.root,
                              text=self.option['2'],
                              width=30,
                              justify=RIGHT,
                              command=select_option_value)
        option_label.place(x=50, y=40)

        select_option_value = partial(self.check_option, self.option['3'],
                                      self.all_question[i])
        option_label = Button(self.root,
                              text=self.option['3'],
                              width=30,
                              justify=RIGHT,
                              command=select_option_value)
        option_label.place(x=350, y=80)

        select_option_value = partial(self.check_option, self.option['4'],
                                      self.all_question[i])
        option_label = Button(self.root,
                              text=self.option['4'],
                              width=30,
                              justify=RIGHT,
                              command=select_option_value)
        option_label.place(x=50, y=80)

        self.score_label = Label(self.root,
                                 text='score:',
                                 font='Bnazanin 10 bold')
        self.score_label.place(x=30, y=120)
        self.progbar1.start()
        self.time_solve = self.root.after(10000, self.new_question)
Ejemplo n.º 2
0
    def __init__(self):
        self.root = tk.Tk()
        self.root.geometry('500x320')
        self.root.title('Creat Test')
        self.json_obj = Json.JsonHandler()

        lable_for_write_test_question = Label(self.root, text=" : سوال ")
        lable_for_write_test_question.place(x=450, y=10)

        question_entry = Entry(self.root,
                               bg='white',
                               justify=RIGHT,
                               width=75,
                               bd=2,
                               selectborderwidth=5)
        question_entry.place(x=20, y=35)

        the_first_option = Label(self.root, text=" :گزینه اول ")
        the_first_option.place(x=430, y=80)

        the_first_option_entry = Entry(self.root,
                                       bg='white',
                                       justify=RIGHT,
                                       width=40,
                                       bd=2,
                                       selectborderwidth=5)
        the_first_option_entry.place(x=230, y=100)

        the_second_option = Label(self.root, text=" :گزینه دوم ")
        the_second_option.place(x=430, y=130)

        the_second_option_entry = Entry(self.root,
                                        bg='white',
                                        justify=RIGHT,
                                        width=40,
                                        bd=2,
                                        selectborderwidth=5)
        the_second_option_entry.place(x=230, y=150)

        the_third_option = Label(self.root, text=" :گزینه سوم ")
        the_third_option.place(x=430, y=180)

        the_third_option_entry = Entry(self.root,
                                       bg='white',
                                       justify=RIGHT,
                                       width=40,
                                       bd=2,
                                       selectborderwidth=5)
        the_third_option_entry.place(x=230, y=200)

        the_option_four = Label(self.root, text=" :گزینه چهارم ")
        the_option_four.place(x=430, y=230)

        the_option_four_entry = Entry(self.root,
                                      bg='white',
                                      justify=RIGHT,
                                      width=40,
                                      bd=2,
                                      selectborderwidth=5)
        the_option_four_entry.place(x=230, y=250)

        CheckVar1 = IntVar(self.root)

        chechbox_label = Label(self.root, text='گزینه صحیح')
        chechbox_label.place(x=30, y=80)

        the_first_option_checkbox = Radiobutton(self.root,
                                                variable=CheckVar1,
                                                value=1)
        the_first_option_checkbox.place(x=50, y=105)

        the_second_option_checkbox = Radiobutton(self.root,
                                                 variable=CheckVar1,
                                                 value=2)
        the_second_option_checkbox.place(x=50, y=150)

        the_third_option_checkbox = Radiobutton(self.root,
                                                variable=CheckVar1,
                                                value=3)
        the_third_option_checkbox.place(x=50, y=200)

        the_optin_four_checkbox = Radiobutton(self.root,
                                              variable=CheckVar1,
                                              value=4)
        the_optin_four_checkbox.place(x=50, y=250)


        store_question_and_option=partial(self.add_question_option,CheckVar1,question_entry,the_first_option_entry,\
                            the_second_option_entry,the_third_option_entry,\
                                the_option_four_entry)

        store_button = Button(self.root,
                              text='Store Question',
                              command=store_question_and_option,
                              bd=4,
                              width=20,
                              activebackground='lightgrey',
                              font='Bnazanin 10 bold')
        store_button.place(x=50, y=285)

        store_button = Button(self.root,
                              text='Next Questtion',
                              command=self.rerun_app,
                              bd=4,
                              width=20,
                              activebackground='lightgrey',
                              font='Bnazanin 10 bold')
        store_button.place(x=280, y=285)