-
Notifications
You must be signed in to change notification settings - Fork 0
/
sistem_kapat.py
145 lines (115 loc) · 5.84 KB
/
sistem_kapat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/env python
from tkinter import *
from tkinter import ttk
from getpass import getuser
import os
"""
# systemctl default
# systemctl rescue
# systemctl emergency
# systemctl halt
# systemctl poweroff
# systemctl reboot
# systemctl suspend
# systemctl hibernate
# systemctl hybrid-sleep
"""
PROGRAM_KLASOR = os.path.dirname(os.path.abspath(__file__))
IKON_KLASOR = os.path.join(PROGRAM_KLASOR, "ikonlar")
#######################################################################
class SistemKapat:
# ---------------------------------------------------------------------
def __init__(self):
self.pencere_olustur_frame()
# ---------------------------------------------------------------------
def dugmeleri_dondur(self):
self.iptalBtn.config(state="disabled")
self.cikisBtn.config(state="disabled")
self.uyutBtn.config(state="disabled")
self.yenidenBaslatBtn.config(state="disabled")
self.kapatBtn.config(state="disabled")
# ---------------------------------------------------------------------
def iptal_et(self):
self.dugmeleri_dondur()
self.pencere.destroy()
# ---------------------------------------------------------------------
def _cikis_yap(self):
self.dugmeleri_dondur()
self.durumStrVar.set("Openbox' tan çıkılıyor, lütfen bekleyiniz...")
os.system("openbox --exit")
# ---------------------------------------------------------------------
def _uyut(self):
self.dugmeleri_dondur()
self.durumStrVar.set("Uyku moduna geçiliyor, lütfen bekleyiniz...")
os.system("systemctl suspend")
self.pencere.destroy()
# ---------------------------------------------------------------------
def _yeniden_baslat(self):
self.dugmeleri_dondur()
self.durumStrVar.set("Yeniden başlatılıyor, lütfen bekleyiniz...")
os.system("reboot")
# ---------------------------------------------------------------------
def _kapat(self):
self.dugmeleri_dondur()
self.durumStrVar.set("Bilgisayar kapatılıyor, lütfen bekleyiniz...")
os.system("shutdown -h now")
# ---------------------------------------------------------------------
def pencere_olustur_frame(self):
self.pencere = Tk()
pencere_genislik = 550
pencere_yukseklik = 75
ekran_genislik = self.pencere.winfo_screenwidth()
ekran_yukseklik = self.pencere.winfo_screenheight()
x = int((ekran_genislik / 2) - (pencere_genislik / 2))
y = int((ekran_yukseklik / 2) - (pencere_yukseklik / 2))
self.pencere.geometry(f'{pencere_genislik}x{pencere_yukseklik}+{x}+{y}')
# self.pencere.geometry('500x90+400+300')
# self.pencere.geometry('500x90')
self.pencere.configure(background='#333')
self.pencere.title("Kullanıcı: " + getuser() + " Lütfen seçiniz")
genislik = 70
aralik = 5
ustFrame = Frame(self.pencere, bg='#333')
altFrame = Frame(self.pencere, bg='#333')
ustFrame.pack(side=TOP, pady=(13, 4))
altFrame.pack(side=BOTTOM, fill=BOTH, expand=True)
iptal_ikon = PhotoImage(file=os.path.join(IKON_KLASOR, "iptal.png"))
self.iptalBtn = Button(self.pencere, text='İptal', compound="left", image=iptal_ikon, width=genislik, bg='#333',
fg="#eee", relief="solid", font=('arial', 11, 'normal'),
command=self.iptal_et)
self.iptalBtn.pack(in_=ustFrame, side=LEFT, padx=aralik)
cikis_ikon = PhotoImage(file=os.path.join(IKON_KLASOR, "cikis.png"))
self.cikisBtn = Button(self.pencere, text='Çıkış', compound="left", image=cikis_ikon, width=genislik, bg='#333',
fg="#eee", relief="solid", font=('arial', 11, 'normal'),
command=self._cikis_yap)
self.cikisBtn.pack(in_=ustFrame, side=LEFT, padx=aralik)
uyut_ikon = PhotoImage(file=os.path.join(IKON_KLASOR, "uyut.png"))
self.uyutBtn = Button(self.pencere, text='Uyut', compound="left", image=uyut_ikon, width=genislik, bg='#333',
fg="#eee", relief="solid", font=('arial', 11, 'normal'),
command=self._uyut)
self.uyutBtn.pack(in_=ustFrame, side=LEFT, padx=aralik)
yeniden_baslat_ikon = PhotoImage(file=os.path.join(IKON_KLASOR, "yeniden_baslat.png"))
self.yenidenBaslatBtn = Button(self.pencere, text='Yeniden', compound="left", image=yeniden_baslat_ikon,
width=genislik,
bg='#333', fg="#eee", relief="solid", font=('arial', 11, 'normal'),
command=self._yeniden_baslat)
self.yenidenBaslatBtn.pack(in_=ustFrame, side=LEFT, padx=aralik)
kapat_ikon = PhotoImage(file=os.path.join(IKON_KLASOR, "kapat.png"))
self.kapatBtn = Button(self.pencere, image=kapat_ikon, compound="left", text='Kapat', width=genislik, bg='#333',
fg="#eee", relief="solid", font=('arial', 11, 'normal'),
command=self._kapat)
# self.kapatBtn.image = kapat_ikon
self.kapatBtn.pack(in_=ustFrame, side=LEFT, padx=aralik)
self.durumStrVar = StringVar()
self.durumStrVar.set("")
self.durumEtk = Label(self.pencere, textvariable=self.durumStrVar, bg='#333', fg="#eee",
font=('arial', 11, 'normal'))
# ~ self.status.pack(in_=altFrame, anchor=CENTER, pady=(0,10))
self.durumEtk.pack(in_=altFrame, anchor=CENTER)
self.pencere.mainloop()
# ---------------------------------------------------------------------
def calistir():
s = SistemKapat()
# ---------------------------------------------------------------------
if __name__ == "__main__":
calistir()