示例#1
0
def newMessage():
	with Context():
		Screen.cls()
		Screen.attr_reset()
		d = Dialog(5, 1, 50, 12)
		d.add(1, 1, WLabel("SWIFT Debug Interface"))
		res = d.loop()
示例#2
0
def getPin():
	with Context():
		Screen.cls()
		Screen.attr_reset()
		pin = ''
		while pin != '1234':
			d = DTextEntry(25, '', title='Enter Pin')
			pin = d.result()
示例#3
0
文件: main.py 项目: pbexe/todoist-tui
def loading_project():
    with Context():
        rows, columns = os.popen('stty size', 'r').read().split()
        Screen.attr_color(C_WHITE, C_RED)
        Screen.cls()
        Screen.attr_reset()
        d = Dialog(0, 0, int(columns), int(rows))
        d.add(1, 1, "Loading Project")
        choice = WListBox(16, int(rows) - 5, ["choice%d" % i for i in range(100)])
        d.add(1, 3, choice)
        b = WButton(8, "Choose")
        d.add(1, int(rows) - 2, b)
        b.finish_dialog = ACTION_OK
        res = d.loop()
示例#4
0
def servStatus():
	with Context():
		Screen.cls()
		Screen.attr_reset()
		d = Dialog(5, 1, 50, 12)
		d.add(1, 1, WLabel("SWIFT Debug Interface"))
		d.add(1, 3, WLabel("SWIFT services:"))
		d.add(1, 5, WLabel("Messaging service:  "+bcolors.OKGREEN+"[ OK ]" + bcolors.ENDC))
		d.add(1, 6, WLabel("Processing service: "+bcolors.OKGREEN+"[ OK ]" + bcolors.ENDC))
		d.add(1, 7, WLabel("Debug service:      "+bcolors.WARNING+"[ OK ]" + bcolors.ENDC))
		d.add(1, 8, WLabel("Input service:      "+bcolors.OKGREEN+"[ OK ]" + bcolors.ENDC))
		d.add(1, 11, WLabel("Processing Directory: "+os.popen("du -sh /root/Downloads/swift/processing").read()))	
		d.add(1, 12, WLabel("Failure Directory: "+os.popen("du -sh /root/Downloads/swift/failed").read()))
		b = WButton(8, "OK")
		d.add(10,16,b)
		b.finish_dialog = ACTION_OK
		res = d.loop()
		mainMenu()
示例#5
0
def failMessage():
	with Context():
		Screen.cls()
		Screen.attr_reset()
		d = Dialog(5, 1, 50, 12)
		d.add(1, 1, WLabel("SWIFT Debug Interface"))
		msgs = os.listdir('failed')
		msgs.append('Main Menu')
		rb = WRadioButton(msgs)
		d.add(1,3,rb)
		b = WButton(8, "OK")
		d.add(10,16,b)
		b.finish_dialog = ACTION_OK
		res = d.loop()
		choice = rb.choice
		if msgs[choice] == 'Main Menu':
			mainMenu()
		else:
			displayMessage('failed/'+msgs[choice],'fail')
示例#6
0
def displayMessage(msg,type):
	with Context():
		Screen.cls()
		Screen.attr_reset()
		file_data = open(msg,'r').readlines()
		d = Dialog(5, 1, 50, 12)
		d.add(1, 1, WLabel("SWIFT Debug Interface"))
		d.add(1, 2, WLabel(bcolors.OKGREEN+"[+] Viewing " + msg+bcolors.ENDC))
		i = 4
		for item in file_data:
			item.strip('\r\n')
			d.add(1,i,WLabel(item))
			i+=1
		b = WButton(8, "OK")
		d.add(10,20,b)
		b.finish_dialog = ACTION_OK
		res = d.loop()
		if type == 'proc':
			procMessage()
		if type == 'fail':
			failMessage()
示例#7
0
def mainMenu():
	with Context():
		Screen.cls()
		Screen.attr_reset()
		d = Dialog(5, 1, 50, 12)
		d.add(1, 1, WLabel("SWIFT Debug Interface"))
		rb = WRadioButton(['View Processing Messages','View Failed Messages','Status','Exit'])
		d.add(1, 3, rb)
		b = WButton(8, "OK")
		d.add(10,16,b)
		b.finish_dialog = ACTION_OK
		res = d.loop()
		choice = rb.choice
		if choice not in [0,1,2,3]:
			res = d.loop()
		elif choice == 0:
			procMessage()
		elif choice == 1:
			failMessage()
		elif choice == 2:
			servStatus()
		elif choice == 3:
			os.system('clear')
			os.system('pkill '+str(os.getpid()))
示例#8
0
from picotui.context import Context
from picotui.screen import Screen
from picotui.widgets import *
from picotui.defs import *

with Context():

    Screen.attr_color(C_WHITE, C_BLUE)
    Screen.cls()
    Screen.attr_reset()
    d = Dialog(5, 5, 50, 12)

    # Can add a raw string to dialog, will be converted to WLabel
    d.add(1, 1, "Label:")
    d.add(11, 1, WLabel("it's me!"))

    d.add(1, 2, "Entry:")
    d.add(11, 2, WTextEntry(4, "foo"))

    d.add(1, 3, "Dropdown:")
    d.add(11, 3, WDropDown(10, ["Red", "Green", "Yellow"]))

    d.add(1, 4, "Combo:")
    d.add(11, 4, WComboBox(8, "fo", ["foo", "foobar", "bar", "long string"]))

    d.add(1, 5, "Auto complete:")
    d.add(15, 5, WAutoComplete(8, "fo",
                               ["foo", "foobar", "bar", "car", "dar"]))

    d.add(1, 6, "Password:"******""))
