Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Mouse-position/Python/mouse-position-1.py
Normal file
19
Task/Mouse-position/Python/mouse-position-1.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import Tkinter as tk
|
||||
|
||||
def showxy(event):
|
||||
xm, ym = event.x, event.y
|
||||
str1 = "mouse at x=%d y=%d" % (xm, ym)
|
||||
# show cordinates in title
|
||||
root.title(str1)
|
||||
# switch color to red if mouse enters a set location range
|
||||
x,y, delta = 100, 100, 10
|
||||
frame.config(bg='red'
|
||||
if abs(xm - x) < delta and abs(ym - y) < delta
|
||||
else 'yellow')
|
||||
|
||||
root = tk.Tk()
|
||||
frame = tk.Frame(root, bg= 'yellow', width=300, height=200)
|
||||
frame.bind("<Motion>", showxy)
|
||||
frame.pack()
|
||||
|
||||
root.mainloop()
|
||||
13
Task/Mouse-position/Python/mouse-position-2.py
Normal file
13
Task/Mouse-position/Python/mouse-position-2.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#simple way of ,get cursor xy data
|
||||
|
||||
from Tkinter import *
|
||||
win=Tk()
|
||||
win.geometry("200x300")
|
||||
def xy(event):
|
||||
xm, ym = event.x, event.y
|
||||
xy_data = "x=%d y=%d" % (xm, ym)
|
||||
lab=Label(win,text=xy_data)
|
||||
lab.grid(row=0,column=0)
|
||||
|
||||
win.bind("<Motion>",xy)
|
||||
mainloop()
|
||||
Loading…
Add table
Add a link
Reference in a new issue