Labels

Showing posts with label pythonprojects. Show all posts
Showing posts with label pythonprojects. Show all posts

July 22, 2021

Login UI using kivymd ,kivy (Python)

 Login User Interface Screen using kivyMD kivy (python).











Source Code

 

from kivymd.app import MDApp
from kivy.lang.builder import Builder
from kivy.core.window import Window
from kivymd.uix.button import MDRectangleFlatButton
from kivymd.uix.dialog import MDDialog

Window.size=(350,600)
UI = '''
#:import Snackbar kivymd.uix.snackbar.Snackbar

MDBoxLayout:
orientation : 'vertical'
MDToolbar :
title : "Wordpress Post"
right_action_items :[["weather-sunny",lambda x : app.blackwhit()]]
elevation : 20

MDGridLayout:
cols : 1
padding : 30,60,30,100
spacing : 10
pos_hint : {"center_x":.5,"center_y":.5}
MDCard:
#size_hint: None, None
#size: "280dp", "180dp"
pos_hint: {"center_x": .5, "center_y": .5}
radius: [20,]
elevation : 30
opacity : .9
MDBoxLayout:
orientation : 'vertical'
padding :10,10,10,70
spacing : 10
Image :
source : "wordpress.png"
#opacity : .9
pos_hint: {"center_x": .5, "center_y": .2}
size_hint : .8,.8

MDTextField :
id : username
hint_text : "Enter username "
helper_text:'Hint : codepyy,codeaj'
helper_text_mode : "on_focus"
icon_right : "wordpress"
icon_right_color : app.theme_cls.primary_color
pos_hint : {'center_x': 0.5, 'center_y': 1}
size_hint_x: None
width : 250

MDTextField :
id : pass
hint_text : "Password"
helper_text:'Hint : CodeAj123'
helper_text_mode : "on_focus"
icon_right : "eye-off"
password : True
icon_right_color : app.theme_cls.primary_color
pos_hint : {'center_x': 0.5, 'center_y': 0.8}
required: True
size_hint_x: None
width : 250

MDRoundFlatButton :
text : "Post"
pos_hint : {'center_x': 0.5, 'center_y': 0.1}
on_press : app.post()
on_release: Snackbar(text="news is poated").open()




'''


class WordPressUI(MDApp):
def build(self):
self.theme_cls.theme_style = "Dark"
self.theme_cls.primary_palette = "Gray"
return Builder.load_string(UI)

def blackwhit(self):

if self.theme_cls.theme_style == "Light" :
self.theme_cls.theme_style = "Dark"
self.theme_cls.primary_palette = "Gray"
else :
self.theme_cls.theme_style = "Light"
self.theme_cls.primary_palette = "Blue"

def close_dilog(self, obj):
self.dialog.dismiss()

def post(self):
print(self.root.ids.username.text)
close = MDRectangleFlatButton(text="Close", on_release=self.close_dilog)
more = MDRectangleFlatButton(text="Download")
self.dialog = MDDialog(title=f"POSTING...",
size_hint_y=None,
height="600",
text=f"Author : ",
size_hint=(0.9, 1),
buttons=[close, more],
)
self.dialog.open()
if __name__ == '__main__':
WordPressUI().run()

please follow 

June 14, 2021

shape detection project using python openCV modul


source code 


import cv2
import numpy as np


