Respuesta a: problemas con la aplicación Menu

#11857

Marcelo Zambon
Participante

La aplicación por si alguien me puede echar una mano es la siguiente

 
<div style=»color: #d4d4d4; background-color: #1e1e1e; font-family: Consolas, ‘Courier New’, monospace; font-size: 14px; line-height: 19px; white-space: pre;»>
<div><span style=»color: #c586c0;»>from</span> tkinter <span style=»color: #c586c0;»>import</span> *</div>
<div><span style=»color: #c586c0;»>from</span> tkinter <span style=»color: #c586c0;»>import</span> ttk</div>
<div><span style=»color: #c586c0;»>from</span> tkinter.ttk <span style=»color: #c586c0;»>import</span> Combobox</div>
<div><span style=»color: #c586c0;»>import</span> mysql.connector</div>
<div><span style=»color: #c586c0;»>import</span> cryptography</div>
<div><span style=»color: #6a9955;»>###############################################################</span></div>
<div><span style=»color: #6a9955;»>#####                                                     #####</span></div>
<div><span style=»color: #6a9955;»>#####  Pop Up para conectarse a la base de datos          #####</span></div>
<div><span style=»color: #6a9955;»>#####                                                     #####</span></div>
<div><span style=»color: #6a9955;»>###############################################################</span></div>
<div><span style=»color: #569cd6;»>class</span> <span style=»color: #4ec9b0;»>PopupUserPass</span>(<span style=»color: #4ec9b0;»>object</span>):</div>
<div>    <span style=»color: #569cd6;»>def</span> <span style=»color: #dcdcaa;»>__init__</span>(<span style=»color: #9cdcfe;»>self</span>,<span style=»color: #9cdcfe;»>vent</span>):</div>
<div>        top=<span style=»color: #569cd6;»>self</span>.top=Toplevel(vent)</div>
<div>        top.title(<span style=»color: #ce9178;»>»Conexión a la base de datos»</span>)</div>
<div>        top.iconbitmap(<span style=»color: #ce9178;»>»silosoft.ico»</span>)</div>
<div>        top.geometry(<span style=»color: #ce9178;»>»250×100″</span>)</div>
<div>        top.grid_columnconfigure(<span style=»color: #b5cea8;»>0</span>, <span style=»color: #9cdcfe;»>weight</span> = <span style=»color: #b5cea8;»>1</span>)</div>
<div>        top.grid_columnconfigure(<span style=»color: #b5cea8;»>5</span>, <span style=»color: #9cdcfe;»>weight</span> = <span style=»color: #b5cea8;»>1</span>)</div>
<div>        <span style=»color: #569cd6;»>self</span>.label1=Label(top,<span style=»color: #9cdcfe;»>text</span>=<span style=»color: #ce9178;»>»Usuario»</span>, <span style=»color: #9cdcfe;»>anchor</span> = <span style=»color: #ce9178;»>’w'</span>)</div>
<div>        <span style=»color: #569cd6;»>self</span>.label1.grid(<span style=»color: #9cdcfe;»>row</span> = <span style=»color: #b5cea8;»>1</span>, <span style=»color: #9cdcfe;»>column</span> = <span style=»color: #b5cea8;»>1</span>, <span style=»color: #9cdcfe;»>padx</span> = <span style=»color: #b5cea8;»>5</span>, <span style=»color: #9cdcfe;»>pady</span> = <span style=»color: #b5cea8;»>5</span>, <span style=»color: #9cdcfe;»>sticky</span> = W + E)</div>
<div>        <span style=»color: #569cd6;»>self</span>.user=Entry(top)</div>
<div>        <span style=»color: #569cd6;»>self</span>.user.grid(<span style=»color: #9cdcfe;»>row</span> = <span style=»color: #b5cea8;»>1</span>, <span style=»color: #9cdcfe;»>column</span> = <span style=»color: #b5cea8;»>2</span>, <span style=»color: #9cdcfe;»>padx</span> = <span style=»color: #b5cea8;»>5</span>, <span style=»color: #9cdcfe;»>pady</span> = <span style=»color: #b5cea8;»>5</span>,<span style=»color: #9cdcfe;»>sticky</span> = W + E)</div>
<div>        <span style=»color: #569cd6;»>self</span>.user.focus()</div>
<div>        <span style=»color: #569cd6;»>self</span>.label2=Label(top, <span style=»color: #9cdcfe;»>text</span> = <span style=»color: #ce9178;»>» Contraseña»</span>, <span style=»color: #9cdcfe;»>anchor</span> = <span style=»color: #ce9178;»>’w'</span>)</div>
<div>        <span style=»color: #569cd6;»>self</span>.label2.grid(<span style=»color: #9cdcfe;»>row</span> = <span style=»color: #b5cea8;»>2</span>, <span style=»color: #9cdcfe;»>column</span> = <span style=»color: #b5cea8;»>1</span>, <span style=»color: #9cdcfe;»>padx</span> = <span style=»color: #b5cea8;»>5</span>, <span style=»color: #9cdcfe;»>pady</span> = <span style=»color: #b5cea8;»>5</span>,<span style=»color: #9cdcfe;»>sticky</span> = W + E)</div>
<div>        <span style=»color: #569cd6;»>self</span>.clave = Entry(top)</div>
<div>        <span style=»color: #569cd6;»>self</span>.clave.grid(<span style=»color: #9cdcfe;»>row</span> = <span style=»color: #b5cea8;»>2</span>, <span style=»color: #9cdcfe;»>column</span> = <span style=»color: #b5cea8;»>2</span>, <span style=»color: #9cdcfe;»>padx</span> = <span style=»color: #b5cea8;»>5</span>, <span style=»color: #9cdcfe;»>pady</span> = <span style=»color: #b5cea8;»>5</span>,<span style=»color: #9cdcfe;»>sticky</span> = W + E)</div>
<div>        <span style=»color: #569cd6;»>self</span>.clave.config(<span style=»color: #9cdcfe;»>show</span>=<span style=»color: #ce9178;»>’*'</span>)</div>
<div>        <span style=»color: #569cd6;»>self</span>.OkButton=Button(top,<span style=»color: #9cdcfe;»>text</span>=<span style=»color: #ce9178;»>’Ok'</span>,<span style=»color: #9cdcfe;»>command</span>= <span style=»color: #569cd6;»>self</span>.top.destroy, <span style=»color: #9cdcfe;»>borderwidth</span> = <span style=»color: #b5cea8;»>4</span>,</div>
<div>         <span style=»color: #9cdcfe;»>anchor</span> = CENTER, <span style=»color: #9cdcfe;»>relief</span> = RAISED)</div>
<div>        <span style=»color: #569cd6;»>self</span>.OkButton.grid(<span style=»color: #9cdcfe;»>row</span> = <span style=»color: #b5cea8;»>3</span>, <span style=»color: #9cdcfe;»>column</span> = <span style=»color: #b5cea8;»>1</span>, <span style=»color: #9cdcfe;»>columnspan</span> = <span style=»color: #b5cea8;»>2</span>, <span style=»color: #9cdcfe;»>padx</span> = <span style=»color: #b5cea8;»>5</span>, <span style=»color: #9cdcfe;»>pady</span> = <span style=»color: #b5cea8;»>5</span>,<span style=»color: #9cdcfe;»>sticky</span> = W + E)</div>
<div></div>
<div></div>
<div><span style=»color: #6a9955;»>###############################################################</span></div>
<div><span style=»color: #6a9955;»>#####                                                     #####</span></div>
<div><span style=»color: #6a9955;»>##### transaccion es la rutina por la cual se genera      ##### </span></div>
<div><span style=»color: #6a9955;»>##### la interfaz gráfica inicial                         #####</span></div>
<div><span style=»color: #6a9955;»>#####                                                     #####</span></div>
<div><span style=»color: #6a9955;»>###############################################################</span></div>
<div><span style=»color: #569cd6;»>class</span> <span style=»color: #4ec9b0;»>transaccion</span> ():</div>
<div>    <span style=»color: #6a9955;»>#definicion de la base de datos sobre la que se va a trabajar</span></div>
<div></div>
<div></div>
<div>    <span style=»color: #569cd6;»>def</span> <span style=»color: #dcdcaa;»>__init__</span> (<span style=»color: #9cdcfe;»>self</span>, <span style=»color: #9cdcfe;»>ventana</span>):</div>
<div>        <span style=»color: #569cd6;»>self</span>.vent = ventana</div>
<div>        <span style=»color: #569cd6;»>self</span>.vent.title(<span style=»color: #ce9178;»>»AGRICOLA EL PERDIDO – MOVIMIENTO DE GRANOS»</span>)</div>
<div>        <span style=»color: #569cd6;»>self</span>.vent.iconbitmap ( <span style=»color: #ce9178;»>»silosoft.ico»</span>)</div>
<div>        <span style=»color: #569cd6;»>self</span>.vent.config(<span style=»color: #9cdcfe;»>bg</span>  = <span style=»color: #ce9178;»>»LightCyan2″</span>)</div>
<div>        <span style=»color: #569cd6;»>self</span>.vent.geometry(<span style=»color: #ce9178;»>»900×600″</span>)</div>
<div>        <span style=»color: #569cd6;»>self</span>.vent.borderwidth = <span style=»color: #b5cea8;»>4</span></div>
<div>        <span style=»color: #569cd6;»>self</span>.BarraMenu = Menu(<span style=»color: #569cd6;»>self</span>.vent)</div>
<div>        <span style=»color: #569cd6;»>self</span>.vent.config(<span style=»color: #9cdcfe;»>menu</span> = <span style=»color: #569cd6;»>self</span>.BarraMenu)</div>
<div></div>
<div>        <span style=»color: #569cd6;»>self</span>.MenuSilos = Menu(<span style=»color: #569cd6;»>self</span>.BarraMenu, <span style=»color: #9cdcfe;»>tearoff</span> = <span style=»color: #b5cea8;»>0</span>)</div>
<div></div>
<div>        <span style=»color: #569cd6;»>self</span>.MenuArchivo = Menu(<span style=»color: #569cd6;»>self</span>.BarraMenu, <span style=»color: #9cdcfe;»>tearoff</span> = <span style=»color: #b5cea8;»>0</span>)</div>
<div>        <span style=»color: #569cd6;»>self</span>.MenuArchivo.add_command(<span style=»color: #9cdcfe;»>label</span> = <span style=»color: #ce9178;»>»Login»</span>,<span style=»color: #9cdcfe;»>command</span> = <span style=»color: #569cd6;»>self</span>.PopupLogin())</div>
<div>        <span style=»color: #569cd6;»>self</span>.MenuArchivo.add_command(<span style=»color: #9cdcfe;»>label</span> = <span style=»color: #ce9178;»>»Salir»</span>) <span style=»color: #6a9955;»>#, command = self.Destroy)</span></div>
<div></div>
<div>        <span style=»color: #569cd6;»>self</span>.MenuSilos = Menu(<span style=»color: #569cd6;»>self</span>.BarraMenu, <span style=»color: #9cdcfe;»>tearoff</span> = <span style=»color: #b5cea8;»>0</span>)</div>
<div></div>
<div>        <span style=»color: #569cd6;»>self</span>.MenuReporte = Menu(<span style=»color: #569cd6;»>self</span>.BarraMenu, <span style=»color: #9cdcfe;»>tearoff</span> = <span style=»color: #b5cea8;»>0</span>)</div>
<div>        <span style=»color: #569cd6;»>self</span>.MenuAdmin = Menu(<span style=»color: #569cd6;»>self</span>.BarraMenu, <span style=»color: #9cdcfe;»>tearoff</span> = <span style=»color: #b5cea8;»>0</span>)</div>
<div>        <span style=»color: #569cd6;»>self</span>.BarraMenu.add_cascade(<span style=»color: #9cdcfe;»>label</span> = <span style=»color: #ce9178;»>’Archivo'</span>, <span style=»color: #9cdcfe;»>menu</span> = <span style=»color: #569cd6;»>self</span>.MenuArchivo)</div>
<div>        <span style=»color: #569cd6;»>self</span>.BarraMenu.add_cascade(<span style=»color: #9cdcfe;»>label</span> = <span style=»color: #ce9178;»>’Silos'</span>, <span style=»color: #9cdcfe;»>menu</span> = <span style=»color: #569cd6;»>self</span>.MenuSilos)</div>
<div>        <span style=»color: #569cd6;»>self</span>.BarraMenu.add_cascade(<span style=»color: #9cdcfe;»>label</span> = <span style=»color: #ce9178;»>’Reportes'</span>, <span style=»color: #9cdcfe;»>menu</span> = <span style=»color: #569cd6;»>self</span>.MenuReporte)</div>
<div>        <span style=»color: #569cd6;»>self</span>.BarraMenu.add_cascade(<span style=»color: #9cdcfe;»>label</span> = <span style=»color: #ce9178;»>’Admin'</span>, <span style=»color: #9cdcfe;»>menu</span> = <span style=»color: #569cd6;»>self</span>.MenuAdmin)</div>
<div>    <span style=»color: #569cd6;»>def</span> <span style=»color: #dcdcaa;»>PopupLogin</span>(<span style=»color: #9cdcfe;»>self</span>):</div>
<div>        <span style=»color: #569cd6;»>self</span>.w=PopupUserPass(<span style=»color: #569cd6;»>self</span>.vent)</div>
<div></div>
<div>        <span style=»color: #569cd6;»>self</span>.vent.wait_window(<span style=»color: #569cd6;»>self</span>.w.top)</div>
<div></div>
<div></div>
<div></div>
<div></div>
<div><span style=»color: #c586c0;»>if</span> <span style=»color: #9cdcfe;»>__name__</span> == <span style=»color: #ce9178;»>’__main__'</span>:</div>
<div>    ventana = Tk()</div>
<div>    aplicacion = transaccion(ventana)</div>
<div>    ventana.mainloop()</div>
</div>