import customtkinter
import keyboard
import time

#customtkinter.set_widget_scaling(0.9)
#customtkinter.set_window_scaling(0.9)

customtkinter.set_appearance_mode("dark")

app = customtkinter.CTk()
app.title("Crossroad 2023")
app.geometry("1920x1080")
app.grid_rowconfigure(0, weight=1)
app.grid_rowconfigure(1, weight=4)
app.grid_columnconfigure(0, weight=1)


lblPadx = 10
lblPady = 10 
cornerradius = 10
fontName = "Aerial"
fontSize = 150
fontColor = "black"


teamColorBlack = 'black'
teamColorWhite = 'white'
teamColorRed = 'red'
teamColorBlue = 'blue'
teamColorGreen = 'green'
teamColorYellow = 'yellow'
teamColorOrange = 'orange'
teamColorPink = '#FF1493'
teamColorBrown = 'brown'
teamColorPurple = 'purple'

lbl1color = teamColorBlack
lbl2color = teamColorWhite
lbl3color = teamColorRed
lbl4color = teamColorBlue
lbl5color = teamColorGreen
lbl6color = teamColorYellow
lbl7color = teamColorOrange
lbl8color = teamColorPink
lbl9color = teamColorBrown
lbl10color = teamColorPurple

lbl1text = "0"
lbl2text = "0"
lbl3text = "0"
lbl4text = "0"
lbl5text = "0"
lbl6text = "0"
lbl7text = "0"
lbl8text = "0"
lbl9text = "0"
lbl10text = "0"

CounterBlack = 0
CounterWhite = 0
CounterRed = 0
CounterBlue = 0
CounterGreen = 0
CounterYellow = 0
CounterOrange = 0
CounterPink = 0
CounterBrown = 0
CounterPurple = 0

blackActive = True
whiteActive = True
redActive = True
blueActive = True
greenActive = True
yellowActive = True
orangeActive = True
pinkActive = True
brownActive = True
purpleActive = True

buttonClick = 1
timerRunning = False

frame_1 = customtkinter.CTkFrame(app, corner_radius=0, fg_color="grey")
frame_1.grid(row=0, column=0, sticky="nsew")
frame_1.grid_rowconfigure(0, weight=1)
frame_1.grid_columnconfigure(0, weight=1)

frame_2 = customtkinter.CTkFrame(app, corner_radius=0, fg_color="magenta")
frame_2.grid(row=1, column=0, sticky="nsew")
frame_2.grid_rowconfigure((0, 1, 2, 3, 4), weight=1)
frame_2.grid_columnconfigure(0, weight=1)
frame_2.grid_columnconfigure(1, weight=1)

lbl_t = customtkinter.CTkLabel(frame_1, text=lbl1text, corner_radius=cornerradius,fg_color=lbl1color,text_color = 'white', font = (fontName,fontSize))
lbl_t.grid(row=0, column=0, columnspan=2, sticky="nsew", padx=lblPadx, pady=lblPady)

#lbl_1 = customtkinter.CTkLabel("test", fg_color="green")
lbl_1 = customtkinter.CTkLabel(frame_2, text=lbl1text, corner_radius=cornerradius,fg_color=lbl1color,text_color = 'white', font = (fontName,fontSize))
lbl_1.grid(row=0, column=0, sticky="nsew", padx=lblPadx, pady=lblPady)

lbl_2 = customtkinter.CTkLabel(frame_2, text=lbl2text, corner_radius=cornerradius,fg_color=lbl2color,text_color = fontColor, font = (fontName,fontSize))
lbl_2.grid(row=1, column=0, sticky="nsew", padx=lblPadx, pady=lblPady)

lbl_3 = customtkinter.CTkLabel(frame_2, text=lbl3text, corner_radius=cornerradius,fg_color=lbl3color,text_color = fontColor, font = (fontName,fontSize))
lbl_3.grid(row=2, column=0, sticky="nsew", padx=lblPadx, pady=lblPady)

lbl_4 = customtkinter.CTkLabel(frame_2, text=lbl4text, corner_radius=cornerradius,fg_color=lbl4color,text_color = fontColor, font = (fontName,fontSize))
lbl_4.grid(row=3, column=0, sticky="nsew", padx=lblPadx, pady=lblPady)

