首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法在PyQt5中映射icu数据文件

问无法在PyQt5中映射icu数据文件
EN

Stack Overflow用户
提问于 2021-10-04 09:34:07
回答 1查看 130关注 0票数 0

我在pyqt5中使用了QWebEngineView。尝试使用超文本标记语言文件在QWebEnginView中导出PDF。当我在VS Code中运行该文件时,pdf导出并正常工作,但是当我在cmd中使用以下命令将此python文件转换为exe时

代码语言:javascript
复制
pyinstaller --onefile mycode.py

然后运行mycode.exe,我得到了这个错误:无法映射重症监护室数据文件

下面是我用pyqt5编写的全部代码:

代码语言:javascript
复制
import sys
from PyQt5.QtWidgets import (QHBoxLayout, QPushButton, QWidget, 
QApplication, QVBoxLayout, QMessageBox)
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWebEngineWidgets import QWebEngineView


class Example(QWidget):

  def __init__(self):
    super().__init__()

    self.initUI()

  def initUI(self):

    vbox = QVBoxLayout(self)
    hbox = QHBoxLayout()

    self.webEngineView = QWebEngineView()
    self.loadPage()

    expBtn = QPushButton('Export', self)
    expBtn.clicked.connect(self.onClicked)

    hbox.addWidget(expBtn)

    vbox.addWidget(self.webEngineView)
    vbox.addLayout(hbox)
    self.setLayout(vbox)

    self.setGeometry(300, 300, 350, 250)
    self.setWindowTitle('QWebEngineView')
    self.show()

  def onClicked(self):

    self.webEngineView.page().printToPdf('myfile.pdf')
    QMessageBox.information(self, 'info', 'page exported')

  def loadPage(self):

    with open('html.html', encoding="utf8") as f:

        html = f.read()
        self.webEngineView.setHtml(html)

def main():

   app = QApplication(sys.argv)
   ex = Example()
   sys.exit(app.exec_())


if __name__ == '__main__':
   main()

这是我的HTML:

代码语言:javascript
复制
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
  
    <style>
        th, td {
          border-bottom:1px solid black;
          border-right:1px solid black;
          text-align : center;
          padding : 3px;
        }
        * {
        direction: rtl;
        }     
        
        .img{
            border-bottom:1px solid black;
          border-right:1px solid black;
          text-align : center;
          
        }
        .center {
            
            margin-left: auto;
            margin-right: auto;
            width:95%;
            border:1px solid black;
            
            }
        </style>
        
    </head>
<body style="font-family: Arial">
    
      <div style="border: 4px double black;">
        <h3 style="text-align:center; font-size: 30px;">فاکتور خرید</h3>
        <h3 style="text-align:center ;font-size: 30px;">شرکت برنا نوآوران پویا</h3>
        <img src="icon.jpg" alt="Paris" style="width: 5%;">
    </div>
    <div style="border-bottom: 1px dashed black; border-left: 4px double black; border-right: 4px double black;border-top: 1px double black;">

        <p style="text-align:right; font-size: 20px; padding-right: 30px;"> تاریخ : </p>
        <p style="text-align:right; font-size: 20px; padding-right: 30px;">زمان :</p>
    </div>
    <div style="border-bottom: 4px double black; border-left: 4px double black; border-right: 4px double black;border-top: 1px dashed black;">
        <br></br>
        
        <table class = "center">
            <tr >
              <th>شماره بارنامه</th>
              <th>تاریخ ورود محموله</th>
              <th>نرخ دلار</th>
              <th>نرخ پوند</th>
              <th>نرخ یورو</th>
              <th>وزن کل</th>
              <th>هزینه گمرک</th>
              <th>هزینه حمل</th>
              <th>هزینه خرید</th>
              <th>هزینه کارمزد</th>
              <th>مجموع هزینه کل</th>
              <th>تعداد کل کالا</th>
              
            </tr>
            <tr>
              <td>3333</td>
              <td>345</td>
              <td>30000000</td>
              <td>30000000</td>
              <td>30000000</td>
              <td>30000000</td>
              <td>30000000</td>
              <td>30000000</td>
              <td>30000000</td>
              <td>30000000</td>
              <td>30000000</td>
              <td>30000000</td>
              
              
            </tr>
           
          </table>
          <br></br>
        <br></br>
        
          <table class = "center">
            <tr >
              <th>اسم کالا</th>
              <th>تعداد تکی</th>
              <th>قمیت خرید نهایی</th>
              <th>وزن نهایی به گرم</th>
              <th>قیمت کل</th>
              
            </tr>
            <tr>
              <td>30000000</td>
              <td>30000000</td>
              <td>30000000</td>
              <td>30000000</td>
              <td>30000000</td> 
            </tr>

            <tr>
                <td>30000000</td>
                <td>30000000</td>
                <td>30000000</td>
                <td>30000000</td>
                <td>30000000</td> 
              </tr>

              <tr>
                <td>30000000</td>
                <td>30000000</td>
                <td>30000000</td>
                <td>30000000</td>
                <td>30000000</td> 
              </tr>
              <tr>
                <td>30000000</td>
                <td>30000000</td>
                <td>30000000</td>
                <td>30000000</td>
                <td>30000000</td> 
              </tr>
           
          </table>
          
          <br></br>


        <p style="border-bottom: 1px solid black;border-right: 1px solid black; border-radius: 2px; text-align:right; font-size: 20px; margin-right:30px; width: 50%; height: 40px;">
          <span style="display: inline-block; margin-right: 5px; margin-bottom: 7px; margin-top: 7px;">مجموع قیمت کل :</span>
        <span style="display: inline-block; margin-right: 3px; margin-bottom: 7px; margin-top: 7px;">34343</span>
        </p>
        
          <p style="border-bottom: 1px dashed"></p>
          <br></br>
          <table class = "center">
            <tr >
              <th>فاکتور خرید</th>
              <th>بارنامه</th>
              
              
              
            </tr>
            
              <td class = "img">
                <img src="run.jpg" style="width: 90%;">
              </td>
              <td class = "img">
                <img src="run.jpg" style="width: 90%;">
              </td>
            </tr>

          </table>

          <br></br>
        <br></br>
        
          <table class = "center">
            <tr >
              <th>رسید خرید ۱</th>
              <th>رسید خرید ۲</th>             
              
            </tr>
            
              <td class = "img">
                <img src="run.jpg" style="width: 90%;">
              </td>
              <td class = "img">
                <img src="run.jpg" style="width: 90%;">
              </td>
            </tr>

          </table>

          <br></br>
        <br></br>
        <p style="text-align:right; font-size: 20px; padding-right: 30px;">سرمایه گذاران :</p>
        <br></br>
        <br></br>
        <br></br>
        <p style="text-align:right; font-size: 20px; padding-right: 30px;"></p>

        <p style="text-align:right; font-size: 20px; padding-right: 30px;">توضیحات تکمیلی :</p>
        <br></br>
        <br></br>
        <br></br>
        <p style="text-align:right; font-size: 20px; padding-right: 30px;"></p>

        <p style="text-align:right; font-size: 20px; padding-right: 30px;">نام کاربر :</p>
        <br></br>
        <br></br>
        <br></br>
        <p style="text-align:right; font-size: 20px; padding-right: 30px;"></p>

        


    </div>
</body>

</html>

有人知道当我将python文件转换为exe时如何修复这个错误吗?

EN

回答 1

Stack Overflow用户

发布于 2021-10-05 10:02:25

我在一个中文网站上找到了一个解决方案。我不得不把一些文件放到myapp.exe里。以下是链接:请访问https://cxyzjd.com/article/meimeieee/115024971

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69433786

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档