Buenas tardes,
Tengo una duda, alguien sabe como podría hacer que se ejecute una función un
tiempo x después de entrar en un cuadro?
Exactamente lo que quiero es que me imprima el dia de la semana cuando lleve 5
segundos dentro del cuadro.
#!/usr/bin/env python
# -*- coding: cp1252 -*-
import os
import wx
import time
class Aplicacion(wx.App):
def OnInit(self):
self.frame = Ventana(None, -1, title = "Post It")
self.SetTopWindow(self.frame)
self.frame.Show()
return True
"""Main Frame"""
class Ventana(wx.Frame):
"""Constructor"""
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size = (900, 275))
self.panel = Panel(self)
class Panel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
font = wx.Font(15, family = wx.FONTFAMILY_DEFAULT, style =
wx.FONTSTYLE_NORMAL, weight = wx.FONTWEIGHT_BOLD,
encoding = wx.FONTENCODING_CP1252)
self.sizer = wx.BoxSizer(wx.HORIZONTAL)
self.gbsizer = wx.GridBagSizer(2, 2)
self.sizer.Add(self.gbsizer, 1, wx.ALL | wx.EXPAND, border = 6)
self.SetSizer(self.sizer)
self.casa = False
sem = {0 : ("Lunes", 169), 1 : ("Martes", 266), 2 : ("Miercoles" , 359),
3 : ("Jueves", 478), 4 : ("Viernes", 578), 5: ("Sabado", 686),
6 : ("Domingo", 783)}
for num in range(0,7):
self.cont = sem[num]
self.dia = self.cont[0]
y = num + 1
self.collab = wx.StaticText(self, -1, label = self.dia, size =
wx.Size
(103, 23), style = wx.ALIGN_CENTER)
self.collab.SetFont(font)
if y < 6:
self.collab.SetBackgroundColour(wx.Colour(255, 255, 255))
else:
self.collab.SetBackgroundColour(wx.Colour(255, 0, 0))
self.gbsizer.Add(self.collab, pos = wx.GBPosition(0, y), flag =
wx.ALIGN_CENTER_VERTICAL, border = 6)
self.collab.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter)
self.collab.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave)
self.Bind(wx.EVT_PAINT,self.OnPaint)
def OnEnter(self, event):
#Time0 = int(time.clock())
#Time2 = 0
#while Time2 < 5:
#Time1 = int(time.clock())
#Time2 = Time1 - Time0
#if Time2 = 5:
#print(self.dia)
def OnLeave(self, event):
Time3 = int(time.clock())
def OnPaint(self, event):
self.dc = wx.PaintDC(self)
for colu in range (7):
rect_x = 122 + (105 * (colu-1))
width = 105
self.dc.DrawRectangle(rect_x, 5, width, 25)
event.Skip()
if __name__ == "__main__":
app = Aplicacion(False)
app.MainLoop()
_______________________________________________
Python-es mailing list
Python-es@python.org
http://mail.python.org/mailman/listinfo/python-es
FAQ: http://python-es-faq.wikidot.com/