Update canvas

This commit is contained in:
Mylloon 2020-11-30 21:32:17 +01:00
parent 24af460adc
commit bde9dda0de

18
soui.py
View file

@ -1,7 +1,7 @@
import numpy as np import numpy as np
import sounddevice as sd import sounddevice as sd
from time import sleep from time import sleep
from tkinter import Tk, Label, PhotoImage from tkinter import Tk, Canvas, Label, PhotoImage
class Microphone: class Microphone:
@ -36,18 +36,22 @@ class Affichage:
self.notspeaking = "not_speaking.png" self.notspeaking = "not_speaking.png"
def refresh(self): def refresh(self):
if Microphone().get_status_speaking(): self.canvas.config(image = PhotoImage(file = self.get_image()))
self.image.config(PhotoImage(file = self.speaking))
else:
self.image.config(PhotoImage(file = self.notspeaking))
self.fenetre.update_idletasks() self.fenetre.update_idletasks()
self.fenetre.after(self.buffer, self.refresh) self.fenetre.after(self.buffer, self.refresh)
def get_image(self):
if Microphone().get_status_speaking():
return self.speaking
else:
return self.notspeaking
def start(self): def start(self):
self.fenetre = Tk() self.fenetre = Tk()
self.fenetre.title('Microphone') self.fenetre.title('Microphone')
self.image = Label(self.fenetre) self.canvas = Canvas(self.fenetre)
self.image.pack() self.canvas.configure(width = 1080, height = 2140)
self.canvas.create_image(540, 1070, image = PhotoImage(file = self.get_image()))
self.refresh() self.refresh()