2012-02-09 8 views
1

私はGUIを使ってプログラムを開発しようとしています.KDEが大好きなので、私はPyQTにショットをつけることにしました。ここに私がこれまで持っているものの例があります(論理はまだありません。私はUIを表示できるかどうかを見たいと思っていました)。Python 3 PyQT(Designerを使用している)問題が始まって

#!/usr/bin/python3 
# -*- coding: utf-8 -*- 

# Form implementation generated from reading ui file 'QT/at.ui' 
# 
# Created: Thu Feb 9 14:05:42 2012 
#  by: PyQt4 UI code generator 4.9 
# 
# WARNING! All changes made in this file will be lost! 

from PyQt4 import QtCore, QtGui 

try: 
    _fromUtf8 = QtCore.QString.fromUtf8 
except AttributeError: 
    _fromUtf8 = lambda s: s 

class Ui_MainWindow(object): 
    def setupUi(self, MainWindow): 
     MainWindow.setObjectName(_fromUtf8("MainWindow")) 
     MainWindow.resize(410, 322) 
     self.centralwidget = QtGui.QWidget(MainWindow) 
     self.centralwidget.setObjectName(_fromUtf8("centralwidget")) 
     self.tabWidget = QtGui.QTabWidget(self.centralwidget) 
     self.tabWidget.setGeometry(QtCore.QRect(0, 10, 261, 271)) 
     self.tabWidget.setTabPosition(QtGui.QTabWidget.North) 
     self.tabWidget.setTabShape(QtGui.QTabWidget.Rounded) 
     self.tabWidget.setTabsClosable(False) 
     self.tabWidget.setObjectName(_fromUtf8("tabWidget")) 
     self.tab = QtGui.QWidget() 
     self.tab.setObjectName(_fromUtf8("tab")) 
     self.formLayoutWidget = QtGui.QWidget(self.tab) 
     self.formLayoutWidget.setGeometry(QtCore.QRect(0, 0, 251, 111)) 
     self.formLayoutWidget.setObjectName(_fromUtf8("formLayoutWidget")) 
     self.formLayout = QtGui.QFormLayout(self.formLayoutWidget) 
     self.formLayout.setMargin(0) 
     self.formLayout.setObjectName(_fromUtf8("formLayout")) 
     self.jobNameLabel = QtGui.QLabel(self.formLayoutWidget) 
     self.jobNameLabel.setObjectName(_fromUtf8("jobNameLabel")) 
     self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.jobNameLabel) 
     self.jobNameLineEdit = QtGui.QLineEdit(self.formLayoutWidget) 
     self.jobNameLineEdit.setObjectName(_fromUtf8("jobNameLineEdit")) 
     self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.jobNameLineEdit) 
     self.inputDirectoryLabel = QtGui.QLabel(self.formLayoutWidget) 
     self.inputDirectoryLabel.setObjectName(_fromUtf8("inputDirectoryLabel")) 
     self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.inputDirectoryLabel) 
     self.inputDirectoryLineEdit = QtGui.QLineEdit(self.formLayoutWidget) 
     self.inputDirectoryLineEdit.setObjectName(_fromUtf8("inputDirectoryLineEdit")) 
     self.formLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.inputDirectoryLineEdit) 
     self.albumNameLabel = QtGui.QLabel(self.formLayoutWidget) 
     self.albumNameLabel.setObjectName(_fromUtf8("albumNameLabel")) 
     self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.albumNameLabel) 
     self.albumNameLineEdit = QtGui.QLineEdit(self.formLayoutWidget) 
     self.albumNameLineEdit.setObjectName(_fromUtf8("albumNameLineEdit")) 
     self.formLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.albumNameLineEdit) 
     self.scalingAmountLabel = QtGui.QLabel(self.formLayoutWidget) 
     self.scalingAmountLabel.setObjectName(_fromUtf8("scalingAmountLabel")) 
     self.formLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.scalingAmountLabel) 
     self.scalingAmountComboBox = QtGui.QComboBox(self.formLayoutWidget) 
     sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Fixed) 
     sizePolicy.setHorizontalStretch(0) 
     sizePolicy.setVerticalStretch(0) 
     sizePolicy.setHeightForWidth(self.scalingAmountComboBox.sizePolicy().hasHeightForWidth()) 
     self.scalingAmountComboBox.setSizePolicy(sizePolicy) 
     self.scalingAmountComboBox.setObjectName(_fromUtf8("scalingAmountComboBox")) 
     self.scalingAmountComboBox.addItem(_fromUtf8("")) 
     self.scalingAmountComboBox.addItem(_fromUtf8("")) 
     self.scalingAmountComboBox.addItem(_fromUtf8("")) 
     self.scalingAmountComboBox.addItem(_fromUtf8("")) 
     self.scalingAmountComboBox.addItem(_fromUtf8("")) 
     self.scalingAmountComboBox.addItem(_fromUtf8("")) 
     self.scalingAmountComboBox.addItem(_fromUtf8("")) 
     self.scalingAmountComboBox.addItem(_fromUtf8("")) 
     self.scalingAmountComboBox.addItem(_fromUtf8("")) 
     self.scalingAmountComboBox.addItem(_fromUtf8("")) 
     self.formLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.scalingAmountComboBox) 
     self.textEdit = QtGui.QTextEdit(self.tab) 
     self.textEdit.setGeometry(QtCore.QRect(3, 130, 251, 111)) 
     self.textEdit.setObjectName(_fromUtf8("textEdit")) 
     self.label_3 = QtGui.QLabel(self.tab) 
     self.label_3.setGeometry(QtCore.QRect(10, 110, 53, 14)) 
     self.label_3.setObjectName(_fromUtf8("label_3")) 
     self.tabWidget.addTab(self.tab, _fromUtf8("")) 
     self.tab_2 = QtGui.QWidget() 
     self.tab_2.setObjectName(_fromUtf8("tab_2")) 
     self.pushButton_5 = QtGui.QPushButton(self.tab_2) 
     self.pushButton_5.setGeometry(QtCore.QRect(30, 120, 181, 25)) 
     self.pushButton_5.setObjectName(_fromUtf8("pushButton_5")) 
     self.pushButton_4 = QtGui.QPushButton(self.tab_2) 
     self.pushButton_4.setGeometry(QtCore.QRect(30, 150, 181, 25)) 
     self.pushButton_4.setObjectName(_fromUtf8("pushButton_4")) 
     self.pushButton_3 = QtGui.QPushButton(self.tab_2) 
     self.pushButton_3.setGeometry(QtCore.QRect(30, 180, 181, 25)) 
     self.pushButton_3.setObjectName(_fromUtf8("pushButton_3")) 
     self.pushButton_2 = QtGui.QPushButton(self.tab_2) 
     self.pushButton_2.setGeometry(QtCore.QRect(30, 210, 181, 25)) 
     self.pushButton_2.setObjectName(_fromUtf8("pushButton_2")) 
     self.label_2 = QtGui.QLabel(self.tab_2) 
     self.label_2.setGeometry(QtCore.QRect(10, 10, 241, 61)) 
     self.label_2.setFrameShape(QtGui.QFrame.NoFrame) 
     self.label_2.setWordWrap(True) 
     self.label_2.setObjectName(_fromUtf8("label_2")) 
     self.tabWidget.addTab(self.tab_2, _fromUtf8("")) 
     self.tab_3 = QtGui.QWidget() 
     self.tab_3.setObjectName(_fromUtf8("tab_3")) 
     self.pushButton_6 = QtGui.QPushButton(self.tab_3) 
     self.pushButton_6.setGeometry(QtCore.QRect(10, 170, 231, 61)) 
     self.pushButton_6.setObjectName(_fromUtf8("pushButton_6")) 
     self.label = QtGui.QLabel(self.tab_3) 
     self.label.setGeometry(QtCore.QRect(10, 10, 241, 61)) 
     self.label.setFrameShape(QtGui.QFrame.NoFrame) 
     self.label.setWordWrap(True) 
     self.label.setObjectName(_fromUtf8("label")) 
     self.tabWidget.addTab(self.tab_3, _fromUtf8("")) 
     self.pushButton = QtGui.QPushButton(self.centralwidget) 
     self.pushButton.setGeometry(QtCore.QRect(270, 250, 131, 25)) 
     self.pushButton.setObjectName(_fromUtf8("pushButton")) 
     self.label_4 = QtGui.QLabel(self.centralwidget) 
     self.label_4.setGeometry(QtCore.QRect(270, 0, 131, 81)) 
     self.label_4.setWordWrap(True) 
     self.label_4.setObjectName(_fromUtf8("label_4")) 
     self.label_5 = QtGui.QLabel(self.centralwidget) 
     self.label_5.setGeometry(QtCore.QRect(270, 80, 131, 101)) 
     self.label_5.setWordWrap(True) 
     self.label_5.setObjectName(_fromUtf8("label_5")) 
     self.pushButton_7 = QtGui.QPushButton(self.centralwidget) 
     self.pushButton_7.setGeometry(QtCore.QRect(270, 220, 131, 25)) 
     self.pushButton_7.setObjectName(_fromUtf8("pushButton_7")) 
     self.pushButton_8 = QtGui.QPushButton(self.centralwidget) 
     self.pushButton_8.setGeometry(QtCore.QRect(270, 190, 131, 25)) 
     self.pushButton_8.setObjectName(_fromUtf8("pushButton_8")) 
     MainWindow.setCentralWidget(self.centralwidget) 
     self.menubar = QtGui.QMenuBar(MainWindow) 
     self.menubar.setGeometry(QtCore.QRect(0, 0, 410, 21)) 
     self.menubar.setObjectName(_fromUtf8("menubar")) 
     self.menuFileFile = QtGui.QMenu(self.menubar) 
     self.menuFileFile.setObjectName(_fromUtf8("menuFileFile")) 
     self.menuTools = QtGui.QMenu(self.menubar) 
     self.menuTools.setObjectName(_fromUtf8("menuTools")) 
     self.menuHelp = QtGui.QMenu(self.menubar) 
     self.menuHelp.setObjectName(_fromUtf8("menuHelp")) 
     MainWindow.setMenuBar(self.menubar) 
     self.statusbar = QtGui.QStatusBar(MainWindow) 
     self.statusbar.setObjectName(_fromUtf8("statusbar")) 
     MainWindow.setStatusBar(self.statusbar) 
     self.menubar.addAction(self.menuFileFile.menuAction()) 
     self.menubar.addAction(self.menuTools.menuAction()) 
     self.menubar.addAction(self.menuHelp.menuAction()) 

     self.retranslateUi(MainWindow) 
     self.tabWidget.setCurrentIndex(2) 
     QtCore.QMetaObject.connectSlotsByName(MainWindow) 

    def retranslateUi(self, MainWindow): 
     MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8)) 
     self.jobNameLabel.setText(QtGui.QApplication.translate("MainWindow", "Job Name", None, QtGui.QApplication.UnicodeUTF8)) 
     self.inputDirectoryLabel.setText(QtGui.QApplication.translate("MainWindow", "Input Directory", None, QtGui.QApplication.UnicodeUTF8)) 
     self.albumNameLabel.setText(QtGui.QApplication.translate("MainWindow", "Album Name", None, QtGui.QApplication.UnicodeUTF8)) 
     self.scalingAmountLabel.setText(QtGui.QApplication.translate("MainWindow", "Scaling Amount", None, QtGui.QApplication.UnicodeUTF8)) 
     self.scalingAmountComboBox.setItemText(0, QtGui.QApplication.translate("MainWindow", "10% of Original", None, QtGui.QApplication.UnicodeUTF8)) 
     self.scalingAmountComboBox.setItemText(1, QtGui.QApplication.translate("MainWindow", "20% of Original", None, QtGui.QApplication.UnicodeUTF8)) 
     self.scalingAmountComboBox.setItemText(2, QtGui.QApplication.translate("MainWindow", "30% of Original", None, QtGui.QApplication.UnicodeUTF8)) 
     self.scalingAmountComboBox.setItemText(3, QtGui.QApplication.translate("MainWindow", "40% of Original", None, QtGui.QApplication.UnicodeUTF8)) 
     self.scalingAmountComboBox.setItemText(4, QtGui.QApplication.translate("MainWindow", "50% of Original", None, QtGui.QApplication.UnicodeUTF8)) 
     self.scalingAmountComboBox.setItemText(5, QtGui.QApplication.translate("MainWindow", "60% of Original", None, QtGui.QApplication.UnicodeUTF8)) 
     self.scalingAmountComboBox.setItemText(6, QtGui.QApplication.translate("MainWindow", "70% of Original", None, QtGui.QApplication.UnicodeUTF8)) 
     self.scalingAmountComboBox.setItemText(7, QtGui.QApplication.translate("MainWindow", "80% of Original", None, QtGui.QApplication.UnicodeUTF8)) 
     self.scalingAmountComboBox.setItemText(8, QtGui.QApplication.translate("MainWindow", "90% of Original", None, QtGui.QApplication.UnicodeUTF8)) 
     self.scalingAmountComboBox.setItemText(9, QtGui.QApplication.translate("MainWindow", "100% of Original", None, QtGui.QApplication.UnicodeUTF8)) 
     self.label_3.setText(QtGui.QApplication.translate("MainWindow", "Notes", None, QtGui.QApplication.UnicodeUTF8)) 
     self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), QtGui.QApplication.translate("MainWindow", "Information", None, QtGui.QApplication.UnicodeUTF8)) 
     self.pushButton_5.setText(QtGui.QApplication.translate("MainWindow", "Step 1 (Copy Images)", None, QtGui.QApplication.UnicodeUTF8)) 
     self.pushButton_4.setText(QtGui.QApplication.translate("MainWindow", "Step 2 (Resize Images)", None, QtGui.QApplication.UnicodeUTF8)) 
     self.pushButton_3.setText(QtGui.QApplication.translate("MainWindow", "Step 3 (Upload Images)", None, QtGui.QApplication.UnicodeUTF8)) 
     self.pushButton_2.setText(QtGui.QApplication.translate("MainWindow", "Step 4 (Manage Album)", None, QtGui.QApplication.UnicodeUTF8)) 
     self.label_2.setText(QtGui.QApplication.translate("MainWindow", "This is the manual method of uploading your images. Complete all four steps and you\'ll be done!", None, QtGui.QApplication.UnicodeUTF8)) 
     self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), QtGui.QApplication.translate("MainWindow", "Manual", None, QtGui.QApplication.UnicodeUTF8)) 
     self.pushButton_6.setText(QtGui.QApplication.translate("MainWindow", "Express Mode", None, QtGui.QApplication.UnicodeUTF8)) 
     self.label.setText(QtGui.QApplication.translate("MainWindow", "This is the automatic method of uploading your images. Clicking the \'Express Mode\' button will finish the entire process for you.", None, QtGui.QApplication.UnicodeUTF8)) 
     self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_3), QtGui.QApplication.translate("MainWindow", "Automatic", None, QtGui.QApplication.UnicodeUTF8)) 
     self.pushButton.setText(QtGui.QApplication.translate("MainWindow", "Exit", None, QtGui.QApplication.UnicodeUTF8)) 
     self.label_4.setText(QtGui.QApplication.translate("MainWindow", "First, fill out the fields in the Information tab. Next, choose either Manual or Automatic processing.", None, QtGui.QApplication.UnicodeUTF8)) 
     self.label_5.setText(QtGui.QApplication.translate("MainWindow", "There are additional tools and options available in the menubar. If you need any assistance, check out the Help menu for more information!", None, QtGui.QApplication.UnicodeUTF8)) 
     self.pushButton_7.setText(QtGui.QApplication.translate("MainWindow", "Export", None, QtGui.QApplication.UnicodeUTF8)) 
     self.pushButton_8.setText(QtGui.QApplication.translate("MainWindow", "Import", None, QtGui.QApplication.UnicodeUTF8)) 
     self.menuFileFile.setTitle(QtGui.QApplication.translate("MainWindow", "File", None, QtGui.QApplication.UnicodeUTF8)) 
     self.menuTools.setTitle(QtGui.QApplication.translate("MainWindow", "Tools", None, QtGui.QApplication.UnicodeUTF8)) 
     self.menuHelp.setTitle(QtGui.QApplication.translate("MainWindow", "Help", None, QtGui.QApplication.UnicodeUTF8)) 

