# Form implementation generated from reading ui file 'pyuic_helper.ui' # # Created: Fri Mar 7 13:36:05 2003 # by: The Python User Interface Compiler (pyuic) # # WARNING! All changes made in this file will be lost! import os import re import sys from qt import * def wrap_tr(s): if type(s) == type(''): s = QObject.tr(s) return s class pyuic_helper_Form(QDialog): def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl) if name == None: self.setName('Form1') self.resize(356,163) self.setCaption(wrap_tr("pyuic helper")) self.TextLabel1 = QLabel(self,'TextLabel1') self.TextLabel1.setGeometry(QRect(20,10,75,12)) self.TextLabel1.setText(wrap_tr(QString.fromUtf8("入力 ui ファイル"))) self.TextLabel2 = QLabel(self,'TextLabel2') self.TextLabel2.setGeometry(QRect(20,70,78,12)) self.TextLabel2.setText(wrap_tr(QString.fromUtf8("出力 py ファイル"))) self.InputFileName = QLineEdit(self,'InputFileName') self.InputFileName.setGeometry(QRect(10,30,250,22)) self.OutputFileName = QLineEdit(self,'OutputFileName') self.OutputFileName.setGeometry(QRect(10,90,250,22)) self.InputReferButton = QPushButton(self,'InputReferButton') self.InputReferButton.setGeometry(QRect(270,30,80,22)) self.InputReferButton.setText(wrap_tr(QString.fromUtf8("参照..."))) self.InputReferButton.setAutoDefault(1) self.InputReferButton.setDefault(0) self.OutputReferButton = QPushButton(self,'OutputReferButton') self.OutputReferButton.setGeometry(QRect(270,90,80,22)) self.OutputReferButton.setText(wrap_tr(QString.fromUtf8("参照..."))) self.OutputReferButton.setAutoDefault(1) self.ExecButton = QPushButton(self,'ExecButton') self.ExecButton.setGeometry(QRect(180,130,80,22)) self.ExecButton.setText(wrap_tr(QString.fromUtf8("実行"))) self.ExecButton.setAutoDefault(1) self.CloseButton = QPushButton(self,'CloseButton') self.CloseButton.setGeometry(QRect(270,130,80,22)) self.CloseButton.setText(wrap_tr(QString.fromUtf8("閉じる"))) self.connect(self.InputReferButton, SIGNAL('clicked()'), self.InputFileOpen) self.connect(self.OutputReferButton, SIGNAL('clicked()'), self.OutputFileOpen) self.connect(self.ExecButton, SIGNAL('clicked()'), self.Exec) self.connect(self.CloseButton, SIGNAL('clicked()'), self.close) self.InputFile = None self.OutputFile = None def InputFileOpen(self): name = QFileDialog.getOpenFileName(QString.null, QString('ui file (*.ui);;All files (*.*)')) self.InputFileName.setText(name) def OutputFileOpen(self): defname = '' name = str(self.InputFileName.text()) if name != None: defname = re.sub('.ui$', '.py', name) name = QFileDialog.getSaveFileName(QString.fromUtf8(defname), QString('py file (*.py);;All files (*.*)')) self.OutputFileName.setText(name) def Exec(self): cmd = 'C:/Python22/pyuic.exe' input = str(self.InputFileName.text()) output = str(self.OutputFileName.text()) args = (cmd, '-tr', 'wrap_tr', '-o', output, input) os.spawnv(os.P_WAIT, cmd, args) data = open(output).read() f = open(output, 'w') f.write('def wrap_tr(s):\n if type(s) == type(\'\'):\n s = QObject.tr(s)\n return s\n\n') f.write(data) f.close() if __name__ == '__main__': a = QApplication(sys.argv) w = pyuic_helper_Form() a.setMainWidget(w) w.show() a.exec_loop()