簡體   English   中英

Python應用程序,py2exe,Inno安裝程序,os.system()啟動功能不起作用

[英]Python application, py2exe, Inno Setup, os.system() start function does not work

我已經使用PyQt4做了一些應用程序,其中包含os.system()啟動函數作為按鈕,基本上可以打開一個csv文件。

import sqlite3
import sys
import os
.......
class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        ####
        .............
        ####
        # "CSV" button
        self.pushButton_4 = QtGui.QPushButton(self.centralwidget)
        self.pushButton_4.setObjectName(_fromUtf8("pushButton_4"))
        self.horizontalLayout_2.addWidget(self.pushButton_4)
        self.pushButton_4.clicked.connect(self.csv_button)
        #### 
    def csv_button(self):
        import csv
        conn = sqlite3.connect('FamilyFinance_test.db')
        c=conn.cursor()
        myrow_in = c.execute("select * from Income_test order by date desc")
        with open('Income_test.csv', 'wb') as csvfile_in:
            s_in = csv.writer(csvfile_in, delimiter=' ')
            s_in.writerow(['Date']+['Income'])
            for i in myrow_in:
                s_in.writerow([str(i[0])]+[str(i[1])])
        myrow_out = c.execute("select * from Outcome_test order by date desc")
        with open('Outcome_test.csv', 'wb') as csvfile_out:
            s_out = csv.writer(csvfile_out, delimiter=' ')
            s_out.writerow(['Date']+['ATM']+['Spent']+['Reason']+['Category'])
            for j in myrow_out:
                s_out.writerow([str(j[0])]+[str(j[1])]+[str(j[2])]+[str(j[3])]+[str(j[4])])
        os.system("start "+'Income_test.csv')
        os.system("start "+'Outcome_test.csv')

在python本身中,此功能以及與py2exe創建的.exe一起均可正常運行。 但是,在通過InnoSetup成功創建安裝程序並安裝了應用程序之后,我發現相同的按鈕不起作用。

有人可以為解決這個問題提供指導嗎?
使用InnoSetup編譯器還有其他事情要做嗎?

也許您的InnoSetup將程序安裝到C:\\ Program Files(x86)中,這需要UAC提升才能寫入該文件夾。

因此,可以將您的安裝文件夾更改為某些用戶文件夾,或者將您的應用程序與UAC選項一起打包在py2exe中,在此處https://stackoverflow.com/a/1445547/566035進行了說明。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM