WEBLEB
Home
Editor
Login
Pro
English
English
Français
Español
Português
Deutsch
Italiano
हिंदी
пон
58
mironovbogdan341
Open In Editor
Publish Your Code
HTML
Copy
CSS
Copy
<!-- Replace with your CSS Code (Leave empty if not needed) -->
JS
Copy
import tkinter as tk # Function to change the background color based on RGB values def change_color(r, g, b): color = f'#{r:02x}{g:02x}{b:02x}' # Convert RGB to hex root.config(bg=color) # Change the background color # Create the main window root = tk.Tk() root.title('RGB Background Color') root.geometry('300x200') root.config(bg='black') # Set initial background to black # Create a button to change the color button = tk.Button(root, text='Change Color', command=lambda: change_color(255, 0, 0)) # Change to red button.pack(pady=20) # Start the GUI event loop root.mainloop()