def stackImages(scale,imgArray):
rows = len(imgArray)
cols = len(imgArray[0])
rowsAvailable = isinstance(imgArray[0], list)
width = imgArray[0][0].shape[1]
height = imgArray[0][0].shape[0]
if rowsAvailable:
for x in range(0, rows):
for y in range(0, cols):
if imgArray[x][y].shape[:2] == imgArray[0][0].shape[:2]:
imgArray[x][y] = cv2.resize(imgArray[x][y], (0, 0), None, scale, scale)
else:
imgArray[x][y] = cv2.resize(imgArray[x][y], (imgArray[0][0].shape[1], imgArray[0][0].shape[0]),
None, scale, scale)
if len(imgArray[x][y].shape) == 2: imgArray[x][y] = cv2.cvtColor(imgArray[x][y], cv2.COLOR_GRAY2BGR)
imageBlank = np.zeros((height, width, 3), np.uint8)
hor = [imageBlank] * rows
hor_con = [imageBlank] * rows
for x in range(0, rows):
hor[x] = np.hstack(imgArray[x])
ver = np.vstack(hor)
else:
for x in range(0, rows):
if imgArray[x].shape[:2] == imgArray[0].shape[:2]:
imgArray[x] = cv2.resize(imgArray[x], (0, 0), None, scale, scale)
else:
imgArray[x] = cv2.resize(imgArray[x], (imgArray[0].shape[1], imgArray[0].shape[0]), None, scale, scale)
if len(imgArray[x].shape) == 2: imgArray[x] = cv2.cvtColor(imgArray[x], cv2.COLOR_GRAY2BGR)
hor = np.hstack(imgArray)
ver = hor
return ver

def getcounters(img):
countours,hierarchy=cv2.findContours(img,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_NONE)
for cnt in countours:
area=cv2.contourArea(cnt)
print (area)
if area>500:
cv2.drawContours(imgcountour,cnt,-1,(255,0,0),3)
peri=cv2.arcLength(cnt,True)
print(peri)
approx=cv2.approxPolyDP(cnt ,0.02*peri,True)
print(approx)
print(len(approx))
objcor=len(approx)
x,y,w,h=cv2.boundingRect(approx)
if objcor==3:
objectType=f"triangle {area}"
elif objcor==4:
aspectRatio=w/float(h)
if aspectRatio>0.95 and aspectRatio<1.05 :
objectType=f"Square {area}"
else:
objectType=f"Rectangle {area}"
elif objcor>4:
objectType=f"circle {area}"
else:
objectType="not define"

cv2.rectangle(imgcountour,(x,y),(x+w,y+h),(0,255,0),2)

