#πŸ”’ How do i know where x and y positions are on a screen? (need to know for renpy)

38 messages Β· Page 1 of 1 (latest)

versed flicker
#

how do i know the length and width of the screen and know exactly where a certain point on the screen is on a program without having restart a project over and over again till i get the right coordinate

deep narwhalBOT
#

@versed flicker

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

versed flicker
#

.close

#

NOOOO

#

I was gonna help 😭

#

Oh hello xD

#
import tkinter as tk

# Create a root window
root = tk.Tk()

# Get screen dimensions
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()

print(f"Screen width: {screen_width}")
print(f"Screen height: {screen_height}")

# Destroy the window as we only need the dimensions
root.destroy()
#

I thought it was useless to ask here I assumed no one does renpy

#
import pyautogui

# Get the screen size
screen_width, screen_height = pyautogui.size()
print(f"Screen width: {screen_width}")
print(f"Screen height: {screen_height}")

# Get the current position of the mouse
current_mouse_x, current_mouse_y = pyautogui.position()
print(f"Mouse position: ({current_mouse_x}, {current_mouse_y})")
#
import pygame

# Initialize pygame
pygame.init()

# Set up the screen
screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)

# Get screen dimensions
screen_width = screen.get_width()
screen_height = screen.get_height()

print(f"Screen width: {screen_width}")
print(f"Screen height: {screen_height}")

# Main loop to test coordinates
running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
        elif event.type == pygame.MOUSEBUTTONDOWN:
            x, y = pygame.mouse.get_pos()
            print(f"Mouse clicked at: ({x}, {y})")

    # Refresh the screen
    pygame.display.flip()

# Quit pygame
pygame.quit()
versed flicker
#

thank you so so much

#

3 options to pick from

#

i really appreciate it

#

yepp!

#

You are welcome

#

youre awesome

#

thank you bear

#

And never think its useless to ask around here! We always help even with the wierdest problems!

#

.close

night bear
versed flicker
night bear
#

Also the command to close a thread is !close πŸ˜„

versed flicker
#

yeah xD i figured

#

i confuse it with the .close in the mathmatics server

#

!close

versed flicker
#

xD

versed flicker
#

thank you guys

#

take care

#

no worries!!

#

bye

#

have a lovely day/night/evening/afternoon

#

weee

#

!close

deep narwhalBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.