Typing Speed Test Application

from tkinter import *

import ctypes

import random

import tkinter

ctypes.windll.shcore.SetProcessDpiAwareness(1)

storage = Tk()

storage.title('Typing Speed Test')

storage.geometry('1400x700')

storage.option_add("*Label.Font", "consolas 30")

storage.option_add("*Button.Font", "consolas 30")

def handlingLabels():

    random_selection = [

        'Software engineering is the branch of computer science that deals with the design, development, testing, and maintenance of software applications. Software engineers apply engineering principles and knowledge of programming languages to build software solutions for end users.',

        'A web developer is a programmer who develops World Wide Web applications using a client–server model. The applications typically use HTML, CSS, and JavaScript in the client, and any general-purpose programming language in the server. HTTP is used for communications between client and server.'

    ]

    text = random.choice(random_selection).lower()

    splitPoint = 0

    global nameLabelLeft

    nameLabelLeft = Label(storage, text=text[0:splitPoint], fg='green')

    nameLabelLeft.place(relx=0.5, rely=0.5, anchor=E)

    global nameLabelRight

    nameLabelRight = Label(storage, text=text[splitPoint:])

    nameLabelRight.place(relx=0.5, rely=0.5, anchor=W)

    global currentAlphabetLabel

    currentAlphabetLabel = Label(storage, text=text[splitPoint], fg='grey')

    currentAlphabetLabel.place(relx=0.5, rely=0.6, anchor=N)

    global secondsLeft

    headingLabel = Label(storage, text=f'CopyAssignment - Typing Speed Test', fg='blue')

    headingLabel.place(relx=0.5, rely=0.2, anchor=S)

    secondsLeft = Label(storage, text=f'0 Seconds', fg='red')

    secondsLeft.place(relx=0.5, rely=0.4, anchor=S)

    global writeAble

    writeAble = True

    storage.bind('<Key>', handlekeyPress)

    global secondsPassed

    secondsPassed = 0

    storage.after(60000, stopGame)

    storage.after(1000, timeAddition)

def stopGame():

    global writeAble

    writeAble = False

    amountWords = len(nameLabelLeft.cget('text').split(' '))

    secondsLeft.destroy()

    currentAlphabetLabel.destroy()

    nameLabelRight.destroy()

    nameLabelLeft.destroy()

    global labelOfResult

    labelOfResult = Label(storage, text=f'Words per Minute (WPM): {amountWords}', fg='black')

    labelOfResult.place(relx=0.5, rely=0.4, anchor=CENTER)

    global showcaseResults

    showcaseResults = Button(storage, text=f'Retry', command=restartGame)

    showcaseResults.place(relx=0.5, rely=0.6, anchor=CENTER)

def restartGame():

    labelOfResult.destroy()

    showcaseResults.destroy()

    handlingLabels()

def timeAddition():

    global secondsPassed

    secondsPassed += 1

    secondsLeft.configure(text=f'{secondsPassed} Seconds')

    if writeAble:

        storage.after(1000, timeAddition)

def handlekeyPress(event=None):

    try:

        if event.char.lower() == nameLabelRight.cget('text')[0].lower():

            nameLabelRight.configure(text=nameLabelRight.cget('text')[1:])

            nameLabelLeft.configure(text=nameLabelLeft.cget('text') + event.char.lower())

            currentAlphabetLabel.configure(text=nameLabelRight.cget('text')[0])

    except tkinter.TclError:

        pass

handlingLabels()

storage.mainloop()


Open Games Con



 Open Games Con

(The Main Gaming,Art, Tech And Blockchain Event In Europe) 

 Zaragoza, Spain 2023 July, 21-22-23th

Brochure

Drawing Application

from tkinter import *

from tkinter.ttk import Scale

from tkinter import colorchooser,filedialog,messagebox

import PIL.ImageGrab as ImageGrab

