Friday, September 8, 2023

The_App

 It was all a lie; I really prefer a pink background.

So I have working code on my app., and an interface. I need

to work on the look of things a bit more...

                                                            


import tkinter as tk

root = tk.Tk()
root.configure(bg='pink')

# setting the windows size
root.geometry("800x400")

# declaring variables
# for storing code and opacity
red_var = tk.IntVar(value="")
green_var = tk.IntVar(value="")
blue_var = tk.IntVar(value="")
opacity_var = tk.DoubleVar(value="")

res_red = ""
res_green = ""
res_blue = ""
label_res = tk.Label(root, text=" ")

# defining a function that will
# get the code and opacity.

def submit():

opacity =(opacity_var.get())

red = (red_var.get())
res_red = round(255 - opacity*(255 - red))
green = (green_var.get())
res_green = round(255 - opacity*(255 - green))
blue = (blue_var.get())
res_blue = round(255 - opacity*(255 - blue))

label_res.config(text=f"The code is : " + str(res_red) + " " + str(res_green)+" "+ str(res_blue))


print("The code is : ", str(res_red) +" "+str(res_green)+" "+str(res_blue))


# creating a label for
# code using widget Label
instruction_label = tk.Label(root,text="Please enter RGBA values:")


# creating a entry for input
# channels using widget Entry
red_entry = tk.Entry(root, textvariable=red_var, font=('calibre', 10, 'normal'))
green_entry = tk.Entry(root, textvariable=green_var, font=('calibre', 10, 'normal'))
blue_entry = tk.Entry(root, textvariable=blue_var, font=('calibre', 10, 'normal'))
opacity_entry = tk.Entry(root, textvariable=opacity_var, font=('calibre', 10, 'normal'))


# creating a button using the widget
# that will call the submit function.
sub_btn = tk.Button(root, text='Submit', command=submit)


# placing the label and entry in
# the required position using the place
# method

instruction_label.place(x=50, y=50)
red_entry.place(x=50, y=75)

green_entry.place(x=150, y=75)
blue_entry.place(x=250, y=75)
opacity_entry.place(x=350, y=75)
sub_btn.place(x=50, y=175)

label_res.place(x=50, y=225)

# performing an infinite loop
# for the window to display
root.mainloop()

Adding line 27 would disable the cursor once submit is pressed. Not sure this is the best

approach.

                                                                             


           

No comments: