简体   繁体   中英

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

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.

图形用户界面示例

'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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM