欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python實現(xiàn)敲木魚加功德包含加音效和敲擊動作(附demo)

 更新時間:2023年11月03日 12:01:35   作者:xhtdtk  
敲木魚加功德是一款很火的動畫,本文主要介紹了python實現(xiàn)敲木魚加功德包含加音效和敲擊動作,具有一定的參考價值,感興趣的可以了解一下

0、界面展示及視頻演示

這個是界面:

這個是地址:【用python做一個敲木魚試試-嗶哩嗶哩】 https://www.bilibili.com/video/BV1Vy4y1A7r5/

打包好的exe及源碼和其他文件在這里,聽到有說美化和尚和加倍功德,自己改和自己P吧 https://pan.baidu.com/s/1DCbo4hvN1KxGlSsr4EBqAw?pwd=gfqt 

1、先做一個基本界面

import tkinter
from PIL import Image, ImageTk # pip install pillow
 
# 界面
top=tkinter.Tk()
top.title('敲木魚加功德')
top.geometry('410x400')
top.configure(bg='black')
 
# 準備圖片
qiaomuyutupian=ImageTk.PhotoImage(file='敲木魚.jpg') # 轉化為tkinter可以使用的圖片
 
# 初始化功德
gongde=0
 
# 標簽
label1=tkinter.Label(top,text='積攢功德:'+str(gongde),font=('華文新魏',15),fg='white',bg='black',width=18)
label1.place(x=100,y=70)
 
# 方法
def qiaomuyu():
        # 設gongde為全局變量,并更新標簽
        global gongde
        gongde=gongde+1
 
# 按鈕
button1=tkinter.Button(top,image=qiaomuyutupian,relief='ridge',command=qiaomuyu)
button1.place(x=100,y=100)
 
top.mainloop()

2、用pygame添加聲音最簡單,并用多線程啟動(這樣不用等聲音播放完就可以繼續(xù)按了)

import tkinter
import threading
import pygame # pip install pygame
from PIL import Image, ImageTk # pip install pillow
 
# 準備音頻
pygame.mixer.init()
pygame.mixer.music.load('敲.mp3')
 
# 界面
top=tkinter.Tk()
top.title('敲木魚加功德')
top.geometry('410x400')
top.configure(bg='black')
 
# 準備圖片
qiaomuyutupian=ImageTk.PhotoImage(file='敲木魚.jpg') # 轉化為tkinter可以使用的圖片
 
# 初始化功德
gongde=0
 
# 標簽
label1=tkinter.Label(top,text='積攢功德:'+str(gongde),font=('華文新魏',15),fg='white',bg='black',width=18)
label1.place(x=100,y=70)
 
# 方法
def qiaomuyu():
        # 設gongde為全局變量,并更新標簽
        global gongde
        gongde=gongde+1
        label1.config(text='積攢功德:'+str(gongde))
 
        # 多線程啟動解決延時,雖然延遲足夠小,但為了更有效果
        th=threading.Thread(target=pygame.mixer.music.play)
        th.start()
 
# 按鈕
button1=tkinter.Button(top,image=qiaomuyutupian,relief='ridge',command=qiaomuyu)
button1.place(x=100,y=100)
 
top.mainloop()

3、添加上浮移動的文字。

由于實在不能把控件設置成透明色,所以用個背景色為黑色的Text控件,只要逐行刪除就有效果了,同樣多線程啟動

import time
import tkinter
import threading
import pygame # pip install pygame
from PIL import Image, ImageTk # pip install pillow
 
# 準備音頻
pygame.mixer.init()
pygame.mixer.music.load('敲.mp3')
 
# 界面
top=tkinter.Tk()
top.title('敲木魚加功德')
top.geometry('410x400')
top.configure(bg='black')
 
# 準備圖片
qiaomuyutupian=ImageTk.PhotoImage(file='敲木魚.jpg') # 轉化為tkinter可以使用的圖片
 
# 初始化功德
gongde=0
 
# 標簽
label1=tkinter.Label(top,text='積攢功德:'+str(gongde),font=('華文新魏',15),fg='white',bg='black',width=18)
label1.place(x=100,y=70)
 
def showplus():
        for i in range(4):
                text1.insert('insert',' \n')
        else:
                text1.insert('insert',' 功德 + 1')
 
        for i in range(5):
                time.sleep(0.03)
                text1.delete(1.0, 2.0)
 
# 方法
def qiaomuyu():
        # 設gongde為全局變量,并更新標簽
        global gongde
        gongde=gongde+1
        label1.config(text='積攢功德:'+str(gongde))
 
        # 多線程啟動解決延時,雖然延遲足夠小,但為了更有效果
        th=threading.Thread(target=pygame.mixer.music.play)
        th.start()
 
        th2=threading.Thread(target=showplus)
        th2.start()
 
# 按鈕
button1=tkinter.Button(top,image=qiaomuyutupian,relief='ridge',command=qiaomuyu)
button1.place(x=100,y=100)
 
text1=tkinter.Text(top,width=10,height=5,bg='black',bd=0,foreground='white')
text1.place(x=125,y=115)
top.mainloop()

4、P一張敲到木魚的圖片,兩張圖片來回切換就有動畫效果了,同樣多線程啟動

import time
import tkinter
import threading
import pygame # pip install pygame
from PIL import Image, ImageTk # pip install pillow
 
# 準備音頻
pygame.mixer.init()
pygame.mixer.music.load('敲.mp3')
 
# 界面
top=tkinter.Tk()
top.title('敲木魚加功德')
top.geometry('410x400')
top.configure(bg='black')
 
# 準備圖片
qiaomuyutupian=ImageTk.PhotoImage(file='敲木魚.jpg') # 轉化為tkinter可以使用的圖片
qiaomuyutupian2=ImageTk.PhotoImage(file='敲木魚2.jpg') # 轉化為tkinter可以使用的圖片
 
# 初始化功德
gongde=0
 
# 標簽
label1=tkinter.Label(top,text='積攢功德:'+str(gongde),font=('華文新魏',15),fg='white',bg='black',width=18)
label1.place(x=100,y=70)
 
def showplus():
        for i in range(4):
                text1.insert('insert',' \n')
        else:
                text1.insert('insert',' 功德 + 1')
 
        for i in range(5):
                time.sleep(0.03)
                text1.delete(1.0, 2.0)
 
def changetupian():
        button1.config(image=qiaomuyutupian2)
        time.sleep(0.1)
        button1.config(image=qiaomuyutupian)
 
# 方法
def qiaomuyu():
        # 設gongde為全局變量,并更新標簽
        global gongde
        gongde=gongde+1
        label1.config(text='積攢功德:'+str(gongde))
 
        # 多線程啟動解決延時,雖然延遲足夠小,但為了更有效果
        th=threading.Thread(target=pygame.mixer.music.play)
        th.start()
 
        th2=threading.Thread(target=showplus)
        th2.start()
 
        th3=threading.Thread(target=changetupian)
        th3.start()
 
# 按鈕
button1=tkinter.Button(top,image=qiaomuyutupian,relief='ridge',command=qiaomuyu)
button1.place(x=100,y=100)
 
text1=tkinter.Text(top,width=10,height=5,bg='black',bd=0,foreground='white')
text1.place(x=125,y=115)
 
 
top.mainloop()

到此這篇關于python實現(xiàn)敲木魚加功德包含加音效和敲擊動作(附demo)的文章就介紹到這了,更多相關python 敲木魚加功德內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • Python 使用 docopt 解析json參數(shù)文件過程講解

    Python 使用 docopt 解析json參數(shù)文件過程講解

    這篇文章主要介紹了Python 使用 docopt 解析json參數(shù)文件過程講解,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
    2019-08-08
  • python 調(diào)用win32pai 操作cmd的方法

    python 調(diào)用win32pai 操作cmd的方法

    下面小編就為大家?guī)硪黄猵ython 調(diào)用win32pai 操作cmd的方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-05-05
  • Python cookbook(數(shù)據(jù)結構與算法)將多個映射合并為單個映射的方法

    Python cookbook(數(shù)據(jù)結構與算法)將多個映射合并為單個映射的方法

    這篇文章主要介紹了Python cookbook(數(shù)據(jù)結構與算法)將多個映射合并為單個映射的方法,結合實例形式分析了Python字典映射合并操作相關實現(xiàn)技巧,需要的朋友可以參考下
    2018-04-04
  • Python中的星號*還能這么用你知道嗎

    Python中的星號*還能這么用你知道嗎

    這篇文章主要為大家詳細介紹了Python中的星號*用法的相關資料,文中的示例代碼講解詳細,具有一定的學習價值,感興趣的小伙伴可以跟隨小編一起了解一下
    2023-06-06
  • python和ruby,我選誰?

    python和ruby,我選誰?

    本文給大家對比了下python和Ruby的異同以及各自的優(yōu)缺點等,向大家展示了python與Ruby的資源以及學習曲線,非常適合在此兩種語言中猶豫不決的小伙伴,希望大家能夠喜歡
    2017-09-09
  • matlab 計算灰度圖像的一階矩,二階矩,三階矩實例

    matlab 計算灰度圖像的一階矩,二階矩,三階矩實例

    這篇文章主要介紹了matlab 計算灰度圖像的一階矩,二階矩,三階矩實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-04-04
  • python輸入整條數(shù)據(jù)分割存入數(shù)組的方法

    python輸入整條數(shù)據(jù)分割存入數(shù)組的方法

    今天小編就為大家分享一篇python輸入整條數(shù)據(jù)分割存入數(shù)組的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-11-11
  • Python之freegames?零代碼的22個小游戲集合

    Python之freegames?零代碼的22個小游戲集合

    這篇文章主要介紹了,Python之freegames?零代碼的22個小游戲集合,文章內(nèi)容詳細,簡單易懂,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2023-01-01
  • Jupyter Notebook輸出矢量圖實例

    Jupyter Notebook輸出矢量圖實例

    這篇文章主要介紹了Jupyter Notebook輸出矢量圖實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-04-04
  • Python 多線程實例詳解

    Python 多線程實例詳解

    這篇文章主要介紹了Python 多線程實例詳解的相關資料,需要的朋友可以參考下
    2017-03-03

最新評論