rgerum / pylustrator

Visualisations of data are at the core of every publication of scientific research results. They have to be as clear as possible to facilitate the communication of research. As data can have different formats and shapes, the visualisations often have to be adapted to reflect the data as well as possible. We developed Pylustrator, an interface to directly edit python generated matplotlib graphs to finalize them for publication. Therefore, subplots can be resized and dragged around by the mouse, text and annotations can be added. The changes can be saved to the initial plot file as python code.
GNU General Public License v3.0
707 stars 37 forks source link

Issue with saving via pylustrator's Save As... menu on Windows #62

Closed CommanderPho closed 1 year ago

CommanderPho commented 1 year ago

I'm having problems saving using the "Save As..." menu item on Windows. It throws the following exception:

TypeError                                 Traceback (most recent call last)
File [c:\Users\pho\repos\Spike3DWorkEnv\Spike3D\.venv\lib\site-packages\pylustrator\QtGuiDrag.py:522](file:///C:/Users/pho/repos/Spike3DWorkEnv/Spike3D/.venv/lib/site-packages/pylustrator/QtGuiDrag.py:522), in PlotWindow.actionSaveImage(self)
    520 def actionSaveImage(self):
    521     """ save figure as an image """
--> 522     path = QtWidgets.QFileDialog.getSaveFileName(self, "Save Image", getattr(self.fig, "_last_saved_figure", [(None,)])[0][0],
    523                                                  "Images (*.png *.jpg *.pdf)")
    524     if isinstance(path, tuple):
    525         path = str(path[0])

TypeError: getSaveFileName(parent: typing.Optional[QWidget] = None, caption: str = '', directory: str = '', filter: str = '', initialFilter: str = '', options: Union[QFileDialog.Options, QFileDialog.Option] = 0): argument 3 has unexpected type 'WindowsPath'
rgerum commented 1 year ago

ah that was an issue when you called plt.savefig() with a Path object. I now cast the path to string before opening the getSaveFileName dialog.