示例#9
0
    "meanTimePerKmInCity": 360,
    # variance of the normal distribution for departure time (unit: second)
    "departureVariation": 300,
    # proportion of random traffic in the whole traffic demand
    "uniformRandomTraffic": 0.20,
}

#=====================================================#
if True: #for code folding
    from picotui.screen import Screen
    from picotui.context import Context
    from picotui.widgets import (Dialog, WCheckbox, WButton, ACTION_OK)

    _choices = ['%d. %s'%(i+1,x) for (i,x) in enumerate(OPTIONS)]
    _status  = [WCheckbox(x, choice=f) for x,f in zip(_choices,O_FLAGS)] 
    with Context(cls=True):
        _width  = 4 + max( [len(x) for x in _choices] )
        _height = 1 + len(_choices)
        d = Dialog( 0, 0, _width, _height )
        # add multiple checkbox
        for i,x in enumerate(_status):
            d.add(1, i+1, x)
        # add OK butthon
        b = WButton(_width-4, "OK")
        d.add(1+int((_width-b.w)/2), _height, b)
        b.finish_dialog = ACTION_OK
        # rendering
        res = d.loop()
        pass
    Screen.cls() #cleanup the screen
    Screen.goto(0, 0) #cleanup the screen
示例#10
0
 def test_handle_key_with_custom_type_of_items(self):
     with Context():
         users = [User('admin', 30), User('root', 27)]
         widget = UserListBox(width=5, height=5, items=users)
         self.assertIsNone(widget.handle_key(KEY_DOWN))
示例#11
0
async def main():
    connect_error = 0
    freeze = False
    bit = MyBittrex()
    try:
        import termios
        can_term = True
        with Context():
            Screen.attr_color(C_WHITE, C_BLACK)
            Screen.cls()
            Screen.attr_reset()
            d = Dialog(1, 1, 30, 11)

            d.add(1, 1, "Heartbeat: ")
            d.add(4, 2, "Candle:")
            d.add(1, 3, "Summaries:")
            d.add(3, 4, "Summary:")
            d.add(6, 5, "Book:")
            d.add(3, 6, "Tickers:")
            d.add(4, 7, "Ticker:")
            d.add(5, 8, "Trade:")
            d.add(6, 9, "Time:")

            b = WButton(8, "")
            d.add(12, 1, b)
            b.finish_dialog = ACTION_CANCEL

            w_candle = WLabel("", w=14)
            d.add(12, 2, w_candle)

            w_summaries = WLabel("", w=14)
            d.add(12, 3, w_summaries)

            w_summary = WLabel("", w=14)
            d.add(12, 4, w_summary)

            w_book = WLabel("", w=14)
            d.add(12, 5, w_book)

            w_tickers = WLabel("", w=14)
            d.add(12, 6, w_tickers)

            w_ticker = WLabel("", w=14)
            d.add(12, 7, w_ticker)

            w_trade = WLabel("", w=14)
            d.add(12, 8, w_trade)

            w_time = WLabel("", w=19)
            d.add(12, 9, w_time)

            d.redraw()

    except ImportError:
        can_term = False
    while True:
        if can_term:
            await asyncio.sleep(2)
            with Context():
                b.disabled = bit.last_state < (bit.current_time() - 2000)
                b.t = str((bit.current_time() - bit.last_state) / 1000) + 's'
                w_candle.t = str(bit.candle)
                w_summaries.t = str(bit.summaries)
                w_summary.t = str(bit.summary) + '%'
                w_book.t = str(bit.book)
                w_tickers.t = str(bit.tickers)
                w_ticker.t = str(bit.ticker)
                w_trade.t = str("%.2f" % float(bit.trade))
                w_time.t = bit.last_date
                d.redraw()
        else:
            await asyncio.sleep(5)
            if bit.last_state < (bit.current_time() - 10000) and not freeze:
                print(
                    str(bit.last_date) +
                    " — Heartbeat didn't get more than 10 sec")
                freeze = True
                connect_error = 1
                if bit.con_master.started:
                    bit.con_master.close()
            elif freeze and bit.last_state > (bit.current_time() - 10000):
                freeze = False
                print("Heartbeat Unfreezes")
            elif not freeze:
                print(".", end='')
                # print(str(bit.last_date) + ' — Candle: ' + str(bit.candle) +
                #       ', Summaries: ' + str(bit.summaries) +
                #       ', Summary: ' + str(bit.summary) +
                #       '%, Book: ' + str(bit.book) +
                #       ', Tickers: ' + str(bit.tickers) +
                #       ', Ticker: ' + str(bit.ticker) +
                #       ', Trade: ' + str(bit.trade) +
                #       ' — OK: ' + str((bit.current_time() - bit.last_state) / 1000) + 's')
            elif connect_error > 0:
                print(str(bit.last_date) + ' — Reconnect try ' +
                      str(connect_error) + ': ',
                      end='')
                try:
                    bit.restart()
                    connect_error = 0
                    freeze = False
                    print('Success.')
                except Exception as some_ex:
                    print('Error: ' + str(some_ex))
                    connect_error += 1
                    await asyncio.sleep(5)