Exemplo n.º 1
0
def spin_up_edit_button(parent, command):
    global new_item_confirm_button
    new_item_confirm_button = PushButton(parent,
                                         text='DONE',
                                         command=command,
                                         width='fill',
                                         grid=[3, 4, 1, 2],
                                         align='left')
    new_item_confirm_button.font = display_config.text_font
    new_item_confirm_button.text_color = '#00FF21'
    new_item_confirm_button.text_size = display_config.text_size
    new_item_confirm_button.hide()
Exemplo n.º 2
0
def check_win():
    winner = None
    # Vertical lines
    if (board_squares[0][0].text == board_squares[0][1].text ==
            board_squares[0][2].text) and board_squares[0][2].text in [
                "X", "O"
            ]:
        winner = board_squares[0][0]
    elif (board_squares[1][0].text == board_squares[1][1].text ==
          board_squares[1][2].text) and board_squares[1][2].text in ["X", "O"]:
        winner = board_squares[1][0]
    elif (board_squares[2][0].text == board_squares[2][1].text ==
          board_squares[2][2].text) and board_squares[2][2].text in ["X", "O"]:
        winner = board_squares[2][0]
    # Horizontal lines
    elif (board_squares[0][0].text == board_squares[1][0].text ==
          board_squares[2][0].text) and board_squares[2][0].text in ["X", "O"]:
        winner = board_squares[0][0]
    elif (board_squares[0][1].text == board_squares[1][1].text ==
          board_squares[2][1].text) and board_squares[2][1].text in ["X", "O"]:
        winner = board_squares[0][1]
    elif (board_squares[0][2].text == board_squares[1][2].text ==
          board_squares[2][2].text) and board_squares[2][2].text in ["X", "O"]:
        winner = board_squares[0][2]

# Diagonals
    elif (board_squares[0][0].text == board_squares[1][1].text ==
          board_squares[2][2].text) and board_squares[2][2].text in ["X", "O"]:
        winner = board_squares[0][0]
    elif (board_squares[2][0].text == board_squares[1][1].text ==
          board_squares[0][2].text) and board_squares[0][2].text in ["X", "O"]:
        winner = board_squares[0][2]

    if winner is not None:
        message.value = winner.text + " wins!"
    elif moves_taken() == 9:
        message.value = "It's a draw"

    resetbutton = PushButton(board, text="reset", command=clear_board)
    resetbutton.hide()
    if winner is not None:
        resetbutton.show()
Exemplo n.º 3
0
def view():
    global _drawing_w
    global _prev_button
    global _next_button
    global _rand_button
    global _latest_button
    global _loading_window
    global _loading_window_text
    global _app

    _app = App(width=_app_width, height=_app_height, layout='auto')
    _app.set_full_screen()
    _app.tk.config(cursor="none")
    _drawing_w = Drawing(_app, width=_app_width, height=_app_height)
    _prev_button = PushButton(_app,
                              command=prev_button_push,
                              text='prev',
                              width=4,
                              height=2,
                              enabled=False)
    _next_button = PushButton(_app,
                              command=next_button_push,
                              text='next',
                              width=4,
                              height=2,
                              enabled=False)
    _rand_button = PushButton(_app,
                              command=rand_button_push,
                              text='rand',
                              width=4,
                              height=2,
                              enabled=False)
    _latest_button = PushButton(_app,
                                command=latest_button_push,
                                text='latest',
                                width=4,
                                height=2,
                                enabled=False)
    _prev_button.hide()
    _next_button.hide()
    _rand_button.hide()
    _latest_button.hide()

    _app.repeat(_loading_loop_delay, loading_progress_callback)

    logging.info('Displaying app')
    _app.display()
