469,288 Members | 2,353 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,288 developers. It's quick & easy.

Pythoncard - gauge component.

Hello.

I'd to use gauge component in the code below. I want to show
Queue.quantity in gauge (during running thread, every time when it
changed). I don't know which event i must use. I find some info about
Time event for gauge but don't understand how it works. Any
suggestions?
#---gauge.rcrc.py---

{'application':{'type':'Application',
'name':'Template',
'backgrounds': [
{'type':'Background',
'name':'GaugeTest',
'size':(187, 147),

'components': [

{'type':'Gauge',
'name':'gauge',
'position':(4, 10),
'size':(156, 28),
'foregroundColor':(248, 29, 67),
'layout':'horizontal',
'max':100,
'value':0,
},

{'type':'Button',
'name':'startbtn',
'position':(5, 44),
'label':'record',
},
] }] } }
#---------------------------
#--------gauge.py----------------------
from threading import Thread
from threading import Condition
import time

class Queue:
def __init__(self):
self.quantity=0

def produce(self):
self.quantity+=1

def consume(self):
self.quantity-=1
def isEmpty(self):
return not self.quantity

class Prod(Thread):
def __init__(self, queue, cond):
Thread.__init__(self)
self.queue=queue
self.cond=cond
def run(self):
while 1:
self.cond.acquire()
self.queue.produce()
print "Producer produce(1), quantity:",self.queue.quantity
self.cond.notifyAll()
self.cond.release()
time.sleep(1)
class Cons(Thread):
def __init__(self, queue, cond):
Thread.__init__(self)
self.queue=queue
self.cond=cond
def run(self):
while 1:
time.sleep(2)
self.cond.acquire()
while self.queue.isEmpty():
print " >>>Quantity: 0. I'm waiting."
self.cond.wait()
self.queue.consume()
print " >>>Consumer consume(1), quantity:",
self.queue.quantity
self.cond.release()

from PythonCard import model
class PythonCardWin(model.Background):
def on_initialize(self,event):
self.q=Queue()
self.c=Condition()
self.p=Prod(self.q,self.c)
self.c=Cons(self.q,self.c)

def on_startbtn_mouseClick(self,event):
self.p.start()
self.c.start()

def on_gauge_???????(self, event):
??????????/
if __name__ == '__main__':
app = model.Application(PythonCardWin)
app.MainLoop()

Aug 4 '05 #1
0 1052

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Luiz Siqueira Neto | last post: by
reply views Thread by Ron Stephens | last post: by
2 posts views Thread by Adrian Smith | last post: by
1 post views Thread by Oriana | last post: by
2 posts views Thread by PipedreamerGrey | last post: by
1 post views Thread by Varun Hiremath | last post: by
4 posts views Thread by Tequila | last post: by
8 posts views Thread by Kevin Walzer | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.