Code reorganization, tomblocation required field

This commit is contained in:
BoySka 2011-10-24 18:52:10 +02:00 committed by boyska
parent 92e776c6d6
commit afd399efe2
3 changed files with 54 additions and 40 deletions

View File

@ -7,23 +7,29 @@ parentdir = sys.path[0].split(os.sep)[:-1]
sys.path.append(os.sep.join(parentdir))
from tomblib import wrapper
app = QApplication(sys.argv)
window = QWizard()
ui = Ui_Wizard()
ui.setupUi(window)
def create_tomb(*args, **kwargs):
print 'creating'
wrapper.Tomb.create(1,2,3)
print 'created!'
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
_fromUtf8 = lambda s: s
QtCore.QObject.connect(window, QtCore.SIGNAL(_fromUtf8('finished(int)')), create_tomb)
window.show()
sys.exit(app.exec_())
class TombCreateWizard(QWizard):
def __init__(self, *args, **kwargs):
QWizard.__init__(self, *args, **kwargs)
self.ui = ui = Ui_Wizard()
ui.setupUi(self)
ui.wizardPage_tomb_location.registerField('tombpath*', ui.lineEdit_tombpath) #required field, note the *
QtCore.QObject.connect(self, QtCore.SIGNAL(_fromUtf8('finished(int)')), self.create_tomb)
def create_tomb(self, *args, **kwargs):
print 'creating'
wrapper.Tomb.create(1,2,3)
print 'created!'
if __name__ == '__main__':
app = QApplication(sys.argv)
window = TombCreateWizard()
window.show()
sys.exit(app.exec_())

View File

@ -88,14 +88,21 @@
<bool>true</bool>
</property>
<property name="buddy">
<cstring>lineEdit</cstring>
<cstring>lineEdit_tombpath</cstring>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="lineEdit"/>
<widget class="QLineEdit" name="lineEdit_tombpath">
<property name="frame">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>/path/to/file.tomb</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
@ -370,11 +377,11 @@ p, li { white-space: pre-wrap; }
<hints>
<hint type="sourcelabel">
<x>62</x>
<y>212</y>
<y>29</y>
</hint>
<hint type="destinationlabel">
<x>164</x>
<y>243</y>
<x>99</x>
<y>29</y>
</hint>
</hints>
</connection>
@ -385,12 +392,12 @@ p, li { white-space: pre-wrap; }
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>118</x>
<y>212</y>
<x>99</x>
<y>29</y>
</hint>
<hint type="destinationlabel">
<x>677</x>
<y>246</y>
<x>99</x>
<y>29</y>
</hint>
</hints>
</connection>
@ -406,7 +413,7 @@ p, li { white-space: pre-wrap; }
</hint>
<hint type="destinationlabel">
<x>77</x>
<y>267</y>
<y>29</y>
</hint>
</hints>
</connection>
@ -421,8 +428,8 @@ p, li { white-space: pre-wrap; }
<y>356</y>
</hint>
<hint type="destinationlabel">
<x>117</x>
<y>267</y>
<x>99</x>
<y>29</y>
</hint>
</hints>
</connection>
@ -433,12 +440,12 @@ p, li { white-space: pre-wrap; }
<slot>check_password_match()</slot>
<hints>
<hint type="sourcelabel">
<x>339</x>
<y>105</y>
<x>99</x>
<y>29</y>
</hint>
<hint type="destinationlabel">
<x>99</x>
<y>85</y>
<y>29</y>
</hint>
</hints>
</connection>
@ -450,11 +457,11 @@ p, li { white-space: pre-wrap; }
<hints>
<hint type="sourcelabel">
<x>99</x>
<y>85</y>
<y>29</y>
</hint>
<hint type="destinationlabel">
<x>117</x>
<y>152</y>
<x>99</x>
<y>29</y>
</hint>
</hints>
</connection>
@ -465,12 +472,12 @@ p, li { white-space: pre-wrap; }
<slot>check_password_match()</slot>
<hints>
<hint type="sourcelabel">
<x>289</x>
<y>126</y>
<x>99</x>
<y>29</y>
</hint>
<hint type="destinationlabel">
<x>49</x>
<y>70</y>
<y>14</y>
</hint>
</hints>
</connection>

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'create.ui'
#
# Created: Mon Oct 24 03:26:55 2011
# Created: Mon Oct 24 18:27:59 2011
# by: PyQt4 UI code generator 4.8.5
#
# WARNING! All changes made in this file will be lost!
@ -19,7 +19,6 @@ class Ui_Wizard(object):
Wizard.setObjectName(_fromUtf8("Wizard"))
Wizard.resize(710, 368)
Wizard.setWindowTitle(QtGui.QApplication.translate("Wizard", "Wizard", None, QtGui.QApplication.UnicodeUTF8))
Wizard.setWizardStyle(QtGui.QWizard.ModernStyle)
Wizard.setOptions(QtGui.QWizard.HaveHelpButton|QtGui.QWizard.IndependentPages)
self.wizardPage_intro = QtGui.QWizardPage()
self.wizardPage_intro.setTitle(QtGui.QApplication.translate("Wizard", "Tomb", None, QtGui.QApplication.UnicodeUTF8))
@ -67,9 +66,11 @@ class Ui_Wizard(object):
self.verticalLayout_3.addWidget(self.label_4)
self.horizontalLayout_2 = QtGui.QHBoxLayout()
self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
self.lineEdit = QtGui.QLineEdit(self.wizardPage_tomb_location)
self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
self.horizontalLayout_2.addWidget(self.lineEdit)
self.lineEdit_tombpath = QtGui.QLineEdit(self.wizardPage_tomb_location)
self.lineEdit_tombpath.setFrame(True)
self.lineEdit_tombpath.setPlaceholderText(QtGui.QApplication.translate("Wizard", "/path/to/file.tomb", None, QtGui.QApplication.UnicodeUTF8))
self.lineEdit_tombpath.setObjectName(_fromUtf8("lineEdit_tombpath"))
self.horizontalLayout_2.addWidget(self.lineEdit_tombpath)
self.pushButton = QtGui.QPushButton(self.wizardPage_tomb_location)
self.pushButton.setText(QtGui.QApplication.translate("Wizard", "Open file", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton.setObjectName(_fromUtf8("pushButton"))
@ -206,7 +207,7 @@ class Ui_Wizard(object):
self.verticalLayout_8.addWidget(self.checkBox)
Wizard.addPage(self.wizardPage_end)
self.label_3.setBuddy(self.spinBox)
self.label_4.setBuddy(self.lineEdit)
self.label_4.setBuddy(self.lineEdit_tombpath)
self.label_8.setBuddy(self.lineEdit_pass)
self.label_9.setBuddy(self.lineEdit_pass_again)