С этой модификацией окно приложения будетрасполагаться в центре экрана при его запуске.
With this modification, the application window will be positioned in the center of the screen when it is launched.
This commit is contained in:
1 parent
4d41b160a3
commit
07df8ff71e
1 file changed
+13
-4
@@ -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()
|
||||
Reference in new issue
Block a user