Graphical interface: tkinter
Answers are for parents and teachers.
1
Put a label and a button in a window: when the button is pressed the label should change to “Bosildi”. Write the code.
import tkinter as tk ⏎ def bos(): ⏎ yorliq.config(text="Bosildi") ⏎ oyna = tk.Tk() ⏎ yorliq = tk.Label(oyna, text="Kutilmoqda") ⏎ yorliq.grid(row=0, column=0) ⏎ tugma = tk.Button(oyna, text="Bos", command=bos) ⏎ tugma.grid(row=1, column=0) ⏎ oyna.mainloop()
2
Write the main line of a function that finds the circle area (3.14 * r * r) from the radius in an Entry: r = int(maydon.get()); what comes next?
natija.config(text=str(3.14 * r * r))
3
If the button in the die window is pressed 3 times, how many numbers stay in the label?
One – the last number; config(text=…) replaces the old one.
4
Why should a GUI app not ask for personal data (a password, an address)?
They could fall into the wrong hands; numbers and plain text are enough for a study app.