You must be logged in to access this section.
Login/Sign uplet msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
import customtkinter as ctk
from tkinter import messagebox
app = ctk.CTk()
app.title("T_Color")
app.geometry("220x70")
frame = ctk.CTkFrame(app , corner_radius = 0)
frame.pack(fill = "both" , expand = True)
label = ctk.CTkLabel(frame , text = "تغییر تم برنامه" , font = ("B nazanin" , 17))
label.pack(pady = 1)
def changecolor(color):
if color == "روشن":
ctk.set_appearance_mode("Light")
elif color == "تیره":
ctk.set_appearance_mode("Dark")
elif color == "سیستم":
ctk.set_appearance_mode("System")
menu_color = ctk.CTkOptionMenu(frame , values = ["سیستم" , "روشن" , "تیره"] , command = changecolor , font = ("B nazanin" , 15))
menu_color.pack(pady = 1)
app.mainloop()
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body{
text-align: center;
padding: 50px;
}
select{
padding: 10px;
font-size: 16px;
}
</style>
</head>
<body>
<select onchange="changBackgraund(this.value)">
<option value="#ffcccc">red</option>
<option value="#ccffcc">green</option>
<option value="#ccccff">blue</option>
<option value="#ffffff">waite</option>
<option value="#000000">black</option>
</select>
<script>
let changBackgraund=(color)=>{
document.body.style.backgroundColor=color
}
</script>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Change-Color</title>
<style>
body{
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.note{
font-family: sans-serif , Arial;
font-size: 2rem;
font-weight: bold;
border: 4px solid black;
border-radius: 10px;
text-shadow: 5px 5px 8px #66e666;
margin: 100px;
padding: 20px;
}
.color{
text-align: center;
width: 150px;
height: 50px;
padding: 5px;
font-family: sans-serif , Arial;
font-weight: bolder;
text-shadow: 5px 5px 8px #66e666;
border: 5px solid black;
border-radius: 10px;
}
</style>
</head>
<body>
<div class="note">
<h1>please pick color</h1>
</div>
<div>
<select class="color">
<option value="white">White</option>
<option value="crimson">Crimson</option>
<option value="forestgreen">Forestgreen</option>
<option value="dodgerblue">Dodgerblue</option>
<option value="aqua">Aqua</option>
<option value="gray">Gray</option>
<option value="chocolate">Chocolate</option>
<option value="goldenrod">Goldenrod</option>
</select>
</div>
<script>
const grabColor = document.querySelector(".color");
grabColor.addEventListener('change' , function (){
const selectedColor = grabColor.value;
grabColor.style.backgroundColor = selectedColor;
if (selectedColor){
document.body.style.backgroundColor = selectedColor;
}
});
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Practice</title>
<style>
.color {
width: 100px;
height: 100px;
}
#red {
background-color: red;
}
#green {
background-color: green;
}
#blue {
background-color: blue;
}
#white {
background-color: white;
}
#black {
background-color: black;
}
</style>
</head>
<body id="bg">
<h1>Practices</h1>
<p>Select a color :</p>
<div id="red" class="color"> red </div>
<div id="green" class="color"> green </div>
<div id="blue" class="color"> blue </div>
<div id="white" class="color"> white </div>
<div id="black" class="color"> black </div>
<script>
document.getElementById("red").addEventListener("click",() => {
document.getElementById("bg").style.backgroundColor = "red"
})
document.getElementById("green").addEventListener("click",() => {
document.getElementById("bg").style.backgroundColor = "green"
})
document.getElementById("blue").addEventListener("click",() => {
document.getElementById("bg").style.backgroundColor = "blue"
})
document.getElementById("white").addEventListener("click",() => {
document.getElementById("bg").style.backgroundColor = "white"
})
document.getElementById("black").addEventListener("click",() => {
document.getElementById("bg").style.backgroundColor = "black"
})
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BOM</title>
</head>
<body>
<select id="changeColor">
<option value="blue">Blue</option>
<option value="green">Green</option>
<option value=""></option>
</select>
<button id="submitBtn">ثبت انتخاب</button>
<script>
const bgcolorchange = document.getElementById("changeColor");
const submitBtn = document.getElementById("submitBtn");
const body = document.body;
bgcolorchange.addEventListener("change", function () {
const selectedColor = this.value;
if (selectedColor === "blue") {
body.style.backgroundColor = "blue";
}
});
submitBtn.addEventListener("click", function () {
const selectedValue = bgcolorchange.value;
if (selectedValue === "blue") {
body.style.backgroundColor = "blue";
} else if (selectedValue === "green") {
body.style.backgroundColor = "green";
} else if (selectedValue === "black") {
body.style.backgroundColor = "black";
}
});
</script>
</body>
</html>
package opp;
import java.util.Scanner;
public class changecolor {
public static void print(Object message) {
System.out.println(message);
}
public static final String RESET = "\u001B[0m";
public static final String BG_BLACK = "\u001B[40m";
public static final String BG_RED = "\u001B[41m";
public static final String BG_GREEN = "\u001B[42m";
public static final String BG_YELLOW = "\u001B[43m";
public static final String BG_BLUE = "\u001B[44m";
public static final String BG_PURPLE = "\u001B[45m";
public static final String BG_CYAN = "\u001B[46m";
public static final String BG_WHITE = "\u001B[47m";
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("For change color :"
+ "\n1-blue" + "\n2-red" + "\n3-yellow\nPlease Enter the number:");
int x = sc.nextInt();
if(x==1) {
print(BG_BLUE + "Changed background color to blue");
}else if(x==2) {
print(BG_RED + "Changed background color to red");
}else if(x==3) {
print(BG_YELLOW + "Changed background color to yellow");
}
}
}
from tkinter import *
from PIL import Image,ImageTk
class Backgrand:
def __init__(self):
self.windo = None
self.bnt_black = None
self.bnt_blue = None
self.bnt_green = None
self.btn_white = None
self.btn_pink = None
self.btn_close = None
self.img = None
self.icon = None
def close_btn_enter(self,e):
self.btn_close.config(background="brown",fg="white",cursor="hand2")
def close_btn_leave(self,e):
self.btn_close.config(background="purple",fg="white",cursor="arrow")
def close_windo(self):
self.windo.destroy()
def bg_color(self,color):
self.windo.config(background=color)
def windo_bg(self):
self.windo = Tk()
self.windo.title("backgrand")
self.windo.geometry("300x300")
self.windo.resizable(False,False)
self.img = Image.open("image/1157969.png")
self.icon = ImageTk.PhotoImage(self.img)
self.windo.iconphoto(False,self.icon)
self.bnt_black = Button(self.windo,bg="black",width=5,command=lambda:self.bg_color("black"))
self.bnt_black.pack(padx=5,pady=5)
self.bnt_blue = Button(self.windo,bg="blue",width=5,command=lambda:self.bg_color("blue"))
self.bnt_blue.pack(padx=5,pady=5)
self.bnt_green = Button(self.windo,bg="green",width=5,command=lambda:self.bg_color("green"))
self.bnt_green.pack(padx=5,pady=5)
self.btn_white = Button(self.windo,bg="white",width=5,command=lambda:self.bg_color("white"))
self.btn_white.pack(padx=5,pady=5)
self.btn_pink = Button(self.windo,bg="pink",width=5,command=lambda:self.bg_color("pink"))
self.btn_pink.pack(padx=5,pady=5)
self.btn_close = Button(self.windo,text="close",font=("arial",16),bg="purple",fg="white",width=5,command=self.close_windo)
self.btn_close.pack(padx=10,pady=10)
self.btn_close.bind("<Enter>",self.close_btn_enter)
self.btn_close.bind("<Leave>",self.close_btn_leave)
self.windo.mainloop()
app = Backgrand()
app.windo_bg()
Submitting answers is currently unavailable.
You must be logged in to access this section.
Login/Sign up If you don’t understand the exercise or can’t solve it for any reason, that’s completely
normal—don’t worry 😊
Try checking out easier exercises and reviewing different answers
submitted by others. Gradually, you can move on to more challenging exercises. Also, your answer
might be correct even if it’s different from others.