Bueno estoy haciendo un programa que hace una función especifica.
Quiero que inicie un proceso, pero que tambien lo detenga con el mismo boton, pero cuando entra al ciclo while corre el proceso, pero se cicla todo el programa.
este es mi codigo:
# -*- coding: utf-8 -*-
import wx
import wx.xrc
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( 50,80 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
bSizer1 = wx.BoxSizer( wx.VERTICAL )
self.m_button1 = wx.Button( self, wx.ID_ANY, u"MyButton", wx.DefaultPosition, wx.DefaultSize, 0 )
bSizer1.Add( self.m_button1, 0, wx.ALL, 5 )
self.SetSizer( bSizer1 )
self.Layout()
self.Centre( wx.BOTH )
# Connect Events
self.m_button1.Bind( wx.EVT_BUTTON, self.m_button1OnButtonClick )
# Virtual event handlers, overide them in your derived class
def m_button1OnButtonClick( self, event ):
if self.m_button1.GetLabel() == "MyButton":
self.m_button1.SetLabel("OTRO")
while self.m_button1.GetLabel() == "OTRO":
print "hola"
else:
self.m_button1.SetLabel("MyButton")
Window = wx.App(False)
Principal = MyFrame1(None)
Principal.Show(True)
Window.MainLoop()
Saludos!!!