Implement Split/Dual Meters #65

Closed
jarvisteach opened this Issue Oct 23, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@jarvisteach
Owner

jarvisteach commented Oct 23, 2016

Want 3 types of meter:

  • Basic meter - shows progress from 0 - 100%
  • Split meter - show 2 colours, with midline, midline moves left & right to show 'possession'
  • Dual meter - shows midline with colours moving out left & right - showing progress towards finish

All should use same getters/setters
All should use gradiated colours
All should be able to show text on the meter

jarvisteach pushed a commit that referenced this issue Oct 23, 2016

Richard Jarvis
Meter Tidy-up (#65)
Reduced functions same get/set for each meter
addMeter now uses generic helper
@maestroi

This comment has been minimized.

Show comment
Hide comment
@maestroi

maestroi Jan 2, 2017

If i put a timer in a loop and run it will crash the gui.

Crashes on all types of meters.

from appJar import gui
import time


def teller():
    for i in range(1,100,1):
        test2 = i + 1
        print test2
        app.setMeter("teller2",test2)
        time.sleep(0.5)

def press(btn):
    if btn == "test":
        teller()


app=gui("test", "400x450")
app.setExpand("both")
app.setFont(10)
app.setSticky("news")
app.addButton("test", press,1,1,0)
app.addMeter("teller2",2,1)
app.go()

maestroi commented Jan 2, 2017

If i put a timer in a loop and run it will crash the gui.

Crashes on all types of meters.

from appJar import gui
import time


def teller():
    for i in range(1,100,1):
        test2 = i + 1
        print test2
        app.setMeter("teller2",test2)
        time.sleep(0.5)

def press(btn):
    if btn == "test":
        teller()


app=gui("test", "400x450")
app.setExpand("both")
app.setFont(10)
app.setSticky("news")
app.addButton("test", press,1,1,0)
app.addMeter("teller2",2,1)
app.go()
@jarvisteach

This comment has been minimized.

Show comment
Hide comment
@jarvisteach

jarvisteach Jan 5, 2017

Owner

That's right - you can't have loops in your code, as they will cause the GUI to hang. This is a common theme with most GUIs - calling app.go() starts a loop, that is checking for events. If you then start another loop (especially with a sleep), the event loop will hang waiting for the second loop to finish.

In order to have background processes run, you need to register them with the GUI, and have the GUI call them

In this case, call app.registerEvent(teller)
You can change the frequency of events, by calling app.setPollTime(xxx)

If you want the event to stop after a certain number of calls, add a global variable to count each time the function is called, then don't perform the action when you reach the target.

Owner

jarvisteach commented Jan 5, 2017

That's right - you can't have loops in your code, as they will cause the GUI to hang. This is a common theme with most GUIs - calling app.go() starts a loop, that is checking for events. If you then start another loop (especially with a sleep), the event loop will hang waiting for the second loop to finish.

In order to have background processes run, you need to register them with the GUI, and have the GUI call them

In this case, call app.registerEvent(teller)
You can change the frequency of events, by calling app.setPollTime(xxx)

If you want the event to stop after a certain number of calls, add a global variable to count each time the function is called, then don't perform the action when you reach the target.

jarvisteach added a commit that referenced this issue Jan 29, 2017

jarvisteach added a commit that referenced this issue Jan 29, 2017

@jarvisteach jarvisteach self-assigned this Feb 25, 2017

@jarvisteach jarvisteach added this to the 0.05 milestone Feb 25, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment