Skip to content

Commit 431ff9e

Browse files
authored
Merge pull request #3 from liuyou/master
fix: Windows cannot load screenshot
2 parents cca07a7 + 3cbda13 commit 431ff9e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

uiviewer/_device.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import abc
44
import traceback
55
import tempfile
6+
import os
67
from typing import List, Dict, Union, Tuple, Optional
78
from functools import cached_property # python3.8+
89

@@ -55,10 +56,14 @@ def _display_size(self) -> Tuple:
5556
return self.hdc.display_size()
5657

5758
def take_screenshot(self) -> str:
59+
png_base64 = None
5860
with tempfile.NamedTemporaryFile(delete=True, suffix=".png") as f:
5961
path = f.name
62+
f.close()
6063
self.hdc.screenshot(path)
61-
return file2base64(path)
64+
png_base64 = file2base64(path)
65+
os.remove(path)
66+
return png_base64
6267

6368
def dump_hierarchy(self) -> BaseHierarchy:
6469
packageName, pageName = self.hdc.current_app()

0 commit comments

Comments
 (0)