lbl_5 = customtkinter.CTkLabel(frame_2, text=lbl5text, corner_radius=cornerradius,fg_color=lbl5color,text_color = fontColor, font = (fontName,fontSize))
lbl_5.grid(row=4, column=0, sticky="nsew", padx=lblPadx, pady=lblPady)

lbl_6 = customtkinter.CTkLabel(frame_2, text=lbl6text, corner_radius=cornerradius,fg_color=lbl6color,text_color = fontColor, font = (fontName,fontSize))
lbl_6.grid(row=0, column=1, sticky="nsew", padx=lblPadx, pady=lblPady)

lbl_7 = customtkinter.CTkLabel(frame_2, text=lbl7text, corner_radius=cornerradius,fg_color=lbl7color,text_color = fontColor, font = (fontName,fontSize))
lbl_7.grid(row=1, column=1, sticky="nsew", padx=lblPadx, pady=lblPady)

lbl_8 = customtkinter.CTkLabel(frame_2, text=lbl8text, corner_radius=cornerradius,fg_color=lbl8color,text_color = fontColor, font = (fontName,fontSize))
lbl_8.grid(row=2, column=1, sticky="nsew", padx=lblPadx, pady=lblPady)

lbl_9 = customtkinter.CTkLabel(frame_2, text=lbl9text, corner_radius=cornerradius,fg_color=lbl9color,text_color = fontColor, font = (fontName,fontSize))
lbl_9.grid(row=3, column=1, sticky="nsew", padx=lblPadx, pady=lblPady)

lbl_10 = customtkinter.CTkLabel(frame_2, text=lbl10text, corner_radius=cornerradius,fg_color=lbl10color,text_color = fontColor, font = (fontName,fontSize))
lbl_10.grid(row=4, column=1, sticky="nsew", padx=lblPadx, pady=lblPady)


def ButtonClick(event):
    global buttonClick
    global eventTime
    global eventColor
    global timer
    global timerRunning
    global blackActive
    global whiteActive
    global redActive
    global blueActive
    global greenActive
    global yellowActive
    global orangeActive
    global pinkActive
    global brownActive
    global purpleActive
    global startTime
    global CounterBlack
    global CounterWhite
    global CounterRed
    global CounterBlue
    global CounterGreen
    global CounterYellow
    global CounterOrange
    global CounterPink
    global CounterBrown
    global CounterPurple



    eventTextcolor = "black"
    lblUpdate = False

    if event.name == 'space':
        if timerRunning == False:
            startTime = time.time()
            timerRunning = True
            update()
        else:
            timerRunning =  False
            print(timerRunning)

    if event.name == 'backspace':
        timerRunning = False
        buttonClick = 1
        timer = ""
        eventColor = "white"
        eventTime = ""
        eventTextcolor = "black" 
        CounterBlack = 0
        CounterWhite = 0
        CounterRed = 0
        CounterBlue = 0
        CounterGreen = 0
        CounterYellow = 0
        CounterOrange = 0
        CounterPink = 0
        CounterBrown = 0
        CounterPurple = 0

        
        lbl_1.configure(text=CounterBlack)
        lbl_2.configure(text=CounterWhite)
        lbl_3.configure(text=CounterRed)
        lbl_4.configure(text=CounterBlue)
        lbl_5.configure(text=CounterGreen)
        lbl_6.configure(text=CounterYellow)
        lbl_7.configure(text=CounterOrange)
        lbl_8.configure(text=CounterPink)
        lbl_9.configure(text=CounterBrown) 
        lbl_10.configure(text=CounterPurple)
        
        blackActive = True
        whiteActive = True
        redActive = True
        blueActive = True
        greenActive = True
        yellowActive = True
        orangeActive = True 
        pinkActive = True
        brownActive = True
        purpleActive = True    


    if timerRunning == True:
        if event.name == '1' and blackActive == True:
            CounterBlack += 1
            lbl_1.configure(text=CounterBlack)

        if event.name == '2' and whiteActive == True:
            CounterWhite += 1
            lbl_2.configure(text=CounterWhite)        

        if event.name == '3' and redActive == True:
            CounterRed += 1
            lbl_3.configure(text=CounterRed)

        if event.name == '4' and blueActive == True:
            CounterBlue += 1
            lbl_4.configure(text=CounterBlue)

        if event.name == '5' and greenActive == True:
            CounterGreen += 1
            lbl_5.configure(text=CounterGreen)

        if event.name == '6' and yellowActive == True:
            CounterYellow += 1
            lbl_6.configure(text=CounterYellow)

        if event.name == '7' and orangeActive == True:
            CounterOrange += 1
            lbl_7.configure(text=CounterOrange)
        
        if event.name == '8' and pinkActive == True:
            CounterPink += 1
            lbl_8.configure(text=CounterPink)
         
        if event.name == '9' and brownActive == True:
            CounterBrown += 1
            lbl_9.configure(text=CounterBrown)
         
        if event.name == '0' and purpleActive == True:
            CounterPurple += 1
            lbl_10.configure(text=CounterPurple)  

