You could always generate all your checkboxes (while storing them in a list when you create them) and then choose an item randomly in the list, store it, and when the user clicks, compare the one he clicked to the one you've stored.
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 10 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 9 Answers
manpreet
Best Answer
2 years ago
Disclaimer - Brand new to programming, with Python (3.x) being my choice of language to begin with.
I recently completed a Python course on codeacademy in which I created a mini battleships game. As a learning project I'm developing a GUI using Tkinter and Checkbuttons for the game board so that it can be played outside of the interpreter.
I'm now blocked as I don't know how to have Python randomly select the Checkbutton position for the battleship location - and keep it invisible from the player.
Here's my Tkinter code so far...
Perhaps I should first create my Checkbutton Grid (5 x 5) instead of just trying it with a single Checkbutton (I was attempting to slice up my development into logical problems)?
Here is the original game code (no GUI)...