Python Forum
Display more than one button in GUI to display MPU6000 Sensor readings
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Display more than one button in GUI to display MPU6000 Sensor readings
#2
if you are referring to the
B = ttk.Button(root, text =value, command = helloCallBack)
statement, you can destroy it before creating the next button,
if B:
    B.destroy()
You do have to place a B=None statement at the top of your code to eliminate a "B doesn't exist" error on the first pass through the function. Also you can use one function for the value and key function. Something like this but you will have to test it yourself
 def dropCall(*args):
    value = tkvar.get()
    ## using a dictionary instead of if statements
    ## to show how dictionaries are used
    baud_dict={9600:val1, 38400:val3, 119200:val2}
    if value in baud_dict:
        ard.baudrate = int(baud_dict[value])
Reply


Messages In This Thread
RE: Display more than one button in GUI to display MPU6000 Sensor readings - by woooee - Dec-28-2018, 08:31 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] PyQt5 window closing when trying to display a graph bianca 4 1,742 Aug-12-2023, 03:25 PM
Last Post: bianca
  [PyQt] [solved] How to display a pdf-file in a PyQt6 widget BigMan 13 16,275 May-06-2023, 09:27 AM
Last Post: Axel_Erfurt
  [PyQt] [Solved]Display PyQtTable results from A->Z & Z->A Extra 2 1,175 Jul-18-2022, 04:04 PM
Last Post: Extra
  [PyQt] [Solved]Display Search Results in QTable Extra 5 2,477 Jun-29-2022, 10:20 PM
Last Post: Extra
  [PyQt] Cannot Display Image after Selecting Image bintangkecil 4 2,603 Jun-12-2022, 08:18 AM
Last Post: Axel_Erfurt
  looking for scripts that do simple image display Skaperen 10 4,294 Sep-13-2021, 05:35 PM
Last Post: FullOfHelp
  [PyQt] How do I display the DB table I will choose from the QComboBox in QTableWidget JokerSob 2 2,331 Aug-05-2021, 03:00 PM
Last Post: JokerSob
  Scaling text QLabel following display mode windows '100%, 125% ...) VIGNEAUD 2 2,273 Jul-07-2021, 06:38 PM
Last Post: deanhystad
  [Tkinter] How display matrix on canvas eedenj 9 9,037 Mar-17-2021, 03:58 PM
Last Post: eedenj
  [Tkinter] Display IP address in listbox dominicrsa 2 2,196 Oct-21-2020, 01:00 PM
Last Post: dominicrsa

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020