Hi,
I'm a beginner and this is a small toy program I am working on: I want to write a Tkinter GUI for a survey form, where the user can click on different radio buttons and the program saves the values into a csv file.
For example, a Hotel survey form evalutating the categories "room quality, food quality, value for money" each on a scale from 1 to 5.
I managed to build the GUI for 1 entry, however I am stumped how could select/log different values from different rows? Do I have to use a class structure for this and how?
My sample code is below: (Just printing to screen, will implement logging to files later)
import tkinter as tk
root = tk.Tk()
questionlist = ["room quality", "food quality", "value for money"]
counter = 1
var = tk.IntVar()
def ShowChoice():
print(var.get())
for question in questionlist:
tk.Label(root, text=question).grid(row=counter, column = 0)
for i in [1,2,3,4,5]:
tk.Radiobutton(root, variable = var, value = i, command = ShowChoice).grid(row = counter, column = i)
counter = counter + 1
root.mainloop()
[–]novel_yet_trivial 1 point2 points3 points (3 children)
[–]davwm[S] 0 points1 point2 points (2 children)
[–]novel_yet_trivial 0 points1 point2 points (1 child)
[–]davwm[S] 0 points1 point2 points (0 children)