问题描述
几个月来,我一直在寻找一种干净的方法来使用具有模块的 python3 程序为 Linux 构建 deb,但似乎没有任何工作正常。我试过 stdeb 但它不尊重我的 python3 >= 3.6 并且它把模块放在 python3 库中所以本地测试并不简单,因为我必须从 import stuff 来回更改 import 到 import myscript.stuff as stuff .我发现大量示例适用于单个 Python 文件或根本不起作用。
我的示例文件是:
simqt_0.0-1
simqt
simqt.ui
stuff.py
simqt 包含
#!/usr/bin/python3
import sys,os
from functools import partial
from PyQt5.QtWidgets import QApplication,QMainWindow
from PyQt5 import uic
import stuff
class main(QMainWindow):
def __init__(self):
super().__init__()
path,filename = os.path.split(os.path.realpath(__file__))
uic.loadUi(os.path.join(path,'simqt.ui'),self)
self.setGeometry(50,50,500,300)
self.setwindowTitle("PyQT5 Minimal!")
self.pushButton.clicked.connect(partial(stuff.reply,self))
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
gui = main()
sys.exit(app.exec_())
东西.py
def reply(parent):
parent.label.setText("Reply from Stuff")
simqt.ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>200</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="qgridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Load ui file</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Minimal</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Get Reply</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)