Using the Tkinter radio-button widget for a GUI in my python application

166 Views Asked by At

I'm developing a python application that models forex derivatives. The intent of the project is to create a GUI that can:

  • create data models
  • display visualizations of that data
  • update the visuals while they're open
  • quit all windows with one button

This all functions as intended.

Currently, the GUI uses 6 Tkinter 'entry' widgets and 5 Tkinter 'button' widgets.

GUI example

'Update' buttons use (their respective) entry fields to generate 'result-sets', which are then saved to .txt files.

'Display' buttons read data in the .txt files, and create visuals using Matplotlib's Animation function.

What I want to do: replace the 'size' entry field with: radio-button / checkbox / slider Tkinter widgets.

For example: Consider a user who wants to model the purchase of 10 forex contracts. Instead of typing 10 into the 'size' field (and clicking update), they mark the 10 radio-button and click 'update'.

What I've attempted and failed to do: I've read a number of Tkinter radio-button / checkbox widget tutorials which have been a waste of time. Honestly, I'm struggling to conceptualize how I can add this functionality.

If applicable, the GUI is formatted by a class.

1

There are 1 best solutions below

4
On

The best approach imo would be a slider.

slider = tk.Scale(master, from_=0, to=10, orient=HORIZONTAL)

and then later make a function to get that chosen value from slider like:

size = slider.get()

Have a good day.