📜 ⬆️ ⬇️

We talk about PyQt4 - seating first

image

Small introduction


Actually, then, long ago, I decided to try Qt, because I often heard about the convenience of developing for it and saw with my own eyes what elegant documentation is presented on the manufacturer's website. I can not say that it was easy to do (I used to write a little on GTK a bit), I was especially confused in these endless classes on " Q ", but gradually I started to like it more and more. In particular, because there is an excellent binding to it for the Python language, on which I, in fact, mostly write.
Why not? Well, I could tell that it works both on almost all desktop systems, and on many mobile ones, tell about a completely brilliant object system of widgets, etc. But - why? I don’t like holivars with adherents of other visual libraries :) So let's consider this topic to be a bit of a sharing experience and reasoning on the topic.

Let's go...


Due to the peculiarities of modern education, many programmers of the younger generation (among whom your humble servant also ranks himself) live with Pascal and Delphi imprisoned in their heads. Well, what, after all, it is convenient - you draw windows with the mouse, you link components, you prescribe methods for them - and in the shortest time you get a beautiful window application. I myself sat on them for quite a while, even doing a couple of freelancing projects. But one day something clicked in my head - and brown Ubuntu settled on a laptop instead of sparkling Vista. I will not tell why and how I chose Python, but once there was a need to get out of the black bowels of the console and write something windowed.
Both Qt and GTK have their own visual editors, the interface of which is literally intuitive not only to the former developer, but also to the developer who decided to pop into desktop development for the first time. For GTK, this is Glade , for Qt, the Qt Designer tool that comes with the SDK. And both of them exist both as standalone applications, and as plugins for the well-known and dearly beloved Eclipse environment, and for Qt a very, very good native IDE recently appeared - Qt Creator , which was also included in the SDK. The only drawback is that there is not yet a sane plugin that allows it to be used for development in Python. At the output of both - the file with the xml-structure, something reminiscent of its purpose dfm-files Delphi. That is, they can be put in a folder with a project and connected with several lines of code - and everything is almost ready.
To heighten convenience, there is an intermediary package between Qt Designer and Python, and it bears the name pyqt4-dev-tools , and inside it lies the pyuic4 program, which is used for conveniently translating ui- files of the “designer” into a clean and neat Python code. BUT! As usual in this life, the good old principle of “press the button and beautifully” does not work here. Moreover, I really do not advise you to use pyuic4 for serious projects. Why? I'll tell you now.
Pyuic4 is a completely indispensable thing when mastering PyQt4. What could be more convenient - I threw a couple of widgets onto the form, translated the resulting file with a single command to the Python script - and you’ve already picked the code, looking at what methods are called when creating widgets, accessing them, creating labels, etc. But pyuic4 also generates a bunch of unnecessary, in my opinion, code, without which you can do and make everything more convenient and more compact without loss of readability and convenience. Here is an example of the code generated by pyuic4 for the simplest form with two buttons and an input field (and yes, do not scold me for the standard names for widgets, this is just an example :)):
Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  1. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  2. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  3. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  4. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  5. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  6. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  7. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  8. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  9. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  10. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  11. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  12. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  13. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  14. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  15. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  16. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  17. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  18. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  19. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  20. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  21. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  22. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  23. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  24. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  25. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  26. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  27. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  28. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  29. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  30. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  31. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  32. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  33. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  34. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  35. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  36. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  37. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  38. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  39. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  40. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  41. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  42. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  43. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  44. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())
  45. Copy Source | Copy HTML # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/home/username/ /habr.ui' # # Created: Fri Nov 13 23:52:05 2009 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName( "MainWindow" ) MainWindow.resize( 226 , 146 ) self .centralwidget = QtGui.QWidget(MainWindow) self .centralwidget.setObjectName( "centralwidget" ) self .lineEdit = QtGui.QLineEdit( self .centralwidget) self .lineEdit.setGeometry(QtCore.QRect( 10 , 10 , 201 , 26 )) self .lineEdit.setObjectName( "lineEdit" ) self .pushButton = QtGui.QPushButton( self .centralwidget) self .pushButton.setGeometry(QtCore.QRect( 10 , 50 , 92 , 28 )) self .pushButton.setObjectName( "pushButton" ) self .pushButton_2 = QtGui.QPushButton( self .centralwidget) self .pushButton_2.setGeometry(QtCore.QRect( 120 , 50 , 92 , 28 )) self .pushButton_2.setObjectName( "pushButton_2" ) MainWindow.setCentralWidget( self .centralwidget) self .menubar = QtGui.QMenuBar(MainWindow) self .menubar.setGeometry(QtCore.QRect( 0 , 0 , 226 , 25 )) self .menubar.setObjectName( "menubar" ) MainWindow.setMenuBar( self .menubar) self .statusbar = QtGui.QStatusBar(MainWindow) self .statusbar.setObjectName( "statusbar" ) MainWindow.setStatusBar( self .statusbar) self . retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi (self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate( "MainWindow" , "" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) self .pushButton_2.setText(QtGui.QApplication.translate( "MainWindow" , "PushButton" , None, QtGui.QApplication.UnicodeUTF8)) if __name__ == "__main__" : import sys app = QtGui.QApplication( sys .argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow () ui. setupUi (MainWindow) MainWindow.show() sys .exit(app.exec_())

First, as we see, the class is not inherited from QMainWindow , but from object — this is the so-called “new” version of Python classes, and an object of type QMainWindow is passed to the class method as a parameter. This creates some confusion when working with widgets - widget objects are fields not of the window class, but of the parent class Ui_MainWindow . But as with convenience, and with the inconvenience of this, of course, you can argue. Here it is to each his own.
Each object is assigned an internal name, and this is a rather curious thing - something between the Delphi properties Caption and Name. In fact, this name is required in the case when the widget is not very convenient to refer to as a class field. If you do not have complex forms generated on the fly and large chains of inheritance - you can safely do without these names, which I usually do. In addition, to create an interface that supports translation into different languages, all text data is run through the translator and converted to UTF-8 encoding, and this is in a separate class method. And everything is good, only for each object this hefty line is copied:
QtGui.QApplication.translate ("MainWindow", "HabraWindow", None, QtGui.QApplication.UnicodeUTF8)

Why not put it into a separate class method? :) Let's do it in our code (which we will write based on the generated file), for example, like this:
Copy Source | Copy HTML
  1. def toUtf (self, text):
  2. return QtGui.QApplication.translate ( "MainWindow" , text, None, QtGui.QApplication.UnicodeUTF8)

The code does not deteriorate in terms of readability, but strings returned from third-party functions will be easily converted to the desired type.
By the way, the fact that in the generated pyuic4 code the full address of each module of the first level is indicated is in this case a plus, since for development it is really useful to know the parent for a particular method. Although battles between lovers of full addresses and supporters of lines like " from module import * " never subside.

Give praaaktikyu!


I feel that I’m already tired of talking to me on abstract topics, so let's take a break from the quarry and analyze some typical examples faced by people studying PyQt4. No, I will not write here a guide for beginners, but simply describe my own experience and the pitfalls that I had to face.
To begin, let's do such a thing - we will move the form into a separate module that connects to the project. Because of the double class structure described above, you will have to return two arguments from the window creation function, and as many as three arguments when creating the main window. So, on the agenda of the day two files - launch:
Copy Source | Copy HTML
  1. #! / usr / bin / python
  2. # - * - coding: utf-8 - * -
  3. import sys
  4. from forms import MainForm
  5. def main ():
  6. app, mainForm, window = MainForm.init ()
  7. window.show ()
  8. sys .exit (app.exec_ ())
  9. if __name__ == "__main__" :
  10. main ()

and the file itself is of the form:
Copy Source | Copy HTML
  1. # - * - coding: utf-8 - * -
  2. import sys
  3. from PyQt4 import QtCore, QtGui, Qt
  4. class mainWindow (object):
  5. def setupUi (self, MainWindow):
  6. # set a fixed size for the window (knowledge of the method will not be superfluous)
  7. MainWindow.setFixedSize ( 950 , 550 )
  8. # I'm in charge, and all widgets from me are inherited
  9. self .main = QtGui.QWidget (MainWindow)
  10. MainWindow.setCentralWidget ( self .main)
  11. # for the completeness of sensations create a menu "File"
  12. self .menubar = QtGui.QMenuBar (MainWindow)
  13. self .menubar.setGeometry (QtCore.QRect ( 0 , 0 , 559 , 25 ))
  14. # create a QAction trigger action to bind it to a menu item
  15. self .menu_file_exit = QtGui.QAction ( self .main)
  16. self .menu_file_exit.setText ( self . toUtf ( "& Exit" ))
  17. MainWindow.connect ( self .menu_file_exit, QtCore.SIGNAL ( 'triggered ()' ), sys .exit)
  18. # create a menu item and add our QAction to it
  19. self .menu_file = self .menubar.addMenu ( self . toUtf ( '& File' ))
  20. self .menu_file.addAction ( self .menu_file_exit)
  21. MainWindow.setMenuBar ( self .menubar)
  22. # for solidity we attach statusbar
  23. self .statusbar = QtGui.QStatusBar (MainWindow)
  24. MainWindow.setStatusBar ( self .statusbar)
  25. # move the window where we want
  26. MainWindow.move ( 140 , 80 )
  27. self . retranslateUi (MainWindow)
  28. def retranslateUi (self, MainWindow):
  29. # give the window a name
  30. MainWindow.setWindowTitle ( self . ToUtf ( "HabraWindow 2.0" ))
  31. def toUtf (self, text):
  32. # that translation function
  33. return QtGui.QApplication.translate ( "MainWindow" , text, None, QtGui.QApplication.UnicodeUTF8)
  34. def init ():
  35. # initialize Qt
  36. app = QtGui.QApplication ( sys .argv)
  37. # create a separate, independent window object ...
  38. MainWindow = QtGui.QMainWindow ()
  39. # ... and run it through our class
  40. form = mainWindow ()
  41. form. setupUi (MainWindow)
  42. return app, form, MainWindow

In this case, the project has the following structure:
main.py
forms /
> __init__.py (an empty file is needed for the folder to be recognized as a Python package)
> MainForm.py

I know that this method of separation can be scolded and cursed, but how much useful we learned about the creation of the window! :) And now let's not stop there and create a child window so that it is not so lonely for us (not for nothing, I created a separate forms directory). Moreover, we will make it modal (the parent window will not react to user actions while the child is open) so that the playful hands of users will not lead to bad consequences. To do this, create in the forms directory the file ChildForm.py, in which we describe the child form:
Copy Source | Copy HTML
  1. # - * - coding: utf-8 - * -
  2. from PyQt4 import QtCore, QtGui
  3. class childWindow (object):
  4. def setupUi (self, SmallWindow):
  5. SmallWindow.setFixedSize ( 330 , 200 )
  6. SmallWindow.setWindowFlags (QtCore.Qt.Window)
  7. self . retranslateUi (SmallWindow)
  8. SmallWindow.setWindowModality (QtCore.Qt.WindowModal)
  9. def retranslateUi (self, Form):
  10. Form.setWindowTitle ( self . ToUtf ( "I am a child window" ))
  11. def toUtf (self, text):
  12. return QtGui.QApplication.translate ( "SmallWindow" , text, None, QtGui.QApplication.UnicodeUTF8)
  13. def init (parentwindow):
  14. SmallWindow = QtGui.QWidget (parentwindow)
  15. form = childWindow ()
  16. form. setupUi (SmallWindow)
  17. Return form, SmallWindow

and also make some changes to the main form file:
Copy Source | Copy HTML
  1. ...
  2. from forms import ChildForm
  3. ...
  4. # create your own window class, this is needed to solve some problems with inheritance
  5. class myQMainWindow (QtGui.QMainWindow):
  6. def __init__ (self, parent = None):
  7. QtGui.QMainWindow. __init__ (self, parent)
  8. ...
  9. def setupUi (self, MainWindow):
  10. ...
  11. # we take out the window in the class field for more convenient inheritance
  12. self .mainwindow = MainWindow
  13. # draw a button by which the child window will be displayed
  14. self .btnHello = QtGui.QPushButton ( self .main)
  15. self .btnHello.setGeometry (QtCore.QRect ( 20 , 19 , 92 , 28 ))
  16. MainWindow.connect ( self .btnHello, QtCore.SIGNAL ( 'clicked ()' ), self . ShowChildWindow )
  17. ...
  18. def retranslateUi (self, MainWindow):
  19. ...
  20. self .btnHello.setText ( self .toUtf ( "Click!" ))
  21. ...
  22. def showChildWindow (self):
  23. self .childForm, self .childWindow = ChildForm. init ( self .mainwindow)
  24. self .childWindow.show ()
  25. def init ():
  26. ...
  27. #MainWindow = QtGui.QMainWindow ()
  28. MainWindow = myQMainWindow ()
  29. ...

Voila! We have parent and child windows.

I think we’ll finish the sit-in today, but this is only the beginning :) I know that this topic doesn’t contain as much useful information as I would like, but I promise to correct it - there will be a lot of practice at the next gathering.
And yes, thanks to the user poltergeist from the python.su forum for a bunch of useful tips!

')

Source: https://habr.com/ru/post/75226/


All Articles