tkinter學習07

來源:互聯網
上載者:User

標籤:apt-get   ext   get   button   src   oval   try   沒有   recent   

解決ubuntu系統 上沒有tkinter模組的問題

[email protected]:~/案頭$ python3 canvesTraceback (most recent call last):  File "canves", line 3, in <module>    import tkinter as tkModuleNotFoundError: No module named ‘tkinter‘[email protected]:~/案頭$ sudo apt-get install python3-tk正在讀取軟體包列表... 完成正在分析軟體包的相依樹狀結構       正在讀取狀態資訊... 完成       將會同時安裝下列軟體:  blt libtcl8.6 libtk8.6 tk8.6-blt2.5建議安裝:  blt-demo tcl8.6 tk8.6 tix python3-tk-dbg下列【新】軟體包將被安裝:  blt libtcl8.6 libtk8.6 python3-tk tk8.6-blt2.5升級了 0 個軟體包,新安裝了 5 個軟體包,要卸載 0 個軟體包,有 239 個軟體包未被升級。需要下載 2,252 kB 的歸檔。解壓縮後會消耗 9,231 kB 的額外空間。您希望繼續執行嗎? [Y/n] y擷取:1 http://cn.archive.ubuntu.com/ubuntu bionic/main amd64 libtcl8.6 amd64 8.6.8+dfsg-3 [881 kB]

 已安裝成功。

#!/usr/bin/python3import tkinter as tkwindow=tk.Tk()window.title("my window")window.geometry("200x200")canvas = tk.Canvas(window, bg=‘blue‘, height=100, width=200)canvas.pack()image_file = tk.PhotoImage(file=‘ins.gif‘)image = canvas.create_image(10, 10, anchor=‘nw‘, image=image_file)x0, y0, x1, y1= 50, 50, 80, 80line = canvas.create_line(x0, y0, x1, y1)oval = canvas.create_oval(x0, y0, x1, y1, fill=‘red‘)  #建立一個圓,填充色為`red`紅色arc = canvas.create_arc(x0+30, y0+30, x1+30, y1+30, start=0, extent=180)  #建立一個扇形rect = canvas.create_rectangle(100, 30, 100+20, 30+20)   #建立一個矩形def moveit():    canvas.move(rect, 0, 2)b=tk.Button(window,text="move",command=moveit).pack()window.mainloop()



tkinter學習07

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.