From 07df8ff71ea5b61f4eb060aa6714feced743ee3b Mon Sep 17 00:00:00 2001 From: kromskii2 <146603192+kromskii2@users.noreply.github.com> Date: Mon, 25 Mar 2024 20:06:05 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A1=20=D1=8D=D1=82=D0=BE=D0=B9=20=D0=BC?= =?UTF-8?q?=D0=BE=D0=B4=D0=B8=D1=84=D0=B8=D0=BA=D0=B0=D1=86=D0=B8=D0=B5?= =?UTF-8?q?=D0=B9=20=D0=BE=D0=BA=D0=BD=D0=BE=20=D0=BF=D1=80=D0=B8=D0=BB?= =?UTF-8?q?=D0=BE=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B1=D1=83=D0=B4=D0=B5?= =?UTF-8?q?=D1=82=D1=80=D0=B0=D1=81=D0=BF=D0=BE=D0=BB=D0=B0=D0=B3=D0=B0?= =?UTF-8?q?=D1=82=D1=8C=D1=81=D1=8F=20=D0=B2=20=D1=86=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D1=80=D0=B5=20=D1=8D=D0=BA=D1=80=D0=B0=D0=BD=D0=B0=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B8=20=D0=B5=D0=B3=D0=BE=20=D0=B7=D0=B0=D0=BF=D1=83?= =?UTF-8?q?=D1=81=D0=BA=D0=B5.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With this modification, the application window will be positioned in the center of the screen when it is launched. --- Menu.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Menu.py b/Menu.py index 5a1a811..069e6ac 100644 --- a/Menu.py +++ b/Menu.py @@ -9,13 +9,22 @@ class RoundedMenuApp: self.root = tk.Tk() self.root.title("Rounded Menu") - self.root.geometry(f"{width}x{height}") + + # Get the screen width and height + screen_width = self.root.winfo_screenwidth() + screen_height = self.root.winfo_screenheight() + + # Calculate x and y position for the Tk root window + x = (screen_width / 2) - (width / 2) + y = (screen_height / 2) - (height / 2) + + self.root.geometry(f"{width}x{height}+{int(x)}+{int(y)}") # Set geometry with position self.canvas = tk.Canvas(self.root, width=width, height=height, bg="white", highlightthickness=0) self.canvas.pack() self.draw_rounded_corners() - self.create_youtube_button() # Создание кнопки YouTube + self.create_youtube_button() def draw_rounded_corners(self): x0, y0 = 0, 0 @@ -35,12 +44,12 @@ class RoundedMenuApp: youtube_button.place(relx=1, rely=1, anchor="se") def open_youtube(self): - webbrowser.open_new_tab("https://www.youtube.com/") # Открыть ссылку в браузере в новой вкладке + webbrowser.open_new_tab("https://www.youtube.com/") def run(self): self.root.mainloop() -# Создание и запуск приложения +# Create and run the application app = RoundedMenuApp(width=646, height=396, corner_radius=30) app.run()