Programa de configuración del sistema
Publicado por Yandri (1 intervención) el 22/10/2019 06:52:59
Hola soy nuevo en python y tkinter estoy intentando hacer un programa de configuración del sistema ya que uso por que tengo un sistema minimalista y no tengo ninguno de estos elementos, el problema es que cuando presiono el botón de la configuración deseada, si aparcece pero cuando voy a la segunda opcion de configuración no puede ir sin haber presionado una vez más la opción que se eligío antes y tambien tengo problemas con llamar los modulos así que los modulos ahora estan incluidos en el mismo archivo.
este es el código de lo que tengo.
asi queria dejar con los módulos:
este es el del mouse
y este de usuarios
este es el código de lo que tengo.
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
import sys
import os
import subprocess as sh
PYTHON_VERSION = sys.version_info.major
if PYTHON_VERSION < 3:
try:
from Tkinter import *
except ImportError:
raise ImportError("Se requiere el modulo tkinter")
else:
try:
from tkinter import *
except ImportError:
raise ImportError("Se requiere el modulo tkinter")
class app(Tk):
def __init__(self):
super().__init__()
self.geometry('900x900')
self.menu = Frame(self)
self.menu.grid(row=0, column=0, sticky='nsew')
self.user = Frame(self)
self.pr = Frame(self)
self.mouse = Frame(self)
self.rowconfigure(0, weight=1)
for i in range(3):
self.columnconfigure(i, weight=1)
Label(self.menu, text='MENÚ').grid(row=0, column=0, sticky='nsew')
Label(self.mouse,text='MOUSE').grid(row=0, column=0, sticky='nsew')
self.i = "img/usuarios.png"
self.i = PhotoImage(file=self.i)
self.i = self.i.zoom(3)
self.i = self.i.subsample(25)
Label(self.user, image=self.i).grid(row=2, column=1)
Label(self.user, text="Cuentas de Usuarios", fg="red", font=("slender", 20)).grid(row=2, column=2)
# Agregar Usuario
self.im = "img/añadir.png"
self.im = PhotoImage(file=self.im)
self.im = self.im.zoom(2)
self.im = self.im.subsample(24)
Label(self.user, image=self.im).grid(row=5, column=0)
Label(self.user, text="Agregar Usuario", fg="red", font=("ComicRelief", 12)).grid(row=5, column=1)
# Nombre de Usuario
Label(self.user, text="Usuario:", font=("ComicRelief",10, "bold")).grid(row=7, column=1)
us = Entry(self.user).grid(row=7, column=2)
# Password
Label(self.user, text="Password:", font=("ComicRelief",10, "bold")).grid(row=9, column=1)
pas = Entry(self.user).grid(row=9, column=2)
# Grupos
Label(self.user, text="Grupos Alternos:", font=("ComicRelief",10, "bold")).grid(row=11, column=1)
gr = Entry(self.user).grid(row=11, column=2)
def new(self):
self.file = open("/home/lcp/.sistema/programas/configuracion/doc/nuevo_usuario.lcp", "w")
self.file.write("#!/bin/sh" + os.linesep)
self.file.write("doas adduser -G " + str( gr.get()) + " -w yes" + str( pas.get()))
self.file.close()
self.sh.run(["chmod", "+x", "/home/lcp/.sistema/programas/configuracion/doc/nuevo_usuario.lcp"])
#self.sh.run(["/home/lcp/.sistema/programas/configuracion/doc/nuevo_usuario.ilcp"])
self.crear = Button(self.user, text="Crear Usuario", command=new)
def ver(value):
print(value)
self.scl = Scale(self.mouse, from_=1, to=20, tickinterval=2, length=400, resolution=1, showvalue=NO, orient='horizontal', command=ver, label="Velocidad del Puntero")
self.scl.grid(row=4, column=1, sticky='nse')
def velocidad():
self.file = open("/home/lcp/.sistema/programas/configuracion/doc/mouse.lcp", "w")
self.file.write("#!/bin/sh" + os.linesep)
self.file.write("xset m " + str( self.scl.get())+ " 1")
self.file.close()
self.sh.run(["chmod", "+x", "/home/lcp/.sistema/programas/configuracion/doc/mouse.lcp"])
self.sh.run(["/home/lcp/.sistema/programas/configuracion/doc/mouse.lcp"])
self.aplicar = Button(self.mouse, text="Aplicar", command=velocidad)
self.aplicar.grid(row=5, column=1, sticky='nse')
self.status = False
# Boton Cuentas de usuario
self.users = Button(self.menu,text="Cuentas de Usuario",width=20,command=self.usuarios)
self.users.grid(row=2, column=0, sticky='nse')
# Boton Funciones del mouse
self.raton = Button(self.menu, text="Mouse",width=20,command=self.moused)
self.raton.grid(row=3, column=0, sticky='nse')
def usuarios(self):
if self.status:
self.user.grid_forget()
self.status = False
self.users.config(text="Cuentas de Usuario")
else:
self.status = True
self.user.grid(row=0, column=1,sticky='nsew')
self.users.config(text="Cuentas de Usuario")
def moused(self):
if self.status:
self.mouse.grid_forget()
self.status = False
self.moused.config(text="Mouse")
else:
self.status = True
self.mouse.grid(row=0, column=1,sticky='nsew')
self.moused.config(text="Mouse")
app().mainloop()
asi queria dejar con los módulos:
este es el del mouse
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
def raton():
def ver(value):
print(value)
scl = Scale(
from_=1,
to=20,
tickinterval=2,
length=400,
resolution=1,
showvalue=NO,
orient='horizontal',
command=ver,
label="Velocidad del Puntero"
)
scl.pack(expand=YES, fill=Y)
def velocidad():
file = open("/home/lcp/.sistema/programas/mouse.sh", "w")
file.write("#!/bin/sh" + os.linesep)
file.write("xset m " + str( scl.get())+ " 1")
file.close()
sh.run(["chmod", "+x", "/home/lcp/.sistema/programas/mouse.sh"])
sh.run(["/home/lcp/.sistema/programas/mouse.sh"])
aplicar = Button(
text="Aplicar",
command=velocidad
)
aplicar.pack()
y este de usuarios
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
def titulo(self):
self.i = "img/usuarios.png"
self.i = PhotoImage(file=i)
self.i = im.zoom(3)
self.i = im.subsample(25)
Label(conf, image=im).place(x=74,y=30)
Label(conf, text="Cuentas de Usuarios", fg="red", font=("slender", 20)).place(x=150,y=30)
# Agregar Usuario
def nuevo(self):
self.i = "img/añadir.png"
self.i = PhotoImage(file=self.i)
self.i = self.i.zoom(2)
self.i= self.i.subsample(24)
Label(self, image=self.i).place(x=19,y=110)
Label(self, text="Agregar Usuario", fg="red", font=("ComicRelief", 12)).place(x=70,y=115)
# Nombre de Usuario
Label(self, text="Usuario:", font=("ComicRelief",10, "bold")).place(x=20,y=150)
us = Entry(self).place(x=184,y=155)
# Password
Label(conf, text="Password:", font=("ComicRelief",10, "bold")).place(x=20,y=180)
pas = Entry(self).place(x=184,y=185)
# Grupos
Label(self, text="Grupos Alternos:", font=("ComicRelief",10, "bold")).place(x=20,y=210)
gr = Entry(conf).place(x=184,y=215)
def new(self):
self.file = open("/home/lcp/.sistema/programas/configuracion/doc/nuevo_usuario.lcp", "w")
self.file.write("#!/bin/sh" + os.linesep)
self.file.write("doas adduser -G " + str( gr.get()) + " -w yes" + str( pas.get()))
self.file.close()
self.sh.run(["chmod", "+x", "/home/lcp/.sistema/programas/configuracion/doc/nuevo_usuario.lcp"])
#self.sh.run(["/home/lcp/.sistema/programas/configuracion/doc/nuevo_usuario.ilcp"])
self.crear = Button(self.user, text="Crear Usuario", command=new)
Valora esta pregunta


0