RECOMENDAR NUESTROS PROGRAMAS

Indica tus datos y los datos de la persona que recibira la recomendación.

Titulo:  minicalculadora   ver. 0
Autor:  Rolando Jose Torres Sanchez ([email protected])
  Apartado:  Matemóticos (Linux)
TCLTK permite hacer programas para casi cualquier Sistema Operativo sin cambiar el codigo, y minimizando el codigo, en este ejemplo presento una calculadora escrita en 20 lineas de codigo, que se puede ejecutar desde python con la libreria tkinter que es compatible tanto en Windows Linux o Mac, como tambien en Android, si se instala python 3 y la libreria tkinter.

codigo en tcl:
catch {destroy .c}
toplevel .c -bg #AAA
wm geometry .c "350x350+0+0"
wm withdraw .
set c 0
set col "#AAA"
place [entry .c.ev -textvar evl -width 20] -x 50 -y 50
foreach {t tc} "0 n 1 n 2 n 3 n 4 n 5 n 6 n 7 n 8 n 9 n . n pi o + o - o x o / o % o ^ o C r M r = r" {
if {$tc=="n"} {set col "#FAA"}
if {$tc=="o"} {set col "#FFA"}
if {$tc=="r"} {set col "#AFA"}
place [button .c.b$c -text $t -bg $col -command "append evl [set t]"] -x [expr 50+($c/3)*30] -y [expr (($c%3)*50)+90]
incr c
}
.c.b11 config -command {set evl [expr 4*atan(1)]}
.c.b18 config -command {set evl ""}
.c.b20 config -command {set evl [expr [string map "{M} {\ } {\/} {*1.0/} {x} {*} {^} {**}" $evl]]}

codigo en python:
import tkinter as tk
w=tk.Tk()
code='''
catch {destroy .c}
toplevel .c -bg #AAA
wm geometry .c "350x350+0+0"
wm withdraw .
set c 0
set col "#AAA"
place [entry .c.ev -textvar evl -width 20] -x 50 -y 50
foreach {t tc} "0 n 1 n 2 n 3 n 4 n 5 n 6 n 7 n 8 n 9 n . n pi o + o - o x o / o % o ^ o C r M r = r" {
if {$tc=="n"} {set col "#FAA"}
if {$tc=="o"} {set col "#FFA"}
if {$tc=="r"} {set col "#AFA"}
place [button .c.b$c -text $t -bg $col -command "append evl [set t]"] -x [expr 50+($c/3)*30] -y [expr (($c%3)*50)+90]
incr c
}
.c.b11 config -command {set evl [expr 4*atan(1)]}
.c.b18 config -command {set evl ""}
.c.b20 config -command {set evl [expr [string map "{M} {\ } {\/} {*1.0/} {x} {*} {^} {**}" $evl]]}
'''
w.eval(code)
w.mainloop()
 idioma: Español - Votar [0.00 / 0 votos] - GNU - 1 Kb
 Comentarios: 0 Comentar

Tu Nombre
Tu dirección de Correo
Nombre del destinatario
Dirección de Correo del destinatario
Comentarios