Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- from PyQt4 import QtGui, QtCore
- from PyQt4.QtGui import QApplication, QWidget, QVBoxLayout, QPushButton
- from functools import partial
- from collections import OrderedDict
- import os
- but_width = 190
- butnum = 1
- global voffset
- voffset = 60
- gui_width = 460
- gui_height = 200
- class Window(QtGui.QMainWindow):
- def __init__(self):
- super(Window, self).__init__()
- self.setGeometry(50, 50, gui_width, gui_height)
- self.setWindowTitle("JWMSession")
- def pos_button():
- if butnum % 2 > 0:
- lm1=20
- else:
- lm1=250
- return lm1;
- #Format 'label':'progname'
- dic=OrderedDict()
- dic['Lock Screen'] = 'i3lock -c c59a7a'
- dic['Suspend'] = 'systemctl suspend'
- dic['Logout'] = 'jwm -exit'
- dic['Restart'] = 'systemctl reboot'
- dic['Shutdown'] = 'systemctl poweroff'
- dic['Cancel'] = 'kill -9 -$PPID'
- vbox = QVBoxLayout(self)
- global butnum
- butnum = 1
- myFont = QtGui.QFont("", 11, QtGui.QFont.Bold)
- ltxt1="What do you want to do?"
- len1 = len(ltxt1)
- lbl1 = QtGui.QLabel(ltxt1, self)
- lbl1.setFont(myFont)
- lbl1.setFixedWidth(gui_width)
- lbl1.setAlignment(QtCore.Qt.AlignHCenter)
- lbl1.move(0,20)
- vbox.addWidget(lbl1)
- for key,value in dic.items():
- global voffset
- btemp = butnum
- btn = QPushButton(" " + key, self)
- btn.setStyleSheet("Text-align:left")
- btn.setFixedWidth(but_width)
- btn.clicked.connect(partial(self.doit, value))
- lm1 = pos_button()
- if btemp % 2 == 0: btemp=btemp-1
- btn.move(lm1, (btemp*20)+voffset)
- butnum += 1
- if butnum == 15:
- voffset=120
- vbox.addWidget(btn)
- def doit(self, text):
- print("%s" % text)
- os.system(text)
- if __name__ == "__main__":
- app = QApplication([])
- w = Window()
- w.show()
- app.exec_()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement