Python Forum

Full Version: dynamic object creation using python
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have the following requirement
1. Create several geometric objects such as square, triangle, circle etc.
2. Need to create a drop down menu that displays number 1 to 10 corresponding to each of the objects
3. Now depending upon user selection, the screen shall display corresponding numbers of the objects. For example
if the user selects 3 triangles and 2 squares, then corresponding objects shall appear on screen.

please suggest method to do so
Sounds like you should start with basic python tutorial,
I'd suggest:
Think like a computer scientist
or perhaps:
Python Course
I have used Visual basic earlier and getting used to python. Pointed direction would be highly useful for the said requirement.
I would write a program that draws a circle. Then I would change the program to draw 3 circles using identical code except for changing 1 to 3. Then I would write a program that draws 3 circles and 4 triangles. Then I would write a program that draws N number of all the different shapes you need to draw. Then I would write a program where I have a button for each shape, and when I press the button it draws one of that shape. Then I would write a program that replaces the buttons with drop down menus that let me select how many of that shape to draw. Then I am done.

How can you draw a circle? Have you received any instruction on how to do that?
"Think like a computer scientist" is one of my favorites. If that link is to the first edition which explains Python2, this link is second edition, Python3 https://greenteapress.com/wp/think-python-2e/
Old joke: Think like a computer scientist:

Quote:Wife says to her computer scientist husband:

Go to the grocer and get a loaf of bread, and if they have eggs, get six.

Hubby comes home with six loaves of bread!
Ok. I have got the right resource to get started. Thank you. I also have a requirement to create similar UI which shall have impressive look as displayed in webpage https://vcvrack.com/Rack. Could anybody provide pointers for development
You can use website templates which save a tremendous amount of time.
There are many sites available to either buy or get them free.
One of the simplest to incorporate into your site is bootstrap.
Flask or Django are the two most popular web frameworks, but there are also
web2py, bottle and probably others.
Just search for 'website templates' and you'll get a huge list.
I use Flask which I think allows more flexibility.
You can build your own, but using a template is recommended. it's a huge time saver, and your website will look great