Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #248087

Re: which program can show X/Y position of mouse pointer

From Michael Lange <klappnase@freenet.de>
Newsgroups linux.debian.user
Subject Re: which program can show X/Y position of mouse pointer
Date 2022-05-11 11:30 +0200
Message-ID <ElQPn-eJqg-3@gated-at.bofh.it> (permalink)
References <El9hn-ej4N-1@gated-at.bofh.it> <El9Kp-ejts-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, 9 May 2022 07:09:57 -0400
Dan Ritter <dsr@randomstring.org> wrote:

(...)
> xdotool getmouselocation does it once.
> 
> You may wish to run it via watch in a tiny xterm and make that
> xterm always-on-top.

just for fun I wrote a little Python/Tk script that does what I believe
the OP wants (requires python3-tk):

#############################################################

#!/usr/bin/python3
# -*- coding: utf-8 -*-
'''Shows a tooltip-like window that displays the
x- and y-positions of the mouse pointer on the screen.
Left-click into this window to quit the program.'''

# coordinates of upper left window corner, edit to fit your needs:
WINDOW_X = 0
WINDOW_Y = 0

from tkinter import *
from signal import signal

root = Tk()
root.withdraw()
l = Label(root, text='Mouse position:\nX: 9999   Y:9999',
          width=18, relief='solid', bd=2)
l.pack()
l.is_running = 0
root.wm_overrideredirect(1)
root.wm_geometry('+%d+%d' %(WINDOW_X, WINDOW_Y))

def show_mouse_pos():
    x, y = l.winfo_pointerxy()
    l.configure(text='Mouse position:\nX: %d   Y: %d' % (x, y))
    if l.is_running:
        l.after(100, show_mouse_pos)

def start():
    l.is_running = 1
    l.after(100, show_mouse_pos)

def quit(*args):
    l.is_running = 0
    l.after(200, root.quit)

root.bind('<1>', quit)
for sig in (2, 3, 6, 15):
    signal(sig, quit)
root.update_idletasks()
start()
root.deiconify()
root.mainloop()
root.destroy()

#####################################################

Have a nice day,

Michael

.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

Killing is wrong.
		-- Losira, "That Which Survives", stardate unknown

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

which program can show X/Y position of mouse pointer lou <loushanguan2015@sina.com> - 2022-05-09 13:00 +0200
  Re: which program can show X/Y position of mouse pointer Dan Ritter <dsr@randomstring.org> - 2022-05-09 13:30 +0200
    Re: which program can show X/Y position of mouse pointer lou <loushanguan2015@sina.com> - 2022-05-09 14:00 +0200
      Re: which program can show X/Y position of mouse pointer Dan Ritter <dsr@randomstring.org> - 2022-05-09 15:40 +0200
        Re: which program can show X/Y position of mouse pointer lou <loushanguan2015@sina.com> - 2022-05-10 01:30 +0200
          Re: which program can show X/Y position of mouse pointer David Wright <deblis@lionunicorn.co.uk> - 2022-05-10 03:50 +0200
    Re: which program can show X/Y position of mouse pointer Michael Lange <klappnase@freenet.de> - 2022-05-11 11:30 +0200
      Re: which program can show X/Y position of mouse pointer lou <loushanguan2015@sina.com> - 2022-05-12 04:40 +0200
        Re: which program can show X/Y position of mouse pointer Michael Lange <klappnase@freenet.de> - 2022-05-12 11:00 +0200
  Re: which program can show X/Y position of mouse pointer John Hasler <john@sugarbit.com> - 2022-05-10 02:50 +0200

csiph-web