Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_Zero_Window_Frame_2.py -- sort of hack
- ttt = 'Drag This Label'
- try:
- from Tkinter import *
- except:
- from tkinter import *
- import time
- from ctypes import windll, Structure, c_ulong, byref
- import ctypes
- mask = "#393939"
- cw = 400
- ch = 200
- root = Tk()
- ww = root.winfo_screenwidth()
- hh = root.winfo_screenheight()
- root.geometry(str(ww+10)+"x"+str(hh+10)+"+-10+-32") # to hide the frame
- root.title('Zero Window Frame 2')
- root.attributes("-transparentcolor", mask)
- root.configure(background=mask)
- canvas = Canvas(root, width=cw, height=ch, bg='darkgray')
- canvas.place(x=100,y=100)
- root.pack_propagate(0)
- class POINT(Structure):
- _fields_ = [("x", c_ulong), ("y", c_ulong)]
- def onLeftClick(event):
- xx,yy = event.x,event.y
- if xx > cw-25:
- if yy < 35:
- root.destroy()
- prev[0] = (xx,yy)
- def onLeftDrag(event):
- # xx,yy = event.x, event.y
- pt = POINT()
- windll.user32.GetCursorPos(byref(pt))
- x1, y1 = prev[0]
- x2, y2 = pt.x, pt.y
- t = 'X=%s Y=%s' % (x2,y2)
- canvas.itemconfigure(info,text=t)
- canvas.place(x=x2-x1,y=y2-y1)
- xy = 0
- prev = [0]
- font_a = ('arial', 24, 'bold')
- font_b = ('verdana', 32, 'bold')
- canvas.create_text((cw/2,ch/2), anchor=CENTER, text=ttt, fill='purple', font=font_b)
- exit = canvas.create_text((cw-15,20), text='X', fill='red', font=font_a)
- info = canvas.create_text((cw/2,ch/2-50), anchor=CENTER, text='***', fill = 'black', font=font_a)
- canvas.bind('<B1-Motion>', onLeftDrag )
- canvas.bind('<Button-1>' , onLeftClick)
- canvas.focus()
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement