Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Mensajes - xiquipython

#1
Cita de: Guarrino en 11 Febrero 2019, 12:19 PM
Código (python) [Seleccionar]
from tkinter import Tk,Label,Button,Frame

proceso=0

def iniciar(contador=0):
    global proceso

   
    time['text'] = contador

   
    proceso=time.after(1000, iniciar, (contador+1))

def parar():
    global proceso
    time.after_cancel(proceso)

root = Tk()
root.title('Cronometro')

time = Label(root, fg='red', width=20, font=("","18"))
time.pack()


frame=Frame(root)
btnIniciar=Button(frame, fg='blue', text='Iniciar', command=iniciar)
btnIniciar.grid(row=1, column=1)
btnParar=Button(frame, fg='blue', text='Parar', command=parar)
btnParar.grid(row=1, column=2)
frame.pack()

root.mainloop()


A mi este código me funciona. Debería ser igual. Escribe todo tu código de esta manera, donde dice aquí y quita los espacios.

[  code=python  ]  Aqui  [  /code ]


Lo probe quitando los espacios i me saldo error en la linia 3, me estado peleando un rato con la composicon i no hay manera
#2
Funciona lo que me dices, pero  ahora me sale error mas abajo debe ser otra cosa.

Traceback (most recent call last):
 File "C:\Users\xiqui\Desktop\python\xiqui2\cronometro.py", line 40, in <module>
   btnParar=Button(frame, fg='blue', text='Parar', command=parar)
NameError: name 'parar' is not defined





https://likegeeks.com/es/ejemplos-de-la-gui-de-python/
#3
Scripting / Re: Mi primer ejercicio con Tkinter
9 Febrero 2019, 15:45 PM
Garcias, entre tu explicaicon i lo que e ido provando e consido fijarlo a mis necessidades


https://likegeeks.com/es/ejemplos-de-la-gui-de-python/


Estoy aprendiendo cada mes esto de Tkinter aqui os ajunto mi nueva creacion:

https://jordixicarspython.wordpress.com/2019/02/09/ejercicio-6-pestanas-con-los-meses/


MOD: No hacer triple post. Usa el botón modificar.
#4
Scripting / Mi tercer progrma en Tkinter, error!
9 Febrero 2019, 12:28 PM
https://www.lawebdelprogramador.com/codigo/Python/4752-Simple-cronometro-con-TK.html

from tkinter import Tk,Label,Button,Frame

proceso=0

def iniciar(contador=0):

   global proceso

   time['text'] = contador


   proceso=time.after(1000, iniciar, (contador+1))



def parar():

   global proceso
       
       time.after_cancel(proceso)


root = Tk()

root.title('Cronometro')


time = Label(root, fg='red', width=20, font=("","18"))

time.pack()


frame=Frame(root)

btnIniciar=Button(frame, fg='blue', text='Iniciar', command=iniciar)

btnIniciar.grid(row=1, column=1)

btnParar=Button(frame, fg='blue', text='Parar', command=parar)

btnParar.grid(row=1, column=2)

frame.pack()


root.mainloop()
#5
Scripting / Mi primer ejercicio con Tkinter
8 Febrero 2019, 20:03 PM
Emepze con Tkinter i aproveche un script de dar informacion i con un boton de salida, pero mi texto es demasiado grande para el tamaño i no consigo ver como hacer mas grande la ventana sin interferir a los botones. Alguien sabria como verlo mas grande.


https://jordixicarspython.wordpress.com/2019/02/08/prueba-con-tkinter/
#6
Gracias, voy a probar de instalar Tkinter i realizar el ejercicio

#7
Quiero entar los datos del erjercio 1 i que me rederrecione al ejercico 2 una vez los datos sean correctos. Soy inesperto en pyhton asi que si alguein sabe de algun comando que me contese al mensaje

https://jordixicarspython.files.wordpress.com/2019/02/programilla-1.png?w=680

https://jordixicarspython.files.wordpress.com/2019/02/mesmenu.png
#9
Esto es un programa donde podemos ver el numero de mes.

def pedirNumeroEntero():

   correcto=False
   num=0
   while(not correcto):
       try:
           num = int(input("Introduce el numero de mes: "))
           correcto=True
       except ValueError:
           print('Error, introduce un numero entero')
   
   return num

salir = False
opcion = 0

while not salir:

   print ("\n1. Enero")
   print ("2. Febrero")
   print ("3. Marzo")
   print ("4. Abril")
   print ("5. Mayo")
   print ("6. Junio")
   print ("7. Julio")
   print ("8. Agosto")
   print ("9. Septiemnbre")
   print ("10. Octubre")
   print ("11. Noviembre")
   print ("12. Diciembre")
   print ("13. Salir")
   print ("\nElige una opcion")

   opcion = pedirNumeroEntero()

   if opcion == 1:
       print ("\n*********Enero*********")
   elif opcion == 2:
       print ("\n*********Febrero*********")
   elif opcion == 3:
       print("\n*********Marzo*********")
   elif opcion == 4:
       print ("\n*********Abril*********")
   elif opcion == 5:
       print ("\n*********Mayo*********")
   elif opcion == 6:
       print("\n*********Junio*********")
   elif opcion == 7:
       print ("\n*********Julio*********")
   elif opcion == 8:
       print("\n*********Agosto*********")
   elif opcion == 9:  
           print ("\n*********Septiembre*********")
   elif opcion == 10:
       print("\n*********Ocutbre*********")
   elif opcion == 11:  
           print ("\n*********Noviembre*********")
   elif opcion == 12:
           print("\n*********Diciembre*********")
   elif opcion == 13:
       salir = True
   else:
       print ("Introduce un numero entre 1 y 12")

print ("Fin")