Я новый Python, и я пытаюсь создать окно конфигурации системы, но у меня проблема с кнопками, когда я нажимаю кнопку пользователя, появляется конфигурация пользователя, я нажимаю кнопку мыши, появляется конфигурация мыши,но если я нажму еще раз, кнопка пользователя больше не будет отображать пользовательские настройки. Пока у меня есть это ...
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.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)
self.users = Entry(self.user)
self.users.grid(row=7, column=2)
# Password
Label(self.user, text="Password:", font=("ComicRelief",10, "bold")).grid(row=9, column=1)
self.passwd = Entry(self.user, show="*")
self.passwd.grid(row=9, column=2)
# Grupos
Label(self.user, text="Grupos Alternos:", font=("ComicRelief",10, "bold")).grid(row=11, column=1)
self.grupo = Entry(self.user)
self.grupo.grid(row=11, column=2)
def new():
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 -n " + str( self.users.get()))
self.file.close()
sh.run(["chmod", "+x", "/home/lcp/.sistema/programas/configuracion/doc/nuevo_usuario.lcp"])
#self.users.sh.run(["/home/lcp/.sistema/programas/configuracion/doc/nuevo_usuario.ilcp"])
self.crear = Button(self.user, text="Crear Usuario", command=new)
self.crear.grid(row=15, column=2)
self.scl = Scale(self.mouse, from_=1, to=20, tickinterval=2, length=400, resolution=1, showvalue=NO, orient='horizontal', label="Pointer Speed")
self.scl.grid(row=4, column=1, sticky='nse')
def velocity():
self.file = open("/home/lcp/.sistem/widgets/configuration/doc/mouse.lcp", "w")
self.file.write("#!/bin/sh" + os.linesep)
self.file.write("xset m " + str( self.scl.get())+ " 1")
self.file.close()
sh.run(["chmod", "+x", "/home/lcp/.sistem/widgets/configuration/doc/mouse.lcp"])
sh.run(["/home/lcp/.sistem/widgets/configuration/doc/mouse.lcp"])
self.apply = Button(self.mouse, text="Apply", command=velocity)
self.apply.grid(row=5, column=1, sticky='nse')
# Button User Account
self.usr = Button(self.menu,text="User Account",width=20,command=self.users)
self.usr.grid(row=2, column=0, sticky='nse')
# Button Mouse
self.raton = Button(self.menu, text="Mouse",width=20,command=self.moused)
self.raton.grid(row=3, column=0, sticky='nse')
#self.status = False
#
def users(self):
#if self.status:
# self.user.grid_forget()
# self.user.status = False
#else:
# self.status = True
self.user.grid(row=0, column=1,sticky='nsew')
# Mouse Action
def moused(self):
#if self.status:
# self.mouse.grid_forget()
# self.status = False
#else:
# self.status = True
self.mouse.grid(row=0, column=1,sticky='nsew')
app().mainloop()