Interrupcion en interfaz grafica
Publicado por Jorge (1 intervención) el 12/07/2017 19:18:58
Buen dia, me encuentro realizando un programa donde necesito detener (en caso de ser necesario) una accion que es un ciclo, hice un pequeño programa simulando lo mismo para despues adaptarlo pero no logro interrumpir el ciclo, ya que al precionar detener el programa se bloquea, de hecho segun parece una vez inicia el ciclo el los botoner parecen no estar disponibles. ¿Existe alguna funcion para interrupciones? les dejo el codigo, espero me puedan ayudar, gracias.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# -*- coding: utf-8 -*-
###########################################################################
## Python code generated with wxFormBuilder (version Jun 17 2015)
## http://www.wxformbuilder.org/
##
## PLEASE DO "NOT" EDIT THIS FILE!
###########################################################################
import wx
import wx.xrc
import time
###########################################################################
## Class MyFrame1
###########################################################################
num=1
class MyFrame1 ( wx.Frame ):
def __init__( self, parent ):
wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 500,300 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
bSizer1 = wx.BoxSizer( wx.VERTICAL )
self.static = wx.StaticText( self, wx.ID_ANY, u"MyLabel", wx.DefaultPosition, wx.DefaultSize, 0 )
self.static.Wrap( -1 )
self.static.SetForegroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNTEXT ) )
self.static.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_HIGHLIGHTTEXT ) )
bSizer1.Add( self.static, 0, wx.ALL, 5 )
self.ini = wx.Button( self, wx.ID_ANY, u"iniciar", wx.DefaultPosition, wx.DefaultSize, 0 )
bSizer1.Add( self.ini, 0, wx.ALL, 5 )
self.det = wx.Button( self, wx.ID_ANY, u"detener", wx.DefaultPosition, wx.DefaultSize, 0 )
bSizer1.Add( self.det, 0, wx.ALL, 5 )
self.SetSizer( bSizer1 )
self.Layout()
self.Centre( wx.BOTH )
# Connect Events
self.ini.Bind( wx.EVT_BUTTON, self.start )
self.det.Bind( wx.EVT_BUTTON, self.stop )
def __del__( self ):
pass
# Virtual event handlers, overide them in your derived class
def start( self, event ):
global num
num=1
for i in range (100):
if num==1:
self.static.SetLabel("Numero %fmm" %i)
time.sleep(2)
else:
i=100
def stop( self, event ):
global num
num=0
app = wx.App()
fr = MyFrame1(None)
fr.Show()
app.MainLoop()
Valora esta pregunta


0