Exemplo n.º 4
0
class Ultimate:
    def __init__(self, app):
        # score & highscore is being loaded in from a separate file
        start_up = open("startup_vars", "rb")
        get_dict_data = pickle.load(start_up)

        self.score = 0
        self.highscore = get_dict_data.get("highscore")
        app = app

        # after each start of the quiz window,
        # reset the counter and randomize the question order
        global order_counter
        order_counter = 0
        global questions_order
        random.shuffle(questions_order)

        #-----------------------------Ultimate Window--------------------------------#

        self.ultimate_window = Window(app, width=700, height=700, bg="#FFED7C")

        # Quiz contantainers from top to bottom; ultimate_container_1 = Image container, ultimate_container_2 = Question container, ultimate_container_3 = filler container, ultimate_container_4 = upper answer button container, ultimate_container_5 = filler container, ultimate_container_6 = lower answer button container, ultimate_container_7 = bottom container with score and question
        ultimate_container_1 = Box(
            self.ultimate_window, width=700, height=250)
        ultimate_container_2 = Box(
            self.ultimate_window, width=700, height=100, border=2)
        ultimate_container_3 = Box(
            self.ultimate_window, width=700, height=25)
        ultimate_container_4 = Box(
            self.ultimate_window, width=700, height=100)
        ultimate_container_5 = Box(
            self.ultimate_window, width=700, height=25)
        ultimate_container_6 = Box(
            self.ultimate_window, width=700, height=100)
        ultimate_container_7 = Box(
            self.ultimate_window, width=700, height=100)

        # containers where the upper buttons are positioned
        ultimate_filler_box_1 = Box(ultimate_container_4,
                                    align="left",
                                    width=150,
                                    height=100)
        ultimate_filler_box_2 = Box(ultimate_container_4,
                                    align="right",
                                    width=150,
                                    height=100)
        ultimate_button_1 = Box(ultimate_container_4,
                                align="left",
                                width=180,
                                height=80)
        ultimate_button_2 = Box(ultimate_container_4,
                                align="right",
                                width=180,
                                height=80)

        # containers where the lower buttons are positioned
        ultimate_filler_box_3 = Box(ultimate_container_6,
                                    align="left",
                                    width=150,
                                    height=100)
        ultimate_filler_box_4 = Box(ultimate_container_6,
                                    align="right",
                                    width=150,
                                    height=100)
        ultimate_button_3 = Box(ultimate_container_6,
                                align="left",
                                width=180,
                                height=80)
        ultimate_button_4 = Box(ultimate_container_6,
                                align="right",
                                width=180,
                                height=80)

        # bottom section with score and questions
        ultimate_bottom = Box(ultimate_container_7,
                              align="bottom",
                              width=700,
                              height=50)
        ultimate_bottom_question = Box(ultimate_bottom,
                                       align="right",
                                       width=200,
                                       height=25,
                                       )
        ultimate_bottom_score = Box(ultimate_bottom,
                                    align="left",
                                    width=100,
                                    height=25,
                                    )

        ultimate_bottom_highscore = Box(ultimate_bottom,
                                        width=150,
                                        height=25,
                                        align="left",
                                        )

        #-----------------------------Ultimate Widgets--------------------------------#

        # Question Image
        self.ultimate_image = Picture(ultimate_container_1,
                                      width=700,
                                      height=250)

        # Question Text
        self.ultimate_question = Text(ultimate_container_2,
                                      text="Question",
                                      width=100,
                                      height=100)
        self.ultimate_question.bg = "#FF8108"

        # Score, High Score & Question Num
        self.ultimate_question_number = Text(ultimate_bottom_question,
                                             text="Question Num: 1/10")

        self.ultimate_question_score = Text(
            ultimate_bottom_score, text="Score: 0")

        self.high_score_display = Text(ultimate_bottom_highscore,
                                       text="High Score: " +
                                       str(self.highscore),
                                       align="bottom")

        # Answer Buttons
        self.ultimate_answer_1 = PushButton(ultimate_button_1,
                                            align="left",
                                            width=100,
                                            height=70,
                                            command=self.check_a1)
        self.ultimate_answer_1.bg = "#54C03D"
        self.ultimate_answer_1.font = "sans-serif"
        self.ultimate_answer_2 = PushButton(ultimate_button_2,
                                            align="right",
                                            width=100,
                                            height=70,
                                            command=self.check_a2)
        self.ultimate_answer_2.bg = "#2D73A9"
        self.ultimate_answer_2.font = "sans-serif"
        self.ultimate_answer_3 = PushButton(ultimate_button_3,
                                            align="left",
                                            width=100,
                                            height=70,
                                            command=self.check_a3)
        self.ultimate_answer_3.bg = "#DB4692"
        self.ultimate_answer_3.font = "sans-serif"
        self.ultimate_answer_4 = PushButton(ultimate_button_4,
                                            align="right",
                                            width=100,
                                            height=70,
                                            command=self.check_a4)
        self.ultimate_answer_4.bg = "#FFFA13"
        self.ultimate_answer_4.font = "sans-serif"

        self.next_question()

    def next_question(self):
        global order_counter, menu_score_disp

        # ----------------------- check if end of the quiz ----------------------------- #
        if order_counter >= 40:
            # display the final score
            # maybe something that looks better than popup?

            # saves
            get_session_scores["score"] = self.score
            if self.score >= self.highscore:
                self.highscore = self.score
                self.high_score_display.value = "High Score: " + \
                    str(self.highscore)

                get_session_scores["highscore"] = self.highscore

            start_up = open("startup_vars", "wb")
            pickle.dump(get_session_scores, start_up)
            start_up.close()

            self.ultimate_window.info(
                "Congratulation", "Your score: " + str(self.score)+" /40")

            menu_score_disp = str(self.score)

            # in the later stages remember to pass info
            # if the user has passed the test
            # to unlock the ultimate test
            self.ultimate_window.destroy()

        try:
            # ------------------- update question and answers --------------------- #
            q = list_questions[questions_order[order_counter]].get_q_text()

            # Code below will set an image for the question
            if list_questions[questions_order[order_counter]].get_img_parameter() == "":
                self.ultimate_image.value = "imgs/img_blank.PNG"
            else:
                self.ultimate_image.value = list_questions[questions_order[order_counter]
                                                           ].get_img_parameter()
            self.showAllAnswersButtons()
            # randomizing the answers
            answers = list_questions[questions_order[order_counter]
                                     ].get_randomize_answers()
            a1 = answers[0]
            a2 = answers[1]
            a3 = answers[2]
            a4 = answers[3]

            self.ultimate_question.value = q
            self.ultimate_answer_1.text = a1
            self.ultimate_answer_2.text = a2
            self.ultimate_answer_3.text = a3
            self.ultimate_answer_4.text = a4

            self.hideBlankButtons()

            # set the counter for the next question
            order_counter += 1

            # ----------------------- update score and question number --------------------- #

            self.ultimate_question_score.value = "Score: " + str(self.score)
            self.ultimate_question_number.value = "Question Num: " + \
                str(order_counter) + "/40"
        except IndexError:
            pass

        return menu_score_disp

    def check_a1(self):
        """this function is called after pressing answer button 1
            it checks if the answer was correct and continue to the next question 
        """
        answer = self.ultimate_answer_1.text
        print(answer)

        # the counter is already set for the next question
        # so we need to reduce it by one
        if list_questions[questions_order[order_counter - 1]].is_answer_correct(answer):
            self.score += 1

        # after checking the answer we can move to the next question
        self.next_question()

    def check_a2(self):
        """this function is called after pressing answer button 2
            it checks if the answer was correct and continue to the next question 
        """
        answer = self.ultimate_answer_2.text
        print(answer)

        # the counter is already set for the next question
        # so we need to reduce it by one
        if list_questions[questions_order[order_counter - 1]].is_answer_correct(answer):
            self.score += 1

        # after checking the answer we can move to the next question
        self.next_question()

    def check_a3(self):
        """this function is called after pressing answer button 3
            it checks if the answer was correct and continue to the next question 
        """
        answer = self.ultimate_answer_3.text
        print(answer)

        # the counter is already set for the next question
        # so we need to reduce it by one
        if list_questions[questions_order[order_counter - 1]].is_answer_correct(answer):
            self.score += 1

        # after checking the answer we can move to the next question
        self.next_question()

    def check_a4(self):
        """this function is called after pressing answer button 4
            it checks if the answer was correct and continue to the next question 
        """
        answer = self.ultimate_answer_4.text
        print(answer)

        # the counter is already set for the next question
        # so we need to reduce it by one
        if list_questions[questions_order[order_counter - 1]].is_answer_correct(answer):
            self.score += 1

        # after checking the answer we can move to the next question
        self.next_question()

    def showAllAnswersButtons(self):
        self.ultimate_answer_1.show()
        self.ultimate_answer_2.show()
        self.ultimate_answer_3.show()
        self.ultimate_answer_4.show()

    def hideBlankButtons(self):
        if self.ultimate_answer_1.text == "":
            self.ultimate_answer_1.hide()
        if self.ultimate_answer_2.text == "":
            self.ultimate_answer_2.hide()
        if self.ultimate_answer_3.text == "":
            self.ultimate_answer_3.hide()
        if self.ultimate_answer_4.text == "":
            self.ultimate_answer_4.hide()
Exemplo n.º 5
0
	else:
		confirm.disable()
FILENAME = "patients.txt"
patients = []
usernames = []
passhashes = []
try:
	with open(FILENAME) as d:
		for line in d:
			fields = line.split("\t")
			usernames.append(fields[0])
			passhashes.append(fields[1].strip())
except:
	d = open(FILENAME,"w+")
	d.close()
app = App(title = "New user registration")
intro = Text(app, text = "Welcome to Litlitlit!\n")
prompt2 = Text(app, text = "Please enter your username.")
username = TextBox(app, width = 20)
prompt3 = Text(app, text = "Please enter your password.")
password = TextBox(app, width = 20)
password.tk.config(show="*")
txt2 = Text(app, text = "")
confirm = PushButton(app, text = "Confirm registration", command = checkgood)
confirm.disable()
success = Text(app, text = "")
exit = PushButton(app, text = "Finish", command = finish)
exit.hide()
if app.enabled:
	success.repeat(100, allfilled)
app.display()
Exemplo n.º 6
0
    if selection.value == "1":
        info("well done", "you chose wisely")
        goodbye()
    else:
        warn("arrrgh", "next time, choose wisely!")
        app.after(2000, show_the_selection)


def goodbye():
    change_message("Thanks")
    logo.show()