class Draw():

    def __init__(self,root):

        self.root =root

        self.root.title("Painter")

        self.root.configure(background="white")

        self.pointer= "black"

        self.erase="white"    

        text=Text(root)

        text.tag_configure("tag_name", justify='center', font=('arial',25),background='#292826',foreground='orange')

        text.insert("1.0", "Drawing Application ")

        text.tag_add("tag_name", "1.0", "end")

        text.pack()

        self.pick_color = LabelFrame(self.root,text='Colors',font =('arial',15),bd=5,relief=RIDGE,bg="white")

        self.pick_color.place(x=0,y=40,width=90,height=185)

        colors = ['blue','red','green', 'orange','violet','black','yellow','purple','pink','gold','brown','indigo']

        i=j=0

        for color in colors:

            Button(self.pick_color,bg=color,bd=2,relief=RIDGE,width=3,command=lambda col=color:self.select_color(col)).grid(row=i,column=j)

            i+=1

            if i==6:

                i=0

                j=1

        self.eraser_btn= Button(self.root,text="Eraser",bd=4,bg='white',command=self.eraser,width=9,relief=RIDGE)

        self.eraser_btn.place(x=0,y=197)

        self.clear_screen= Button(self.root,text="Clear Screen",bd=4,bg='white',command= lambda : self.background.delete('all'),width=9,relief=RIDGE)

        self.clear_screen.place(x=0,y=227)

        self.save_btn= Button(self.root,text="ScreenShot",bd=4,bg='white',command=self.save_drawing,width=9,relief=RIDGE)

        self.save_btn.place(x=0,y=257)

        self.bg_btn= Button(self.root,text="Background",bd=4,bg='white',command=self.canvas_color,width=9,relief=RIDGE)

        self.bg_btn.place(x=0,y=287)

        self.pointer_frame= LabelFrame(self.root,text='size',bd=5,bg='white',font=('arial',15,'bold'),relief=RIDGE)

        self.pointer_frame.place(x=0,y=320,height=200,width=70)

        self.pointer_size =Scale(self.pointer_frame,orient=VERTICAL,from_ =48 , to =0, length=168)

        self.pointer_size.set(1)

        self.pointer_size.grid(row=0,column=1,padx=15)

        self.background = Canvas(self.root,bg='white',bd=5,relief=GROOVE,height=470,width=680)

        self.background.place(x=80,y=40)

        self.background.bind("<B1-Motion>",self.paint) 

    def paint(self,event):       

        x1,y1 = (event.x-2), (event.y-2)  

        x2,y2 = (event.x+2), (event.y+2)  

        self.background.create_oval(x1,y1,x2,y2,fill=self.pointer,outline=self.pointer,width=self.pointer_size.get())

    def select_color(self,col):

        self.pointer = col

    def eraser(self):

        self.pointer= self.erase

    def canvas_color(self):

        color=colorchooser.askcolor()

        self.background.configure(background=color[1])

        self.erase= color[1]

    def save_drawing(self):

        try:

            file_ss =filedialog.asksaveasfilename(defaultextension='jpg')

            x=self.root.winfo_rootx() + self.background.winfo_x()

            y=self.root.winfo_rooty() + self.background.winfo_y()

            x1= x + self.background.winfo_width() 

            y1= y + self.background.winfo_height()

            ImageGrab.grab().crop((x , y, x1, y1)).save(file_ss)

            messagebox.showinfo('Screenshot Successfully Saved as' + str(file_ss))

        except:

            print("Error in saving the screenshot")

if __name__ =="__main__":

    root = Tk()

    p= Draw(root)

    root.mainloop()

Fire detection

import cv2

import numpy as np

import matplotlib.pyplot as plt

live_camera = cv2.VideoCapture(0)

while(live_camera.isOpened()):

    ret, frame = live_camera.read()

    cv2.imshow("Fire Detection",frame)

    if cv2.waitKey(10) == 27:

        break

img_RGB = cv2.cvtColor(frame,cv2.COLOR_BGR2RGB)

img_cap = plt.imshow(img_RGB)

plt.show()

live_camera.release()

cv2.destroyAllWindows()


Notepad

import tkinter

import os

from tkinter import *

from tkinter.messagebox import *

from tkinter.filedialog import *

class Notepad:

__root = Tk()

__thisWidth = 300

__thisHeight = 300

__thisTextArea = Text(__root)

__thisMenuBar = Menu(__root)

__thisFileMenu = Menu(__thisMenuBar, tearoff=0)

__thisEditMenu = Menu(__thisMenuBar, tearoff=0)

__thisHelpMenu = Menu(__thisMenuBar, tearoff=0)

__thisScrollBar = Scrollbar(__thisTextArea)

__file = None

def __init__(self,**kwargs):

try:

self.__root.wm_iconbitmap("Notepad.ico")

except:

pass

try:

self.__thisWidth = kwargs['width']

except KeyError:

pass

try:

self.__thisHeight = kwargs['height']

except KeyError:

pass

self.__root.title("Untitled - Notepad")

screenWidth = self.__root.winfo_screenwidth()

screenHeight = self.__root.winfo_screenheight()

left = (screenWidth / 2) - (self.__thisWidth / 2)

top = (screenHeight / 2) - (self.__thisHeight /2)

self.__root.geometry('%dx%d+%d+%d' % (self.__thisWidth,

self.__thisHeight,

left, top))

self.__root.grid_rowconfigure(0, weight=1)

self.__root.grid_columnconfigure(0, weight=1)

self.__thisTextArea.grid(sticky = N + E + S + W)

self.__thisFileMenu.add_command(label="New",

command=self.__newFile)

self.__thisFileMenu.add_command(label="Open",

command=self.__openFile)

self.__thisFileMenu.add_command(label="Save",

command=self.__saveFile)

self.__thisFileMenu.add_separator()

self.__thisFileMenu.add_command(label="Exit",

command=self.__quitApplication)

self.__thisMenuBar.add_cascade(label="File",

menu=self.__thisFileMenu)

self.__thisEditMenu.add_command(label="Cut",

command=self.__cut)

self.__thisEditMenu.add_command(label="Copy",

command=self.__copy)

self.__thisEditMenu.add_command(label="Paste",

command=self.__paste)

self.__thisMenuBar.add_cascade(label="Edit",

menu=self.__thisEditMenu)

self.__thisHelpMenu.add_command(label="About Notepad",

command=self.__showAbout)

self.__thisMenuBar.add_cascade(label="Help",

menu=self.__thisHelpMenu)

self.__root.config(menu=self.__thisMenuBar)

self.__thisScrollBar.pack(side=RIGHT,fill=Y)

self.__thisScrollBar.config(command=self.__thisTextArea.yview)

self.__thisTextArea.config(yscrollcommand=self.__thisScrollBar.set)

def __quitApplication(self):

self.__root.destroy()

def __showAbout(self):

showinfo("Notepad","Mrinal Verma")

def __openFile(self):

self.__file = askopenfilename(defaultextension=".txt",

filetypes=[("All Files","*.*"),

("Text Documents","*.txt")])

if self.__file == "":

self.__file = None

else:

self.__root.title(os.path.basename(self.__file) + " - Notepad")

self.__thisTextArea.delete(1.0,END)

file = open(self.__file,"r")

self.__thisTextArea.insert(1.0,file.read())

file.close()

def __newFile(self):

self.__root.title("Untitled - Notepad")

self.__file = None

self.__thisTextArea.delete(1.0,END)

def __saveFile(self):

if self.__file == None:

self.__file = asksaveasfilename(initialfile='Untitled.txt',

defaultextension=".txt",

filetypes=[("All Files","*.*"),

("Text Documents","*.txt")])

if self.__file == "":

self.__file = None

else:

file = open(self.__file,"w")

file.write(self.__thisTextArea.get(1.0,END))

file.close()

self.__root.title(os.path.basename(self.__file) + " - Notepad")

else:

file = open(self.__file,"w")

file.write(self.__thisTextArea.get(1.0,END))

file.close()

def __cut(self):

self.__thisTextArea.event_generate("<<Cut>>")

def __copy(self):

self.__thisTextArea.event_generate("<<Copy>>")

def __paste(self):

self.__thisTextArea.event_generate("<<Paste>>")

def run(self):

self.__root.mainloop()

notepad = Notepad(width=600,height=400)

notepad.run()