cv2.putText(imgcountour,objectType,(x+(w//2)-10,y+(h//2)-10),cv2.FONT_HERSHEY_COMPLEX,0.5,(0,0,0),2)


#path='shape.jpg'

#img=cv2.imread(path)

cap=cv2.VideoCapture(0)
cap.set(3,1080) #width (chanel number,size)
cap.set(4,800) #height
cap.set(10,100) #brightness
while True:
sucess,img=cap.read()


imgcountour= img.copy()

imgGray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
imgBlur = cv2.GaussianBlur(imgGray,(7,7),1)
imgCanny=cv2.Canny(imgBlur,50,50)
getcounters(imgCanny)

imgBlank=np.zeros_like(img)

# stackimg=stackImages(0.8,([img],[imgcountour]))
cv2.imshow("image ",imgcountour)
#cv2.imshow("stack image ",stackimg)
#cv2.waitKey(0)
#cv2.imshow("video", img)

if cv2.waitKey(1) & 0xff == ord("q"):
break

May 18, 2021

covid19 updater

 covid19 updater is a desktop app used to upload live coronavirus data on your Facebook page post. by just click on the start button. 


Screenshots 




output post photo :




download exe file 

covid19 updater


April 04, 2021

weather app using tkinter python

In this app, we use API to get the weather information. 
 we use free API in this project you can also buy.

screenshots of Weather app




SOURCE CODE 

#IMPORTS MODULE 
import tkinter as tk
import requests
import time
import os

#DEFINE FUNCTION TO GET WEATHER INFORMATION
def getweather(root):
    try:
        city=textfield.get()
        api="http://api.openweathermap.org/data/2.5/weather?q="+city+"&appid=d9db53c6ebe4a8110caa93993b1d48d5"
        json_data=requests.get(api).json()
        condition= json_data['weather'][0]['main']
        temp=int(json_data['main']['temp']-273.15)
        temp_min = int(json_data['main']['temp_min'] - 273.15)
        temp_max = int(json_data['main']['temp_max'] - 273.15)
        pressure = json_data['main']['pressure']
        humidity = json_data['main']['humidity']
        wind = json_data['wind']['speed']
        sunrise=time.strftime("%I:%M:%S", time.gmtime(json_data['sys']['sunrise']-19800))
        sunset = time.strftime("%I:%M:%S", time.gmtime(json_data['sys']['sunset'] - 19800))

        final_info = condition + "\n" + str(temp) + "℃"
        final_data = "\nMax Temperature : "+str(temp_max)+"\nMin Temperature : "+str(temp_min)+"\nPressure : "+str(pressure)+"\nHumidity : "+str(humidity)+"\nWind Speed : "+str(wind)+"\nSunRise : "+str(sunrise)+"\nSunSet : "+str(sunset)


        l1.config(text = final_info)
        l2.config(text = final_data)
    except:
        invalid="invalid city name OR there is no internet connection !! "
        i.config(text=invalid)

#GUI PART USING TKINTER
root = tk.Tk()
root.geometry("500x600")
root.title ("weather app")
f=("poppins",15,"bold")
t=("poppins",35,"bold")
col='gray22'
fcol='gray'


root.configure(background = col)    #backgroung color
l0=tk.Label(root,text='City/Place Name',font=t,bg= col,fg=fcol).pack()
l3=tk.Label(root ,text='powered by ajay',font='poppins 10 bold', bg = col,fg= fcol ).place(x='350',y='550')


textfield=tk.Entry(root,font=t,bg=col,fg=fcol)
textfield.pack(pady=20)
textfield.focus()
textfield.bind('<Return>',getweather)

i=tk.Label(root,bg=col,fg=fcol,font ='areal 10 bold')
i.pack()

l1=tk.Label(root,font = t,bg=col,fg=fcol)
l1.pack()
l2=tk.Label(root,font=f,bg=col,fg=fcol)
l2.pack()

# it creates a loop to view the GUI continues.
root.mainloop()


Project GIT link












March 19, 2021

mini robot project using python

 Mini robot using python 













In this project we use four library

1. SpeechRecognition library

2. wikipedia libirary

3. gTTS library

4. pyaudio library

5. playsound library 



source code

import speech_recognition as sr

import wikipedia

from gtts import gTTS

from playsound import playsound


#recording part

for i in range(1,10):

    rec = sr.Recognizer()

    with sr.Microphone() as source:

        print("clearing backgroung noise.....")

        rec.adjust_for_ambient_noise(source, duration=1)

        print("weating for your message : ")

        recaudio = rec.listen(source)

        print("recording done... !")

    try:

        # recording to text converting part

        print("printing the message ....")

        text = rec.recognize_google(recaudio, language='hindi-IN')

        print(f"your messange is : {format(text)}")


        # listining part

        topic = (f"searching for ---> {format(text)}")

        summ = wikipedia.summary(topic)

        print(summ)

        tts = gTTS(summ)

        tts.save(f"wiki{format(text)}.mp3")


        # reading audio file

        print("reading.....")

        playsound(f"wiki{format(text)}.mp3")


    except:

        print("keyword is not found !!")


March 01, 2021

create text input and submit button using kivy python

kivy project



 import kivy

from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button

class MyGradeLayout(GridLayout):
def __init__(self, **kwargs):
super(MyGradeLayout,self).__init__(**kwargs)
self.cols=2
#name:
self.add_widget(Label(text='name : ',font_size=30))
self.name=TextInput(multiline=False)
self.add_widget(self.name)
#movies:
self.add_widget(Label(text='movies : ',font_size=30))
self.movies = TextInput(multiline=False)
self.add_widget(self.movies)
#ratig:
self.add_widget(Label(text='rating : ',font_size=30))
self.rating = TextInput(multiline=False)
self.add_widget(self.rating)
#button
self.submit=Button(text="submit",font_size=32)
self.submit.bind(on_press = self.press)
self.add_widget(self.submit)

def press(self,instance):
name = self.name.text
movies = self.movies.text
rating = self.rating.text
#print(f"hello {name}, you love {movies}, because the rating of this moves is {rating}")
self.add_widget(Label(text=f"Hello {name},\n you love '{movies}' movies,\n because the rating of this moves is {rating}"))
#after press the button clear input boxes
self.name.text=""
self.rating.text=""
self.movies.text=""



class MyApp(App):
def build(self):
return MyGradeLayout()


if __name__=='__main__':
MyApp().run()

February 01, 2021

Create Music player
















from tkinter import *

from playsound import playsound

import os

root= Tk()

def play():

    playsound("C:\\Users\\Hacking knowledge\\Desktop\\songs\\a (1).mp3")

def allsong1(): 

    allsong=os.listdir("C:\\Users\\Hacking knowledge\\Desktop\\songs")

    print("LIST OF SONGS ")

    verticaltable="\n".join(allsong)

    print (verticaltable)

            

def push():

    pass


root.title("Aj player")

root.geometry("245x400")

f1=Frame(root,bg="yellow4",padx="7",borderwidth= "6")

f1.pack(side=LEFT,fill="y")


b1=Button(f1,text="all song",bg="yellow1",fg="gray",padx="10",pady="10",font="arial 10 bold",borderwidth="10",command=allsong1)

b1.pack(side=LEFT)

b2=Button(f1,text="stop",bg="yellow1",fg="gray",padx="10",pady="10",font="arial 10 bold",borderwidth="10")

b2.pack(side=LEFT)

b3=Button(f1,text="play",bg="yellow1",fg="gray",padx="10",pady="10",font="arial 10 bold",borderwidth="10",command=play)

b3.pack(side=LEFT)


root.mainloop()


January 31, 2021

Create button using tkinter python

 









from tkinter import *

obj=Tk()

def name():

    print ("ajay pandit")


def profilepic():

    root=Tk()

    root.geometry("0x0")

    root.title("ajay pandit")

    photo=PhotoImage(file="4.png")

    aj=Label(image=photo)

    aj.pack()

    root.mainloop()


def aboutus():

    print('''\n\n

The computer science engineer

expert on programming(c,c++,java,python,html,css,sql)

certified ethical hacker''')


def contactus():

    print('''\n\n

phonr no. : 0123456789

email : ajayoneness123@gmail.com

instagram.com/hacking_knowledge

www.codeajay.blogspot.com

fb.com/hackingknowledge''')

obj.geometry("500x900")

f1 =Frame(obj,bg="green",borderwidth=6,relief=RAISED)

f1.pack()

b1=Button(f1,text="contact us",font ="arial,20,bold",padx=10,pady=10,bg="gray",command=contactus)

b1.pack(side=RIGHT,anchor="nw")

b2=Button(f1,text="about us",font ="arial,10,bold",padx=10,pady=10,bg="gray",command=aboutus)

b2.pack(side=RIGHT,anchor="nw")

b3=Button(f1,text="profile pic",font ="arial,10,bold",padx=10,pady=10,bg="gray",command=profilepic)

b3.pack(side=RIGHT,anchor="nw")

b4=Button(f1,text="name",font ="arial,10,bold",padx=10,pady=10,bg="gray",command=name)

b4.pack(side=RIGHT,anchor="nw")

obj.mainloop()


January 27, 2021

Happy birth day project


 










from tkinter import *

import time

import playsound

#BORDER STYLE(relief)= SUNKEN, RAISED, GROOVE, RIDGE

for i in range(1,10):

    root=Tk()

    root.geometry("1000x1000")

    f1=Frame(root)

    f1.pack()

    f2=Frame(root)

    f2.pack()


    lb=Label(f1,text=f'''It's 28th jan \nshivraj birthday!!!\nHAPPY BIRTHDAY TO YOU SHIVRAJ''',bg="gray",

             fg="black",padx="40",pady="20",font="arial 30 bold", borderwidth=10,relief=RAISED)

    lb.pack(anchor="ne",fill="x")

    pic=PhotoImage(file="3.png")

    lb=Label(f2,image=pic,bg="purple",

             fg="black",padx="40",pady="20",font="arial 20 bold", borderwidth=10,relief=RAISED)

    lb.pack(anchor="ne",fill="x")

    root.mainloop()

    time.sleep(0.4)


find the cube of the range given digits. || codeAj

Find the cube of the range given Digits. Source Code r= int ( input ( "enter the range of digit : " )) def number_conter (n): ...