# create the app and the widgets
app = App()
message_text = Text(app, text="Welcome to guizero")
button = PushButton(app, clicked_the_button, text="Click me")
button.hide()
selection = ButtonGroup(app,
                        selected=0,
                        command=selection_chosen,
                        options=["choose me", "don't choose me"])
selection.hide()
logo = Picture(app, "guizero.gif")
logo.hide()

# show the first message after 2 seconds
app.after(2000, message1)

app.display()
Exemplo n.º 7
0
                        command=menuScreen,
                        text="Menu",
                        align="left")
toppingscartButton = PushButton(buttonBox,
                                command=addtoppingsCart,
                                text="Add to cart",
                                align="right")
specialcartButton = PushButton(buttonBox,
                               command=addspecialsCart,
                               text="Add to cart",
                               align="right")
sidescartButton = PushButton(buttonBox,
                             command=addsidesCart,
                             text="Add to cart",
                             align="right")
toppingscartButton.hide()
specialcartButton.hide()
sidescartButton.hide()
clearButton = PushButton(buttonBox,
                         command=clearAll,
                         text="Clear Selections",
                         align="right")
#welcome
welcomeMessage = Text(app,
                      text="Welcome to the Pizza Place!",
                      size=25,
                      font="Times New Roman",
                      color="black",
                      align="top")
