Pythoncard - gauge component.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • fiddlehead

    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':'Applic ation',
    'name':'Templat e',
    'backgrounds': [
    {'type':'Backgr ound',
    'name':'GaugeTe st',
    'size':(187, 147),

    'components': [

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

    {'type':'Button ',
    'name':'startbt n',
    '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=queu e
    self.cond=cond
    def run(self):
    while 1:
    self.cond.acqui re()
    self.queue.prod uce()
    print "Producer produce(1), quantity:",self .queue.quantity
    self.cond.notif yAll()
    self.cond.relea se()
    time.sleep(1)
    class Cons(Thread):
    def __init__(self, queue, cond):
    Thread.__init__ (self)
    self.queue=queu e
    self.cond=cond
    def run(self):
    while 1:
    time.sleep(2)
    self.cond.acqui re()
    while self.queue.isEm pty():
    print " >>>Quantity: 0. I'm waiting."
    self.cond.wait( )
    self.queue.cons ume()
    print " >>>Consumer consume(1), quantity:",
    self.queue.quan tity
    self.cond.relea se()

    from PythonCard import model
    class PythonCardWin(m odel.Background ):
    def on_initialize(s elf,event):
    self.q=Queue()
    self.c=Conditio n()
    self.p=Prod(sel f.q,self.c)
    self.c=Cons(sel f.q,self.c)

    def on_startbtn_mou seClick(self,ev ent):
    self.p.start()
    self.c.start()

    def on_gauge_?????? ?(self, event):
    ??????????/


    if __name__ == '__main__':
    app = model.Applicati on(PythonCardWi n)
    app.MainLoop()

Working...