X-FTP
[x93.git/.git] / xftp.git / ext / puntua.pyw
1 from tkinter import Tk,Label,Entry,StringVar,IntVar,Checkbutton,Button,Text,END,messagebox\r
2 from tkinter.ttk import Scrollbar\r
3 import os,getpass\r
4 try:\r
5         import ext.crud as crud\r
6 except:\r
7         import crud\r
8 import smtplib\r
9 from email.mime.text import MIMEText\r
10 import io\r
11 from color import Color\r
12 \r
13 \r
14 \r
15 def conn():\r
16         global theme2,color,color2,banner,banner1,banner_name2\r
17         try:\r
18                 theme=io.open("configs\\themes\\theme.thm","r")\r
19                 theme2=theme.readlines()\r
20                 print("THEME-NAME: ",theme2[0].rstrip(" \n"))\r
21                 try:\r
22                         color_class=Color(theme2[1].rstrip(" \n"))\r
23                 except:\r
24                         color_class=Color("#000000")\r
25                 color=color_class.get()\r
26                 print(len(color))\r
27                 color2_class=Color(theme2[2].rstrip("\n"))\r
28                 color2=color2_class.get()\r
29                 banner=Color(theme2[3].rstrip("\n"))\r
30                 banner1=Color(theme2[4].rstrip("\n"))\r
31                 banner=banner.get()\r
32                 banner1=banner1.get()\r
33                 banner_name2=theme2[5].rstrip("\n")\r
34                 theme.close()\r
35                 del(theme)\r
36         except ValueError:\r
37                 messagebox.showwarning("ColorError","Uno/s color no esta bien escrito")\r
38                 raise(ValueError)\r
39         except:\r
40                 try:\r
41                         os.mkdir("configs")\r
42                 except:\r
43                         pass\r
44                 try:\r
45                         os.mkdir("configs\\themes")\r
46                 except:\r
47                         pass\r
48                 theme=io.open("configs\\themes\\theme.thm","w")\r
49                 theme.write("Photoshop-theme\n#5e5c5c\n#ffffff\n#5e5c5c\n#ffffff\nSERVIDOR FTP V6.5")\r
50                 theme.close()\r
51                 theme=io.open("configs\\themes\\theme.thm","r")\r
52                 theme2=theme.readlines()\r
53                 theme.close()\r
54                 color_class=Color(theme2[1].rstrip(" \n"))\r
55                 color=color_class.get()\r
56                 color2_class=Color(theme2[2].rstrip(" \n"))\r
57                 color2=color2_class.get()\r
58                 banner=Color(theme2[3].rstrip("\n"))\r
59                 banner1=Color(theme2[4].rstrip("\n"))\r
60                 banner=banner.get()\r
61                 banner1=banner1.get()\r
62                 banner_name2=theme2[5].rstrip(" \n")\r
63                 del(theme)\r
64                 print("THEME-NAME: ",theme2[0].rstrip(" \n"))\r
65 conn()\r
66 \r
67 \r
68 \r
69 root=Tk()\r
70 root.title("Puntuanos")\r
71 root.geometry("340x220")\r
72 root.config(bg=color)\r
73 \r
74 \r
75 \r
76 user=StringVar()\r
77 user.set(getpass.getuser())\r
78 \r
79 \r
80 r1=IntVar()\r
81 r2=IntVar()\r
82 r3=IntVar()\r
83 r4=IntVar()\r
84 r5=IntVar()\r
85 \r
86 \r
87 \r
88 \r
89 l1=Label(text="Usuario",fg=color2,bg=color)\r
90 l1.place(x=30,y=20)\r
91 \r
92 l2=Label(text="Mensaje",fg=color2,bg=color)\r
93 l2.place(x=30,y=110)\r
94 \r
95 l3=Label(text="Puntuación",fg=color2,bg=color)\r
96 l3.place(x=30,y=63)\r
97 \r
98 e1=Entry(textvariable=user,width=32,fg=color2,bg=color)\r
99 e1.place(x=100,y=20)\r
100 \r
101 t1=Text(width=24,height=3,fg=color2,bg=color)\r
102 t1.insert(0.1,"La app me a encantado")\r
103 s1=Scrollbar(command=t1.yview)\r
104 s1.place(x=300,y=95)\r
105 t1.place(x=100,y=95)\r
106 t1.config(yscrollcommand=s1.set)\r
107 \r
108 punt=0\r
109 def punt1():\r
110         if r5.get()==1 or r4.get()==1 or r3 .get()==1 or r2.get()==1:\r
111                 r5.set(0)\r
112                 r4.set(0)\r
113                 r3.set(0)\r
114                 r2.set(0)\r
115                 punt="⭐❌❌❌❌"\r
116         \r
117         elif r1.get()==1:\r
118                 pass\r
119         else:\r
120                 r1.set(0)\r
121                 punt="❌❌❌❌❌"\r
122 def punt2():\r
123         if r5.get()==1 or r4.get()==1 or r3.get()==1 or r1.get()==1:\r
124                 r5.set(0)\r
125                 r4.set(0)\r
126                 r3.set(0)\r
127                 r1.set(1)\r
128                 punt="⭐⭐❌❌❌"\r
129         elif r1.get()==0:\r
130                 r1.set(1)\r
131                 r2.set(1)\r
132         else:\r
133                 r2.set(0)\r
134                 punt="⭐❌❌❌❌"\r
135 def punt3():\r
136         if r5.get()==1 or r4.get()==1 or r2.get()==1 or r1.get()==1:\r
137                 r5.set(0)\r
138                 r4.set(0)\r
139                 r2.set(1)\r
140                 r1.set(1)\r
141                 punt="⭐⭐⭐❌❌"\r
142         elif r1.get()==0:\r
143                 r1.set(1)\r
144                 r2.set(1)\r
145                 r3.set(1)\r
146         else:\r
147                 r3.set(0)\r
148                 punt="⭐⭐❌❌❌"\r
149 def punt4():\r
150         if r5.get()==1 or r3.get()==1 or r2.get()==1 or r1.get()==1:\r
151                 r5.set(0)\r
152                 r3.set(1)\r
153                 r2.set(1)\r
154                 r1.set(1)\r
155                 punt="⭐⭐⭐⭐❌"\r
156         elif r1.get()==0:\r
157                 r1.set(1)\r
158                 r2.set(1)\r
159                 r3.set(1)\r
160                 r4.set(1)\r
161         else:\r
162                 r4.set(0)\r
163                 punt="⭐⭐⭐❌❌"\r
164 def punt5():\r
165         if r5.get()==1:\r
166                 r1.set(1)\r
167                 r2.set(1)\r
168                 r3.set(1)\r
169                 r4.set(1)\r
170                 punt="⭐⭐⭐⭐⭐"\r
171         elif r1.get()==0:\r
172                 r1.set(1)\r
173                 r2.set(1)\r
174                 r3.set(1)\r
175                 r4.set(1)\r
176                 r5.set(1)\r
177         else:\r
178                 punt="⭐⭐⭐⭐❌"\r
179 \r
180 r5.set(1)\r
181 punt5()\r
182 \r
183 \r
184 \r
185 c_1=Checkbutton(variable=r1,onvalue=1,offvalue=0,command=punt1,selectcolor=color,fg=color2,bg=color,overrelief="sunken")\r
186 c_2=Checkbutton(variable=r2,onvalue=1,offvalue=0,command=punt2,selectcolor=color,fg=color2,bg=color,overrelief="sunken")\r
187 c_3=Checkbutton(variable=r3,onvalue=1,offvalue=0,command=punt3,selectcolor=color,fg=color2,bg=color,overrelief="sunken")\r
188 c_4=Checkbutton(variable=r4,onvalue=1,offvalue=0,command=punt4,selectcolor=color,fg=color2,bg=color,overrelief="sunken")\r
189 c_5=Checkbutton(variable=r5,onvalue=1,offvalue=0,command=punt5,selectcolor=color,fg=color2,bg=color,overrelief="sunken")\r
190 c_1.place(y=62,x=125)\r
191 c_2.place(y=62,x=155)\r
192 c_3.place(y=62,x=185)\r
193 c_4.place(y=62,x=215)\r
194 c_5.place(y=62,x=245)\r
195 \r
196 \r
197 \r
198 \r
199 def send():\r
200         mailServer = smtplib.SMTP('smtp.nauta.cu',25)\r
201         mailServer.ehlo()\r
202         mailServer.starttls()\r
203         mailServer.ehlo()\r
204         mailServer.login("borisdanielmm@nauta.cu",crud.decode("YmFsYmlub3RBMTIu"))\r
205         mensaje = MIMEText("\n"+"Puntuación: "+punt+"\n"+t1.get("1.0",END))\r
206         mensaje['From']="borisdanielmm@nauta.cu"\r
207         mensaje['To']="borisdanielmm@nauta.cu"\r
208         mensaje['Subject']="Calificación"\r
209         # Envio del mensaje\r
210         mailServer.sendmail("borisdanielmm@nauta.cu",\r
211         "borisdanielmm@nauta.cu",\r
212         mensaje.as_string())\r
213         mailServer.close()\r
214 \r
215 b1=Button(text="Enviar",overrelief="sunken",command=send,fg=color2,bg=color,width=20)\r
216 b1.place(x=92,y=170)\r
217 \r
218 \r
219 \r
220 \r
221 \r
222 \r
223 \r
224 \r
225 \r
226 \r
227 root.mainloop()\r