def __init__(self, routine, dimension, header, textandoptions=None, **kwargs): super(optioninput, self).__init__(routine, dimension, **kwargs) "in default display a option(s) inputbox" self.text = header tmp = [] for text, flag in textandoptions.items(): if text != 'default': tmp.append(text + " (" + flag + ")") self.text = ", ".join(tmp) self.text += " [" + textandoptions['default'] + "] " self.label = label( self.routine, Dimension(self.dimension.line, self.dimension.coln, len(self.text.encode('big5')), 1), self.text) self.input = input( self.routine, Dimension(self.dimension.line, self.dimension.coln + len(self.text.encode('big5')) + 1, 2, 1), fg=ForegroundColors.White, bg=BackgroundColors.Black)
def __init__(self, routine, dimension, boardid): super(createBoard, self).__init__(routine, dimension) self.boardid = boardid self.title = '' warning = u'標題格式有錯誤,請重新輸入。' enterid = u'請輸入看板標題: ' self.titlelabel = label( self.routine, Dimension(self.dimension.height / 2 + 5, 0, len(enterid.encode('big5')), 1), enterid) self.titleinput = input( self.routine, Dimension(self.dimension.height / 2 + 5, len(enterid.encode('big5')) + 1, 20, 1)) self.warninglabel = label(self.routine, Dimension(self.dimension.height / 2 + 6, 0, len(warning.encode('big5')), 1), warning, visible=False) self.add(self.titlelabel) self.add(self.titleinput) self.add(self.warninglabel) self.setFocusedControl(self.titleinput)
def __init__(self, routine, dimension, boardid): super(createThread, self).__init__(routine, dimension) self.boardid = boardid self.title = '' self.content = '' warning = u'標題格式有錯誤,請重新輸入。' enterid = u'請輸入文章標題: ' self.titlelabel = label( self.routine, Dimension(3, 0, len(enterid.encode('big5')), 1), enterid) self.titleinput = input( self.routine, Dimension(3, len(enterid.encode('big5')) + 1, 20, 1)) self.warninglabel = label(self.routine, Dimension(4, 0, len(warning.encode('big5')), 1), warning, visible=False) # need a control for multi-line input self.contentinput = multilineinput( self.routine, Dimension(6, 0, self.dimension.width, 5)) # need a control for confirmation self.confirmationinput = optioninput( self.routine, Dimension(self.dimension.height - 3, 0, self.dimension.width, 1), u'請確認', { u'發送': 'Y', u'繼續編輯': 'N', 'default': 'N' }) self.add(self.titlelabel) self.add(self.titleinput) self.add(self.warninglabel) self.add(self.contentinput) self.add(self.confirmationinput) self.setFocusedControl(self.titleinput)
def __init__(self, routine, dimension): super(quit, self).__init__(routine, dimension) self.msg = u'Bye bye' self.add(footer(self.routine)) self.add( label( self.routine, Dimension(self.dimension.height / 2, 0, len(self.msg.encode('big5')), 1), self.msg))
def __init__(self, routine, dimension, threadid): super(threadViewer, self).__init__(routine, dimension) self.threadid = threadid self.content = scrollableMenu( self.routine, Dimension(2, 0, self.dimension.width, self.dimension.height - 3), self.routine.loadThread(self.threadid).split("\n")) self.add(self.content)
def __init__(self, routine, dimension): super(notfinished, self).__init__(routine, dimension) self.msg = u'對不起,請稍後再試!' self.add(footer(self.routine)) self.add( label( self.routine, Dimension(self.dimension.height / 2, 0, len(self.msg.encode('big5')), 1), self.msg))
def __init__(self, routine, dimension, boardid): super(boardlist, self).__init__(routine, dimension) self.boardid = boardid self.boards = selectionMenu( self.routine, Dimension(3, 0, self.dimension.width, self.dimension.height), self.routine.loadBoards(self.boardid)) self.administration = label(self.routine, Dimension(2, 0, self.dimension.width, 1), "Key C-x creates a board here", self.dimension.width, Align.Left) self.header = header(self.routine, u"【看板列表】", u"批踢踢py實業坊") self.footer = footer(self.routine) self.add(self.administration) self.add(self.boards) self.add(self.header) self.add(self.footer)
def __init__(self, routine, dimension): super(announce, self).__init__(routine, dimension) self.announcements = scrollableMenu( self.routine, Dimension(4, 0, self.dimension.width, self.dimension.height - 2), self.routine.loadAnnouncement()) self.header = header(self.routine, u"【公佈欄】", u"批踢踢py實業坊") self.footer = footer(self.routine) self.add(self.announcements) self.add(self.header) self.add(self.footer)
def __init__(self, routine, **kwargs): super(anykey, self).__init__(routine, Dimension(routine.height, 0, routine.width, 1), **kwargs) self.buffer = label(self.routine, self.dimension, u"按隨意鍵跳出", self.dimension.width, Align.Center, fg=ForegroundColors.Yellow, bg=BackgroundColors.LightBlue).buffer print repr(self.buffer)
def __init__(self, routine, dimension, **kwargs): super(multilineinput, self).__init__(routine, dimension, **kwargs) self.index = 0 # this is the focus index for the inputs self.bounds = 0 # it is actually just lower bound self.inputs = [ input( self.routine, Dimension(self.dimension.line + i, self.dimension.coln, self.dimension.width, 1)) for i in xrange(self.dimension.height) ] self.texts = [ ("", 0) ] * self.dimension.height # tuple: (text, position of cursor)
def __init__(self, routine, dimension): super(topMenu, self).__init__(routine, dimension) self.items = [(-1, "(A)nnouncement"), (-1, "(B)oards"), (-1, "(C)hatroom"), (-1, "(G)ames"), (-1, "(S)ettings"), (-1, "(Q)uit")] self.selectionMenu = selectionMenu( self.routine, Dimension(4, 20, 45, self.dimension.height - 2), self.items) self.header = header(self.routine, u"【主功能表】", u"批踢踢py實業坊") self.footer = footer(self.routine) self.add(self.header) self.add(self.footer) self.add(self.selectionMenu)
def __init__(self, routine, dimension): super(login, self).__init__(routine, dimension) self.id = '' self.pw = '' title = u'=Welcome to BBS=' warning = u'帳號或密碼有錯誤,請重新輸入。' lenwarning = len(warning.encode('big5')) enterid = u'請輸入帳號,或以 guest 參觀,或以 new 註冊: ' lenenterid = len(enterid.encode('big5')) enterpw = u'請輸入密碼:' lenenterpw = len(enterpw.encode('big5')) #artwork = art(self.routine, 0, 0, self.width, self.height, '../../res/Welcome_birth') self.artwork = label(self.routine, Dimension(self.dimension.height / 2, 0, self.dimension.width, self.dimension.height), title, self.dimension.width, Align.Center, fg=ForegroundColors.White, bg=BackgroundColors.White) self.idLabel = label( self.routine, Dimension(self.dimension.height / 2 + 5, 0, lenenterid, 1), enterid) self.idInput = input( self.routine, Dimension(self.dimension.height / 2 + 5, lenenterid + 1, 20, 1)) self.pwLabel = label(self.routine, Dimension(self.dimension.height / 2 + 5, 0, lenenterpw, 1), enterpw, visible=False) self.pwInput = input(self.routine, Dimension(self.dimension.height / 2 + 5, lenenterpw + 1, 20, 1), concealed=True, visible=False) self.warningLabel = label(self.routine, Dimension(self.dimension.height / 2 + 6, 0, lenwarning, 1), warning, visible=False) self.add(self.idLabel) self.add(self.idInput) self.add(self.pwLabel) self.add(self.pwInput) self.add(self.artwork) self.add(self.warningLabel) self.setFocusedControl(self.idInput)
def __init__(self, routine, **kwargs): super(footer, self).__init__(routine, Dimension(routine.height, 0, routine.width, 1), **kwargs) self.buffer = label(self.routine, self.dimension, u"批踢踢py實業坊", self.dimension.width, Align.Center, fg=ForegroundColors.White, bg=BackgroundColors.LightBlue).buffer + label( self.routine, self.dimension, u"【 主功能表 】", fg=ForegroundColors.Yellow, bg=BackgroundColors.LightBlue).buffer '''
def __init__(self, routine, location, title, **kwargs): super(header, self).__init__(routine, Dimension(0, 0, routine.width, 1), **kwargs) # just for testing #self.location = u"【 主功能表 】" #self.title = u"批踢踢py實業坊" self.buffer = label(self.routine, self.dimension, title, self.dimension.width, Align.Center, fg=ForegroundColors.White, bg=BackgroundColors.LightBlue).buffer + label( self.routine, self.dimension, location, fg=ForegroundColors.Yellow, bg=BackgroundColors.LightBlue).buffer
def initialize(self): print "Routine initializing" self.stack.push( screenlets.login(self, Dimension(0, 0, self.width, self.height))) '''