dso_gui module
Note
This mudule can only be used on DSO!
- class dso_gui.DrawObject(*args, **kwargs)
Bases:
__Gui_Init- class Draw_A_B(x, y, x_size, y_size, bg_color=gds.Theme(dark_mode=True).bg_color, grid_color=gds.Theme(dark_mode=True).grid_color)
Bases:
object- add_a_b_data(data_color=color.RED)
- draw_a_b_data(a_data, b_data, a_float=0, b_float=0, point_num=0)
- get_a_b_type()
- set_a_b_min_max(a_min, a_max, b_min, b_max)
- set_style_xy(x_div=11, y_div=11, x_div_minor=6, y_div_minor=6, str_color=gds.Theme(dark_mode=True).text_color, str_font=font)
- class Plot(x: int, y: int, width: int, height: int, dark_mode: bool = True)
Bases:
objectThe tool can plot on your DSO.
- Parameters:
A simple example is as follows.
import dso_gui import gds_info as gds import dso_colors as color # Initialize the GUI gui = dso_gui.DrawObject() gui.set_bg_color(gds.Theme().bg_color) # Create figure object fig = gui.Plot(x=120, y=43, width=630, height=350) fig.grid(x_major=12, y_major=10, line_color=gds.Theme().grid_color, bg_color=gds.Theme().bg_color, x_minor=5, y_minor=5) fig.set_x_axis_on(text_color=gds.Theme().text_color, line_color=gds.Theme().grid_color, fmt='%d') fig.set_y_axis_on(text_color=gds.Theme().text_color, line_color=gds.Theme().grid_color, fmt='%.1f') # Add axis labels gui.draw_text(400, 440, "Time(h)", gds.Theme().text_color) gui.draw_text(30, 300, f"Temperature({chr(176)}C)", gds.Theme().text_color, 270) # Add legend gui.draw_text(310, 15, "Sample A", gds.Theme().text_color) gui.draw_line(270,25,300,25, color.LTGREEN) gui.draw_text(460, 15, "Sample B", gds.Theme().text_color) gui.draw_line(420,25,450,25, color.YELLOW) # Draw data point for Sample A valx = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] valy = [20.0, 23.4, 26.8, 29.5, 33.2, 37.6, 41.2, 45.7, 50.0, 56.1, 62.7, 62.5, 62.8] fig.plot(valx, valy, color=color.LTGREEN) # Draw data point for Sample B valy = [20.0, 26.2, 32.5, 38.3, 45.7, 52.4, 59.3, 67.8, 75.4, 75.1, 75.2, 75.6, 75.3] fig.plot(valx, valy, color=color.YELLOW)
- get_xlim() float
Return the x-axis view limits.
- Returns:
The current x-axis limits in data coordinates.
- Return type:
- get_ylim() float
Return the y-axis view limits.
- Returns:
The current y-axis limits in data coordinates.
- Return type:
- grid(x_major: int = 10, y_major: int = 10, **kwargs)
Configure the grid lines.
- Parameters:
- Keyword Arguments:
line_color – The grid color.
bg_color – The grid background color.
font – The font
x_minor – The minor X division number.
y_minor – The minor X division number.
- hold(b: bool = True)
Set the hold state.
>>> hold() # hold is on >>> hold(True) # hold is on >>> hold(False) # hold is off
- Parameters:
b (bool, optional) – Defaults to True.
- plot(*args, **kwargs)
Plot y versus x as lines or marks.
Both x and y will be a number or 1-D list
>>> plot(x, y) # plot x and y using default color >>> plot(y) # plot y using x as index array 0..N-1 >>> plot(x, y, color=lv.color_hex(0x000000)) # plot x and y using hex color code
- Keyword Arguments:
color – the line color
- set_line_width(width: int = 1)
Set the line width, with 0 is only the mark.
- Parameters:
width (int, optional) – Defaults to 1.
- set_size(size: int = 1)
The marker size in points.
- Parameters:
size (int, optional) – Defaults to 1.
- set_x_axis_off()
Hide all visual components of the x-axis.
- set_x_axis_on(**kwargs)
Configure and show the x-axis.
If you change grid’s configure, then you have to run it once.
- Keyword Arguments:
text_color – The y-axis text color.
line_color – The y-axis color
fmt – The y-axis text string format. ex:’%.2f’
- set_y_axis_off()
Hide all visual components of the y-axis.
- set_y_axis_on(**kwargs)
Configure and show the y-axis.
If you change grid’s configure, then you have to run it once.
- Keyword Arguments:
text_color – The y-axis text color.
line_color – The y-axis color
fmt – The y-axis text string format. ex:’%.2f’
- clear()
- draw_arc(x1, y1, x2, y2, color=color.WHITE, rol=0)
- draw_arc_ex(x, y, start_angle, end_angle, color=color.WHITE, width=1, radius=10)
- draw_fillpolygon_ex(x1, y1, x2, y2, x3, y3, color=color.WHITE)
- draw_fillrect_ex(x, y, x_width, y_hight, color=color.WHITE)
- draw_line(x1, y1, x2, y2, color=color.WHITE, width=1)
- draw_line_ex(x1, y1, x2, y2, color=color.WHITE, width=1)
- draw_png(x, y, path)
- draw_point_ex(x, y, color=color.WHITE)
- draw_polygon_ex(x1, y1, x2, y2, x3, y3, color=color.WHITE)
- draw_popup(str, delay)
- draw_rect(x, y, x_width, y_hight, color=color.WHITE, width=1)
- draw_rect_ex(x, y, x_width, y_hight, color=color.WHITE)
rect_style = lv.draw_rect_dsc_t() rect_style.init() #rect_style.bg_color = self.canvas_bg_color rect_style.border_color = color rect_style.border_width = 1 self.canvas.draw_rect(x, y, x_width, y_hight, rect_style)
- draw_text_ex(x, y, str, color=color.WHITE, font=font)
- initial = False
- instance = None
- set_bg_color(color)
- set_font(size=16, fnt_path=None)