Created
February 17, 2021 22:32
-
-
Save Tschucker/51a2d65839658d5470f62843cf80508d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "# DearPyGui Demos" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 1, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "from dearpygui.core import *\n", | |
| "from dearpygui.simple import *\n", | |
| "\n", | |
| "def save_callback(sender, data):\n", | |
| " print(\"Save Clicked\")\n", | |
| "\n", | |
| "with window(\"Example Window\"):\n", | |
| " add_text(\"Hello world\")\n", | |
| " add_button(\"Save\", callback=save_callback)\n", | |
| " add_input_text(\"string\")\n", | |
| " add_slider_float(\"float\")\n", | |
| " add_button(\"+\")\n", | |
| "\n", | |
| "start_dearpygui()" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 2, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "from dearpygui.core import *\n", | |
| "from dearpygui.simple import *\n", | |
| "from math import cos, sin\n", | |
| "\n", | |
| "def plot_callback(sender, data):\n", | |
| "\n", | |
| " data1x = []\n", | |
| " data1y = []\n", | |
| " for i in range(0, 100):\n", | |
| " data1x.append(3.14 * i / 180)\n", | |
| " data1y.append(cos(3 * 3.14 * i / 180))\n", | |
| "\n", | |
| " data2x = []\n", | |
| " data2y = []\n", | |
| " for i in range(0, 100):\n", | |
| " data2x.append(3.14 * i / 180)\n", | |
| " data2y.append(sin(2 * 3.14 * i / 180))\n", | |
| "\n", | |
| " add_line_series(\"Plot\", \"Cos\", data1x, data1y, weight=2, color=[0, 0, 255, 100])\n", | |
| " add_shade_series(\"Plot\", \"Cos\", data1x, data1y, weight=2, fill=[255, 0, 0, 100])\n", | |
| " add_scatter_series(\"Plot\", \"Sin\", data2x, data2y, outline=[0, 255, 0, 100])\n", | |
| "\n", | |
| "with window(\"Tutorial\", width=500, height=500):\n", | |
| " add_button(\"Plot data\", callback=plot_callback)\n", | |
| " add_plot(\"Plot\", height=-1)\n", | |
| "\n", | |
| "start_dearpygui()" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 3, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "from dearpygui.core import *\n", | |
| "from dearpygui.simple import *\n", | |
| "from math import cos\n", | |
| "\n", | |
| "def plot_callback(sender, data):\n", | |
| " # keeping track of frames\n", | |
| " frame_count = get_data(\"frame_count\")\n", | |
| " frame_count += 1\n", | |
| " add_data(\"frame_count\", frame_count)\n", | |
| "\n", | |
| " # updating plot data\n", | |
| " plot_datax = get_data(\"plot_datax\")\n", | |
| " plot_datay = get_data(\"plot_datay\")\n", | |
| " if len(plot_datax) > 2000:\n", | |
| " frame_count = 0\n", | |
| " plot_datax.clear()\n", | |
| " plot_datay.clear()\n", | |
| " plot_datax.append(3.14 * frame_count / 180)\n", | |
| " plot_datay.append(cos(3 * 3.14 * frame_count / 180))\n", | |
| " add_data(\"plot_datax\", plot_datax)\n", | |
| " add_data(\"plot_datay\", plot_datay)\n", | |
| "\n", | |
| " # plotting new data\n", | |
| " add_line_series(\"Plot\", \"Cos\", plot_datax, plot_datay, weight=2)\n", | |
| "\n", | |
| "with window(\"Tutorial\", width=500, height=500):\n", | |
| " set_window_pos(\"Tutorial\", 0, 0)\n", | |
| " add_plot(\"Plot\", height=-1)\n", | |
| " add_data(\"plot_datax\", [])\n", | |
| " add_data(\"plot_datay\", [])\n", | |
| " add_data(\"frame_count\", 0)\n", | |
| " add_input_text(\"freq\")\n", | |
| " with menu_bar(\"Main Menu Bar\"):\n", | |
| " with menu(\"File\"):\n", | |
| " add_menu_item(\"test\")\n", | |
| " set_render_callback(plot_callback)\n", | |
| "\n", | |
| "with window(\"Heat\", width=500, height=500):\n", | |
| " set_window_pos(\"Heat\", 500, 0)\n", | |
| " add_plot(\"HeatPlot\", show_color_scale=False, scale_min=0.0, scale_max=6.0, \n", | |
| " scale_height=400, no_legend=True, \n", | |
| " no_mouse_pos=True, xaxis_lock_min=True, xaxis_lock_max=True, xaxis_no_gridlines=True, xaxis_no_tick_marks=True,\n", | |
| " yaxis_no_gridlines=True, yaxis_no_tick_marks=True, yaxis_lock_min=True, yaxis_lock_max=True, height=400)\n", | |
| " set_color_map(\"HeatPlot\", 6)\n", | |
| " values = [0.8, 2.4, 2.5, 3.9, 0.0, 4.0, 0.0,\n", | |
| " 2.4, 0.0, 4.0, 1.0, 2.7, 0.0, 0.0,\n", | |
| " 1.1, 2.4, 0.8, 4.3, 1.9, 4.4, 0.0,\n", | |
| " 0.6, 0.0, 0.3, 0.0, 3.1, 0.0, 0.0,\n", | |
| " 0.7, 1.7, 0.6, 2.6, 2.2, 6.2, 0.0,\n", | |
| " 1.3, 1.2, 0.0, 0.0, 0.0, 3.2, 5.1,\n", | |
| " 0.1, 2.0, 0.0, 1.4, 0.0, 1.9, 6.3]\n", | |
| " add_heat_series(\"HeatPlot\", \"heat data\", values, 7, 7, 0, 6, format='')\n", | |
| " \n", | |
| "\n", | |
| "start_dearpygui()" | |
| ] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "Python 3", | |
| "language": "python", | |
| "name": "python3" | |
| }, | |
| "language_info": { | |
| "codemirror_mode": { | |
| "name": "ipython", | |
| "version": 3 | |
| }, | |
| "file_extension": ".py", | |
| "mimetype": "text/x-python", | |
| "name": "python", | |
| "nbconvert_exporter": "python", | |
| "pygments_lexer": "ipython3", | |
| "version": "3.7.6" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 4 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment