Подскажите пожалуйста, как такую штуку скомпилировать?
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
from PyQt4.QtGui import *
header1 = ['N', u'Тип', 'V', u'Pг', u'Pн', u'Qн']
header2 = [u'Nн', u'Nк', 'R', 'X']
class MyTable(QTableWidget):
def __init__(self, header, *args):
QTableWidget.__init__(self, *args)
self.header = header
self.setHorizontalHeaderLabels(header)
self.setColumnWidth(0, 40)
self.setColumnWidth(1, 40)
self.resizeRowsToContents()
self.verticalScrollBar()
class MainWidget(QWidget):
def __init__(self):
QWidget.__init__(self)
self.setGeometry(250, 150, 400, 300)
self.setWindowTitle("SceneDirector")
self.tab_widget = QTabWidget()
self.tab1 = QWidget()
self.tab2 = QWidget()
self.tab3 = QWidget()
self.tab_widget.addTab(self.tab1, u"Узлы")
self.tab_widget.addTab(self.tab2, u"Ветви")
self.tab_widget.addTab(self.tab3, u"Расчет")
#Uzli on tab1
self.table = {}
self.table[0] = MyTable(header1, 1, 6, self.tab1)
self.table[0].resize(525, 430)
self.table[0].show()
#Vetvi on tab2
self.table[1] = MyTable(header2, 1, 4, self.tab2)
self.table[1].resize(525, 430)
self.table[1].show()
#bottom del1
btn1_del = QPushButton(u"удалить", self.tab1)
btn1_del.clicked.connect(self.delrow)
btn1_del.move(530, 30)
#bottom del2
btn2_del = QPushButton(u"удалить", self.tab2)
btn2_del.clicked.connect(self.delrow)
btn2_del.move(530, 30)
#bottom add1
combo1 = QComboBox(self.tab1)
kaka = ["car1", "car1", "car3", "car4"]
for i in kaka:
combo1.addItem(i)
combo1.activated[str].connect(self.addrow)
combo1.move(530, 0)
# btn1_add = QPushButton("add row", self.tab1)
# btn1_add.clicked.connect(self.addrow)
# btn1_add.move(530, 0)
#bottom add2
btn2_add = QPushButton("add row", self.tab2)
btn2_add.clicked.connect(self.addrow)
btn2_add.move(530, 0)
#layout
vbox = QVBoxLayout()
vbox.addWidget(self.tab_widget)
self.setLayout(vbox)
def delrow(self):
self.table[self.tab_widget.currentIndex()].removeRow(self.table[self.tab_widget.currentIndex()].currentRow())
def addrow(self, text):
self.table[self.tab_widget.currentIndex()].insertRow(self.table[self.tab_widget.currentIndex()].rowCount())
print(text)
self.table[self.tab_widget.currentIndex()].resizeRowsToContents()
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
widget = MainWidget()
widget.resize(640, 480)
widget.show()
sys.exit(app.exec_())
Пробовал через “python setup.py build” –> exe-шник запускается и сразу же вылетает.