DEV Community

Cover image for number guess game with flet

Posted on

number guess game with flet

A simple number guessing game where players have to guess randomly generated numbers in a given range. which I created using flet which is a python module.

This number guessing game, written in Thai, is a great example of how to use the flet module in Python. In the game, players are asked to guess a randomly generated number within a given range. The range can be customized by the user, and can be as small or large as desired. After each guess, the player will be told whether their guess was too high, too low, or correct. The game will continue until the player correctly guesses the random number, at which point they will be declared the winner. Players can play as many rounds as they like, and the game will keep track of their win/loss record. Whether you're a seasoned pro or a beginner, this game is sure to provide hours of fun and challenge! The use of the flet module in this game allows for easy customization and flexibility, making it a great tool for any Python developer to have in their toolkit.

Image description

I use markdown files to assist me in writing out the instructions for how to play.

Image description

This code example

with open(self.path_markdown, "r", encoding="utf-8") as f:
            self.filemarkdown =
        self.markdown_help = ft.Markdown(
Enter fullscreen mode Exit fullscreen mode

I encountered a problem when trying to change the page, so I implemented a solution using a class and a method to delete all the controls within it in order to change the page.

menu_game = MenuGame()
menu_game_all = menu_game.container_main
def back_to_menu_main_from_levelScene(e):
        change to menu scene
Enter fullscreen mode Exit fullscreen mode

This may not be the most effective way to solve this issue, but it did work for me. If anyone has a better solution, please feel free to submit a pull request.

image desc

You can access the game at this link:

Top comments (0)

50 CLI Tools You Can't Live Without

The top 50 must-have CLI tools, including some scripts to help you automate the installation and updating of these tools on various systems/distros.