pizzaGif = Picture(app, image="homer.gif")
Exemplo n.º 8
0
class Mathematics:
    def __init__(self, app):
        self.score = 0
        app = app

        # after each start of the quiz window,
        # reset the counter and randomize the question order
        global order_counter
        order_counter = 0
        global questions_order
        random.shuffle(questions_order)

        #------------------------------Mathematics Window-----------------------------------#

        self.math_window = Window(app, width=850, height=700, bg="#FFED7C")

        # Quiz contantainers from top to bottom; mathematics_container_1 = Image container, mathematics_container_2 = Question container, mathematics_container_3 = filler container, mathematics_container_4 = upper answer button container, mathematics_container_5 = filler container, mathematics_container_6 = lower answer button container, mathematics_container_7 = bottom container with score and question
        mathematics_container_1 = Box(self.math_window, width=850, height=250)
        mathematics_container_2 = Box(self.math_window,
                                      width=850,
                                      height=100,
                                      border=2)
        mathematics_container_3 = Box(self.math_window, width=700, height=25)
        mathematics_container_4 = Box(self.math_window, width=700, height=100)
        mathematics_container_5 = Box(self.math_window, width=700, height=25)
        mathematics_container_6 = Box(self.math_window, width=700, height=100)
        mathematics_container_7 = Box(self.math_window, width=700, height=100)

        # containers where the upper buttons are positioned
        math_filler_box_1 = Box(mathematics_container_4,
                                align="left",
                                width=150,
                                height=100)
        math_filler_box_2 = Box(mathematics_container_4,
                                align="right",
                                width=150,
                                height=100)
        mathematics_button_1 = Box(mathematics_container_4,
                                   align="left",
                                   width=180,
                                   height=80)
        mathematics_button_2 = Box(mathematics_container_4,
                                   align="right",
                                   width=180,
                                   height=80)

        # containers where the lower buttons are positioned
        math_filler_box_3 = Box(mathematics_container_6,
                                align="left",
                                width=150,
                                height=100)
        math_filler_box_4 = Box(mathematics_container_6,
                                align="right",
                                width=150,
                                height=100)
        mathematics_button_3 = Box(mathematics_container_6,
                                   align="left",
                                   width=180,
                                   height=80)
        mathematics_button_4 = Box(mathematics_container_6,
                                   align="right",
                                   width=180,
                                   height=80)

        # bottom section with score and questions
        mathematics_bottom = Box(mathematics_container_7,
                                 align="bottom",
                                 width=700,
                                 height=50)
        mathematics_bottom_question = Box(mathematics_bottom,
                                          align="right",
                                          width=200,
                                          height=25)
        mathematics_bottom_score = Box(mathematics_bottom,
                                       align="left",
                                       width=100,
                                       height=25)

        #-----------------------------Mathematics Widgets------------------------------#‎‎‏‏‎‏‏‎

        # Question Image
        self.math_image = Picture(mathematics_container_1,
                                  width=850,
                                  height=250)

        # Question Text
        self.math_question = TextBox(mathematics_container_2,
                                     text="Question",
                                     width=100,
                                     height=100,
                                     multiline=True)
        self.math_question.bg = "#FF8108"
        self.math_question.font = "sans-serif"
        self.math_question.text_size = 12

        # Score & Question Num
        self.math_question_number = Text(mathematics_bottom_question,
                                         text="Question Num: 1/10")
        self.math_question_score = Text(mathematics_bottom_score,
                                        text="Score: 0")

        # Answer Buttons
        self.math_answer_1 = PushButton(mathematics_button_1,
                                        align="left",
                                        width=100,
                                        height=70,
                                        command=self.check_a1)
        self.math_answer_1.bg = "#54C03D"
        self.math_answer_1.font = "sans-serif"
        self.math_answer_2 = PushButton(mathematics_button_2,
                                        align="right",
                                        width=100,
                                        height=70,
                                        command=self.check_a2)
        self.math_answer_2.bg = "#2D73A9"
        self.math_answer_2.font = "sans-serif"
        self.math_answer_3 = PushButton(mathematics_button_3,
                                        align="left",
                                        width=100,
                                        height=70,
                                        command=self.check_a3)
        self.math_answer_3.bg = "#DB4692"
        self.math_answer_3.font = "sans-serif"
        self.math_answer_4 = PushButton(mathematics_button_4,
                                        align="right",
                                        width=100,
                                        height=70,
                                        command=self.check_a4)
        self.math_answer_4.bg = "#FFFA13"
        self.math_answer_4.font = "sans-serif"

        self.next_question()

    def next_question(self):
        global order_counter

        # ----------------------- check if end of the quiz ----------------------------- #
        if order_counter >= 10:
            # display the final score
            # maybe something that looks better than popup?
            self.math_window.info("Congratulation",
                                  "Your score: " + str(self.score) + " /10")

            # in the later stages remember to pass info
            # if the user has passed the test
            # to unlock the ultimate test
            self.math_window.destroy()

        try:

            # ------------------- update question and answers --------------------- #
            q = list_questions[questions_order[order_counter]].get_q_text()

            # Code below will set an image for the question
            if list_questions[
                    questions_order[order_counter]].get_img_parameter() == "":
                self.math_image.value = "imgs/img_blank.PNG"
            else:
                self.math_image.value = list_questions[
                    questions_order[order_counter]].get_img_parameter()

            self.showAllAnswersButtons()
            # randomizing the answers
            answers = list_questions[
                questions_order[order_counter]].get_randomize_answers()
            a1 = answers[0]
            a2 = answers[1]
            a3 = answers[2]
            a4 = answers[3]

            self.math_question.value = q
            self.math_answer_1.text = a1
            self.math_answer_2.text = a2
            self.math_answer_3.text = a3
            self.math_answer_4.text = a4

            self.hideBlankButtons()

            # set the counter for the next question
            order_counter += 1

            # ----------------------- update score and question number --------------------- #

            self.math_question_score.value = "Score: " + str(self.score)
            self.math_question_number.value = "Question Num: " + \
                str(order_counter) + "/10"
        except IndexError:
            pass

    def check_a1(self):
        """this function is called after pressing answer button 1
            it checks if the answer was correct and continue to the next question 
        """
        answer = self.math_answer_1.text
        print(answer)

        # the counter is already set for the next question
        # so we need to reduce it by one
        if list_questions[questions_order[order_counter -
                                          1]].is_answer_correct(answer):
            self.score += 1

        # after checking the answer we can move to the next question
        self.next_question()

    def check_a2(self):
        """this function is called after pressing answer button 2
            it checks if the answer was correct and continue to the next question 
        """
        answer = self.math_answer_2.text
        print(answer)

        # the counter is already set for the next question
        # so we need to reduce it by one
        if list_questions[questions_order[order_counter -
                                          1]].is_answer_correct(answer):
            self.score += 1

        # after checking the answer we can move to the next question
        self.next_question()

    def check_a3(self):
        """this function is called after pressing answer button 3
            it checks if the answer was correct and continue to the next question 
        """
        answer = self.math_answer_3.text
        print(answer)

        # the counter is already set for the next question
        # so we need to reduce it by one
        if list_questions[questions_order[order_counter -
                                          1]].is_answer_correct(answer):
            self.score += 1

        # after checking the answer we can move to the next question
        self.next_question()

    def check_a4(self):
        """this function is called after pressing answer button 4
            it checks if the answer was correct and continue to the next question 
        """
        answer = self.math_answer_4.text
        print(answer)

        # the counter is already set for the next question
        # so we need to reduce it by one
        if list_questions[questions_order[order_counter -
                                          1]].is_answer_correct(answer):
            self.score += 1

        # after checking the answer we can move to the next question
        self.next_question()

    def showAllAnswersButtons(self):
        self.math_answer_1.show()
        self.math_answer_2.show()
        self.math_answer_3.show()
        self.math_answer_4.show()

    def hideBlankButtons(self):
        if self.math_answer_1.text == "":
            self.math_answer_1.hide()
        if self.math_answer_2.text == "":
            self.math_answer_2.hide()
        if self.math_answer_3.text == "":
            self.math_answer_3.hide()
        if self.math_answer_4.text == "":
            self.math_answer_4.hide()
