Hello bs,
try to put a Refresh() call after setting the value, something like:
def __updateText(self):
textList=['a','b','c','d','e']
dim=len(textList)-1
for i in range(dim+1):
self.txtDisplay.SetValue(textList[i])
self.txtDisplay.Refresh()
sleep(2)
I would prefer using wx:MilliSleep(2000) instead of sleep(2), but that
doesn't matter...
HTH.
Andrea.
···
_______________________________________________
Andrea Gavana
Reservoir Engineer
MOGI ? Reservoir Characterization and Modeling Dept.
ENI S.p.A. ? Exploration & Production Division
Via Emilia, 1 ? 20097 San Donato Milanese (MI) ? Italy
Phone: +39 02 520 62972
Fax: +39 02 520 61824
E-mail: andrea.gavana@agip.it
Restyled Internet Site: http://xoomer.virgilio.it/infinity77/
____________________________________________________
Eni S.p.A.
Sede legale in Roma,
Piazzale Enrico Mattei 1, 00144 Roma
Tel. centralino: +39 06598.21
www.eni.it
Capitale sociale 4.002.934.326 i.v.
Registro Imprese di Roma,
Codice Fiscale 00484960588
Part. IVA 00905811006
R.E.A. Roma n. 756453
Hi Andrea,
this, I have also thought, but it didn't work.
So I remember of wx.Yield and this lead to sucess.
On WinXp at least: if you remove comment Refresh out and
comment wx.Yield, it doesn't work.
With Ok Button, you launch the process.
(wxPy is really strange sometimes...)
import wx
from time import *
class MyDialog(wx.Dialog):
def __init__(self,parent):
wx.Dialog.__init__(self,parent,-1)
self.text1 = wx.TextCtrl(self, pos = (20, 20))
self.text2 = wx.TextCtrl(self, pos = (120, 20))
btn = wx.Button(self, pos = (70, 100), label = "OK")
btn.Bind (wx.EVT_BUTTON, self.ShowText)
def ShowText(self, evt):
textList=['a','b','c','d','e']
dim=len(textList)-1
for i in range(dim+1):
self.text1.SetValue(textList[i])
#self.text1.Refresh()
wx.Yield()
sleep(1)
class App(wx.App):
def OnInit(self):
frame = wx.Frame(None, pos = (400, 0))
frame.Show(True)
d=MyDialog(None)
d.ShowModal()
d.Destroy()
return True
app = App(False)
app.MainLoop()
···
On Wed, 23 Nov 2005 14:39:19 +0100, andrea.gavana@agip.it wrote:
Hello bs,
try to put a Refresh() call after setting the value, something like:
def __updateText(self):
textList=['a','b','c','d','e']
dim=len(textList)-1
for i in range(dim+1):
self.txtDisplay.SetValue(textList[i])
self.txtDisplay.Refresh()
sleep(2)
I would prefer using wx:MilliSleep(2000) instead of sleep(2), but that
doesn't matter...
HTH.
Andrea.
--
Franz Steinhaeusler
It's not all that strange, you just need to reailze that you can only do
one thing at a time unless you explicitly create threads to do other
things.
In this case, a better option would be to just use a wx.Timer instance.
import wx
from time import *
textList=['a','b','c','d','e']
class MyDialog(wx.Dialog):
def __init__(self,parent):
wx.Dialog.__init__(self,parent,-1)
self.text1 = wx.TextCtrl(self, pos = (20, 20))
self.text2 = wx.TextCtrl(self, pos = (120, 20))
btn = wx.Button(self, pos = (70, 100), label = "Start")
btn.Bind(wx.EVT_BUTTON, self.Start)
self.btn = btn
self.timer = wx.Timer(self, -1)
self.Bind(wx.EVT_TIMER, self.IncrText)
def Start(self, evt):
if self.btn.GetLabel() == "Start":
self.btn.SetLabel("Stop")
self.timer.Start(2000)
else:
self.btn.SetLabel("Start")
self.timer.Stop()
def IncrText(self, evt):
if self.text1.GetValue() in textlist:
a = textlist.index(self.text1.GetValue())
else:
a = -1
a = (a + 1)%len(textList)
self.text1.SetValue(textlist[a])
class App(wx.App):
def OnInit(self):
frame = wx.Frame(None, pos = (400, 0))
frame.Show(True)
d=MyDialog(None)
d.ShowModal()
d.Destroy()
return True
app = App(False)
app.MainLoop()
···
Franz Steinhaeusler <franz.steinhaeusler@gmx.at> wrote:
On Wed, 23 Nov 2005 14:39:19 +0100, andrea.gavana@agip.it wrote:
>
>Hello bs,
>
>try to put a Refresh() call after setting the value, something like:
>
>def __updateText(self):
> textList=['a','b','c','d','e']
> dim=len(textList)-1
> for i in range(dim+1):
> self.txtDisplay.SetValue(textList[i])
> self.txtDisplay.Refresh()
> sleep(2)
>
>I would prefer using wx:MilliSleep(2000) instead of sleep(2), but that
>doesn't matter...
>
>HTH.
>
>Andrea.
Hi Andrea,
this, I have also thought, but it didn't work.
So I remember of wx.Yield and this lead to sucess.
On WinXp at least: if you remove comment Refresh out and
comment wx.Yield, it doesn't work.
With Ok Button, you launch the process.
(wxPy is really strange sometimes...)
So I remember of wx.Yield and this lead to sucess.
On WinXp at least: if you remove comment Refresh out and
comment wx.Yield, it doesn't work.
With Ok Button, you launch the process.
(wxPy is really strange sometimes...)
It's not all that strange, you just need to reailze that you can only do
one thing at a time unless you explicitly create threads to do other
things.
In this case, a better option would be to just use a wx.Timer instance.
Yes, that is clear of course.
I was only interested with the quick solution.
It is clear for me, while stuck in process one event,
it is not possible to process another event in the same (Main)thread.
So what does wx.Yield.
It seems to start another process only for updating GUI Controls, and then
terminate it(?).
Please correct it, if I'm wrong, it is only important for my basic
understanding, what is going under the hood.
···
--
Franz Steinhaeusler
wx.Yield() executes a single event that may be pending in the wxPython
event queue.
- Josiah
···
Franz Steinhaeusler <franz.steinhaeusler@gmx.at> wrote:
Yes, that is clear of course.
I was only interested with the quick solution.
It is clear for me, while stuck in process one event,
it is not possible to process another event in the same (Main)thread.
So what does wx.Yield.
It seems to start another process only for updating GUI Controls, and then
terminate it(?).