Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537
kinter(也叫Tk接?)是Tk圖形?戶(hù)界??具包標(biāo)準(zhǔn)的Python接?。Tk是?個(gè)輕量級(jí)的跨平臺(tái)圖形?戶(hù)界?(GUI)開(kāi)發(fā)?具。
Tkinter是Python自帶的官方標(biāo)準(zhǔn)庫(kù),安裝Python之后直接導(dǎo)入就可以使用,我們常見(jiàn)的python IDLE就是使用TKinter實(shí)現(xiàn)的。
在Win10命令行窗口輸入python、import tkinter、dir(tkinter)、help(tkinter),可獲得tkinter的相關(guān)幫助信息。
help(tkinter)命令的執(zhí)行結(jié)果,列出了模塊幫助文檔的鏈接: https://docs.python.org/3.10/library/tkinter.html
實(shí)現(xiàn)打開(kāi)并顯示圖片的源代碼如下:
import tkinter as tk
import tkinter.filedialog
from PIL import Image,ImageTk
#選擇并顯示圖片
def choosepic():
path_=tkinter.filedialog.askopenfilename()
path.set(path_)
print(path)
img_open=Image.open(entry.get())
#img=ImageTk.PhotoImage(img_open.resize((200,200)))
img=ImageTk.PhotoImage(img_open)
lableShowImage.config(image=img)
lableShowImage.image=img
if __name__=='__main__':
#生成tk界面 app即主窗口
app=tk.Tk()
#修改窗口titile
app.title("顯示圖片")
#設(shè)置主窗口的大小和位置
app.geometry("800x400+200+200")
#Entry widget which allows displaying simple text.
path=tk.StringVar()
entry=tk.Entry(app, state='readonly', text=path,width=100)
entry.pack()
#使用Label顯示圖片
lableShowImage=tk.Label(app)
lableShowImage.pack()
#選擇圖片的按鈕
buttonSelImage=tk.Button(app, text='選擇圖片', command=choosepic)
buttonSelImage.pack()
#buttonSelImage.pack(side=tk.BOTTOM)
#Call the mainloop of Tk.
app.mainloop()
假設(shè)將源代碼保存在文件“d:\temp\MyShowImage.py”。在命令行執(zhí)行命令
python d:\temp\MyShowImage.py
程序運(yùn)行,界面如下圖所示
Tkinter(也叫Tk接?)是Tk圖形?戶(hù)界??具包標(biāo)準(zhǔn)的Python接?。Tk是?個(gè)輕量級(jí)的跨平臺(tái)圖形?戶(hù)界?(GUI)開(kāi)發(fā)?具。
Tkinter是Python自帶的官方標(biāo)準(zhǔn)庫(kù),安裝Python之后直接導(dǎo)入就可以使用,我們常見(jiàn)的python IDLE就是使用TKinter實(shí)現(xiàn)的。
在Win10命令行窗口輸入python、import tkinter、dir(tkinter)、help(tkinter),可獲得tkinter的相關(guān)幫助信息。
help(tkinter)命令的執(zhí)行結(jié)果,列出了模塊幫助文檔的鏈接: https://docs.python.org/3.10/library/tkinter.html
實(shí)現(xiàn)打開(kāi)并顯示圖片的源代碼如下:
import tkinter as tk
import tkinter.filedialog
from PIL import Image,ImageTk
#選擇并顯示圖片
def choosepic():
path_=tkinter.filedialog.askopenfilename()
path.set(path_)
print(path)
img_open=Image.open(entry.get())
#img=ImageTk.PhotoImage(img_open.resize((200,200)))
img=ImageTk.PhotoImage(img_open)
lableShowImage.config(image=img)
lableShowImage.image=img
if __name__=='__main__':
#生成tk界面 app即主窗口
app=tk.Tk()
#修改窗口titile
app.title("顯示圖片")
#設(shè)置主窗口的大小和位置
app.geometry("800x400+200+200")
#Entry widget which allows displaying simple text.
path=tk.StringVar()
entry=tk.Entry(app, state='readonly', text=path,width=100)
entry.pack()
#使用Label顯示圖片
lableShowImage=tk.Label(app)
lableShowImage.pack()
#選擇圖片的按鈕
buttonSelImage=tk.Button(app, text='選擇圖片', command=choosepic)
buttonSelImage.pack()
#buttonSelImage.pack(side=tk.BOTTOM)
#Call the mainloop of Tk.
app.mainloop()
假設(shè)將源代碼保存在文件“d:\temp\MyShowImage.py”。在命令行執(zhí)行命令
python d:\temp\MyShowImage.py
程序運(yùn)行,界面如下圖所示
點(diǎn)擊“選擇圖片”按鈕,彈出打開(kāi)文件對(duì)話(huà)框,
選擇要打開(kāi)的圖片文件,點(diǎn)擊“打開(kāi)”按鈕,圖片就會(huì)顯示在圖形界面上了,如下圖所示:
上述代碼實(shí)現(xiàn)了圖片的選擇和顯示功能,但也有不足之處,比如“沒(méi)有滾動(dòng)條,無(wú)法完全顯示比屏幕大的圖片”。
(1)https://blog.csdn.net/xyzhan/article/details/113856833 (2021年開(kāi)發(fā)Python圖形用戶(hù)界面(GUI)的6種最佳Python GUI框架)
(2)https://wenku.baidu.com/view/8f03733bf9d6195f312b3169a45177232e60e44d.html (推薦8款常?的PythonGUI圖形界?開(kāi)發(fā)框架)
(3)https://github.com/honghaier-game/TKinterDesigner (honghaier-game/TKinterDesigner)
(4)https://blog.csdn.net/HG0724/article/details/112248635 (Python之Tkinter進(jìn)行GUI開(kāi)發(fā))
(5)https://blog.csdn.net/wj0807/article/details/120890111 (在tkinter中顯示圖片和圖片名)
(6)https://www.cnpython.com/qa/58793 (如何在gui中使用tkinter顯示圖像)
(7)https://m.php.cn/article/419452.html (python idle是什么)
(8)https://docs.python.org/3.10/library/tkinter.html (tkinter — Python interface to Tcl/Tk)
(9)https://blog.csdn.net/tyler880/article/details/106862322?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1-106862322-blog-112248635.pc_relevant_aa&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1-106862322-blog-112248635.pc_relevant_aa&utm_relevant_index=2 (python GUI編程(Tkinter))
(10)https://www.cnpython.com/qa/308976 (用滾動(dòng)條在Tkinter中顯示多個(gè)圖像)
ppt怎么設(shè)置點(diǎn)擊鏈接文字顯示圖片?
1、首先,打開(kāi)PTP,找到需要鏈接的文字,然后選中該文字,比如圖中的“趟門(mén)柜”
2、選擇工具欄中的“插入”,再選擇“超鏈接”,如圖中所示
3、就會(huì)彈出一個(gè)插入超鏈接的窗口,然后我們?cè)诓檎曳秶抢镞x擇我們要鏈接的圖片的路徑,選擇要鏈接的圖片,在單擊“確定”,如圖所示
4、操作完第三步之后發(fā)現(xiàn),我們選擇超鏈接的文字變顏色了,這代表我們已經(jīng)鏈接成功
5、播放PTP,然后單擊變顏色的文字,如圖中”趟門(mén)柜”
6、操作完第五步后,就好彈出我們剛剛選擇鏈接的圖片
生javascript實(shí)現(xiàn)帶動(dòng)畫(huà)的提示型彈窗,常用于網(wǎng)站彈層的彈窗也有很多,一般用插件比較多,所以今天就來(lái)寫(xiě)一寫(xiě)該功能,如有錯(cuò)誤之處請(qǐng)指出!
彈出跟消失都有放大縮小動(dòng)畫(huà)在里面!
實(shí)現(xiàn)方法:
html:
可以自己輸入內(nèi)容,再點(diǎn)擊彈出即可看到彈窗效果
css:
javascript:
*請(qǐng)認(rèn)真填寫(xiě)需求信息,我們會(huì)在24小時(shí)內(nèi)與您取得聯(lián)系。