Replies: 6 comments 30 replies
-
Features: Drag window precisely: ✅ |
Beta Was this translation helpful? Give feedback.
-
Windows11 in this moment: >_< |
Beta Was this translation helpful? Give feedback.
-
hi @Akascape very nice fully custom window. one little bug i found was when i trigger button_max ounce the app just vanish from the taskbar, edit : i found out how to get over it by adding this into the code. but will only work on windows #library to import
from ctypes import windll
#variable to create
GWL_EXSTYLE=-20
WS_EX_APPWINDOW=0x00040000
WS_EX_TOOLWINDOW=0x00000080
#function to add
def set_appwindow(root):
hwnd = windll.user32.GetParent(root.winfo_id())
style = windll.user32.GetWindowLongW(hwnd, GWL_EXSTYLE)
style = style & ~WS_EX_TOOLWINDOW
style = style | WS_EX_APPWINDOW
res = windll.user32.SetWindowLongW(hwnd, GWL_EXSTYLE, style)
# re-assert the new window style
root.wm_withdraw()
root.after(10, lambda: root.wm_deiconify())
#only add the line below the commented message
def max_window():
if resizable==True:
global fullscreen
if fullscreen==False:
root.update_idletasks()
root.overrideredirect(False)
root.wm_state('zoomed')
root.overrideredirect(True)
#add this line
root.after(10, lambda: set_appwindow(root))
root.state('normal')
fullscreen=True
else:
root.geometry(f'+{x}+{y}')
fullscreen=False |
Beta Was this translation helpful? Give feedback.
-
Can you please show only the part that is responsible for the rounded corners? My application will not have a way to minimize the window or maximize it. This is a very cool decision, I was always amazed at such people. |
Beta Was this translation helpful? Give feedback.
-
Hello it's me from your youtube comments Rosa_God and i have a problem when i put my code into class its not finding definitions can you help me please? import customtkinter
from tkinter import *
from ctypes import windll
import tkinter as tk
import os
from PIL import Image, ImageTk
from pathlib import Path
# from tkinter import *
# Explicit imports to satisfy Flake8
from tkinter import Tk, Canvas, Entry, Text, Button, PhotoImage
class Main_Win():
customtkinter.set_appearance_mode("dark")
customtkinter.set_default_color_theme("blue")
# Template Options
app_title = "" # Application name
geometry = "1000x600" # Enter window geometry
title_bar_color = "grey10" # Specify the color of top bar
title_color = "grey" # Title label color
window_color = None # fg_color of window
resizable = True # Resize window dynamically
round_corner = 20 # adjust corner radius
def oldxyset(event):
global oldx, oldy
oldx = event.x
oldy = event.y
def move_window(event):
global x, y
if fullscreen==False:
y=event.y_root - oldy
x=event.x_root - oldx
root.geometry(f'+{x}+{y}')
def close_window():
root.destroy()
def frame_mapped(e):
root.update_idletasks()
root.overrideredirect(True)
root.state('normal')
def min_window():
root.update_idletasks()
root.overrideredirect(False)
root.state('iconic')
def max_window():
if resizable==True:
global fullscreen
if fullscreen==False:
root.update_idletasks()
root.overrideredirect(False)
root.wm_state('zoomed')
root.after(10, lambda: set_appwindow(root))
root.overrideredirect(True)
root.state('normal')
fullscreen=True
else:
root.geometry(f'+{x}+{y}')
fullscreen=False
def set_appwindow(root):
hwnd = windll.user32.GetParent(root.winfo_id())
style = windll.user32.GetWindowLongW(hwnd, GWL_EXSTYLE)
style = style & ~WS_EX_TOOLWINDOW
style = style | WS_EX_APPWINDOW
res = windll.user32.SetWindowLongW(hwnd, GWL_EXSTYLE, style)
root.wm_withdraw()
root.after(10, lambda: root.wm_deiconify())
def change_cursor(event):
if (event.x in range(app.winfo_width()-10, app.winfo_width())
and event.y in range(app.winfo_height()-10, app.winfo_height())):
root.config(cursor="size_nw_se")
else:
root.config(cursor="")
def resize(event):
if root.cget('cursor')=="size_nw_se":
if event.x>100 and event.y>100:
root.geometry(f"{event.x_root-x}x{event.y_root-y}")
root = customtkinter.CTk()
root.overrideredirect(1)
root.config(background='#000001')
root.attributes("-transparentcolor", "#000001")
root.geometry(geometry)
root.grid_columnconfigure(0, weight=1)
root.grid_rowconfigure(0, weight=1)
root.bind("<1>", lambda event: event.widget.focus_set())
x = root.winfo_x()
y = root.winfo_y()
fullscreen = False
GWL_EXSTYLE = -20
WS_EX_APPWINDOW = 0x00040000
WS_EX_TOOLWINDOW = 0x00000080
frame_top = customtkinter.CTkFrame(root, corner_radius=round_corner, fg_color=title_bar_color, background_corner_colors=("#000001","#000001","grey10","grey10"))
frame_top.grid(sticky="nwe", row=0)
frame_top.grid_columnconfigure(0, weight=1)
frame_top.grid_rowconfigure(0, weight=1)
frame_top.bind("<ButtonPress-1>", oldxyset)
frame_top.bind("<B1-Motion>", move_window)
app = customtkinter.CTkFrame(root, corner_radius=round_corner, bg_color="#000001", fg_color=window_color, background_corner_colors=(customtkinter.ThemeManager.theme["CTkFrame"]["fg_color"],customtkinter.ThemeManager.theme["CTkFrame"]["fg_color"],None,None))
app.grid(sticky="nsew", row=0,pady=(28,0))
app.bind("<Map>",frame_mapped)
title_label = customtkinter.CTkLabel(frame_top, width=1, height=60,
text=app_title, anchor="n",
text_color=title_color)
title_label.grid(row=0, sticky="w", padx=150, pady=8)
title_label.bind("<ButtonPress-1>", oldxyset)
title_label.bind("<B1-Motion>", move_window)
button_close = customtkinter.CTkButton(frame_top, corner_radius=10, width=10, height=10, text="", hover_color="dark red", fg_color="red",command=close_window)
button_close.grid(row=0, column=2, sticky="ne", padx=(0,15), pady=10)
button_close.configure(cursor="arrow")
button_min = customtkinter.CTkButton(frame_top, corner_radius=10, width=10, height=10, text="", hover_color="light green", fg_color="green",
command=min_window)
button_min.grid(row=0, column=1, sticky="ne", padx=(0,10) ,pady=10)
button_min.configure(cursor="arrow")
OUTPUT_PATH = Path(__file__).parent
ASSETS_PATH = OUTPUT_PATH / Path(r"C:\Users\Rosa\Desktop\coding\AURA SPOOFER 2.0\Python Tkinter Modern GUI login and sign up form\main page figma — kopia\build\assets\frame0")
def relative_to_assets(path: str) -> Path:
return ASSETS_PATH / Path(path)
canvas = Canvas(
app,
bg = "#000001",
height = 572,
width = 1000,
bd = 0,
highlightthickness = 0,
relief = "ridge"
)
canvas.place(x = 0, y = 0)
image_image_1 = PhotoImage(
file=relative_to_assets("image_1.png"))
image_1 = canvas.create_image(
500.0,
285.0,
image=image_image_1
)
image_image_2 = PhotoImage(
file=relative_to_assets("image_2.png"))
image_2 = canvas.create_image(
40.0,
40.0,
image=image_image_2
)
canvas.create_text(
80.0,
25.0,
anchor="nw",
text="Aura Spoofer 2.0",
fill="#FFFFFF",
font=("Inter ExtraBold", 20 * -1)
)
image_image_3 = PhotoImage(
file=relative_to_assets("image_3.png"))
image_3 = canvas.create_image(
739.0,
539.0,
image=image_image_3
)
image_image_4 = PhotoImage(
file=relative_to_assets("image_4.png"))
image_4 = canvas.create_image(
826.0,
539.0,
image=image_image_4
)
image_image_5 = PhotoImage(
file=relative_to_assets("image_5.png"))
image_5 = canvas.create_image(
500.0,
300.0,
image=image_image_5
)
button_image_1 = PhotoImage(
file=relative_to_assets("button_1.png"))
button_1 = Button(
image=button_image_1,
borderwidth=0,
highlightthickness=0,
command=lambda: print("button_1 clicked"),
relief="flat",
bg="#311e4d",
activebackground="#311e4d"
)
button_1.place(
x=425.0,
y=395.0,
width=150.0,
height=46.0
)
button_image_2 = PhotoImage(
file=relative_to_assets("button_2.png"))
button_2 = Button(
image=button_image_2,
borderwidth=0,
highlightthickness=0,
command=lambda: print("button_2 clicked"),
relief="flat",
bg="#2a1647",
activebackground="#2a1647"
)
button_2.place(
x=19.0,
y=535.0,
width=43.0,
height=42.0
)
root.mainloop() |
Beta Was this translation helpful? Give feedback.
-
Hello Please see my customtkitnter mdoern spoitfy project here sir |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is a template code for those users who are using windows 10 and want round corners in their main window!
Classic Theme
Modern Theme
Code Template:
You are free to use this template :)
CTk Version: 5.0
Beta Was this translation helpful? Give feedback.
All reactions