daily pastebin goal
28%
SHARE
TWEET

Zamykacz

a guest Jul 13th, 2013 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3.  
  4. import sys
  5. import os
  6. import subprocess
  7. from PyQt4 import QtGui
  8. from PyQt4 import QtCore
  9. from subprocess import call
  10. cmd0 = 'sudo shutdown -h now'
  11. cmd1 = 'sudo shutdown -r now'
  12. cmd2 = 'sudo pm-suspend'
  13. cmd3 = 'sudo pm-hibernate'
  14.  
  15. class Example(QtGui.QWidget):
  16.    
  17.     def __init__(self):
  18.         super(Example, self).__init__()
  19.        
  20.         self.initUI()
  21.        
  22.     def initUI(self):
  23.  
  24.        
  25.         btn = QtGui.QPushButton('Zamknij system', self)
  26.         btn.resize(180, 40)
  27.         btn.move(20, 35)      
  28.         btn.clicked.connect(lambda: os.system(cmd0))
  29.         btn.clicked.connect(self.close)
  30.  
  31.         btn = QtGui.QPushButton('Uruchom ponownie', self)
  32.         btn.resize(180, 40)
  33.         btn.move(20, 80)
  34.         btn.clicked.connect(lambda: os.system(cmd1))
  35.         btn.clicked.connect(self.close)
  36.  
  37.         btn = QtGui.QPushButton('Wstrzymaj', self)
  38.         btn.resize(180, 40)
  39.         btn.move(20, 125)
  40.         btn.clicked.connect(lambda: os.system(cmd2))
  41.         btn.clicked.connect(self.close)
  42.  
  43.         btn = QtGui.QPushButton('Zahibernuj', self)
  44.         btn.resize(180, 40)
  45.         btn.move(20, 170)
  46.         btn.clicked.connect(lambda: os.system(cmd3))
  47.         btn.clicked.connect(self.close)
  48.  
  49.         qbtn = QtGui.QPushButton('Anuluj', self)
  50.         qbtn.clicked.connect(QtCore.QCoreApplication.instance().quit)
  51.         qbtn.resize(180, 40)
  52.         qbtn.move(20, 260)      
  53.  
  54.         self.setGeometry(100, 100, 225, 360)
  55.         self.setWindowTitle('Zamknij')    
  56.         self.show()
  57.  
  58.     def keyPressEvent(self, e):
  59.        
  60.         if e.key() == QtCore.Qt.Key_Escape:
  61.             self.close()
  62.  
  63. def main():
  64.    
  65.     app = QtGui.QApplication(sys.argv)
  66.     ex = Example()
  67.     sys.exit(app.exec_())
  68.  
  69.  
  70. if __name__ == '__main__':
  71.     main()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top