473,772 Members | 2,414 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what's wrong with this if statement?

Here's the full code, but you can probably safely ignore most of it,
especially the wxPython stuff:

-----------------------------------

import wx
class MyFrame(wx.Fram e):

def __init__(self):
wx.Frame.__init __(self, parent=None, id=wx.ID_ANY)
panel = wx.Panel(self)

mainSizer = wx.BoxSizer(wx. VERTICAL)
inputSizer = wx.BoxSizer(wx. HORIZONTAL)

self.count = 0
self.progress = wx.Gauge(panel, wx.ID_ANY, 100, size=(300, 20))
self.status = wx.StaticText(p anel, wx.ID_ANY, 'test')
prompt = wx.StaticText(p anel, wx.ID_ANY, 'Time:')
self.input = wx.TextCtrl(pan el, wx.ID_ANY, size=(20, 20))
self.start = wx.Button(panel , wx.ID_ANY, 'Start')
self.timer = wx.Timer(self)

mainSizer.Add(s elf.progress, flag=wx.ALIGN_C ENTER | wx.TOP,
border=10)
mainSizer.Add(s elf.status, flag=wx.ALIGN_C ENTER | wx.ALL,
border=10)
mainSizer.Add(i nputSizer, flag=wx.ALIGN_C ENTER)
inputSizer.Add( prompt, flag=wx.ALIGN_C ENTER)
inputSizer.Add( self.input, flag=wx.ALL, border=10)
inputSizer.Add( self.start, flag=wx.ALIGN_C ENTER)

self.Bind(wx.EV T_TIMER, self.OnTimer, self.timer)
self.Bind(wx.EV T_BUTTON, self.OnStart, self.start)

panel.SetSizer( mainSizer)

def OnStart(self, event):
self.time = self.input.GetV alue()
self.timer.Star t(1000)

def OnTimer(self, event):
self.count += 1
if self.count < self.time:
self.progress.S etValue(self.co unt)
self.status.Set Label(str(self. count))
class MyApp(wx.App):

def OnInit(self):
frame = MyFrame()
self.SetTopWind ow(frame)
frame.Show()
return True
if __name__ == '__main__':
app = MyApp(redirect= False)
app.MainLoop()

------------------------------------

The code in question is mainly this:

def OnTimer(self, event):
self.count += 1
if self.count < self.time:
self.progress.S etValue(self.co unt)
self.status.Set Label(str(self. count))

When I run the program, the progress bar and the status label continue
to increase even after self.count has (presumably) become larger than
self.time. Why is this? All I do is enter in '10' as the value to test
it, and it keeps counting even beyond 10.
Jul 21 '06 #1
2 1103
John Salerno wrote:
Here's the full code, but you can probably safely ignore most of it,
especially the wxPython stuff:

-----------------------------------

import wx
class MyFrame(wx.Fram e):

def __init__(self):
wx.Frame.__init __(self, parent=None, id=wx.ID_ANY)
panel = wx.Panel(self)

mainSizer = wx.BoxSizer(wx. VERTICAL)
inputSizer = wx.BoxSizer(wx. HORIZONTAL)

self.count = 0
self.progress = wx.Gauge(panel, wx.ID_ANY, 100, size=(300, 20))
self.status = wx.StaticText(p anel, wx.ID_ANY, 'test')
prompt = wx.StaticText(p anel, wx.ID_ANY, 'Time:')
self.input = wx.TextCtrl(pan el, wx.ID_ANY, size=(20, 20))
self.start = wx.Button(panel , wx.ID_ANY, 'Start')
self.timer = wx.Timer(self)

mainSizer.Add(s elf.progress, flag=wx.ALIGN_C ENTER | wx.TOP,
border=10)
mainSizer.Add(s elf.status, flag=wx.ALIGN_C ENTER | wx.ALL,
border=10)
mainSizer.Add(i nputSizer, flag=wx.ALIGN_C ENTER)
inputSizer.Add( prompt, flag=wx.ALIGN_C ENTER)
inputSizer.Add( self.input, flag=wx.ALL, border=10)
inputSizer.Add( self.start, flag=wx.ALIGN_C ENTER)

self.Bind(wx.EV T_TIMER, self.OnTimer, self.timer)
self.Bind(wx.EV T_BUTTON, self.OnStart, self.start)

panel.SetSizer( mainSizer)

def OnStart(self, event):
self.time = self.input.GetV alue()
self.timer.Star t(1000)

def OnTimer(self, event):
self.count += 1
if self.count < self.time:
self.progress.S etValue(self.co unt)
self.status.Set Label(str(self. count))
class MyApp(wx.App):

def OnInit(self):
frame = MyFrame()
self.SetTopWind ow(frame)
frame.Show()
return True
if __name__ == '__main__':
app = MyApp(redirect= False)
app.MainLoop()

------------------------------------

The code in question is mainly this:

def OnTimer(self, event):
self.count += 1
if self.count < self.time:
self.progress.S etValue(self.co unt)
self.status.Set Label(str(self. count))

When I run the program, the progress bar and the status label continue
to increase even after self.count has (presumably) become larger than
self.time. Why is this? All I do is enter in '10' as the value to test
it, and it keeps counting even beyond 10.


Check the type of self.time: unicode - you need to convert it to int
first ... plus your timer will need to be shutdown when you're done.

Regards,

Philippe
Jul 21 '06 #2
Philippe Martin wrote:
Check the type of self.time: unicode - you need to convert it to int
first ... plus your timer will need to be shutdown when you're done.
Ah, of course! Thanks!
Jul 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2522
by: serge | last post by:
/* This is a long post. You can paste the whole message in the SQL Query Analyzer. I have a scenario where there are records with values pointing to wrong records and I need to fix them using an Update statement. I have a sample code to reproduce my problem. To simplify the scenario I am trying to use Order related tables to explain a little better the tables i have to work with.
51
13388
by: WindAndWaves | last post by:
Can anyone tell me what is wrong with the goto command. I noticed it is one of those NEVER USE. I can understand that it may lead to confusing code, but I often use it like this: is this wrong????? Function x select case z
6
407
by: Daniel Rudy | last post by:
What is wrong with this program? When I try to compile it, I get the following error. Compiler is gcc on FreeBSD. strata:/home/dcrudy/c 1055 $$$ ->cc -g -oe6-3 e6-3.c e6-3.c: In function `main': e6-3.c:32: syntax error before `||' e6-3.c:33: syntax error before `printf' e6-3.c:36: syntax error before `||' e6-3.c:40: syntax error before `(' e6-3.c:40: syntax error before `strcpy'
8
1838
by: Brian Basquille | last post by:
Hello all, Bit of a change of pace now. As opposed to the typical questions regarding my Air Hockey game, am also working on a Photo Album which uses an Access Database to store information about photos. This information is held inside the database (photoDB.mdb) in a table called 'photos' - information being recorded in there are photo information (photoID, location, phDate, category, caption). I have inputted my own photos (not via...
1
1335
by: THY | last post by:
can anyone tell me what's wrong with this statement ? cn.execute("update table set data = 'test'") the asp.net keep telling me syntax error in update statement ... help me please ...
22
2292
by: noridotjabi | last post by:
Okay. I'm quite embarased to be asking this but I cannot seem to get files to work. I don't know what the problem is. Is there something wrong with this: (file related) #include <stdio.h> main() { FILE *pfsin; pfsin = fopen("msm.pfs", "r"); char mystr;
669
26212
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic paper written on this subject. On the Expressive Power of Programming Languages, by Matthias Felleisen, 1990. http://www.ccs.neu.edu/home/cobbe/pl-seminar-jr/notes/2003-sep-26/expressive-slides.pdf
5
10807
by: Ryan | last post by:
{"POINTID":77902,"MAPID":762,"LONG":-122.21654892,"LAT":"37.1834331019","CITY":"Boulder Creek","STATE":"CA","DIST":5745.4} I get an "invalid label" error... I'm kinda new to this. Thanks!
15
9046
by: robert maas, see http://tinyurl.com/uh3t | last post by:
Here's the source: #include <stdio.h> #include <errno.h> main () { char* str = "9999999999"; long long int llin; char* endptr; /* Set by strtoll */ int nch; errno = 0; llin = strtoll(str, &endptr, 10); printf("errno=%d\n", errno);
6
2015
by: CTG | last post by:
"update set UPDATE-FLAG=false, UPDATE-DT= '10/09/2007 4:09:59 PM' WHERE ICCID='I1' " UPDATE_FLAG is a YES/NO ICCID is TEXT I have tried YES, NO as well but still fails,
0
9619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9911
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8934
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.