Exemplo n.º 9
0
def Main():
	def finish():
		err.destroy()
	def allfilled():
		if (username.value != "" and password.value != "" and app.enabled):
			login.enable()
		else:
			login.disable()
	def verify():
		passhashed = hashlib.sha256(password.value.encode()).hexdigest()
		if username.value in usernames:
			ind = usernames.index(username.value)
			if passhashed == passhashes[ind]:
				success.value = "Logged in"
				app.disable()
				cont.enable()
				cont.show()
			else:
				success.value = "Incorrect password"
		else:
			success.value = "Username not found"
	def endfunc():
		if cont.enabled:
			ind = usernames.index(username.value)
			ret.append(username.value)
			ret.append(dochashes[ind])
			ret.append(True)
		app.destroy()
	FILENAME = "patients.txt"
	dochashes = []
	usernames = []
	passhashes = []
	ret = []
	try:
		with open(FILENAME) as d:
			for line in d:
				fields = line.split("\t")
				usernames.append(fields[0])
				dochashes.append(fields[1])
				passhashes.append(fields[2].strip())
	except:
		err = App(title = "Error")
		message = Text(err, text = "There are no patients in the database.\nPlease register first.")
		badending = PushButton(err, text = "Exit", command = finish)
		err.display()
		return["","",False]
	else:
		app = App(title = "Patient Login")
		greet = Text(app, text = "Welcome to AnonyComm!\nThis is the login for patients.\n")
		prompt1 = Text(app, text = "Username:"******"Password:"******"*")
		login = PushButton(app, text = "Login", command = verify)
		login.disable()
		success = Text(app, text = "")
		cont = PushButton(app, text = "Continue", command = endfunc)
		cont.hide()
		if app.enabled:
			success.repeat(100, allfilled)
		app.on_close(endfunc)
		app.display()
		if not ret:
			ret = ["","",False]
		return ret
Exemplo n.º 10
0
	val_2=collections.Counter([(v,w) for (u,v,w,x,y,z) in people])
	val_3=collections.Counter([(v,w,x) for (u,v,w,x,y,z) in people])
	val_4=collections.Counter([(v,w,x,y) for (u,v,w,x,y,z) in people])
	#val_5=collections.Counter([(v,w,x,y) for (u,v,w,x,y,z) in people])
	i=3
	for person in people:
		if(val_1[person[1]]==1):
			values.append(Text(app, text= person[0]+"\t"+str(person[1]),grid=[0,i],align="left"))
		elif(val_2[person[1],person[2]]==1):
			values.append(Text(app, text= person[0]+"\t"+str(person[1])+" "+str(person[2]),grid=[0,i],align="left"))
		elif(val_3[person[1],person[2],person[3]]==1):
			values.append(Text(app, text= person[0]+"\t"+str(person[1])+" "+str(person[2])+" "+str(person[3]),grid=[0,i],align="left"))
		elif(val_4[person[1],person[2],person[3],person[4]]==1):
			values.append(Text(app, text= person[0]+"\t"+str(person[1])+" "+str(person[2])+" "+str(person[3])+" "+str(person[4]),grid=[0,i],align="left"))
		else:
			values.append(Text(app, text= person[0]+"\t"+str(person[1])+" "+str(person[2])+" "+str(person[3])+" "+str(person[4])+" "+str(person[5]),grid=[0,i],align="left"))
		i+=1

		

app = App(title="Initiative Generator", width=250, height=500, layout="grid")
box = TextBox(app,grid=[1,0])
box.hide()
sub_button = PushButton(app, command=get_name, text="submit name", grid=[1,1])
sub_button.hide()
name_button = PushButton(app, command=enter_names, text="enter names\t", grid=[0,0])
init_button = PushButton(app, command=init, text="generate init\t", grid=[0,1])
exit_button  = PushButton(app, command=exit_, text="exit\t\t", grid=[0,2])

app.display()
Exemplo n.º 11
0
    tacoB.show()
    tacoBB.show()
    change_screens_Taco.show()
    welcome_Message.set(
        "Please order a Taco, or change screens for Mac & Cheese")


#welcome message, followed by GUI elements

tacoA = Text(app, text="Enter Taco Quantity")
tacoAA = TextBox(app)
tacoB = Text(app, text="Enter Taco Flavor")
tacoBB = TextBox(app)

macA = Text(app, text="Enter Mac Quantity")
macAA = TextBox(app)
macB = Text(app, text="Enter Mac Flavor")
macBB = TextBox(app)
macA.hide()
macAA.hide()
macB.hide()
macBB.hide()

change_screens_Taco = PushButton(app, command=tacoScreen, text="Mac & Cheese")
change_screens_Mac = PushButton(app, command=macScreen, text="Tacos")
change_screens_Mac.hide()
#button for roll

#display app!
app.display()
Exemplo n.º 12
0
def Main():
    def finish():
        quit()

    def adduser():
        passhashed = hashlib.sha256(password.value.encode()).hexdigest()
        dockey = random.randint(100000, 999999)
        if not doctors:
            towrite = "%s\t%s\t%s\t%d" % (name.value, username.value,
                                          passhashed, dockey)
        else:
            towrite = "\n%s\t%s\t%s\t%d" % (name.value, username.value,
                                            passhashed, dockey)
        with open(FILENAME, "a") as d:
            d.write(towrite)
        success.value = "Registration successful! Your 6-digit verification key is %d" % (
            dockey)
        exit.enable()
        exit.show()

    def checkgood():
        if username.value in usernames:
            success.value = "This username is already taken. Please try another."
        else:
            success.value = "Registration successful!"
            app.disable()
            adduser()

    def allfilled():
        if (name.value != "" and username.value != "" and password.value != ""
                and app.enabled):
            confirm.enable()
        else:
            confirm.disable()

    FILENAME = "doctors.txt"
    doctors = []
    usernames = []
    passhashes = []
    try:
        with open(FILENAME) as d:
            for line in d:
                fields = line.split("\t")
                doctors.append(fields[0])
                usernames.append(fields[1])
                passhashes.append(fields[2].strip())
    except:
        d = open(FILENAME, "w+")
        d.close()
    app = App(title="New doctor registration")
    intro = Text(app, text="Welcome to AnonyComm!\n")
    prompt1 = Text(app, text="Please enter your name (First Last).")
    name = TextBox(app, width=20)
    prompt2 = Text(app, text="Please enter your username.")
    username = TextBox(app, width=20)
    prompt3 = Text(app, text="Please enter your password.")
    password = TextBox(app, width=20)
    password.tk.config(show="*")
    txt2 = Text(app, text="")
    confirm = PushButton(app, text="Confirm registration", command=checkgood)
    confirm.disable()
    success = Text(app, text="")
    exit = PushButton(app, text="Finish", command=finish)
    exit.hide()
    if app.enabled:
        success.repeat(100, allfilled)
    app.display()
Exemplo n.º 13
0
  text2.show()
  num = text2.value

def prev():

  subprocess.call(['libreoffice', '--view','--writer', brow.value])

def prin():

  subprocess.run(['python', '/home/pi/print.py'+ num])

app = App(title="FLASH DRIVE", width=500, height=500, layout="auto")
button1 = PushButton(app, command=brow, text="Browse File", align="right")
brow = Text(app, text = "")
brow.hide()
btnpreview = PushButton(app, command=prev, text="Preview File", align="right")
btnpreview.hide()
btnprint = PushButton(app, command=prin, text="Print File", align="right")
btnprint.hide()
text1 = Text(app, text="")
text1.hide()
text2= Text(app,text="")
text2.hide()
text3=Text(app, text="")
lblnumcopy=Text(app, text="Number of Copies: ") 
lblnumcopy.hide()
copies=TextBox(app)
copies.hide()

app.display()
Exemplo n.º 14
0
#buttons
buttonBox = Box(app, width="fill", align="bottom")

insultButton = PushButton(buttonBox,
                          text="Generate Insult",
                          command=insult,
                          align="bottom")
insultButton.text_size = 15
insultButton.font = "Free Mono"
insultButton.bg = "firebrick3"
insultButton.text_color = "snow"

moreInsults = PushButton(buttonBox,
                         text="Get another insult",
                         command=moreInsult,
                         align="left")
moreInsults.text_size = 13
moreInsults.font = "Free Mono"
moreInsults.hide()

createInsults = PushButton(buttonBox,
                           text="Create your own insults",
                           command=cyo,
                           align="right")
