import sys
from PyQt5.Qt import QVBoxLayout, QLabel, QDialog, QDialogButtonBox, Qt
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QMainWindow, QAction, qApp, QApplication
class InfoDialog(QDialog):
def __init__(self, info_str, parent=None):
super(InfoDialog, self).__init__(parent)
layout = QVBoxLayout(self)
layout.addWidget(QLabel(info_str))
buttons = QDialogButtonBox(QDialogButtonBox.Ok, Qt.Horizontal, self)
buttons.accepted.connect(self.accept)
layout.addWidget(buttons)
class Example(QMainWindow):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
exitAction = QAction(QIcon('RM.png'), 'Exit', self)
exitAction.setShortcut('Ctrl+Q')
exitAction.triggered.connect(qApp.quit)
infoAction = QAction(QIcon(), "Info", self)
infoAction.triggered.connect(self.onInfoAction)
self.toolbar = self.addToolBar('Exit')
self.toolbar.addAction(exitAction)
self.toolbar.addAction(infoAction)
self.setGeometry(300, 300, 300, 200)
self.setWindowTitle('Toolbar')
self.show()
def onInfoAction(self):
w = InfoDialog("Some information", self)
w.exec_()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
from PyQt4.QtCore import *
from PyQt4 import QtGui
class HelloPython(QtGui.QWidget):
def __init__(self, parent=None):
super(HelloPython, self).__init__(parent)
helloLabel = QtGui.QLabel("Say Hello To PyQT!")
helloLineEdit = QtGui.QLineEdit()
mainLayout = QtGui.QGridLayout()
mainLayout.addWidget(helloLabel, 0, 0)
mainLayout.addWidget(helloLineEdit, 0, 1)
self.setLayout(mainLayout)
self.setWindowTitle("My Python App")
if __name__ == '__main__':
import sys
app = QtGui.QApplication(sys.argv)
helloPythonWidget = HelloPython()
helloPythonWidget.show()
sys.exit(app.exec_())
from distutils.core import setup
import py2exe
setup(windows=['main.py'], options={"py2exe": {"bundle_files": 1, "compressed": True, "includes": ["sip"]}})
"The text can only be a single line: newline characters are not rendered."
from multiprocessing import Pool
def f(x):
return x*x
if __name__ == '__main__':
p = Pool(5)
print(p.map(f, [1, 2, 3]))
from mutagen.mp3 import MP3
f = MP3('test.mp3')
print(f.info.length)