ザ・Pythonスクリプトをする:ここで

は、私はPythonコードにコンパイルするためにpyuicを使用して、次のようになった、at_auto.pyという名前

<?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>410</width> 
    <height>322</height> 
    </rect> 
    </property> 
    <property name="windowTitle"> 
    <string>MainWindow</string> 
    </property> 
    <widget class="QWidget" name="centralwidget"> 
    <widget class="QTabWidget" name="tabWidget"> 
    <property name="geometry"> 
    <rect> 
     <x>0</x> 
     <y>10</y> 
     <width>261</width> 
     <height>271</height> 
    </rect> 
    </property> 
    <property name="tabPosition"> 
    <enum>QTabWidget::North</enum> 
    </property> 
    <property name="tabShape"> 
    <enum>QTabWidget::Rounded</enum> 
    </property> 
    <property name="currentIndex"> 
    <number>2</number> 
    </property> 
    <property name="tabsClosable"> 
    <bool>false</bool> 
    </property> 
    <widget class="QWidget" name="tab"> 
    <attribute name="title"> 
     <string>Information</string> 
    </attribute> 
    <widget class="QWidget" name="formLayoutWidget"> 
     <property name="geometry"> 
     <rect> 
     <x>0</x> 
     <y>0</y> 
     <width>251</width> 
     <height>111</height> 
     </rect> 
     </property> 
     <layout class="QFormLayout" name="formLayout"> 
     <item row="0" column="0"> 
     <widget class="QLabel" name="jobNameLabel"> 
     <property name="text"> 
      <string>Job Name</string> 
     </property> 
     </widget> 
     </item> 
     <item row="0" column="1"> 
     <widget class="QLineEdit" name="jobNameLineEdit"/> 
     </item> 
     <item row="1" column="0"> 
     <widget class="QLabel" name="inputDirectoryLabel"> 
     <property name="text"> 
      <string>Input Directory</string> 
     </property> 
     </widget> 
     </item> 
     <item row="1" column="1"> 
     <widget class="QLineEdit" name="inputDirectoryLineEdit"/> 
     </item> 
     <item row="2" column="0"> 
     <widget class="QLabel" name="albumNameLabel"> 
     <property name="text"> 
      <string>Album Name</string> 
     </property> 
     </widget> 
     </item> 
     <item row="2" column="1"> 
     <widget class="QLineEdit" name="albumNameLineEdit"/> 
     </item> 
     <item row="3" column="0"> 
     <widget class="QLabel" name="scalingAmountLabel"> 
     <property name="text"> 
      <string>Scaling Amount</string> 
     </property> 
     </widget> 
     </item> 
     <item row="3" column="1"> 
     <widget class="QComboBox" name="scalingAmountComboBox"> 
     <property name="sizePolicy"> 
      <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> 
      <horstretch>0</horstretch> 
      <verstretch>0</verstretch> 
      </sizepolicy> 
     </property> 
     <item> 
      <property name="text"> 
      <string>10% of Original</string> 
      </property> 
     </item> 
     <item> 
      <property name="text"> 
      <string>20% of Original</string> 
      </property> 
     </item> 
     <item> 
      <property name="text"> 
      <string>30% of Original</string> 
      </property> 
     </item> 
     <item> 
      <property name="text"> 
      <string>40% of Original</string> 
      </property> 
     </item> 
     <item> 
      <property name="text"> 
      <string>50% of Original</string> 
      </property> 
     </item> 
     <item> 
      <property name="text"> 
      <string>60% of Original</string> 
      </property> 
     </item> 
     <item> 
      <property name="text"> 
      <string>70% of Original</string> 
      </property> 
     </item> 
     <item> 
      <property name="text"> 
      <string>80% of Original</string> 
      </property> 
     </item> 
     <item> 
      <property name="text"> 
      <string>90% of Original</string> 
      </property> 
     </item> 
     <item> 
      <property name="text"> 
      <string>100% of Original</string> 
      </property> 
     </item> 
     </widget> 
     </item> 
     </layout> 
    </widget> 
    <widget class="QTextEdit" name="textEdit"> 
     <property name="geometry"> 
     <rect> 
     <x>3</x> 
     <y>130</y> 
     <width>251</width> 
     <height>111</height> 
     </rect> 
     </property> 
    </widget> 
    <widget class="QLabel" name="label_3"> 
     <property name="geometry"> 
     <rect> 
     <x>10</x> 
     <y>110</y> 
     <width>53</width> 
     <height>14</height> 
     </rect> 
     </property> 
     <property name="text"> 
     <string>Notes</string> 
     </property> 
    </widget> 
    </widget> 
    <widget class="QWidget" name="tab_2"> 
    <attribute name="title"> 
     <string>Manual</string> 
    </attribute> 
    <widget class="QPushButton" name="pushButton_5"> 
     <property name="geometry"> 
     <rect> 
     <x>30</x> 
     <y>120</y> 
     <width>181</width> 
     <height>25</height> 
     </rect> 
     </property> 
     <property name="text"> 
     <string>Step 1 (Copy Images)</string> 
     </property> 
    </widget> 
    <widget class="QPushButton" name="pushButton_4"> 
     <property name="geometry"> 
     <rect> 
     <x>30</x> 
     <y>150</y> 
     <width>181</width> 
     <height>25</height> 
     </rect> 
     </property> 
     <property name="text"> 
     <string>Step 2 (Resize Images)</string> 
     </property> 
    </widget> 
    <widget class="QPushButton" name="pushButton_3"> 
     <property name="geometry"> 
     <rect> 
     <x>30</x> 
     <y>180</y> 
     <width>181</width> 
     <height>25</height> 
     </rect> 
     </property> 
     <property name="text"> 
     <string>Step 3 (Upload Images)</string> 
     </property> 
    </widget> 
    <widget class="QPushButton" name="pushButton_2"> 
     <property name="geometry"> 
     <rect> 
     <x>30</x> 
     <y>210</y> 
     <width>181</width> 
     <height>25</height> 
     </rect> 
     </property> 
     <property name="text"> 
     <string>Step 4 (Manage Album)</string> 
     </property> 
    </widget> 
    <widget class="QLabel" name="label_2"> 
     <property name="geometry"> 
     <rect> 
     <x>10</x> 
     <y>10</y> 
     <width>241</width> 
     <height>61</height> 
     </rect> 
     </property> 
     <property name="frameShape"> 
     <enum>QFrame::NoFrame</enum> 
     </property> 
     <property name="text"> 
     <string>This is the manual method of uploading your images. Complete all four steps and you'll be done!</string> 
     </property> 
     <property name="wordWrap"> 
     <bool>true</bool> 
     </property> 
    </widget> 
    </widget> 
    <widget class="QWidget" name="tab_3"> 
    <attribute name="title"> 
     <string>Automatic</string> 
    </attribute> 
    <widget class="QPushButton" name="pushButton_6"> 
     <property name="geometry"> 
     <rect> 
     <x>10</x> 
     <y>170</y> 
     <width>231</width> 
     <height>61</height> 
     </rect> 
     </property> 
     <property name="text"> 
     <string>Express Mode</string> 
     </property> 
    </widget> 
    <widget class="QLabel" name="label"> 
     <property name="geometry"> 
     <rect> 
     <x>10</x> 
     <y>10</y> 
     <width>241</width> 
     <height>61</height> 
     </rect> 
     </property> 
     <property name="frameShape"> 
     <enum>QFrame::NoFrame</enum> 
     </property> 
     <property name="text"> 
     <string>This is the automatic method of uploading your images. Clicking the 'Express Mode' button will finish the entire process for you.</string> 
     </property> 
     <property name="wordWrap"> 
     <bool>true</bool> 
     </property> 
    </widget> 
    </widget> 
    </widget> 
    <widget class="QPushButton" name="pushButton"> 
    <property name="geometry"> 
    <rect> 
     <x>270</x> 
     <y>250</y> 
     <width>131</width> 
     <height>25</height> 
    </rect> 
    </property> 
    <property name="text"> 
    <string>Exit</string> 
    </property> 
    </widget> 
    <widget class="QLabel" name="label_4"> 
    <property name="geometry"> 
    <rect> 
     <x>270</x> 
     <y>0</y> 
     <width>131</width> 
     <height>81</height> 
    </rect> 
    </property> 
    <property name="text"> 
    <string>First, fill out the fields in the Information tab. Next, choose either Manual or Automatic processing.</string> 
    </property> 
    <property name="wordWrap"> 
    <bool>true</bool> 
    </property> 
    </widget> 
    <widget class="QLabel" name="label_5"> 
    <property name="geometry"> 
    <rect> 
     <x>270</x> 
     <y>80</y> 
     <width>131</width> 
     <height>101</height> 
    </rect> 
    </property> 
    <property name="text"> 
    <string>There are additional tools and options available in the menubar. If you need any assistance, check out the Help menu for more information!</string> 
    </property> 
    <property name="wordWrap"> 
    <bool>true</bool> 
    </property> 
    </widget> 
    <widget class="QPushButton" name="pushButton_7"> 
    <property name="geometry"> 
    <rect> 
     <x>270</x> 
     <y>220</y> 
     <width>131</width> 
     <height>25</height> 
    </rect> 
    </property> 
    <property name="text"> 
    <string>Export</string> 
    </property> 
    </widget> 
    <widget class="QPushButton" name="pushButton_8"> 
    <property name="geometry"> 
    <rect> 
     <x>270</x> 
     <y>190</y> 
     <width>131</width> 
     <height>25</height> 
    </rect> 
    </property> 
    <property name="text"> 
    <string>Import</string> 
    </property> 
    </widget> 
    </widget> 
    <widget class="QMenuBar" name="menubar"> 
    <property name="geometry"> 
    <rect> 
    <x>0</x> 
    <y>0</y> 
    <width>410</width> 
    <height>21</height> 
    </rect> 
    </property> 
    <widget class="QMenu" name="menuFileFile"> 
    <property name="title"> 
    <string>File</string> 
    </property> 
    </widget> 
    <widget class="QMenu" name="menuTools"> 
    <property name="title"> 
    <string>Tools</string> 
    </property> 
    </widget> 
    <widget class="QMenu" name="menuHelp"> 
    <property name="title"> 
    <string>Help</string> 
    </property> 
    </widget> 
    <addaction name="menuFileFile"/> 
    <addaction name="menuTools"/> 
    <addaction name="menuHelp"/> 
    </widget> 
    <widget class="QStatusBar" name="statusbar"/> 
</widget> 
<resources/> 
<connections/> 
</ui> 

at.uiという名前のUIファイルですスタートは次のとおりです。

#!/usr/bin/python3 

from PyQt4 import QtGui, QtCore 
import at_auto, os 

class at(at_auto): 
    def __init__(self): 
     at_auto.__init__(self) 

if __name__ == '__main__': 
    import sys 
    a = QtGui.QApplication(sys.argv) 
    QtCore.QObject.connect(a, QtCore.SIGNAL('lastWindowClosed()'), a, QtCore.SLOT('quit()')) 
    w = at(at_auto.__init__(self)) 
    a.setMainWindow(w) 
    w.show() 
    a.exec_loop() 

プログラムを実行しようと、私は次のエラーを取得する:

Traceback (most recent call last): 
    File "./at.py", line 6, in <module> 
    class at(at_auto): 
TypeError: module.__init__() takes at most 2 arguments (3 given) 

私は、次のチュートリアルからat.pyのコードを変更:

http://wiki.python.org/moin/JonathanGardnerPyQtTutorial#Using_pyuic

はありがとうございました!

答えて

0

まず、リンク先のチュートリアルは古くなっています(これはPyQt4ではなくPyQt3に関連しています)。だから私はあなたにもっと最近の何かを見てみることをお勧めしますhere

しかし、手元の問題に対処するために - あなたは、このコマンドを使用してUIを再コンパイルすることで起動した場合には、多少の事を簡素化します:

pyuic4 -w at.ui > at_auto.py 

はるかに直感的である追加のGUIクラスを生成します-wオプションデフォルトで作成されたものよりも使用します。このクラスの名前は、Qt Designerで作成されたトップレベルオブジェクトと同じ名前になります。この場合、MainWindowになります。

このように、それのインスタンスを、ちょうどあなたのmainスクリプトにインポートし、それを使用するサブクラスを作成し、showするには:

from PyQt4 import QtGui, QtCore 
from at_auto import MainWindow 

class Window(MainWindow): 
    def __init__(self): 
     MainWindow.__init__(self) 
     # do other initialization stuff here... 

if __name__ == '__main__': 

    import sys 
    app = QtGui.QApplication(sys.argv) 
    window = Window() 
    window.show() 
    sys.exit(app.exec_()) 
+0

は答えをいただき、ありがとうございます。それは間違いなく厄介なエラーメッセージを取り除いた。これでプログラムを正しく初期化する方法を理解しておかなければなりません。正しい方向へステップ!まあ、正確に何が起こっているのかを見るためにprintステートメントを追加して、今度はウィンドウを正しく開きます。奇妙な。 –

関連する問題