将代码使用egg加密后 如何才能正确的读取egg文件内的文件

Aperta
#24 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

在我的项目中 打包时候出现了错误 下面这行代码报错:

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列表 也很麻烦

改正前:
https://github.com/xianyongjian080402/Minecraft-Optimal-Starter_3/tree/b068e9e212fe5cf668a50d4c83523f7510749c5f

改正后:
https://github.com/xianyongjian080402/Minecraft-Optimal-Starter_3/tree/8629cf3f5d694ca0ba9eb55a28e1c94776f8b735

Lingua principale
C++
Stelle
1.2k
Fork
146
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di skywind3000/PyStand

Tutte le issue di skywind3000/PyStand

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.