How to create Drop-Down Menu in Python (method_II).



here we will be learning a dropdown menu to select one out of many, like month or week day.
In this section we will be using Combobox.



below is the code to design a drop down menu to select day of the week.

#program

from tkinter import *
from tkinter import ttk


mw = Tk()
mw.geometry(
'400x50+50+50')
mw.title(
"AETies: Automation Expert Technologies")
message =
"This is a sample application to browse a file and read the data from the file and to print it here in a text section"

cmb = ttk.Combobox(mw, width=20)
cmb[
'values'] = ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday')
cmb.pack()
cmb.current(
0)

btn = Button(mw
, text=' collect_value ')
btn.pack()

mw.mainloop()


now we will add functionality to collect value, getvalue() is function to collect value set under Combobox menu 


#program

from tkinter import *
from tkinter import ttk

def getvalue():
a = spin.get()
b = cmb.get()
ent.configure(
state=NORMAL)
print(a, b)

mw = Tk()
mw.geometry(
'400x50+50+50')
mw.title(
"AETies: Automation Expert Technologies")
message =
"This is a sample application to browse a file and read the data from the file and to print it here in a text section"

cmb = ttk.Combobox(mw, width=20)
cmb[
'values'] = ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday')
cmb.pack()
cmb.current(
0)

btn = Button(mw
, text=' collect_value ', command=getvalue)
btn.pack()

mw.mainloop()






 

Comments

My photo
Techno Xpresss
Bangalore, Karnataka, India