|
| 1 | +#!/usr/bin/env python3 |
| 2 | + |
| 3 | +import tkinter as tk |
| 4 | + |
| 5 | +def cap_filter(selection): |
| 6 | + options = { |
| 7 | + 'Arm': ['50kg', '100kg', '200kg', '300kg'], |
| 8 | + 'Arm (Food Grade)': ['75kg'], |
| 9 | + 'Rail': ['125kg', '300kg'], |
| 10 | + 'Drive': ['125kg', '300kg'], |
| 11 | + } |
| 12 | + |
| 13 | + print(options[selection]) |
| 14 | + |
| 15 | + # remove old elements |
| 16 | + cap_dropdown['menu'].delete(0, 'end') |
| 17 | + |
| 18 | + # add new items |
| 19 | + for text in options[selection]: |
| 20 | + cap_dropdown['menu'].add_command(label=text, command=lambda arg=text:length_filter(arg)) |
| 21 | + |
| 22 | +def length_filter(selection): |
| 23 | + type_ = lift_type.get() |
| 24 | + |
| 25 | + if selection == '50kg' and type_ == 'Arm': |
| 26 | + length_choice = ['3m'] |
| 27 | + elif selection == '75kg': |
| 28 | + length_choice = ['4.2m'] |
| 29 | + elif selection == '100kg' and type_ == 'Arm': |
| 30 | + length_choice = ['3m', '4m', '5m'] |
| 31 | + elif selection == '125kg': |
| 32 | + length_choice = ['N/A'] |
| 33 | + elif selection == '200kg' and type_ == 'Arm': |
| 34 | + length_choice = ['3m', '4m', '5m'] |
| 35 | + elif selection == '300kg' and type_ == 'Arm': |
| 36 | + length_choice = ['3m', '4m'] |
| 37 | + elif selection == '300kg' and type_ == 'Rail': |
| 38 | + length_choice = ['N/A'] |
| 39 | + elif selection == '300kg' and type_ == 'Drive': |
| 40 | + length_choice = ['N/A'] |
| 41 | + else: |
| 42 | + length_choice = ['N/A'] |
| 43 | + |
| 44 | + print(length_choice) |
| 45 | + |
| 46 | +app = tk.Tk() |
| 47 | + |
| 48 | +lift_type = tk.StringVar() |
| 49 | +lift_type.set('Lift Type') |
| 50 | +files = ['Arm', 'Arm (Food Grade)', 'Rail', 'Drive'] |
| 51 | + |
| 52 | +lift_dropdown = tk.OptionMenu(app, lift_type, *files, command=cap_filter) |
| 53 | +lift_dropdown.pack() |
| 54 | + |
| 55 | +lift_cap = tk.StringVar() |
| 56 | +lift_cap.set('Capacity') |
| 57 | +cap_choice = [''] |
| 58 | + |
| 59 | +cap_dropdown = tk.OptionMenu(app, lift_cap, *cap_choice, command=length_filter) |
| 60 | +cap_dropdown.pack() |
| 61 | + |
| 62 | +app.mainloop() |
0 commit comments