Created
December 24, 2016 09:31
-
-
Save satouriko/2cdb1370856b97d85f78ec89ffde45ab to your computer and use it in GitHub Desktop.
click_to_co-ordinates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: UTF-8 -*- | |
import tkinter | |
class Tkwin: | |
def __init__(self, root): | |
self.root = root | |
self.frame = tkinter.Frame(root, bd = 2) | |
self.edit = tkinter.Text(self.frame, width = 96, height = 32) | |
self.edit.pack(side = tkinter.LEFT) | |
self.frame.place(y = 50) | |
self.edit.bind('<Button-1>', self.action) | |
def action(self, event): | |
self.edit.insert(tkinter.END, u"窗口坐标x:%d 窗口坐标y:%d\n" % (event.x, event.y)) | |
self.edit.insert(tkinter.END, u"窗口坐标x:%d 窗口坐标y:%d\n" % (event.x_root, event.y_root)) | |
root = tkinter.Tk() | |
window = Tkwin(root) | |
root.minsize(600, 480) | |
root.maxsize(600, 480) | |
# 进入消息循环 | |
root.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment