有人用Python编写了一个非常简单的“画图”程序,我想修改一下。我的一些问题是。如何实现该程序的旋转功能?我想要能够旋转的窗口,程序代表了90度,向右。这个是可能的吗?是否还可以实现从窗口中删除边框的函数。(我说的是桂窗)。
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()发布于 2014-10-09 13:07:46
解决方案是在Linux中旋转屏幕。我通过命令成功地做到了这一点:
xrandr --output HDMI1 --rotate right发布于 2014-10-09 08:10:06
“旋转”您的屏幕,以便将屏幕的不同边缘视为顶部边缘,这是操作系统必须做的事情。例如,在Win 7,右键单击屏幕,选择分辨率,然后选择方向。选择是景观(正常),肖像(左边边缘,从景观开始)是顶部,倒置景观,和倒置肖像。这是可行的,即使屏幕不是物理旋转--但有点奇怪,因为光标移动假定屏幕是旋转的。
发布于 2014-10-09 09:00:57
你为什么要旋转窗户?是因为几何学吗?如果是的话,您可以调整画布的大小,使其看起来像在创建画布时使用宽度和高度参数旋转(或者在创建画布后使用配置)。
若要删除边框(以及其中的标题栏),可以使用:
root.overrideredirect(True)在你的main()里
https://stackoverflow.com/questions/26272322
复制相似问题