gpt4 book ai didi

Python Tkinter 旋转窗口,向右转

转载 作者:太空宇宙 更新时间:2023-11-04 08:58:27 26 4
gpt4 key购买 nike

有人用 Python 写了一个非常简单的“绘画”程序,我想稍微修改一下。我的一些问题是。如何对这个程序实现旋转功能?我希望能够将显示程序的窗口向右旋转 90 度。这可能吗?是否也可以实现从窗口中删除边框的功能。 (我说的是 gui 窗口)。

from Tkinter import *

"""paint.py: not exactly a paint program.. just a smooth line drawing demo."""

b1 = "up"
xold, yold = None, None

def main():
root = Tk()
drawing_area = Canvas(root)
drawing_area.pack()
drawing_area.bind("<Motion>", motion)
drawing_area.bind("<ButtonPress-1>", b1down)
drawing_area.bind("<ButtonRelease-1>", b1up)
root.mainloop()

def b1down(event):
global b1
b1 = "down" # you only want to draw when the button is down
# because "Motion" events happen -all the time-

def b1up(event):
global b1, xold, yold
b1 = "up"
xold = None # reset the line when you let go of the button
yold = None

def motion(event):
if b1 == "down":
global xold, yold
if xold is not None and yold is not None:
event.widget.create_line(xold,yold,event.x,event.y,smooth=TRUE)
# here's where you draw it. smooth. neat.
xold = event.x
yold = event.y

if __name__ == "__main__":
main()

最佳答案

解决方案是在 Linux 中旋转屏幕。我设法用命令做到了这一点:

xrandr --output HDMI1 --rotate right

关于Python Tkinter 旋转窗口,向右转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26272322/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com