Sum of Combobox & Text widget inputs

Tkinter Combobox

Adding Combobox and Text widget values

Adding combobox with selection options

sel1=tk.IntVar() # string variable 
cb1 = ttk.Combobox(my_w, values=data,height=3, width=5,
    font=22, textvariable=sel1)

On click of the button

Here we are using click event of the button to trigger the function my_upd().

Reading and adding values

We collect the input values from Combobox and from the Text widget , then add these two values.
By using config() we will update the Label to display the sum of the values.
def my_upd(*args):
    total=sel1.get() + int(t1.get("1.0",END))
    l1.config(text=total)# update the Label text 
Tkinter adding combobox selection and text widget value and displaying the sum in a Label

Full code is here
import tkinter as tk
from tkinter import ttk
from tkinter import *
my_w = tk.Tk()
my_w.geometry("400x250")  # Size of the window 
my_w.title("")  # Adding a title
def my_upd(*args):
    total=sel1.get() + int(t1.get("1.0",END))
    l1.config(text=total) # update the Label text 

sel1=tk.IntVar() # string variable 
cb1 = ttk.Combobox(my_w, values=data,height=3, 
	width=5,font=22, textvariable=sel1)
t1.insert(tk.END, 0) # initial value of text widget 
#sel1.trace('w',my_upd) # to trigger the function on change 
my_w.mainloop()  # Keep the window open
MySQL , SQLite,CSV and Json data is used to add options for Combobox
Two and Three interlinked Comboboxes
Listbox OptionMenu
Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net


    Dear Sir,
    Thank you for your good instructions. I learn a lot from your videos.
    One question:
    how to delete the combobox option dynamicly?
    i was unable to use cb1['values'] -=(e1.get(),) to delete the option.
    please kindly teach me how to do it.

    Thank you very much.
    I subcribed your yourtube already.



    You can't delete by using cb1['values'] -=(e1.get(),) as it is a tuple. Create a new tuple with all the options except the one you want to delete. Then assign the new tuple to cb1.
    This part is added to this page. Here is the video again.


    In one of the programs which i am working , the combo box freezes when i click on dropdown and then the application stops and crashes. Please advise


    Are you using any onclick event and triggering any function? Just remove the function and see how it is working. Then check the code inside the function.

    Post your comments , suggestion , error , requirements etc here

    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 All rights reserved worldwide Privacy Policy Disclaimer