def update():
    global timer

    if timerRunning == True:
        timer = (round(((time.time()) - startTime), 1))
        lbl_t.configure(text=timer)
        app.after(100, update)
        # schedule next update 1 second later
        
keyboard.on_press(ButtonClick)
app.mainloop()
 

Python Online Compiler

Write, Run & Share Python code online using OneCompiler's Python online compiler for free. It's one of the robust, feature-rich online compilers for python language, supporting both the versions which are Python 3 and Python 2.7. Getting started with the OneCompiler's Python editor is easy and fast. The editor shows sample boilerplate code when you choose language as Python or Python2 and start coding.

Taking inputs (stdin)

OneCompiler's python online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample python program which takes name as input and print your name with hello.

import sys
name = sys.stdin.readline()
print("Hello "+ name)

About Python

Python is a very popular general-purpose programming language which was created by Guido van Rossum, and released in 1991. It is very popular for web development and you can build almost anything like mobile apps, web apps, tools, data analytics, machine learning etc. It is designed to be simple and easy like english language. It's is highly productive and efficient making it a very popular language.

Tutorial & Syntax help

Loops

1. If-Else:

When ever you want to perform a set of operations based on a condition IF-ELSE is used.

if conditional-expression
    #code
elif conditional-expression
    #code
else:
    #code

Note:

Indentation is very important in Python, make sure the indentation is followed correctly

2. For:

For loop is used to iterate over arrays(list, tuple, set, dictionary) or strings.

Example:

mylist=("Iphone","Pixel","Samsung")
for i in mylist:
    print(i)

3. While:

While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.

while condition  
    #code 

Collections

There are four types of collections in Python.

1. List:

List is a collection which is ordered and can be changed. Lists are specified in square brackets.

Example:

mylist=["iPhone","Pixel","Samsung"]
print(mylist)

2. Tuple:

Tuple is a collection which is ordered and can not be changed. Tuples are specified in round brackets.

Example:

myTuple=("iPhone","Pixel","Samsung")
print(myTuple)

Below throws an error if you assign another value to tuple again.

myTuple=("iPhone","Pixel","Samsung")
print(myTuple)
myTuple[1]="onePlus"
print(myTuple)

3. Set:

Set is a collection which is unordered and unindexed. Sets are specified in curly brackets.

Example:

myset = {"iPhone","Pixel","Samsung"}
print(myset)

4. Dictionary:

Dictionary is a collection of key value pairs which is unordered, can be changed, and indexed. They are written in curly brackets with key - value pairs.

Example:

mydict = {
    "brand" :"iPhone",
    "model": "iPhone 11"
}
print(mydict)

Supported Libraries

Following are the libraries supported by OneCompiler's Python compiler

NameDescription
NumPyNumPy python library helps users to work on arrays with ease
SciPySciPy is a scientific computation library which depends on NumPy for convenient and fast N-dimensional array manipulation
SKLearn/Scikit-learnScikit-learn or Scikit-learn is the most useful library for machine learning in Python
PandasPandas is the most efficient Python library for data manipulation and analysis
DOcplexDOcplex is IBM Decision Optimization CPLEX Modeling for Python, is a library composed of Mathematical Programming Modeling and Constraint Programming Modeling