default_keymap = 'X'
description = 'Save dataframe to csv, xlsx, json, ubin, or hdf'
image = ''
df = pd.read_csv('C:\Python\PY3810_64v1\Lib\site-packages\\data\sample.csv')
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def trigger(self, *args):
datalist = [('File Type', ['', '', 'xlsx', 'csv', 'json', 'ubin', 'hdf']),
('', 0.0), # if this line is commented out, the code stops working with matplotlib plot --- this is where the issue lies
('File Path', os.getcwd())]
def apply_callback(data):
(file, path) = data
if file == 'csv':
Save.df.to_csv('path')
fedit(datalist, 'Excel', 'Save the current dataframe', parent=None, apply=apply_callback)
from matplotlib.backend_tools import ToolBase
from matplotlib.backends.qt_editor._formlayout import fedit
import matplotlib.pyplot as plt
import matplotlib
import pandas as pd
import os
class Save(ToolBase):
matplotlib.use('Qt5Agg', force=True)
plt.rcParams['toolbar'] = 'toolmanager'
fig, ax = plt.subplots()
fig.canvas.manager.toolmanager.add_tool('Save', Save)
fig.canvas.manager.toolbar.add_tool('Save', 1, -1)
plt.show()