createInsults.text_size = 13
createInsults.font = "Free Mono"
createInsults.hide()

insultBox = Box(app, border=1, align="top")

app.display()
Exemplo n.º 15
0
def Main():
    def finish():
        quit()

    def writedata():
        ind = docnames.index(docname.value)
        docHashed = hashlib.sha256(docusernames[ind].encode()).hexdigest()
        passhashed = hashlib.sha256(password.value.encode()).hexdigest()
        if not usernames:
            towrite = "%s\t%s\t%s" % (username.value, docHashed, passhashed)
        else:
            towrite = "\n%s\t%s\t%s" % (username.value, docHashed, passhashed)
        with open(FILENAME, "a") as p:
            p.write(towrite)
        findmatch.destroy()
        exit.enable()
        exit.show()

    def matchDoctor():
        if docname.value in docnames:
            ind = docnames.index(docname.value)
            if checkkey.value == dockeys[ind]:
                earlyexit.hide()
                findmatch.disable()
                writedata()
            else:
                matchintro.value = "Incorrect key."
                earlyexit.show()
        else:
            matchintro.value = "Your doctor's name cannot be found.\n(S)he may not have created an account yet."
            earlyexit.show()

    def checkgood():
        if username.value in usernames:
            success.value = "This username is already taken. Please try another."
        else:
            success.value = "Registration successful!"
            app.disable()
            findmatch.enable()
            findmatch.show()

    def allfilled():
        if (username.value != "" and password.value != "" and app.enabled):
            confirm.enable()
        else:
            confirm.disable()

    FILENAME = "patients.txt"  # Format: username TAB hashedDocUsername TAB hashedPassword
    DOCTORS = "doctors.txt"  # Format: name TAB username TAB hashedPassword
    patients = []
    usernames = []
    docnames = []
    docusernames = []
    dockeys = []
    try:
        with open(FILENAME) as p:
            for line in p:
                fields = line.split("\t")
                usernames.append(fields[0])
    except:
        p = open(FILENAME, "w+")
        p.close()
    try:
        with open(DOCTORS) as d:
            for line in d:
                fields = line.split("\t")
                docnames.append(fields[0])
                docusernames.append(fields[1])
                dockeys.append(fields[3].strip())
    except:
        err = App(title="Error")
        message = Text(
            err,
            text=
            "There are no doctors in the database.\nPlease ask your doctor to register first."
        )
        badending = PushButton(err, text="Exit", command=finish)
        err.display()
    else:
        app = App(title="New patient registration")
        intro = Text(app, text="Welcome to AnonyComm!\n")
        prompt2 = Text(app, text="Please enter your username.")
        username = TextBox(app, width=20)
        prompt3 = Text(app, text="Please enter your password.")
        password = TextBox(app, width=20)
        password.tk.config(show="*")
        txt2 = Text(app, text="")
        confirm = PushButton(app,
                             text="Confirm registration",
                             command=checkgood)
        confirm.disable()
        success = Text(app, text="")
        exit = PushButton(app, text="Finish", command=finish)
        exit.hide()
        findmatch = Window(app, title="Doctor name entry")
        matchintro = Text(findmatch,
                          text="Please enter your doctor's name (First Last)")
        docname = TextBox(findmatch, width=20)
        keyprompt = Text(
            findmatch, text="Enter your doctor's six-digit verification key.")
        checkkey = TextBox(findmatch, width=20)
        checkdoc = PushButton(findmatch,
                              text="Find your doctor",
                              command=matchDoctor)
        earlyexit = PushButton(findmatch, text="Quit", command=finish)
        earlyexit.hide()
        findmatch.hide()
        if app.enabled:
            success.repeat(100, allfilled)
        app.display()
Exemplo n.º 16
0
        warn("Warning", "Your document is not saved")
    else:
        app.destroy()


menubar = MenuBar(app,
                  toplevel=["File"],
                  options=[[["open", open_file], ["save", save_file],
                            ["exit", exit]]])
file_box = Box(app, align="top", width="fill")
file_name = TextBox(file_box, text="text_file.txt", width=50, align="left")
save_button = PushButton(file_box,
                         text="SAVE",
                         align="right",
                         command=save_file)
save_button.hide()
save_button.disable()
open_button = PushButton(file_box,
                         text="OPEN",
                         align="right",
                         command=open_file)
editor = TextBox(app,
                 height="fill",
                 width="fill",
                 multiline=True,
                 command=save_enable)
func_box = Box(app, align="bottom", width="fill", border=True)
font = Combo(func_box,
             options=["courier", "times new roman", "verdana"],
             align="left",
             command=change_font)