有人用Python編寫了一個非常簡單的「paint」程序,我想稍微修改一下。我的一些問題是。如何實現這個程序的旋轉功能?我希望能夠將程序以90度表示的窗口旋轉到右側。這可能嗎?也可以實現一個功能從窗口中刪除邊框。 (這是我正在談論的gui窗口)。Python Tkinter旋轉窗口,右轉
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呢?可以在Linux中爲幾個程序旋轉窗口。一個例子是mplayer,如果你從終端用'mplayer rotate = 1'啓動程序,整個窗口將向右旋轉90度,而操作系統中的其他所有內容保持不變。 – 2014-10-09 08:21:00
嗯。我確信的是,庫手冊中的當前tkinter章節不包含'rotate',並且pydoc生成的函數簽名頁面僅包含'rotate'作爲Canvas.postscript的參數。所以我確信tkinter不能獨立旋轉其中一個窗口。 – 2014-10-10 17:21:06