1个回答
展开全部
给你百度一个吧
import Tkinter
root = Tkinter.Tk()
root.overrideredirect(True)
#root.attributes("-alpha", 0.3)窗口透明度70 %
root.attributes("-alpha", 0.4)#窗口透明度60 %
root.geometry("300x200+10+10")
canvas = Tkinter.Canvas(root)
canvas.configure(width = 300)
canvas.configure(height = 200)
canvas.configure(bg = "blue")
canvas.configure(highlightthickness = 0)
canvas.pack()
x, y = 0, 0
def move(event):
global x,y
new_x = (event.x-x)+root.winfo_x()
new_y = (event.y-y)+root.winfo_y()
s = "300x200+" + str(new_x)+"+" + str(new_y)
root.geometry(s)
print("s = ",s)
print(root.winfo_x(),root.winfo_y())
print(event.x,event.y)
print()
def button_1(event):
global x,y
x,y = event.x,event.y
print("event.x, event.y = ",event.x,event.y)
canvas.bind("<B1-Motion>",move)
canvas.bind("<Button-1>",button_1)
root.mainloop()
#自己加个双击鼠标事件 关闭窗口 不然结束程序很不爽 要关闭IDE
import Tkinter
root = Tkinter.Tk()
root.overrideredirect(True)
#root.attributes("-alpha", 0.3)窗口透明度70 %
root.attributes("-alpha", 0.4)#窗口透明度60 %
root.geometry("300x200+10+10")
canvas = Tkinter.Canvas(root)
canvas.configure(width = 300)
canvas.configure(height = 200)
canvas.configure(bg = "blue")
canvas.configure(highlightthickness = 0)
canvas.pack()
x, y = 0, 0
def move(event):
global x,y
new_x = (event.x-x)+root.winfo_x()
new_y = (event.y-y)+root.winfo_y()
s = "300x200+" + str(new_x)+"+" + str(new_y)
root.geometry(s)
print("s = ",s)
print(root.winfo_x(),root.winfo_y())
print(event.x,event.y)
print()
def button_1(event):
global x,y
x,y = event.x,event.y
print("event.x, event.y = ",event.x,event.y)
canvas.bind("<B1-Motion>",move)
canvas.bind("<Button-1>",button_1)
root.mainloop()
#自己加个双击鼠标事件 关闭窗口 不然结束程序很不爽 要关闭IDE
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询