Giter Site home page Giter Site logo

my1e5 / dpg-examples Goto Github PK

View Code? Open in Web Editor NEW
71.0 1.0 9.0 1.73 MB

A collection of example scripts which demonstrate various features/functionality in DearPyGui

Home Page: https://github.com/hoffstadt/DearPyGui

License: MIT License

Python 100.00%
dearpygui example-code gui python

dpg-examples's Introduction

DearPyGui examples

A collection of example scripts which demonstrate various features/functionality in DearPyGui.

        

        

Examples

Examples of how to implement various types of buttons. This includes how to implement a button which changes colour when clicked and how to implement nested radio buttons.

Examples of how to link a data structure to GUI items so that changes made using the GUI are reflected in the underlying data structure.

Examples of how to use the drawing API.

A very simple implementation of a paint app. It demonstrates how you can click and drag the mouse on a dpg.add_drawlist and draw basic free-form lines using dpg.draw_line.

Examples of how to use custom fonts. And some tips on how to get the best results.

Examples of custom listbox widgets which extend the functionality of the default listbox. Includes how to implement a listbox which is unselected by default and how to respond to key presses.

Examples of how to implement all the different types of menubar and how to implement a right-aligned menubar.

Miscellaneous examples.

Examples of how to save and load the state of a GUI. This includes the values of GUI items, the position of windows, etc. A simple example using dict is shown as well as an approach using dataclasses. Both store the app state in a JSON file.

Examples of how to implement various features in plots. Such as enforcing axes limits and updating colours and marker styles.

Examples of how to size/re-size GUI items. There are some quirks with sizing - mainly to do with getting the correct size of an item on startup.

Examples of how to space GUI items using different methods. This includes automatic spacing, spacing using a grid of child windows and spacing using tables.

Examples of how to use tables.

Examples of how to use threading in DearPyGui. Includes a start/stop button which can be used to start/stop a thread and a progress bar to show the progress of a task.

A basic progress bar with a start button. Once running, the start button changes to a pause button. The task can then be paused, upon which the pause button changes to a resume button and a reset button appears.

Examples of how to manage windows. This includes how to create a window which is always on top and how to drag the viewport when decorated=False. Also includes restricting the position of a window and how to implement a clicked handler for child windows.

dpg-examples's People

Contributors

ivannazaruk avatar my1e5 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

dpg-examples's Issues

Plot_ Update_ Time_ How to implement microphone recording with data

I want to use DearPyGui to complete it
But it's unclear how to port to DearPyGui

import queue
import sys

from matplotlib.animation import FuncAnimation
import matplotlib.pyplot as plt
import numpy as np
import sounddevice as sd


channels = [1]
window = 200
interval = 30
downsample = 10

mapping = [c - 1 for c in channels]
q = queue.Queue()


def audio_callback(indata, frames, time, status):

    if status:
        print(status, file=sys.stderr)

    q.put(indata[::downsample, mapping])


def update_plot(frame):

    global plotdata
    while True:
        try:
            data = q.get_nowait()
        except queue.Empty:
            break
        shift = len(data)
        plotdata = np.roll(plotdata, -shift, axis=0)
        plotdata[-shift:, :] = data
    for column, line in enumerate(lines):
        line.set_ydata(plotdata[:, column])
    return lines


try:
    device_info = sd.query_devices(None, "input")
    samplerate = device_info["default_samplerate"]

    length = int(window * samplerate / (1000 * downsample))
    plotdata = np.zeros((length, len(channels)))

    fig, ax = plt.subplots()
    lines = ax.plot(plotdata)
    if len(channels) > 1:
        ax.legend(
            [f"thoroughfare {c}" for c in channels],
            loc="lower left",
            ncol=len(channels),
        )
    ax.axis((0, len(plotdata), -1, 1))
    ax.set_yticks([0])
    ax.yaxis.grid(True)
    ax.tick_params(
        bottom=False,
        top=False,
        labelbottom=False,
        right=False,
        left=False,
        labelleft=False,
    )
    fig.tight_layout(pad=0)

    stream = sd.InputStream(
        device=None,
        channels=max(channels),
        samplerate=samplerate,
        callback=audio_callback,
    )
    ani = FuncAnimation(fig, update_plot, interval=interval, blit=True)
    with stream:
        plt.show()
except Exception as e:
    print(type(e).__name__ + ": " + str(e))

微信截图_20230917165351

https://github.com/my1e5/dpg-examples/blob/main/plots/plot_update_time_data.py

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.