Comment Your Questions in Related Category

Python
Forum
Javascript
Forum
C/C++
Forum
Java
Forum
Web Developer
Forum
Android app Dev.
Forum
IOS app Dev.
Forum

python: weight conversion gui with tkinter

 # Python program to create a simple GUI

# weight converter using Tkinter



from tkinter import *



# Create a GUI window

window = Tk()


# Function to convert weight

# given in kg to grams, pounds

# and ounces

def from_kg():

# convert kg to gram

gram = float(e2_value.get())*1000

# convert kg to pound

pound = float(e2_value.get())*2.20462

# convert kg to ounce

ounce = float(e2_value.get())*35.274

# Enters the converted weight to

# the text widget

t1.delete("1.0", END)

t1.insert(END,gram)

t2.delete("1.0", END)

t2.insert(END,pound)

t3.delete("1.0", END)

t3.insert(END,ounce)


# Create the Label widgets

e1 = Label(window, text = "Enter the weight in Kg")

e2_value = StringVar()

e2 = Entry(window, textvariable = e2_value)

e3 = Label(window, text = 'Gram')

e4 = Label(window, text = 'Pounds')

e5 = Label(window, text = 'Ounce')


# Create the Text Widgets

t1 = Text(window, height = 1, width = 20)

t2 = Text(window, height = 1, width = 20)

t3 = Text(window, height = 1, width = 20)


# Create the Button Widget

b1 = Button(window, text = "Convert", command = from_kg)


# grid method is used for placing

# the widgets at respective positions

# in table like structure

e1.grid(row = 0, column = 0)

e2.grid(row = 0, column = 1)

e3.grid(row = 1, column = 0)

e4.grid(row = 1, column = 1)

e5.grid(row = 1, column = 2)

t1.grid(row = 2, column = 0)

t2.grid(row = 2, column = 1)

t3.grid(row = 2, column = 2)

b1.grid(row = 0, column = 2)


# Start the GUI

window.mainloop()


import pyttsx3

import speech_recognition as sr

import datetime
import wikipedia
import webbrowser
import os
import subprocess as sp

engine = pyttsx3.init('sapi5')
voices = engine.getProperty ('voices')
engine.setProperty('voice',voices [1].id)

def speak(audio):
    engine.say(audio)
    engine.runAndWait()

def wishme():
    hour = int(datetime.datetime.now().hour)
    if hour >= 0 and hour <= 12:
        speak("Good Morning!")

    elif hour >= 12 and hour <=18:
        speak("Good Afternoon!")

    else:
        speak("Good Evening!")

def takecommand():
                                       #It takes microphone input from the user and returns string output

    r = sr.Recognizer()
    with sr.Microphone() as source:
        print("Listening...")
        r.pause_threshold = 1
        audio = r.listen(source)

    try:
        print("Recognizing...")    
        query = r.recognize_google(audiolanguage='en-in')
        print(f"User said: {query}\n")

    except Exception as e:    
        speak('sir, Say that again please...')  
        return "None"
    return query

def username():
    speak('what should i call you sir')
    uname = takecommand()
    speak('welcome mister' or 'welcome miss')
    speak(uname
    speak("How can i Help you, Sir")        


    


if __name__ == "__main__":

    wishme()
    username()
    #speak('Before using me please give come input')
    #a=str(input('Enter notepade app path if you wanna to use it with me:'))

    while True:

        query = takecommand().lower()

        if "wikipedia" in query:
            speak('searching wikipedia...')
            query = query.replace("wikipedia""")
            results = wikipedia.summary(querysentences=3)
            speak("According to wikipedia"results)

        elif "open google" in query:
            speak('opening google')
            webbrowser.open("google.com")
            
# most asked question from google Assistant 
        elif "will you be my gf" in query or "will you be my bf" in query:    
            speak("I'm not sure about, may be you should give me some time"
  
        elif "how are you" in query
            speak("I'm fine, glad you me that"
  
        elif "i love you" in query
            speak("It's hard to understand"

        elif 'open notepad' in query:
            pn="Notepad.exe"
            sp.Popen([pn])