Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import PyBearLibTerminal as T
- def draw_window(x, y, w, h):
- # Transflucent background
- T.color('#C0A0A0A0')
- T.put(x, y, 0x2597) # Corners
- T.put(x+w-1, y, 0x2596)
- T.put(x+w-1, y+h-1, 0x2598)
- T.put(x, y+h-1, 0x259D)
- for i in range(x+1, x+w-1): # Horisontal borders
- T.put(i, y, 0x2584)
- T.put(i, y+h-1, 0x2580)
- for i in range(y+1, y+h-1): # Vertical borders
- T.put(x, i, 0x2590)
- T.put(x+w-1, i, 0x258C)
- for i in range(x+1, x+w-1): # Fill
- for j in range(y+1, y+h-1):
- T.put(i, j, 0x2588)
- # Thin, solid border
- T.color('white')
- T.put(x, y, 0x250C) # Corners
- T.put(x+w-1, y, 0x2510)
- T.put(x+w-1, y+h-1, 0x2518)
- T.put(x, y+h-1, 0x2514)
- for i in range(x+1, x+w-1): # Horisontal borders
- T.put(i, y, 0x2500)
- T.put(i, y+h-1, 0x2500)
- for i in range(y+1, y+h-1): # Vertical borders
- T.put(x, i, 0x2502)
- T.put(x+w-1, i, 0x2502)
- T.open()
- T.set('font: ../ttf-fonts/consola.ttf, size=16')
- T.set('input.filter=[keyboard, system]') # Disable mouse to make read() behave like getch()
- T.set('window.size=28x10')
- T.set('terminal.encoding=utf8')
- T.composition(True) # Simpler than layers
- # Checkered background
- for x in range(0, 12):
- for y in range(0, 8):
- T.color('darkest green' if ((x+y) % 2 == 0) else 'darkest red')
- T.put(x*2 + 2, y + 1, 0x2588)
- T.put(x*2 + 3, y + 1, 0x2588)
- draw_window(5, 2, 18, 6)
- T.printf(5+2, 2+1, '[color=white]Hello, window!')
- T.refresh()
- T.read()
- T.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement