SHOW:
|
|
- or go back to the newest paste.
1 | #!/usr/bin/ env python | |
2 | # -*- coding: utf-8 -*- | |
3 | ||
4 | import pygtk | |
5 | pygtk.require("2.0") | |
6 | - | import gtk,os |
6 | + | import gtk,os,pwd |
7 | ||
8 | usuario = pwd.getpwuid(os.getuid()).pw_name | |
9 | - | os.system("/bin/systemctl reboot") |
9 | + | |
10 | home='/home/' + usuario | |
11 | ||
12 | ||
13 | - | os.system("/bin/systemctl poweroff") |
13 | + | |
14 | os.system("comando1=$(which shutdown) && sudo $comando1 -r now") | |
15 | ||
16 | ||
17 | - | os.system("/usr/bin/openbox --exit") |
17 | + | |
18 | os.system("comando1=$(which shutdown) && sudo $comando1 -h now") | |
19 | ||
20 | ||
21 | - | os.system("/usr/bin/xscreensaver-command --lock") |
21 | + | |
22 | os.system("comando3=$(which openbox) && $comando3 --exit") | |
23 | ||
24 | ||
25 | def bloquear(): | |
26 | os.system("comando4=$(which xscreensaver-command) && $comando4 --lock") | |
27 | ||
28 | ||
29 | class Salir: | |
30 | ||
31 | def __init__(self): | |
32 | self.window = gtk.Window() | |
33 | - | image1.set_from_file("/home/cesarzeta/.icons/cancel.png") |
33 | + | |
34 | self.window.set_decorated(gtk.FALSE) | |
35 | self.window.set_position (gtk.WIN_POS_CENTER) | |
36 | - | image2.set_from_file("/home/cesarzeta/.icons/bloquear.png") |
36 | + | |
37 | self.window.connect ("delete-event", gtk.main_quit) | |
38 | image1=gtk.Image() | |
39 | - | image3.set_from_file("/home/cesarzeta/.icons/salir.png") |
39 | + | image1.set_from_file(home + '/.icons/cancel.png') |
40 | image1.show() | |
41 | image2=gtk.Image() | |
42 | - | image4.set_from_file("/home/cesarzeta/.icons/reiniciar.png") |
42 | + | image2.set_from_file(home + '/.icons/bloquear.png') |
43 | image2.show() | |
44 | image3=gtk.Image() | |
45 | - | image5.set_from_file("/home/cesarzeta/.icons/apagar.png") |
45 | + | image3.set_from_file(home + '/.icons/salir.png') |
46 | image3.show() | |
47 | image4=gtk.Image() | |
48 | image4.set_from_file(home + '/.icons/reiniciar.png') | |
49 | image4.show() | |
50 | image5=gtk.Image() | |
51 | image5.set_from_file(home + '/.icons/apagar.png') | |
52 | image5.show() | |
53 | self.color1=gtk.gdk.Color(0.40,0.40,0.40) | |
54 | self.color2=gtk.gdk.Color(0.1,0.1,0.1) | |
55 | self.color3=gtk.gdk.Color(1.0,1.0,1.0) | |
56 | self.vbox=gtk.VBox() | |
57 | self.box=gtk.HBox(gtk.TRUE) | |
58 | self.b1=gtk.Button() | |
59 | self.b1.connect("clicked",gtk.main_quit) | |
60 | self.b1.modify_bg(gtk.STATE_NORMAL,self.color1) | |
61 | self.b1.add(image1) | |
62 | self.b2=gtk.Button() | |
63 | self.b2.connect("clicked",lambda w: bloquear()) | |
64 | self.b2.modify_bg(gtk.STATE_NORMAL,self.color1) | |
65 | self.b2.add(image2) | |
66 | self.b3=gtk.Button() | |
67 | self.b3.connect("clicked",lambda w: exit()) | |
68 | self.b3.modify_bg(gtk.STATE_NORMAL,self.color1) | |
69 | self.b3.add(image3) | |
70 | self.b4=gtk.Button() | |
71 | self.b4.connect("clicked",lambda w: reiniciar()) | |
72 | self.b4.modify_bg(gtk.STATE_NORMAL,self.color1) | |
73 | self.b4.add(image4) | |
74 | self.b5=gtk.Button() | |
75 | self.b5.connect("clicked",lambda w: apagar()) | |
76 | self.b5.modify_bg(gtk.STATE_NORMAL,self.color1) | |
77 | self.b5.add(image5) | |
78 | self.box.pack_start(self.b1) | |
79 | self.box.pack_start(self.b2) | |
80 | self.box.pack_start(self.b3) | |
81 | self.box.pack_start(self.b4) | |
82 | self.box.pack_start(self.b5) | |
83 | self.b1.show() | |
84 | self.b2.show() | |
85 | self.b3.show() | |
86 | self.b4.show() | |
87 | self.b5.show() | |
88 | self.box.show() | |
89 | self.box1=gtk.HBox(gtk.TRUE) | |
90 | self.ev1=gtk.EventBox() | |
91 | self.ev2=gtk.EventBox() | |
92 | self.ev3=gtk.EventBox() | |
93 | self.ev4=gtk.EventBox() | |
94 | self.ev5=gtk.EventBox() | |
95 | self.l1=gtk.Label("Cancelar") | |
96 | self.l1.set_size_request(140,2) | |
97 | self.l2=gtk.Label("Bloquear") | |
98 | self.l2.set_size_request(140,2) | |
99 | self.l3=gtk.Label("Salir") | |
100 | self.l3.set_size_request(140,2) | |
101 | self.l4=gtk.Label("Reiniciar") | |
102 | self.l4.set_size_request(140,2) | |
103 | self.l5=gtk.Label("Apagar") | |
104 | self.l5.set_size_request(140,2) | |
105 | self.ev1.add(self.l1) | |
106 | self.ev2.add(self.l2) | |
107 | self.ev3.add(self.l3) | |
108 | self.ev4.add(self.l4) | |
109 | self.ev5.add(self.l5) | |
110 | self.ev1.modify_bg(gtk.STATE_NORMAL,self.color2) | |
111 | self.ev2.modify_bg(gtk.STATE_NORMAL,self.color2) | |
112 | self.ev3.modify_bg(gtk.STATE_NORMAL,self.color2) | |
113 | self.ev4.modify_bg(gtk.STATE_NORMAL,self.color2) | |
114 | self.ev5.modify_bg(gtk.STATE_NORMAL,self.color2) | |
115 | self.l1.modify_fg(gtk.STATE_NORMAL,self.color3) | |
116 | self.l2.modify_fg(gtk.STATE_NORMAL,self.color3) | |
117 | self.l3.modify_fg(gtk.STATE_NORMAL,self.color3) | |
118 | self.l4.modify_fg(gtk.STATE_NORMAL,self.color3) | |
119 | self.l5.modify_fg(gtk.STATE_NORMAL,self.color3) | |
120 | self.box1.pack_start(self.ev1) | |
121 | self.box1.pack_start(self.ev2) | |
122 | self.box1.pack_start(self.ev3) | |
123 | self.box1.pack_start(self.ev4) | |
124 | self.box1.pack_start(self.ev5) | |
125 | self.l1.show() | |
126 | self.l2.show() | |
127 | self.l3.show() | |
128 | self.l4.show() | |
129 | self.l5.show() | |
130 | self.ev1.show() | |
131 | self.ev2.show() | |
132 | self.ev3.show() | |
133 | self.ev4.show() | |
134 | self.ev5.show() | |
135 | self.box1.show() | |
136 | self.window.add(self.vbox) | |
137 | self.vbox.pack_start(self.box) | |
138 | self.vbox.pack_start(self.box1) | |
139 | self.vbox.show() | |
140 | self.window.show() | |
141 | ||
142 | def main(self): | |
143 | gtk.main() | |
144 | ||
145 | print __name__ | |
146 | if __name__ == "__main__": | |
147 | salir = Salir() | |
148 | salir.main() |