Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- import sys
- import os
- import subprocess
- from PyQt4 import QtGui
- from PyQt4 import QtCore
- from subprocess import call
- cmd0 = 'sudo shutdown -h now'
- cmd1 = 'sudo shutdown -r now'
- cmd2 = 'sudo pm-suspend'
- cmd3 = 'sudo pm-hibernate'
- class Example(QtGui.QWidget):
- def __init__(self):
- super(Example, self).__init__()
- self.initUI()
- def initUI(self):
- btn = QtGui.QPushButton('Zamknij system', self)
- btn.resize(180, 40)
- btn.move(20, 35)
- btn.clicked.connect(lambda: os.system(cmd0))
- btn.clicked.connect(self.close)
- btn = QtGui.QPushButton('Uruchom ponownie', self)
- btn.resize(180, 40)
- btn.move(20, 80)
- btn.clicked.connect(lambda: os.system(cmd1))
- btn.clicked.connect(self.close)
- btn = QtGui.QPushButton('Wstrzymaj', self)
- btn.resize(180, 40)
- btn.move(20, 125)
- btn.clicked.connect(lambda: os.system(cmd2))
- btn.clicked.connect(self.close)
- btn = QtGui.QPushButton('Zahibernuj', self)
- btn.resize(180, 40)
- btn.move(20, 170)
- btn.clicked.connect(lambda: os.system(cmd3))
- btn.clicked.connect(self.close)
- qbtn = QtGui.QPushButton('Anuluj', self)
- qbtn.clicked.connect(QtCore.QCoreApplication.instance().quit)
- qbtn.resize(180, 40)
- qbtn.move(20, 260)
- self.setGeometry(100, 100, 225, 360)
- self.setWindowTitle('Zamknij')
- self.show()
- def keyPressEvent(self, e):
- if e.key() == QtCore.Qt.Key_Escape:
- self.close()
- def main():
- app = QtGui.QApplication(sys.argv)
- ex = Example()
- sys.exit(app.exec_())
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement