aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dearpygui
diff options
context:
space:
mode:
authorsara <sara.halter@gmx.ch>2021-11-11 20:05:40 +0100
committersara <sara.halter@gmx.ch>2021-11-11 20:05:40 +0100
commit1e873c7ec474b1af4082aafcd33c0ba7a9fd3d51 (patch)
tree98e592e42f27ec2a6bd1db689fc1b4196b4c7573 /tests/dearpygui
parentFIR/Fading implementiert (diff)
parentCreate ZMQ test (diff)
downloadFading-1e873c7ec474b1af4082aafcd33c0ba7a9fd3d51.tar.gz
Fading-1e873c7ec474b1af4082aafcd33c0ba7a9fd3d51.zip
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'tests/dearpygui')
-rw-r--r--tests/dearpygui/test.py57
-rw-r--r--tests/dearpygui/test10.py53
-rw-r--r--tests/dearpygui/test1_updating_series_data.py30
-rw-r--r--tests/dearpygui/test2_axis_limis.py40
-rw-r--r--tests/dearpygui/test3_custom_axis_labels.py34
-rw-r--r--tests/dearpygui/test4_multiple_y_axes.py25
-rw-r--r--tests/dearpygui/test5_annotations.py32
-rw-r--r--tests/dearpygui/test6_drag_points_and_lines.py26
-rw-r--r--tests/dearpygui/test7_querying.py37
-rw-r--r--tests/dearpygui/test8_custom_context_menus.py33
-rw-r--r--tests/dearpygui/test9_colors_and_styles.py50
11 files changed, 417 insertions, 0 deletions
diff --git a/tests/dearpygui/test.py b/tests/dearpygui/test.py
new file mode 100644
index 0000000..3fb0d51
--- /dev/null
+++ b/tests/dearpygui/test.py
@@ -0,0 +1,57 @@
+import dearpygui.dearpygui as dpg
+from math import sin
+
+import qpks as qp
+
+q = qp.qpsk_nogui()
+
+dpg.create_context()
+
+# data = q.analog_random_source_x_0
+
+sindatax = []
+sindatay = []
+for i in range(0, 100):
+ sindatax.append(i / 100)
+ sindatay.append(0.5 + 0.5 * sin(50 * i / 100))
+sindatay2 = []
+for i in range(0, 100):
+ sindatay2.append(2 + 0.5 * sin(50 * i / 100))
+
+with dpg.window(label="Tutorial", width=500, height=400):
+ # create a theme for the plot
+ with dpg.theme(tag="plot_theme"):
+ with dpg.theme_component(dpg.mvStemSeries):
+ dpg.add_theme_color(dpg.mvPlotCol_Line, (150, 255, 0), category=dpg.mvThemeCat_Plots)
+ dpg.add_theme_style(dpg.mvPlotStyleVar_Marker, dpg.mvPlotMarker_Diamond, category=dpg.mvThemeCat_Plots)
+ dpg.add_theme_style(dpg.mvPlotStyleVar_MarkerSize, 7, category=dpg.mvThemeCat_Plots)
+
+ with dpg.theme_component(dpg.mvScatterSeries):
+ dpg.add_theme_color(dpg.mvPlotCol_Line, (60, 150, 200), category=dpg.mvThemeCat_Plots)
+ dpg.add_theme_style(dpg.mvPlotStyleVar_Marker, dpg.mvPlotMarker_Square, category=dpg.mvThemeCat_Plots)
+ dpg.add_theme_style(dpg.mvPlotStyleVar_MarkerSize, 4, category=dpg.mvThemeCat_Plots)
+
+ # create plot
+ with dpg.plot(tag="plot", label="Line Series", height=-1, width=-1):
+
+ # optionally create legend
+ dpg.add_plot_legend()
+
+ # REQUIRED: create x and y axes
+ dpg.add_plot_axis(dpg.mvXAxis, label="x")
+ dpg.add_plot_axis(dpg.mvYAxis, label="y", tag="yaxis")
+
+ # series belong to a y axis
+ # dpg.add_stem_series(data, sindatay, label="Source", parent="yaxis", tag="series_data")
+ dpg.add_stem_series(sindatax, sindatay, label="0.5 + 0.5 * sin(x)", parent="yaxis", tag="series_data")
+ dpg.add_scatter_series(sindatax, sindatay2, label="2 + 0.5 * sin(x)", parent="yaxis", tag="series_data2")
+
+ # apply theme to series
+ dpg.bind_item_theme("series_data", "plot_theme")
+ dpg.bind_item_theme("series_data2", "plot_theme")
+
+dpg.create_viewport(title='Custom Title', width=800, height=600)
+dpg.setup_dearpygui()
+dpg.show_viewport()
+dpg.start_dearpygui()
+dpg.destroy_context() \ No newline at end of file
diff --git a/tests/dearpygui/test10.py b/tests/dearpygui/test10.py
new file mode 100644
index 0000000..d478d9a
--- /dev/null
+++ b/tests/dearpygui/test10.py
@@ -0,0 +1,53 @@
+from dearpygui.core import *
+from dearpygui.simple import *
+from math import cos
+
+def plot_callback(sender, data):
+ # keeping track of frames
+ frame_count = get_data("frame_count")
+ frame_count += 1
+ add_data("frame_count", frame_count)
+
+ # updating plot data
+ plot_datax = get_data("plot_datax")
+ plot_datay = get_data("plot_datay")
+ if len(plot_datax) > 2000:
+ frame_count = 0
+ plot_datax.clear()
+ plot_datay.clear()
+ plot_datax.append(3.14 * frame_count / 180)
+ plot_datay.append(cos(3 * 3.14 * frame_count / 180))
+ add_data("plot_datax", plot_datax)
+ add_data("plot_datay", plot_datay)
+
+ # plotting new data
+ add_line_series("Plot", "Cos", plot_datax, plot_datay, weight=2)
+
+with window("Tutorial", width=500, height=500):
+ add_plot("Plot", height=-1)
+ add_data("plot_datax", [])
+ add_data("plot_datay", [])
+ add_data("frame_count", 0)
+ add_input_text("freq")
+ with menu_bar("Main Menu Bar"):
+ with menu("File"):
+ add_menu_item("test")
+ set_render_callback(plot_callback)
+
+with window("Heat", width=500, height=500):
+ add_plot("HeatPlot", show_color_scale=False, scale_min=0.0, scale_max=6.0,
+ scale_height=400, no_legend=True,
+ no_mouse_pos=True, xaxis_lock_min=True, xaxis_lock_max=True, xaxis_no_gridlines=True, xaxis_no_tick_marks=True,
+ yaxis_no_gridlines=True, yaxis_no_tick_marks=True, yaxis_lock_min=True, yaxis_lock_max=True, height=400)
+ set_color_map("HeatPlot", 6)
+ values = [0.8, 2.4, 2.5, 3.9, 0.0, 4.0, 0.0,
+ 2.4, 0.0, 4.0, 1.0, 2.7, 0.0, 0.0,
+ 1.1, 2.4, 0.8, 4.3, 1.9, 4.4, 0.0,
+ 0.6, 0.0, 0.3, 0.0, 3.1, 0.0, 0.0,
+ 0.7, 1.7, 0.6, 2.6, 2.2, 6.2, 0.0,
+ 1.3, 1.2, 0.0, 0.0, 0.0, 3.2, 5.1,
+ 0.1, 2.0, 0.0, 1.4, 0.0, 1.9, 6.3]
+ add_heat_series("HeatPlot", "heat data", values, 7, 7, 0, 6, format='')
+
+
+start_dearpygui() \ No newline at end of file
diff --git a/tests/dearpygui/test1_updating_series_data.py b/tests/dearpygui/test1_updating_series_data.py
new file mode 100644
index 0000000..1371008
--- /dev/null
+++ b/tests/dearpygui/test1_updating_series_data.py
@@ -0,0 +1,30 @@
+import dearpygui.dearpygui as dpg
+from math import sin
+
+dpg.create_context()
+
+# creating data
+sindatax = []
+sindatay = []
+for i in range(0, 500):
+ sindatax.append(i / 1000)
+ sindatay.append(0.5 + 0.5 * sin(50 * i / 1000))
+
+with dpg.window(label="Tutorial"):
+ # create plot
+ with dpg.plot(label="Line Series", height=400, width=400):
+ # optionally create legend
+ dpg.add_plot_legend()
+
+ # REQUIRED: create x and y axes
+ dpg.add_plot_axis(dpg.mvXAxis, label="x")
+ dpg.add_plot_axis(dpg.mvYAxis, label="y", tag="y_axis")
+
+ # series belong to a y axis
+ dpg.add_line_series(sindatax, sindatay, label="0.5 + 0.5 * sin(x)", parent="y_axis")
+
+dpg.create_viewport(title='Custom Title', width=800, height=600)
+dpg.setup_dearpygui()
+dpg.show_viewport()
+dpg.start_dearpygui()
+dpg.destroy_context() \ No newline at end of file
diff --git a/tests/dearpygui/test2_axis_limis.py b/tests/dearpygui/test2_axis_limis.py
new file mode 100644
index 0000000..bdfeda1
--- /dev/null
+++ b/tests/dearpygui/test2_axis_limis.py
@@ -0,0 +1,40 @@
+import dearpygui.dearpygui as dpg
+from math import sin, cos
+
+dpg.create_context()
+
+sindatax = []
+sindatay = []
+for i in range(0, 500):
+ sindatax.append(i / 1000)
+ sindatay.append(0.5 + 0.5 * sin(50 * i / 1000))
+
+def update_series():
+
+ cosdatax = []
+ cosdatay = []
+ for i in range(0, 500):
+ cosdatax.append(i / 1000)
+ cosdatay.append(0.5 + 0.5 * cos(50 * i / 1000))
+ dpg.set_value('series_tag', [cosdatax, cosdatay])
+ dpg.set_item_label('series_tag', "0.5 + 0.5 * cos(x)")
+
+with dpg.window(label="Tutorial", tag="win"):
+ dpg.add_button(label="Update Series", callback=update_series)
+ # create plot
+ with dpg.plot(label="Line Series", height=400, width=400):
+ # optionally create legend
+ dpg.add_plot_legend()
+
+ # REQUIRED: create x and y axes
+ dpg.add_plot_axis(dpg.mvXAxis, label="x")
+ dpg.add_plot_axis(dpg.mvYAxis, label="y", tag="y_axis")
+
+ # series belong to a y axis
+ dpg.add_line_series(sindatax, sindatay, label="0.5 + 0.5 * sin(x)", parent="y_axis", tag="series_tag")
+
+dpg.create_viewport(title='Custom Title', width=800, height=600)
+dpg.setup_dearpygui()
+dpg.show_viewport()
+dpg.start_dearpygui()
+dpg.destroy_context()
diff --git a/tests/dearpygui/test3_custom_axis_labels.py b/tests/dearpygui/test3_custom_axis_labels.py
new file mode 100644
index 0000000..be6b80b
--- /dev/null
+++ b/tests/dearpygui/test3_custom_axis_labels.py
@@ -0,0 +1,34 @@
+import dearpygui.dearpygui as dpg
+
+dpg.create_context()
+
+with dpg.window(label="Tutorial", width=400, height=400):
+ with dpg.group(horizontal=True):
+ dpg.add_button(label="fit y", callback=lambda: dpg.fit_axis_data("y_axis"))
+ dpg.add_button(label="unlock x limits", callback=lambda: dpg.set_axis_limits_auto("x_axis"))
+ dpg.add_button(label="unlock y limits", callback=lambda: dpg.set_axis_limits_auto("y_axis"))
+ dpg.add_button(label="print limits x", callback=lambda: print(dpg.get_axis_limits("x_axis")))
+ dpg.add_button(label="print limits y", callback=lambda: print(dpg.get_axis_limits("y_axis")))
+
+ with dpg.plot(label="Bar Series", height=-1, width=-1):
+ dpg.add_plot_legend()
+
+ # create x axis
+ dpg.add_plot_axis(dpg.mvXAxis, label="Student", no_gridlines=True, tag="x_axis")
+ dpg.set_axis_limits(dpg.last_item(), 9, 33)
+ dpg.set_axis_ticks(dpg.last_item(), (("S1", 11), ("S2", 21), ("S3", 31)))
+
+ # create y axis
+ dpg.add_plot_axis(dpg.mvYAxis, label="Score", tag="y_axis")
+ dpg.set_axis_limits("y_axis", 0, 110)
+
+ # add series to y axis
+ dpg.add_bar_series([10, 20, 30], [100, 75, 90], label="Final Exam", weight=1, parent="y_axis")
+ dpg.add_bar_series([11, 21, 31], [83, 75, 72], label="Midterm Exam", weight=1, parent="y_axis")
+ dpg.add_bar_series([12, 22, 32], [42, 68, 23], label="Course Grade", weight=1, parent="y_axis")
+
+dpg.create_viewport(title='Custom Title', width=800, height=600)
+dpg.setup_dearpygui()
+dpg.show_viewport()
+dpg.start_dearpygui()
+dpg.destroy_context() \ No newline at end of file
diff --git a/tests/dearpygui/test4_multiple_y_axes.py b/tests/dearpygui/test4_multiple_y_axes.py
new file mode 100644
index 0000000..ebaac7e
--- /dev/null
+++ b/tests/dearpygui/test4_multiple_y_axes.py
@@ -0,0 +1,25 @@
+import dearpygui.dearpygui as dpg
+
+dpg.create_context()
+
+with dpg.window(label="Tutorial", width=400, height=400):
+ with dpg.plot(label="Bar Series", height=-1, width=-1):
+ dpg.add_plot_legend()
+
+ # create x axis
+ dpg.add_plot_axis(dpg.mvXAxis, label="Student", no_gridlines=True)
+ dpg.set_axis_ticks(dpg.last_item(), (("S1", 11), ("S2", 21), ("S3", 31)))
+
+ # create y axis
+ dpg.add_plot_axis(dpg.mvYAxis, label="Score", tag="yaxis_tag")
+
+ # add series to y axis
+ dpg.add_bar_series([10, 20, 30], [100, 75, 90], label="Final Exam", weight=1, parent="yaxis_tag")
+ dpg.add_bar_series([11, 21, 31], [83, 75, 72], label="Midterm Exam", weight=1, parent="yaxis_tag")
+ dpg.add_bar_series([12, 22, 32], [42, 68, 23], label="Course Grade", weight=1, parent="yaxis_tag")
+
+dpg.create_viewport(title='Custom Title', width=800, height=600)
+dpg.setup_dearpygui()
+dpg.show_viewport()
+dpg.start_dearpygui()
+dpg.destroy_context() \ No newline at end of file
diff --git a/tests/dearpygui/test5_annotations.py b/tests/dearpygui/test5_annotations.py
new file mode 100644
index 0000000..9deff6b
--- /dev/null
+++ b/tests/dearpygui/test5_annotations.py
@@ -0,0 +1,32 @@
+import dearpygui.dearpygui as dpg
+from math import sin
+
+dpg.create_context()
+
+
+sindatax = []
+sindatay = []
+for i in range(0, 100):
+ sindatax.append(i / 100)
+ sindatay.append(0.5 + 0.5 * sin(50 * i / 100))
+
+with dpg.window(label="Tutorial", width=400, height=400):
+ with dpg.plot(label="Annotations", height=-1, width=-1):
+ dpg.add_plot_legend()
+ dpg.add_plot_axis(dpg.mvXAxis, label="x")
+ dpg.add_plot_axis(dpg.mvYAxis, label="y")
+ dpg.add_line_series(sindatax, sindatay, label="0.5 + 0.5 * sin(x)", parent=dpg.last_item())
+
+ # annotations belong to the plot NOT axis
+ dpg.add_plot_annotation(label="BL", default_value=(0.25, 0.25), offset=(-15, 15), color=[255, 255, 0, 255])
+ dpg.add_plot_annotation(label="BR", default_value=(0.75, 0.25), offset=(15, 15), color=[255, 255, 0, 255])
+ dpg.add_plot_annotation(label="TR not clampled", default_value=(0.75, 0.75), offset=(-15, -15),
+ color=[255, 255, 0, 255], clamped=False)
+ dpg.add_plot_annotation(label="TL", default_value=(0.25, 0.75), offset=(-15, -15), color=[255, 255, 0, 255])
+ dpg.add_plot_annotation(label="Center", default_value=(0.5, 0.5), color=[255, 255, 0, 255])
+
+dpg.create_viewport(title='Custom Title', width=800, height=600)
+dpg.setup_dearpygui()
+dpg.show_viewport()
+dpg.start_dearpygui()
+dpg.destroy_context()
diff --git a/tests/dearpygui/test6_drag_points_and_lines.py b/tests/dearpygui/test6_drag_points_and_lines.py
new file mode 100644
index 0000000..c6d8862
--- /dev/null
+++ b/tests/dearpygui/test6_drag_points_and_lines.py
@@ -0,0 +1,26 @@
+import dearpygui.dearpygui as dpg
+
+dpg.create_context()
+
+def print_val(sender):
+ print(dpg.get_value(sender))
+
+with dpg.window(label="Tutorial", width=400, height=400):
+ with dpg.plot(label="Drag Lines/Points", height=-1, width=-1):
+ dpg.add_plot_legend()
+ dpg.add_plot_axis(dpg.mvXAxis, label="x")
+ dpg.set_axis_limits(dpg.last_item(), -5, 5)
+ dpg.add_plot_axis(dpg.mvYAxis, label="y")
+ dpg.set_axis_limits(dpg.last_item(), -5, 5)
+
+ # drag lines/points belong to the plot NOT axis
+ dpg.add_drag_line(label="dline1", color=[255, 0, 0, 255], default_value=2.0, callback=print_val)
+ dpg.add_drag_line(label="dline2", color=[255, 255, 0, 255], vertical=False, default_value=-2, callback=print_val)
+ dpg.add_drag_point(label="dpoint1", color=[255, 0, 255, 255], default_value=(1.0, 1.0), callback=print_val)
+ dpg.add_drag_point(label="dpoint2", color=[255, 0, 255, 255], default_value=(-1.0, 1.0), callback=print_val)
+
+dpg.create_viewport(title='Custom Title', width=800, height=600)
+dpg.setup_dearpygui()
+dpg.show_viewport()
+dpg.start_dearpygui()
+dpg.destroy_context() \ No newline at end of file
diff --git a/tests/dearpygui/test7_querying.py b/tests/dearpygui/test7_querying.py
new file mode 100644
index 0000000..06f3ceb
--- /dev/null
+++ b/tests/dearpygui/test7_querying.py
@@ -0,0 +1,37 @@
+import dearpygui.dearpygui as dpg
+from math import sin
+
+dpg.create_context()
+
+sindatax = []
+sindatay = []
+for i in range(0, 100):
+ sindatax.append(i / 100)
+ sindatay.append(0.5 + 0.5 * sin(50 * i / 100))
+
+with dpg.window(label="Tutorial", width=400, height=600):
+ dpg.add_text("Click and drag the middle mouse button over the top plot!")
+
+
+ def query(sender, app_data, user_data):
+ dpg.set_axis_limits("xaxis_tag2", app_data[0], app_data[1])
+ dpg.set_axis_limits("yaxis_tag2", app_data[2], app_data[3])
+
+
+ # plot 1
+ with dpg.plot(no_title=True, height=200, callback=query, query=True, no_menus=True, width=-1):
+ dpg.add_plot_axis(dpg.mvXAxis, label="x")
+ dpg.add_plot_axis(dpg.mvYAxis, label="y")
+ dpg.add_line_series(sindatax, sindatay, parent=dpg.last_item())
+
+ # plot 2
+ with dpg.plot(no_title=True, height=200, no_menus=True, width=-1):
+ dpg.add_plot_axis(dpg.mvXAxis, label="x1", tag="xaxis_tag2")
+ dpg.add_plot_axis(dpg.mvYAxis, label="y1", tag="yaxis_tag2")
+ dpg.add_line_series(sindatax, sindatay, parent="yaxis_tag2")
+
+dpg.create_viewport(title='Custom Title', width=800, height=600)
+dpg.setup_dearpygui()
+dpg.show_viewport()
+dpg.start_dearpygui()
+dpg.destroy_context() \ No newline at end of file
diff --git a/tests/dearpygui/test8_custom_context_menus.py b/tests/dearpygui/test8_custom_context_menus.py
new file mode 100644
index 0000000..b459d15
--- /dev/null
+++ b/tests/dearpygui/test8_custom_context_menus.py
@@ -0,0 +1,33 @@
+import dearpygui.dearpygui as dpg
+from math import sin
+
+dpg.create_context()
+
+sindatax = []
+sindatay = []
+for i in range(0, 100):
+ sindatax.append(i / 100)
+ sindatay.append(0.5 + 0.5 * sin(50 * i / 100))
+
+with dpg.window(label="Tutorial", width=400, height=400):
+ # create plot
+ dpg.add_text("Right click a series in the legend!")
+ with dpg.plot(label="Line Series", height=-1, width=-1):
+ dpg.add_plot_legend()
+
+ dpg.add_plot_axis(dpg.mvXAxis, label="x")
+ dpg.add_plot_axis(dpg.mvYAxis, label="y", tag="yaxis")
+
+ # series 1
+ dpg.add_line_series(sindatax, sindatay, label="series 1", parent="yaxis", tag="series_1")
+ dpg.add_button(label="Delete Series 1", parent=dpg.last_item(), callback=lambda: dpg.delete_item("series_1"))
+
+ # series 2
+ dpg.add_line_series(sindatax, sindatay, label="series 2", parent="yaxis", tag="series_2")
+ dpg.add_button(label="Delete Series 2", parent=dpg.last_item(), callback=lambda: dpg.delete_item("series_2"))
+
+dpg.create_viewport(title='Custom Title', width=800, height=600)
+dpg.setup_dearpygui()
+dpg.show_viewport()
+dpg.start_dearpygui()
+dpg.destroy_context()
diff --git a/tests/dearpygui/test9_colors_and_styles.py b/tests/dearpygui/test9_colors_and_styles.py
new file mode 100644
index 0000000..2f1c7ef
--- /dev/null
+++ b/tests/dearpygui/test9_colors_and_styles.py
@@ -0,0 +1,50 @@
+import dearpygui.dearpygui as dpg
+from math import sin
+
+dpg.create_context()
+
+sindatax = []
+sindatay = []
+for i in range(0, 100):
+ sindatax.append(i / 100)
+ sindatay.append(0.5 + 0.5 * sin(50 * i / 100))
+sindatay2 = []
+for i in range(0, 100):
+ sindatay2.append(2 + 0.5 * sin(50 * i / 100))
+
+with dpg.window(label="Tutorial", width=500, height=400):
+ # create a theme for the plot
+ with dpg.theme(tag="plot_theme"):
+ with dpg.theme_component(dpg.mvStemSeries):
+ dpg.add_theme_color(dpg.mvPlotCol_Line, (150, 255, 0), category=dpg.mvThemeCat_Plots)
+ dpg.add_theme_style(dpg.mvPlotStyleVar_Marker, dpg.mvPlotMarker_Diamond, category=dpg.mvThemeCat_Plots)
+ dpg.add_theme_style(dpg.mvPlotStyleVar_MarkerSize, 7, category=dpg.mvThemeCat_Plots)
+
+ with dpg.theme_component(dpg.mvScatterSeries):
+ dpg.add_theme_color(dpg.mvPlotCol_Line, (60, 150, 200), category=dpg.mvThemeCat_Plots)
+ dpg.add_theme_style(dpg.mvPlotStyleVar_Marker, dpg.mvPlotMarker_Square, category=dpg.mvThemeCat_Plots)
+ dpg.add_theme_style(dpg.mvPlotStyleVar_MarkerSize, 4, category=dpg.mvThemeCat_Plots)
+
+ # create plot
+ with dpg.plot(tag="plot", label="Line Series", height=-1, width=-1):
+
+ # optionally create legend
+ dpg.add_plot_legend()
+
+ # REQUIRED: create x and y axes
+ dpg.add_plot_axis(dpg.mvXAxis, label="x")
+ dpg.add_plot_axis(dpg.mvYAxis, label="y", tag="yaxis")
+
+ # series belong to a y axis
+ dpg.add_stem_series(sindatax, sindatay, label="0.5 + 0.5 * sin(x)", parent="yaxis", tag="series_data")
+ dpg.add_scatter_series(sindatax, sindatay2, label="2 + 0.5 * sin(x)", parent="yaxis", tag="series_data2")
+
+ # apply theme to series
+ dpg.bind_item_theme("series_data", "plot_theme")
+ dpg.bind_item_theme("series_data2", "plot_theme")
+
+dpg.create_viewport(title='Custom Title', width=800, height=600)
+dpg.setup_dearpygui()
+dpg.show_viewport()
+dpg.start_dearpygui()
+dpg.destroy_context()