How to make a GUI using PyQt5 and Matplotlib to plot real-time data: PyQt5 tutorial - Part 10

Поделиться
HTML-код
  • Опубликовано: 22 авг 2024
  • Today in Python, we will design a simple but beneficial graphical user interface (GUI) with PyQt5. We will plot live audio data, that is sampled from computer's audio device. We will use the Matplotlib figure and update the canvas in the GUI according to the set interval. We will use pyqtSlot, QTimer, QThreadPool, sounddevice, and queue in this tutorial. This is part 10 of the PyQt5 learning series.
    Source code: pyshine.com/Ho...
    Music: www.bensound.com
    IMPORTANT TUTORIAL LINKS
    Transfer video over sockets from multiple clients: pyshine.com/So...
    How to track Mario in Python: pyshine.com/tr...
    What are yield and return statements in Python: pyshine.com/Di...
    How to automatically arrange the desktop icons: pyshine.com/Ho...
    How to plot realtime frame rate of a web camera: pyshine.com/Ho...
    How to make screen recorder in PyQt5: pyshine.com/Ho...
    How to make a real time voice plot: pyshine.com/Ho...
    How to make a piano in Python: pyshine.com/Ho...
    Making Python GUI for sine and cosine: pyshine.com/Ho...
    Pandas dataframe with hexadecimal and ascii values: pyshine.com/Pa...
    Socket programming to send and receive webcam video: pyshine.com/So...
    Faster and accurate object tracking in Python: pyshine.com/Ob...
    OpenCV and Real time streaming protocol (RTSP): pyshine.com/Re...
    How to deploy Python video processing application on the server: pyshine.com/Ho...
    How to publish-subscribe video using socket programming in Python: pyshine.com/Fa...
    How to send audio from a client computer to a server over the wifi: pyshine.com/Se...
    How to visualize Earthquakes in Python: pyshine.com/Ho...
    How to stream video and bidirectional text in socket programming: pyshine.com/Vi...
    How to send audio data using socket programming in Python: pyshine.com/Ho...
    How to send audio and video using socket programming in Python: pyshine.com/Ho...
    How to send video using UDP socket in Python: pyshine.com/Se...
    How to easily stream picamera video over wifi with Raspberry Pi: pyshine.com/Ea...
    How to configure Raspberry Pi in Ad hoc wifi mode: pyshine.com/Ho...
    How to easily stream webcam video over wifi with Raspberry Pi: pyshine.com/Ea...
    How to easily install OpenCv in Raspberry Pi boards: pyshine.com/Ho...
    How to stream multiple videos on an HTML webpage:pyshine.com/Li...

