Merge branch 'louisnw01:main' into main

This commit is contained in:
James Baber
2023-09-14 09:25:22 -05:00
committed by GitHub
12 changed files with 104 additions and 71 deletions

View File

@ -1,5 +1,6 @@
import asyncio
import os
from base64 import b64decode
from datetime import datetime
from typing import Union, Literal, List, Optional
import pandas as pd
@ -887,6 +888,15 @@ class AbstractChart(Candlestick, Pane):
) -> Table:
return self.win.create_table(width, height, headings, widths, alignments, position, draggable, func)
def screenshot(self) -> bytes:
"""
Takes a screenshot. This method can only be used after the chart window is visible.
:return: a bytes object containing a screenshot of the chart.
"""
self.run_script(f'_~_~RETURN~_~_{self.id}.chart.takeScreenshot().toDataURL()')
serial_data = self.win._return_q.get()
return b64decode(serial_data.split(',')[1])
def create_subchart(self, position: FLOAT = 'left', width: float = 0.5, height: float = 0.5,
sync: Union[str, bool] = None, scale_candles_only: bool = False,
toolbox: bool = False) -> 'AbstractChart':