Skip to content

Commit

Permalink
feat : Add custom image location
Browse files Browse the repository at this point in the history
  • Loading branch information
lzmhc committed Dec 26, 2024
1 parent c5d292a commit 79324fa
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions screenpen/screenpen.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
from PyQt5.QtWidgets import QMainWindow, QApplication, QDesktopWidget
from PyQt5.QtCore import QPoint, Qt, QSize
from PyQt5.QtWidgets import QToolBar, QAction, QDialog, QToolButton, QMenu, QColorDialog
# 文件选择
from PyQt5.QtWidgets import QFileDialog
from PyQt5.QtGui import (
QIcon, QScreen, QPalette, QColor, QCursor,
QSyntaxHighlighter, QPixmap, QKeySequence
Expand Down Expand Up @@ -728,12 +730,15 @@ def captureScreen(self):
for tb in self.toolBars:
tb.show()
return img

def saveLocation(self):
fname = QFileDialog.getExistingDirectory(self, '选择保存目录', '/home')
return fname
def saveDrawing(self):
def _saveDrawing(n=0):
filename = f'{datetime.now().strftime("%Y%m%d_%H%M%S")}.png'
print(f'Saving {filename}')
self.captureScreen().save(f'{filename}')
location = self.saveLocation()+"/"
print(f'Saving {location}{filename}')
self.captureScreen().save(f'{location}{filename}')
return _saveDrawing

def colorPicker(self):
Expand Down

0 comments on commit 79324fa

Please sign in to comment.