Комментарии • 53

  • @TheJacklwilliams
    @TheJacklwilliams 2 года назад +9

    This is, simply outstanding. I'm learning Python and just recently forayed into the front end with PyQt5 and designer. Every tutorial I've found online (well to be fair, nearly every) does the same things, "Hello World". Combining all of the functionality into this app, including matplotlib, numpy, audio processing, this is just the kind of tutorial I've been looking for. I get it, the standard in the programming world is start with "Hello World" and build on it. However, too many never go anywhere substantial. The sample apps they create show some simple signals/slots, use of graphical elements, etc... but never end up anywhere substantial. Thank you. I'm hooked. Subscribed and diving into the material on your channel and web site. Lastly, tying your code base into interfacing with hardware and the raspberry pi? That's my jam. I've got a Pi4 with 8GB ram, 64bit OS and 240GB SSD (booting from). I run my dev environment on this and it absolutely ROCKS! Way to out SHINE the rest and provide lessons that actually go somewhere!

  • @nikse2028
    @nikse2028 3 года назад +4

    this is AWESOMEEEEEEEEEEEEEEEEE!!!!!!!!!!!!!!!!!!!!!!!, its the very very very best thing that i see in a long time, i really love this, i came here searching silver, and i found gold!!!

  • @8051rev8051
    @8051rev8051 2 года назад +2

    great tutorial. Thanks for posting. I will recommend to other learners.

  • @AhmadAsmndr
    @AhmadAsmndr Год назад

    thank you very much just what i wanted

  • @yunusemreaslan3016
    @yunusemreaslan3016 2 года назад +1

    GREATTT!! Thanks a lot!!!

  • @lamify_pro
    @lamify_pro 3 года назад +2

    Thanks!!!

  • @wonderman2864
    @wonderman2864 2 года назад +3

    Hello Sir, how can we plot or scatter plot real-time CSV, txt data files?
    Can you please help with it?

    • @pyshine_official
      @pyshine_official  2 года назад +2

      Hi, please follow this pyshine.com/How-to-plot-real-time-frame-rate-in-opencv-and-matplotlib/ and instead using plt.plot you can work around with plt.scatter

    • @wonderman2864
      @wonderman2864 2 года назад +1

      @@pyshine_official thank you so much, Sir! Good luck with your further works :)

  • @charlesspringer4709
    @charlesspringer4709 Год назад

    Sample rate must be GREATER THAN twice the fundamental and should be much higher. (It takes a nearly infinite amount of time to resolve a signal if the sampling frequency is close to f/2.

  • @1029cristian
    @1029cristian Год назад

    Great development, It was very useful for what I wanted to do. I have a question: You define the function Update_plot with a While loop, but this function is called periodically by QtTimer, so if You quit the While loop is still works. Is the While loop necessary for something else or is just redundant? I cannot see any reason why we would want it. Thank you for your dedication!!!

    • @pyshine_official
      @pyshine_official  Год назад

      Good question, the while can be avoided, simple replace the try except queue.Empty part with data=[0]

  • @uzmahamayun8375
    @uzmahamayun8375 2 года назад +1

    Really nice tutorial. I am trying to plot several page report with pyqt with alternating text and graphs with few push buttons. For example push button 1 will display some text for Milk sale per month with some matplotlib. I am finding it difficult to find a layout for such report. unfortunately i cant upload a sample pdf in comment section, so I am directly emailing you a sample pdf. Please share any idea how to generate such report.

    • @pyshine_official
      @pyshine_official  2 года назад +1

      Probably the closest one is this pyshine.com/Drag-Drop-CSV-File-on-PyQt5-GUI/ Saved your data to csv and use this tutorial for text you can add label under the graph. The text in that label will come from some test file or even from the same csv. For example you can add an extra column in csv that will contain the relevant text for each plot. Bind a bush button to load csv and display data and text

  • @muhammedtahsintasgn3089
    @muhammedtahsintasgn3089 2 года назад +1

    it looks great. EVERYBODY I NEED HELP. I have a task that wants me to make a progressbar which will be updating/refreshing every second with the values that I take from somewhere. lets say its a list. I created a loop for updating it and added a delay time with time.sleep but it didnt work. it takes all the delay time at once and after looking at a blank window for 10 seconds i get a display of a progressbar with the last value in the array. PLEASE HELP

    • @pyshine_official
      @pyshine_official  2 года назад

      This might be helpful focus on the progressbar pyshine.com/Play-Rock-Paper-Scissors-Game-using-PyQt5-GUI/

  • @ipelezikis
    @ipelezikis 2 года назад +1

    Any advise on how we can package this app to an exe?. From my experience packaging apps that make use of libraries such that matplotlib, numpy or pandas make huge executables that makes packaging essentially useless.

  • @rithikarithika1230
    @rithikarithika1230 2 года назад +1

    Can we able to plot the graph without loading ui..i.e create the plot programatically

  • @ashishprajapati6128
    @ashishprajapati6128 2 года назад +1

    how can add command prompt in qt5 Designer

    • @pyshine_official
      @pyshine_official  2 года назад

      Good question, it will be added on pyshine.com, stay tuned

  • @seifeddineomari4962
    @seifeddineomari4962 3 года назад

    Great work, pleas can I aske you some questions please ?

  • @TlNYDlCK
    @TlNYDlCK Год назад

    Hi great tutorials! I tried running the code but I keep getting:
    'ValueError: Multiple input devices found for 'Microphone (NVIDIA Broadcast)':
    [1] Microphone (NVIDIA Broadcast), MME
    [27] Microphone (NVIDIA Broadcast), Windows DirectSound
    [68] Microphone (NVIDIA Broadcast), Windows WASAPI
    This unfortunately happens with every single audio device I try to use. MME, Windows DirectSound, and Windows WASAPI are always in the error message following the name of the audio device.

    • @duncpol
      @duncpol Год назад

      You have to use a simple 3.5 mm jack microphone, not a webcam.

  • @marverickbin
    @marverickbin 3 года назад

    How to make it possible to change the window and other parameters in real time, while is already playing?

    • @pyshine_official
      @pyshine_official  3 года назад

      Excellent question! Since functions are running under various threads with their own parameters. We can use seprate queue based variables to safely provide the parameter value a thread running a function. In that fuction the parameter value can be applied before the next time step.

  • @milenamijuskovic2340
    @milenamijuskovic2340 Год назад

    I loved your video. I am still stuck tho, can you help me with something? I have a QWidget that has 2 tabs. Tab #1 handles data input and tab 2 plots it. I can not make it to work. I have my tab2 as a separate class but it's parent is tab1. I will say tho that main Data Strucutre (Dictionary) is outside my gui class.. do I need to put that inside? please help

    • @milenamijuskovic2340
      @milenamijuskovic2340 Год назад

      I would really really appreciate it, I am at this issue more than a week now. As a beginner I find it very difficult

  • @wilykary
    @wilykary 3 года назад

    I completely copied your code, but Im getting this error:
    QObject::killTimer: Timers cannot be stopped from another thread
    QObject::startTimer: Timers cannot be started from another thread
    QObject::setParent: Cannot set parent, new parent is in a different thread

    • @pyshine_official
      @pyshine_official  3 года назад

      Hi, Please use this for stopping pyshine.com/PyQt5-Live-Audio-GUI-with-Start-and-Stop/

    • @wilykary
      @wilykary 3 года назад

      @@pyshine_official 👍

  • @surendrathakur3479
    @surendrathakur3479 3 года назад

    It's amazing but can you tell me .......the details you show like sample rate , frequency are right...... please help ?

    • @pyshine_official
      @pyshine_official  3 года назад +1

      Yes, these are input parameters and works well as long as hardware allows

    • @surendrathakur3479
      @surendrathakur3479 3 года назад

      @@pyshine_official it's very confusing.....how can you make sample rate of 44100 hz from mic input

    • @pyshine_official
      @pyshine_official  3 года назад

      @@surendrathakur3479 Hi, the mic input is analog signal provided to an analog to digital converter of your sound device. The sample rate is given to sound device digitizer. By default most audio digitizers can sample sound at this rate

    • @surendrathakur3479
      @surendrathakur3479 3 года назад

      @@pyshine_official you are awesome and clearing all my doubt........does downsample drop every 10th sample of the sound by your program.......or can I change all the parameter written in gui....... please I beg to you help me out, the question may arise when I show it to my guide

  • @azharabbas6298
    @azharabbas6298 3 года назад

    How to run nmap im pyqt design

  • @kutilkol
    @kutilkol 2 года назад

    wow! how you did that?

  • @bennguyen1313
    @bennguyen1313 3 года назад

    Any thoughts how you could plot csv data coming that comes streaming from a serial port? Basically, get all the ascii up to the carriage-return/line-feed, then parse / plot each csv value, before getting the next line of data. Or do you think the processing would take too long and drop serial data?

    • @pyshine_official
      @pyshine_official  3 года назад

      Hi! serial port data can be plotted by each chunk, depending on the baud rate the stream of chunks can be appended to a csv file. And in a separated thread simple read that csv and plot. In that way the serial data will not drop and can be plotted.

    • @jaganmohan5099
      @jaganmohan5099 3 года назад

      @@pyshine_official thank you.. how can i do this with separate thread

  • @dimaskurniawan1924
    @dimaskurniawan1924 2 года назад

    i need help, to change the input using a arduino

    • @pyshine_official
      @pyshine_official  2 года назад

      Hi, please elaborate the format of data, is it serial or text based?

    • @dimaskurniawan1924
      @dimaskurniawan1924 2 года назад

      @@pyshine_official its serial data

    • @dimaskurniawan1924
      @dimaskurniawan1924 2 года назад

      can you explain how to change input based on serial plotter from arduino, please?