Advertisement
son_link

Eejmplo de texto en scroll

Sep 20th, 2011
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. # Importamos las librerias necesarias
  5. import gtk, gobject, thread
  6.  
  7. from time import sleep
  8.  
  9. gobject.threads_init()
  10.  
  11. def scroll():
  12.     # Nota: el texto debe de tener espacios al principio y/o al final para que no se mezcle el texto que va saliendo
  13.     texto = '  Soy un texto que se mueve hacia la derecha'
  14.    
  15.     t = len(texto)
  16.     while True:
  17.         texto = texto[1:t] + texto[0:1]
  18.         label.set_text(texto)
  19.         # Pausamos el buvcle durante medio segundo
  20.         sleep(0.5)
  21.        
  22. def close(w):
  23.     exit()
  24.  
  25. mainwin = gtk.Window()
  26. mainwin.set_position(gtk.WIN_POS_CENTER_ALWAYS)
  27.        
  28. box = gtk.VBox(False, 0)
  29. box.set_border_width(0)
  30. mainwin.add(box)
  31. mainwin.connect('destroy', close)
  32.        
  33. label = gtk.Label()
  34. label.set_max_width_chars(15)
  35. label.set_alignment(0, 0)
  36. box.pack_start(label, False, False, 0)
  37.  
  38. thread.start_new_thread(scroll, ())
  39. mainwin.show_all()
  40. gtk.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement