answer_button = Button(button_frame, text= "Answer", command=answer, bg= 'orange', width= 8, font= 10)Īnswer_id(row= 0, column= 0, padx= 10) You can specify padding to add space between the buttons. ![]() Use the grid() manager to place these buttons in one row and three different columns. Also pass the function to run when the user clicks it, the background color, width, and font size. Specify the frame you want to place each button in, and the text it should display. entry_answer = Entry(root, font=( "Arial", 24))ĭeclare three buttons: one to display the correct answer, one to choose another word, and the other to display hints. Set the parent window you want to place the frame in along with the background color. It arranges the layout and provides padding using rectangular sections on the screen. A frame acts as a container directing the placement of other widgets. Specify the parent window you want to place this widget in, along with its font style, and organize it by giving some padding for ample space.ĭefine a Frame for the buttons. Hint_nfig(text= f' ', bg= 'aqua')ĭefine an Entry widget to take input from the user. Increment the count of the hint letter so that the next time the function runs, the program will display the next letter. If the count is less than the word's length, display the next letter of the correct answer. def answer ():Īnswer_nfig(text= "Correct answer!", bg= 'aqua', fg= 'green')Īnswer_nfig(text= "Wrong answer, please try again.", bg= 'aqua', fg= 'red')ĭefine a function, hint, to inspect the global hint_count. ![]() ![]() Otherwise, display that it was the wrong answer in red color. If the word equals the input by the user then display a winning message in green color. The dictionary file-/usr/share/dict/words on Linux/macOS-is an excellent source of words.ĭefine a function, answer. Try loading a set of words from a file as an extension to this project.
0 Comments
Leave a Reply. |