Vous n'êtes pas identifié(e).
Pages : 1
Suite à cette demande http://linuxtrack.net/viewtopic.php?id=1553 et au passage de crunchbang sur debian 8 avec prise en charge de systemd, j'ai modifié le cb-exit pour qu'il prenne en charge systemd et les icone gtk
Le script prend également en compte le français et l'anglais.
[== C++ ==]
#!/usr/bin/env python
# -*- coding: cp1252 -*-
import pygtk
pygtk.require('2.0')
import gtk
import os
import getpass
import locale
LANG = locale.setlocale(locale.LC_ALL, "")[0:2]
class vp_exit:
if LANG == 'fr':
def disable_buttons(self):
self.cancel.set_sensitive(False)
self.logout.set_sensitive(False)
self.suspend.set_sensitive(False)
self.reboot.set_sensitive(False)
self.shutdown.set_sensitive(False)
def cancel_action(self,btn):
self.disable_buttons()
gtk.main_quit()
def logout_action(self,btn):
self.disable_buttons()
self.status.set_label("Déconnection d'Openbox, patientez...")
os.system("openbox --exit")
def suspend_action(self,btn):
self.disable_buttons()
self.status.set_label("Mise en veille, patientez...")
os.system("xscreensaver-command -lock")
os.system("systemctl suspend")
gtk.main_quit()
def reboot_action(self,btn):
self.disable_buttons()
self.status.set_label("Redémarrage, patientez...")
os.system("systemctl reboot")
def shutdown_action(self,btn):
self.disable_buttons()
self.status.set_label("Extinction, patientez...")
os.system("systemctl poweroff")
def create_window(self):
iconsize = gtk.icon_size_register("24x24", 24, 24)
self.window = gtk.Window()
title = "Déconnecter " + getpass.getuser() + "? Choisissez une option:"
self.window.set_title(title)
self.window.set_border_width(5)
self.window.set_size_request(580, 80)
self.window.set_resizable(False)
self.window.set_keep_above(True)
self.window.stick
self.window.set_position(1)
self.window.connect("delete_event", gtk.main_quit)
windowicon = self.window.render_icon(gtk.STOCK_QUIT, gtk.ICON_SIZE_MENU)
self.window.set_icon(windowicon)
#Create HBox for buttons
self.button_box = gtk.HBox()
self.button_box.show()
#Cancel button
self.cancel = gtk.Button(stock = gtk.STOCK_CANCEL)
self.cancel.set_border_width(4)
self.cancel.connect("clicked", self.cancel_action)
self.button_box.pack_start(self.cancel)
self.cancel.show()
#Logout button
self.logout = gtk.Button("_Déconnecter")
ico = gtk.Image()
ico.set_from_icon_name("gnome-logout", iconsize)
self.logout.set_image(ico)
self.logout.set_border_width(4)
self.logout.connect("clicked", self.logout_action)
self.button_box.pack_start(self.logout)
self.logout.show()
#Suspend button
self.suspend = gtk.Button("_Veille")
ico = gtk.Image()
ico.set_from_icon_name("gnome-session-hibernate", iconsize)
self.suspend.set_image(ico)
self.suspend.set_border_width(4)
self.suspend.connect("clicked", self.suspend_action)
self.button_box.pack_start(self.suspend)
self.suspend.show()
#Reboot button
self.reboot = gtk.Button("_Redémarrer")
ico = gtk.Image()
ico.set_from_icon_name("gnome-session-reboot", iconsize)
self.reboot.set_image(ico)
self.reboot.set_border_width(4)
self.reboot.connect("clicked", self.reboot_action)
self.button_box.pack_start(self.reboot)
self.reboot.show()
#Shutdown button
self.shutdown = gtk.Button("_Quitter")
ico = gtk.Image()
ico.set_from_icon_name("gnome-shutdown", iconsize)
self.shutdown.set_image(ico)
self.shutdown.set_border_width(4)
self.shutdown.connect("clicked", self.shutdown_action)
self.button_box.pack_start(self.shutdown)
self.shutdown.show()
#Create HBox for status label
self.label_box = gtk.HBox()
self.label_box.show()
self.status = gtk.Label()
self.status.show()
self.label_box.pack_start(self.status)
#Create VBox and pack the above HBox's
self.vbox = gtk.VBox()
self.vbox.pack_start(self.button_box)
self.vbox.pack_start(self.label_box)
self.vbox.show()
self.window.add(self.vbox)
self.window.show()
def __init__(self):
self.create_window()
else:
def disable_buttons(self):
self.cancel.set_sensitive(False)
self.logout.set_sensitive(False)
self.suspend.set_sensitive(False)
self.reboot.set_sensitive(False)
self.shutdown.set_sensitive(False)
def cancel_action(self,btn):
self.disable_buttons()
gtk.main_quit()
def logout_action(self,btn):
self.disable_buttons()
self.status.set_label("Exiting Openbox, please standby...")
os.system("openbox --exit")
def suspend_action(self,btn):
self.disable_buttons()
self.status.set_label("Suspending, please standby...")
os.system("xscreensaver-command -lock")
os.system("systemctl suspend")
gtk.main_quit()
def reboot_action(self,btn):
self.disable_buttons()
self.status.set_label("Rebooting, please standby...")
os.system("systemctl reboot")
def shutdown_action(self,btn):
self.disable_buttons()
self.status.set_label("Shutting down, please standby...")
os.system("systemctl poweroff")
def create_window(self):
iconsize = gtk.icon_size_register("24x24", 24, 24)
self.window = gtk.Window()
title = "Log out " + getpass.getuser() + "? Choose an option:"
self.window.set_title(title)
self.window.set_border_width(5)
self.window.set_size_request(540, 80)
self.window.set_resizable(False)
self.window.set_keep_above(True)
self.window.stick
self.window.set_position(1)
self.window.connect("delete_event", gtk.main_quit)
windowicon = self.window.render_icon(gtk.STOCK_QUIT, gtk.ICON_SIZE_MENU)
self.window.set_icon(windowicon)
#Create HBox for buttons
self.button_box = gtk.HBox()
self.button_box.show()
#Cancel button
self.cancel = gtk.Button(stock = gtk.STOCK_CANCEL)
self.cancel.set_border_width(4)
self.cancel.connect("clicked", self.cancel_action)
self.button_box.pack_start(self.cancel)
self.cancel.show()
#Logout button
self.logout = gtk.Button("_Logout")
ico = gtk.Image()
ico.set_from_icon_name("gnome-logout", iconsize)
self.logout.set_image(ico)
self.logout.set_border_width(4)
self.logout.connect("clicked", self.logout_action)
self.button_box.pack_start(self.logout)
self.logout.show()
#Suspend button
self.suspend = gtk.Button("_Suspend")
ico = gtk.Image()
ico.set_from_icon_name("gnome-session-hibernate", iconsize)
self.suspend.set_image(ico)
self.suspend.set_border_width(4)
self.suspend.connect("clicked", self.suspend_action)
self.button_box.pack_start(self.suspend)
self.suspend.show()
#Reboot button
self.reboot = gtk.Button("_Reboot")
ico = gtk.Image()
ico.set_from_icon_name("gnome-session-reboot", iconsize)
self.reboot.set_image(ico)
self.reboot.set_border_width(4)
self.reboot.connect("clicked", self.reboot_action)
self.button_box.pack_start(self.reboot)
self.reboot.show()
#Shutdown button
self.shutdown = gtk.Button("_Poweroff")
ico = gtk.Image()
ico.set_from_icon_name("gnome-shutdown", iconsize)
self.shutdown.set_image(ico)
self.shutdown.set_border_width(4)
self.shutdown.connect("clicked", self.shutdown_action)
self.button_box.pack_start(self.shutdown)
self.shutdown.show()
#Create HBox for status label
self.label_box = gtk.HBox()
self.label_box.show()
self.status = gtk.Label()
self.status.show()
self.label_box.pack_start(self.status)
#Create VBox and pack the above HBox's
self.vbox = gtk.VBox()
self.vbox.pack_start(self.button_box)
self.vbox.pack_start(self.label_box)
self.vbox.show()
self.window.add(self.vbox)
self.window.show()
def __init__(self):
self.create_window()
def main():
gtk.main()
if __name__ == "__main__":
go = vp_exit()
main()
Utiliser des logiciels propriétaires, c'est comme les plats préparés, on est incapable de dire les conservateurs qu'ils contiennent, on dira toujours que c'est bon, mais ça ne remplacera jamais le repas fait maison par sa maman.
]:D #! Crunchbang & Archlinux GNU/Linux User ]:D
Hors ligne
J'ai modifié ton script pour éviter les redondances de code, tu me diras si l'affichage est exact.
#!/usr/bin/env python
# -*- coding: cp1252 -*-
import pygtk
pygtk.require('2.0')
import gtk
import os
import getpass
import locale
LOCALE = locale.setlocale(locale.LC_ALL, "")[0:2] # 'fr' or 'en'
if LOCALE == 'fr':
LANG = 0
else:
LANG = 1
# Interface Language
class language:
#[label]
LOGOUT_ACTION_LABEL=["Déconnection d'Openbox, patientez...","Exiting Openbox, please standby..."]
SUSPEND_ACTION_LABEL=["Mise en veille, patientez...","Suspending, please standby..."]
REBOOT_ACTION_LABEL=["Redémarrage, patientez...","Rebooting, please standby..."]
SHUTDOWN_ACTION_LABEL=["Extinction, patientez...","Shutting down, please standby..."]
#[window]
TITLE=["Déconnecter %s? Choisissez une option:","Log out %s? Choose an option:"]
#[button]
LOGOUT_BUTTON=["_Déconnecter","_Logout"]
SUSPEND_BUTTON=["_Veille","_Suspend"]
REBOOT_BUTTON=["_Redémarrer","_Reboot"]
SHUTDOWN_BUTTON=["_Quitter","_Poweroff"]
class vp_exit:
def disable_buttons(self):
self.cancel.set_sensitive(False)
self.logout.set_sensitive(False)
self.suspend.set_sensitive(False)
self.reboot.set_sensitive(False)
self.shutdown.set_sensitive(False)
def cancel_action(self,btn):
self.disable_buttons()
gtk.main_quit()
def logout_action(self,btn):
self.disable_buttons()
self.status.set_label(language.LOGOUT_ACTION_LABEL[LANG])
os.system("openbox --exit")
def suspend_action(self,btn):
self.disable_buttons()
self.status.set_label(language.SUSPEND_ACTION_LABEL[LANG])
os.system("xscreensaver-command -lock")
os.system("systemctl suspend")
gtk.main_quit()
def reboot_action(self,btn):
self.disable_buttons()
self.status.set_label(language.REBOOT_ACTION_LABEL[LANG])
os.system("systemctl reboot")
def shutdown_action(self,btn):
self.disable_buttons()
self.status.set_label(language.SHUTDOWN_ACTION_LABEL[LANG])
os.system("systemctl poweroff")
def create_window(self):
iconsize = gtk.icon_size_register("24x24", 24, 24)
self.window = gtk.Window()
title = language.TITLE[LANG] % (getpass.getuser())
self.window.set_title(title)
self.window.set_border_width(5)
self.window.set_size_request(580, 80)
self.window.set_resizable(False)
self.window.set_keep_above(True)
self.window.stick
self.window.set_position(1)
self.window.connect("delete_event", gtk.main_quit)
windowicon = self.window.render_icon(gtk.STOCK_QUIT, gtk.ICON_SIZE_MENU)
self.window.set_icon(windowicon)
#Create HBox for buttons
self.button_box = gtk.HBox()
self.button_box.show()
#Cancel button
self.cancel = gtk.Button(stock = gtk.STOCK_CANCEL)
self.cancel.set_border_width(4)
self.cancel.connect("clicked", self.cancel_action)
self.button_box.pack_start(self.cancel)
self.cancel.show()
#Logout button
self.logout = gtk.Button(language.LOGOUT_BUTTON[LANG])
ico = gtk.Image()
ico.set_from_icon_name("gnome-logout", iconsize)
self.logout.set_image(ico)
self.logout.set_border_width(4)
self.logout.connect("clicked", self.logout_action)
self.button_box.pack_start(self.logout)
self.logout.show()
#Suspend button
self.suspend = gtk.Button(language.SUSPEND_BUTTON[LANG])
ico = gtk.Image()
ico.set_from_icon_name("gnome-session-hibernate", iconsize)
self.suspend.set_image(ico)
self.suspend.set_border_width(4)
self.suspend.connect("clicked", self.suspend_action)
self.button_box.pack_start(self.suspend)
self.suspend.show()
#Reboot button
self.reboot = gtk.Button(language.REBOOT_BUTTON[LANG])
ico = gtk.Image()
ico.set_from_icon_name("gnome-session-reboot", iconsize)
self.reboot.set_image(ico)
self.reboot.set_border_width(4)
self.reboot.connect("clicked", self.reboot_action)
self.button_box.pack_start(self.reboot)
self.reboot.show()
#Shutdown button
self.shutdown = gtk.Button(language.SHUTDOWN_BUTTON[LANG])
ico = gtk.Image()
ico.set_from_icon_name("gnome-shutdown", iconsize)
self.shutdown.set_image(ico)
self.shutdown.set_border_width(4)
self.shutdown.connect("clicked", self.shutdown_action)
self.button_box.pack_start(self.shutdown)
self.shutdown.show()
#Create HBox for status label
self.label_box = gtk.HBox()
self.label_box.show()
self.status = gtk.Label()
self.status.show()
self.label_box.pack_start(self.status)
#Create VBox and pack the above HBox's
self.vbox = gtk.VBox()
self.vbox.pack_start(self.button_box)
self.vbox.pack_start(self.label_box)
self.vbox.show()
self.window.add(self.vbox)
self.window.show()
def __init__(self):
self.create_window()
def main():
gtk.main()
if __name__ == "__main__":
go = vp_exit()
main()
Edit: j'ai renommé les propriétés pour qu'elles soit plus dans les conventions (en majuscules et séparés par des _ )
Hors ligne
j'ai testé les 2 sur une vm viperr
j'ai pu tester les fonctions annuler, déconnecter, redémarrer, quitter (marchent parfaitement).
pour la fonction veille sur virtualbox ?
teste de lancé avec ./fichier et python fichier.py
IceF0x
WarLocG
partent tout les 2 en respectant le thème avec simple clic gauche.
intéressant !
merci @+
Dernière modification par WangXiangzhai (02-05-2015 23:08:53)
PC: HP-pavilion a6227.fr | wifi: Awus036H et HWGUSB2-54 | CG: NVIDIA geforce 8400 GS | OS: Debian-8.1.0-i386 Xfce | EN TESTE kali-linux-openbox-rolling-i386.iso (KaliBang), bento-openbox-14.04.3-i386.iso et Viperr8_i686.iso
Hors ligne
J'ai modifié ton script pour éviter les redondances de code, tu me diras si l'affichage est exact.
http://pix.toile-libre.org/upload/origi … 592836.png
j'ai renommé les propriétés pour qu'elles soit plus dans les conventions (en majuscules et séparés par des _ )
Nickel chrome, merci pour la correction, et merci WangXiangzhai pour le test
Utiliser des logiciels propriétaires, c'est comme les plats préparés, on est incapable de dire les conservateurs qu'ils contiennent, on dira toujours que c'est bon, mais ça ne remplacera jamais le repas fait maison par sa maman.
]:D #! Crunchbang & Archlinux GNU/Linux User ]:D
Hors ligne
J'en ai fait un rpm. Fonctionne très bien sur la bêta de viperr7
Security is always excessive until it’s not enough. — Robbie Sinclair
Hors ligne
PC: HP-pavilion a6227.fr | wifi: Awus036H et HWGUSB2-54 | CG: NVIDIA geforce 8400 GS | OS: Debian-8.1.0-i386 Xfce | EN TESTE kali-linux-openbox-rolling-i386.iso (KaliBang), bento-openbox-14.04.3-i386.iso et Viperr8_i686.iso
Hors ligne
marche impec sur ma Debian 8.1 i386 openbox.
encore merci à tout les deux
PC: HP-pavilion a6227.fr | wifi: Awus036H et HWGUSB2-54 | CG: NVIDIA geforce 8400 GS | OS: Debian-8.1.0-i386 Xfce | EN TESTE kali-linux-openbox-rolling-i386.iso (KaliBang), bento-openbox-14.04.3-i386.iso et Viperr8_i686.iso
Hors ligne
Je confirme ! ce script est officielement utilisé dans Viperr.
Merci coyotus et WarLocG
vi est mon ami pour la vie
Ph'nglui nglw-nafh Cthulhu R'lyeh wgah-nagl fhtagn
Hors ligne
Pages : 1