将代码使用egg加密后 如何才能正确的读取egg文件内的文件
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- build-system, desktop
Research direction
Start with script/UI/Custom_UI/QToolTip.py and the referenced QToolTip.qss, then inspect how PyStand packages and exposes files inside an egg. Reproduce the FileNotFoundError using the packaged project and verify that the QSS resource can be read after packaging without converting it into a Python module.
Written by the indexing model from the issue text.
Description
在我的项目中 打包时候出现了错误 下面这行代码报错:
file = os.path.join("UI","Custom_UI","QToolTip.qss")
with open(file,'r') as f:
self.setStyleSheet(f.read())
这里的qss文件是一个需要被读取的文件 用来设置UI样式
压缩成egg后 运行报错:
C:\Users\xyj\Desktop\3.0.0-alpha>Traceback (most recent call last):
Traceback (most recent call last):
File "<string>", line 34, in <module>
File "C:\Users\xyj\Desktop\3.0.0-alpha\MOS.int", line 13, in <module>
Run()
File "C:\Users\xyj\Desktop\3.0.0-alpha\script\Code\MainWindow.py", line 544, in Run
ui = RunUi()
File "C:\Users\xyj\Desktop\3.0.0-alpha\script\Code\MainWindow.py", line 58, in __init__
self.__init__setToolTipDuration()
File "C:\Users\xyj\Desktop\3.0.0-alpha\script\Code\MainWindow.py", line 498, in __init__setToolTipDuration
self._toolTip = ToolTip(parent=self)
File "C:\Users\xyj\Desktop\3.0.0-alpha\script\UI\Custom_UI\QToolTip.py", line 44, in __init__
self.__setQss()
File "C:\Users\xyj\Desktop\3.0.0-alpha\script\UI\Custom_UI\QToolTip.py", line 66, in __setQss
with open(file,'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'UI\\Custom_UI\\QToolTip.qss'
之后我只好更改了代码 将需要被读取的内容改成一个py文件 并且内建一个函数 调用之后 就返回这个文件的内容 虽然这么可以解决这个问题 但是我并不想这么解决 (因为这个方法很不好 而且以后想快速的改这个qss列表 也很麻烦
- Dominant language
- C++
- Stars
- 1.2k
- Forks
- 146
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from skywind3000/PyStand
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
skywind3000/PyStand#111 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
skywind3000/PyStand#109 · 5 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
skywind3000/PyStand#105 · 3 reactions ·
-
文档拉胯 Open
Difficulty 5/5 Over a week Newbie friendliness 25/100
skywind3000/PyStand#104 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
skywind3000/PyStand#102 · 5 comments ·
All issues in skywind3000/PyStand
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
NVIDIA/cuda-samples#453 ·