Related
I am writing a program, that users enter information in which the data is then outputted into a CSV once clicked generate.
The info that needs to be entered is: Date, Time, Test Station, Serial Number, and then 3 radio button selections.
Currently, i have it so i can enter the date, time, and serial number. But i want the application to automatically update the date and time so that users don't have to enter it. I have imported a date module but no idea how to get it working within the text box.
from tkinter import *
from datetime import date
today = date.today()
d1 = today.strftime("%d/%m/%y")
def save_info():
date_info = date.get()
time_info = time.get()
serialNumber_info = serialNumber.get()
serialNumber_info = str(serialNumber_info)
print(date_info, time_info, serialNumber_info)
file = open("test.csv", "a")
file.write(date_info)
file.write(",")
file.write(time_info)
file.write(",")
file.write(serialNumber_info)
file.write("\n")
file.close()
print(" User ", date_info, " Has been registered")
date_entry.delete(0, END)
time_entry.delete(0, END)
serialNumber_entry.delete(0, END)
screen = Tk()
d1_var = StringVar(screen, d1)
screen.geometry("500x500")
screen.title("Python Form")
heading = Label(text = "Python Form", bg = "grey", fg = "black", width = "500", height = "3")
heading.pack()
date_text = Label(text = "Enter Date '(13/12/2022)' ",)
time_text = Label(text = "Enter Time '(16:45)'",)
serialNumber_text = Label(text = "Enter Serial Number ",)
date_text.place(x = 15, y = 70)
time_text.place(x = 210, y = 70)
serialNumber_text.place(x = 15, y = 210)
date = StringVar()
time = StringVar()
serialNumber = IntVar()
date_entry = Entry(textvariable = d1_var, width = "30")
time_entry = Entry(textvariable = time, width = "30")
serialNumber_entry = Entry(textvariable = serialNumber, width = "30")
date_entry.place(x = 15, y = 100)
time_entry.place(x = 210, y = 100)
serialNumber_entry.place(x = 15, y = 240)
register = Button(screen,text = "Register", width = "30", height = "2", command = save_info, bg = "grey")
register.place(x = 15, y = 400)
the text variable you define to your Entry widget should be a tkinter StringVar. You can define it after creating the Tk() and set any value you want.
screen = Tk()
d1_var = StringVar(screen, d1)
Then just change the Entry textvariable to d1_var instead:
date_entry = Entry(textvariable = d1_var, width = "30")
I have managed to program a simple python weather forecast that returns the weather results of the city which you entered. I followed a tutorial on Youtube.
I need your help to create a selecting menu for countries and cities that open weather supports. My instructor demanded me to make a choice menu instead of simple search bar.
I intended to approach the problem by creating json files that contain cities and their longitude, latitude. Each countries will have their own files. I can call the data from json files but I'm stumped on how to make the menu because I just started on IT and this is my first big project so I'd be delighted if you could help me solve it.
from string import capwords
import json
import PIL
import requests
from tkinter import *
import tkinter as tk
from tkinter import ttk, messagebox
from PIL import ImageTk
from PIL import Image
from geopy.geocoders import Nominatim
from datetime import *
import pytz
from timezonefinder import TimezoneFinder
root = Tk()
root.title("MerryWeather")
root.geometry("1000x500+300+300")
root.configure(bg = "#57adff")
root.resizable(False, False)
#Get weather information
def getWeather():
##Get timezone
city = searchText.get()
##Get city's coordinate
complete_api_link = "https://api.openweathermap.org/data/2.5/weather?q="+city+"&appid=####"
api_link = requests.get(complete_api_link)
api_data = api_link.json()
lonposition = api_data['coord']['lon']
latposition = api_data['coord']['lat']
long_lat.config(text = f"{round(latposition,4)}°N, {round(lonposition,4)}°E")
##Get current local time
obj = TimezoneFinder()
result = obj.timezone_at(lng = lonposition, lat = latposition)
timeZone.config(text = result)
local_time = pytz.timezone(result)
localTime = datetime.now(local_time)
currentTime = localTime.strftime("%I:%M %p")
clock.config(text = currentTime)
##Get weather information
apiURL = "https://api.openweathermap.org/data/2.5/onecall?lat="+str(latposition)+"&lon="+str(lonposition)+"&appid=####"
json_data = requests.get(apiURL).json()
temp = json_data['current']['temp'] - 273.15
humidity = json_data['current']['humidity']
pressure = json_data['current']['pressure']
wind_spd = json_data['current']['wind_speed']
weather_desc = json_data['current']['weather'][0]['description']
t.config(text = ("{:.2f}°C".format(temp)))
h.config(text = (humidity, "%"))
p.config(text = (pressure, "hPa"))
w.config(text = (wind_spd, "m/s"))
d.config(text = capwords(weather_desc))
##Show weekdays
###Day 1 info
first = datetime.now()
day1.config(text = first.strftime("%A"))
firsticon = json_data['daily'][0]['weather'][0]['icon']
icon1 = Image.open(f"images/{firsticon}.png")
resized1 = icon1.resize((130,130))
icon1r = ImageTk.PhotoImage(resized1)
day1icon.config(image = icon1r)
day1icon.image = icon1r
tempday1 = json_data['daily'][0]['temp']['day'] - 273.15
tempnight1 = json_data['daily'][0]['temp']['night'] - 273.15
day1temp.config(text = ("Day: {:.2f}°C\n".format(tempday1) + "Night: {:.2f}°C".format(tempnight1)))
###Day 2 info
second = first + timedelta(days = 1)
day2.config(text = second.strftime("%A"))
secondicon = json_data['daily'][1]['weather'][0]['icon']
icon2 = Image.open(f"images/{secondicon}.png")
resized2 = icon2.resize((80,80))
icon2r = ImageTk.PhotoImage(resized2)
day2icon.config(image = icon2r)
day2icon.image = icon2r
tempday2 = json_data['daily'][1]['temp']['day'] - 273.15
tempnight2 = json_data['daily'][1]['temp']['night'] - 273.15
day2temp.config(text = ("Day: {:.2f}°C\n".format(tempday2) + "Night: {:.2f}°C".format(tempnight2)))
###Day 3 info
third = first + timedelta(days = 2)
day3.config(text = third.strftime("%A"))
thirdicon = json_data['daily'][2]['weather'][0]['icon']
icon3 = Image.open(f"images/{thirdicon}.png")
resized3 = icon3.resize((80,80))
icon3r = ImageTk.PhotoImage(resized3)
day3icon.config(image = icon3r)
day3icon.image = icon3r
tempday3 = json_data['daily'][2]['temp']['day'] - 273.15
tempnight3 = json_data['daily'][2]['temp']['night'] - 273.15
day3temp.config(text = ("Day: {:.2f}°C\n".format(tempday3) + "Night: {:.2f}°C".format(tempnight3)))
###Day 4 info
fourth = first + timedelta(days = 3)
day4.config(text = fourth.strftime("%A"))
fourthicon = json_data['daily'][3]['weather'][0]['icon']
icon4 = Image.open(f"images/{fourthicon}.png")
resized4 = icon4.resize((80,80))
icon4r = ImageTk.PhotoImage(resized4)
day4icon.config(image = icon4r)
day4icon.image = icon4r
tempday4 = json_data['daily'][3]['temp']['day'] - 273.15
tempnight4 = json_data['daily'][3]['temp']['night'] - 273.15
day4temp.config(text = ("Day: {:.2f}°C\n".format(tempday4) + "Night: {:.2f}°C".format(tempnight4)))
###Day 5 info
fifth = first + timedelta(days = 4)
day5.config(text = fifth.strftime("%A"))
fifthicon = json_data['daily'][4]['weather'][0]['icon']
icon5 = Image.open(f"images/{fifthicon}.png")
resized5 = icon5.resize((80,80))
icon5r = ImageTk.PhotoImage(resized5)
day5icon.config(image = icon5r)
day5icon.image = icon5r
tempday5 = json_data['daily'][4]['temp']['day'] - 273.15
tempnight5 = json_data['daily'][4]['temp']['night'] - 273.15
day5temp.config(text = ("Day: {:.2f}°C\n".format(tempday5) + "Night: {:.2f}°C".format(tempnight5)))
###Day 6 info
sixth = first + timedelta(days = 5)
day6.config(text = sixth.strftime("%A"))
sixthicon = json_data['daily'][5]['weather'][0]['icon']
icon6 = Image.open(f"images/{sixthicon}.png")
resized6 = icon6.resize((80,80))
icon6r = ImageTk.PhotoImage(resized6)
day6icon.config(image = icon6r)
day6icon.image = icon6r
tempday6 = json_data['daily'][5]['temp']['day'] - 273.15
tempnight6 = json_data['daily'][5]['temp']['night'] - 273.15
day6temp.config(text = ("Day: {:.2f}°C\n".format(tempday6) + "Night: {:.2f}°C".format(tempnight6)))
###Day 7 info
seventh = first + timedelta(days = 6)
day7.config(text = seventh.strftime("%A"))
seventhicon = json_data['daily'][6]['weather'][0]['icon']
icon7 = Image.open(f"images/{seventhicon}.png")
resized7 = icon7.resize((80,80))
icon7r = ImageTk.PhotoImage(resized7)
day7icon.config(image = icon7r)
day7icon.image = icon7r
tempday7 = json_data['daily'][6]['temp']['day'] - 273.15
tempnight7 = json_data['daily'][6]['temp']['night'] - 273.15
day7temp.config(text = ("Day: {:.2f}°C\n".format(tempday7) + "Night: {:.2f}°C".format(tempnight7)))
#Interface
##Icon
image_icon = PhotoImage(file="images/01d.png")
root.iconphoto(False, image_icon)
##Current weather stats
Round_box1 = PhotoImage(file="images/rounded_bg1.png")
Label(root, image = Round_box1, bg = "#57adff").place(x = 30, y = 110)
temp = Label(root, text = "Temperature:", font = ('Helvetica', 11), fg = "white", bg = "#002167").place(x = 40, y = 115)
t = Label(root, font = ('Helvetica', 11), fg = "white", bg = "#002167")
t.place(x = 131, y = 115)
humid = Label(root, text = "Humidity :", font = ('Helvetica', 11), fg = "white", bg = "#002167").place(x = 40, y = 135)
h = Label(root, font = ('Helvetica', 11), fg = "white", bg = "#002167")
h.place(x = 131, y = 135)
pressure = Label(root, text = "Pressure :", font = ('Helvetica', 11), fg = "white", bg = "#002167").place(x = 40, y = 155)
p = Label(root, font = ('Helvetica', 11), fg = "white", bg = "#002167")
p.place(x = 131, y = 155)
wind = Label(root, text = "Wind speed :", font = ('Helvetica', 11), fg = "white", bg = "#002167").place(x = 40, y = 175)
w = Label(root, font = ('Helvetica', 11), fg = "white", bg = "#002167")
w.place(x = 131, y = 175)
desc = Label(root, text = "Description :", font = ('Helvetica', 11), fg = "white", bg = "#002167").place(x = 40, y = 195)
d = Label(root, font = ('Helvetica', 11), fg = "white", bg = "#002167")
d.place(x = 131, y = 195)
##City search box
searchField = PhotoImage(file="images/rounded_bg2.png")
search_field = Label(root, image = searchField, bg = "#57adff").place(x = 287, y = 130)
searchText = tk.Entry(root, justify = 'center', width = 15, font = ('Helvetica', 25, 'bold'), bg = "#414141", border = 0, fg = 'white')
searchText.place(x = 497, y = 150)
searchText.focus()
weatIcon = PhotoImage(file="images/logo.png")
weat_icon = Label(root, image = weatIcon, bg = "#414141").place(x = 317, y = 135)
searchIcon = PhotoImage(file="images/search.png")
search_icon = Button(root, image = searchIcon, borderwidth = 0, cursor = "hand2", bg = "#414141", command = getWeather).place(x = 887, y = 137)
##Big forecast box
bottomFrame = Frame(root, width = 1000, height = 200, bg = "#57adff")
bottomFrame.pack(side = BOTTOM)
Round_box3 = PhotoImage(file="images/rounded_bg3.png")
Label(bottomFrame, image = Round_box3, bg = "#57adff").place(x = -2, y = -5)
##Today weather box
todayWeat = PhotoImage(file="images/weather_box1.png")
Label(bottomFrame, image = todayWeat, bg = "#002060").place(x = 30, y = 23)
##Weather forecast box
weatForeBox = PhotoImage(file="images/weather_box2.png")
for x in range(6):
Label(bottomFrame, image=weatForeBox, bg="#002060").place(x=300 + x*115, y=23)
##Cell
###1st cell
first_cell = Frame(root, width = 240, height = 140, bg = "#303030").place(x = 37, y = 330)
day1icon = Label(root, bg = "#303030")
day1icon.place(x = 40, y = 330)
day1 = Label(root, font = ("Helvetica", 15), fg = "white", bg = "#303030")
day1.place(x = 165, y = 333)
day1temp = Label(root, font = ("Helvetica", 13), fg = "white", bg = "#303030")
day1temp.place(x = 161, y = 380)
###2nd cell
second_cell = Frame(root, width = 90, height = 140, bg = "#303030").place(x = 307, y = 330)
day2icon = Label(root, bg = "#303030")
day2icon.place(x = 310, y = 350)
day2 = Label(root, font = ("Helvetica", 11), fg = "white", bg = "#303030")
day2.place(x = 310, y = 333)
day2temp = Label(root, font = ("Helvetica", 10), fg = "white", bg = "#303030")
day2temp.place(x = 307, y = 430)
###3rd cell
third_cell = Frame(root, width = 90, height = 140, bg = "#303030").place(x = 422, y = 330)
day3icon = Label(root, bg = "#303030")
day3icon.place(x = 425, y = 350)
day3 = Label(root, font = ("Helvetica", 11), fg = "white", bg = "#303030")
day3.place(x = 425, y = 333)
day3temp = Label(root, font = ("Helvetica", 10), fg = "white", bg = "#303030")
day3temp.place(x = 422, y = 430)
###4th cell
fourth_cell = Frame(root, width = 90, height = 140, bg = "#303030").place(x = 537, y = 330)
day4icon = Label(root, bg = "#303030")
day4icon.place(x = 540, y = 350)
day4 = Label(root, font = ("Helvetica", 11), fg = "white", bg = "#303030")
day4.place(x = 540, y = 333)
day4temp = Label(root, font = ("Helvetica", 10), fg = "white", bg = "#303030")
day4temp.place(x = 537, y = 430)
###5th cell
fifth_cell = Frame(root, width = 90, height = 140, bg = "#303030").place(x = 652, y = 330)
day5icon = Label(root, bg = "#303030")
day5icon.place(x = 655, y = 350)
day5 = Label(root, font = ("Helvetica", 11), fg = "white", bg = "#303030")
day5.place(x = 655, y = 333)
day5temp = Label(root, font = ("Helvetica", 10), fg = "white", bg = "#303030")
day5temp.place(x = 652, y = 430)
###6th cell
sixth_cell = Frame(root, width = 90, height = 140, bg = "#303030").place(x = 767, y = 330)
day6icon = Label(root, bg = "#303030")
day6icon.place(x = 770, y = 350)
day6 = Label(root, font = ("Helvetica", 11), fg = "white", bg = "#303030")
day6.place(x = 770, y = 333)
day6temp = Label(root, font = ("Helvetica", 10), fg = "white", bg = "#303030")
day6temp.place(x = 767, y = 430)
###7th cell
seventh_cell = Frame(root, width = 90, height = 140, bg = "#303030").place(x = 882, y = 330)
day7icon = Label(root, bg = "#303030")
day7icon.place(x = 885, y = 350)
day7 = Label(root, font = ("Helvetica", 11), fg = "white", bg = "#303030")
day7.place(x = 885, y = 333)
day7temp = Label(root, font = ("Helvetica", 10), fg = "white", bg = "#303030")
day7temp.place(x = 882, y = 430)
##Time
clock = Label(root, font = ("Helvetica", 30, 'bold'), fg = "white", bg = "#57adff")
clock.place(x = 40, y =20)
##Timezone
timeZone = Label(root, font = ("Helvetica", 20), fg = "white", bg = "#57adff")
timeZone.place(x = 700, y = 20)
long_lat = Label(root, font = ("Helvetica", 10), fg = "white", bg = "#57adff")
long_lat.place(x = 700, y = 50)
#Launch
root.mainloop()
I'm also aware that my coding is horrendously unoptimized but as I said, I'm a newborn in this major so I can't modify it much without breaking everything and have to play "wack-a-mole" with bugs so any suggestion on how to optimize the program is also welcomed
from tkinter import *
import time
def checkTime():
if len(hourInput.get()) != 0 and len(minuteInput.get()) != 0 and len(secondInput.get()) != 0:
if hourInput.get() == time.strftime("%H"):
print("good")
window.after(500, checkTime)
def pressButton(button):
button.config(relief=SUNKEN)
if __name__=='__main__':
window = Tk()
window.geometry("1920x1080")
canvas = Canvas(window, width = 1980, height = 1020)
canvas.pack()
hourInput = StringVar()
minuteInput = StringVar()
secondInput = StringVar()
setHour = Entry(window, text = hourInput, font = (20))
setHour.place(x = 100, y = 20, width = 100, height = 40)
setMinute = Entry(window, text = minuteInput, font = (20))
setMinute.place(x = 300, y = 20, width = 100, height = 40)
setSecond = Entry(window, text = secondInput, font = (20))
setSecond.place(x = 500, y = 20, width = 100, height = 40)
canvas.create_text(60, 40, text = "Hour: ", font = (20))
canvas.create_text(260, 40, text = "Minute: ", font = (20))
canvas.create_text(460, 40, text = "Second: ", font = (20))
submit = Button(text = "Submit", height = 2, width = 10, font = (10))
submit.config(command = lambda submit=submit:pressButton(submit))
submit.place(x = 100, y = 100)
checkTime()
window.mainloop()
I want the function checkTime() to be called when my button is pressed. But how to get the status of my button and compare it ? I want to use the function only if the button is pressed as a test that the user agree with his inputs
You can modify the button declaration as follows so that the checkTime() will trigger when the button is pressed.
submit = Button(text = "Submit", height = 2, width = 10, font = (10), relief=SUNKEN)
submit['command'] = checkTime # no parentheses here
Also make sure that the checkTime() method call in the bottom is removed
I put the function checkTime() inside the pressButton() function, and now the program works fine.
from tkinter import *
import time
def checkTime():
if len(hourInput.get()) != 0 and len(minuteInput.get()) != 0 and len(secondInput.get()) != 0:
if hourInput.get() == time.strftime("%H"):
print("good")
window.after(500, checkTime)
def pressButton(button):
button.config(relief = SUNKEN)
checkTime()
if __name__== '__main__':
window = Tk()
window.geometry("1920x1080")
canvas = Canvas(window, width = 1980, height = 1020)
canvas.pack()
hourInput = StringVar()
minuteInput = StringVar()
secondInput = StringVar()
setHour = Entry(window, text = hourInput, font = (20))
setHour.place(x = 100, y = 20, width = 100, height = 40)
setMinute = Entry(window, text = minuteInput, font = (20))
setMinute.place(x = 300, y = 20, width = 100, height = 40)
setSecond = Entry(window, text = secondInput, font = (20))
setSecond.place(x = 500, y = 20, width = 100, height = 40)
canvas.create_text(60, 40, text = "Hour: ", font = (20))
canvas.create_text(260, 40, text = "Minute: ", font = (20))
canvas.create_text(460, 40, text = "Second: ", font = (20))
submit = Button(text = "Submit", height = 2, width = 10, font = (10))
submit.config(command = lambda submit=submit:pressButton(submit))
submit.place(x = 100, y = 100)
window.mainloop()
from tkinter import *
import time
check = False
window = Tk()
window.geometry("1920x1080")
def typeTime():
hour = int(time.strftime("%H"))
minute = int(time.strftime("%M"))
second = int(time.strftime("%S"))
hourInput2 = int(hourInput.get())
minuteInput2 = int(minuteInput.get())
secondInput2 = int(secondInput.get())
if(hour == hourInput2 and minute == minuteInput2 and second == secondInput2):
print("now")
global check
check = True
canvas = Canvas(window, width = 1980, height = 1020)
canvas.pack()
hourInput = StringVar()
minuteInput = StringVar()
secondInput = StringVar()
setHour = Entry(window, text = hourInput, font = (20)).place(x = 100, y = 20, width = 100, height = 40)
setMinute = Entry(window, text = minuteInput, font = (20)).place(x = 300, y = 20, width = 100, height = 40)
setSecond = Entry(window, text = secondInput, font = (20)).place(x = 500, y = 20, width = 100, height = 40)
canvas.create_text(60, 40, text = "Hour: ", font = (20))
canvas.create_text(260, 40, text = "Minute: ", font = (20))
canvas.create_text(460, 40, text = "Second: ", font = (20))
submit = Button(text = "Submit", height = 2, width = 10, font = (10), command = typeTime)
submit.place(x = 100, y = 100)
if check == True:
print("Pressed")
submit.config(relief = SUNKEN)
window.mainloop()
I'm trying to make a button to stay pressed, so I tried to make this happens with a global variable. The variable check is initially False, but when typeTime() is called via the submit object it should change its value in True and when check will be tested later to keep my button pressed using config method.
What am I doing wrong, as neither the button is still pressed nor the message "Pressed" is displayed in the console ?
The window.mainloop() is the internal loop inside object window, not in your script so that is why it didn't work. You need to add the action inside the function typeTime:
from tkinter import *
import time
if __name__=='__main__':
check = False
window = Tk()
window.geometry("1920x1080")
def typeTime(button):
hour = int(time.strftime("%H"))
minute = int(time.strftime("%M"))
second = int(time.strftime("%S"))
hourInput2 = int(hourInput.get())
minuteInput2 = int(minuteInput.get())
secondInput2 = int(secondInput.get())
if(hour == hourInput2 and minute == minuteInput2 and second == secondInput2):
print("now")
# global check
# check = True
print('Pressed')
button.config(relief=SUNKEN)
canvas = Canvas(window, width = 1980, height = 1020)
canvas.pack()
hourInput = StringVar()
minuteInput = StringVar()
secondInput = StringVar()
setHour = Entry(window, text = hourInput, font = (20)).place(x = 100, y = 20, width = 100, height = 40)
setMinute = Entry(window, text = minuteInput, font = (20)).place(x = 300, y = 20, width = 100, height = 40)
setSecond = Entry(window, text = secondInput, font = (20)).place(x = 500, y = 20, width = 100, height = 40)
canvas.create_text(60, 40, text = "Hour: ", font = (20))
canvas.create_text(260, 40, text = "Minute: ", font = (20))
canvas.create_text(460, 40, text = "Second: ", font = (20))
submit = Button(text = "Submit", height = 2, width = 10, font = (10))
submit.config(command = lambda submit=submit:typeTime(submit))
submit.place(x = 100, y = 100)
# if check == True:
# print("Pressed")
# submit.config(relief = SUNKEN)
window.mainloop()
The following code gets an error as it says name 'Combo_Box Value' is not defined.
from tkinter import *
from tkinter.ttk import Progressbar
from tkinter.ttk import Combobox
from tkinter.ttk import Notebook
import tkinter.font
class Pounds_Converter():
def __init__(self, parent):
self.gui(parent)
def gui(self, parent):
if parent == 0:
self.w1 = Tk()
self.w1.configure(bg = '#e4f3ff')
self.w1.geometry('370x350')
else:
self.w1 = Frame(parent)
self.w1.configure(bg = '#e4f3ff')
self.w1.place(x = 0, y = 0, width = 370, height = 350)
self.label3 = Label(self.w1, text = "Pounds Converter", bg = "#e4f3ff", fg = "#002d5e", font = tkinter.font.Font(family = "Myanmar Text", size = 24), cursor = "arrow", state = "normal")
self.label3.place(x = 55, y = 50, width = 260, height = 62)
self.label4 = Label(self.w1, text = "Pounds", bg = "#e4f3ff", fg = "#006fe8", font = tkinter.font.Font(family = "Myanmar Text", size = 12), cursor = "arrow", state = "normal")
self.label4.place(x = 60, y = 135, width = 60, height = 22)
self.combo1 = Combobox(self.w1, font = tkinter.font.Font(family = "Myanmar Text", size = 12), cursor = "arrow", state = "normal")
self.combo1.place(x = 250, y = 135, width = 76, height = 22)
self.combo1['values'] = ("Dollars", "Euros")
self.combo1.current(0)
self.combo1.bind("<<ComboboxSelected>>", self.Combo_Box)
self.ltext3 = Entry(self.w1, bg = "#efffff", font = tkinter.font.Font(family = "MS Shell Dlg 2", size = 8), cursor = "arrow", state = "normal")
self.ltext3.place(x = 20, y = 170, width = 140, height = 32)
self.ltext3.insert(INSERT, "0.00")
self.ltext4 = Entry(self.w1, bg = "#efffff", font = tkinter.font.Font(family = "MS Shell Dlg 2", size = 8), cursor = "arrow", state = "normal")
self.ltext4.place(x = 220, y = 170, width = 140, height = 32)
self.button2 = Button(self.w1, text = "Convert", bg = "#efffff", fg = "#006fe8", font = tkinter.font.Font(family = "MS Shell Dlg 2", size = 8), cursor = "arrow", state = "normal")
self.button2.place(x = 120, y = 270, width = 130, height = 30)
self.button2['command'] = self.Convert
self.button3 = Button(self.w1, text = "Home", bg = "#e4f3ff", fg = "#006fe8", font = tkinter.font.Font(family = "Myanmar Text", size = 8), cursor = "arrow", state = "normal")
self.button3.place(x = 20, y = 20, width = 40, height = 16)
def Combo_Box(self, e):
Combo_Box_Value=self.combo1.get()
return Combo_Box_Value
def Convert(self):
global Combo_Box_Value
Pounds=self.ltext3.get()
Pounds = float(Pounds)
if Combo_Box_Value== "Dollars":
Dollars=Pounds*1.38
self.ltext4.delete("0",END)
self.ltext4.insert(INSERT,Dollars)
a = Pounds_Converter(0)
a.w1.mainloop()
That is the full code for that GUI widget. I would like to get the value of the combo box once it is changed then I need to use it in another variable.