Sure, usually in gui's you have "widgets" placed on the screen at co-ord's (from top left). Widgets are anything, text, text boxes, buttons, check-boxes ect. XTerm is kinda a wibbly-wobbly set of standards for command lines. Some things you can count on are UTF-8 character set, being told how large the screen is, (in characters), and mouse clicks. I want a bunch of classes that allow me to make widgets that display stuff. Full with colors (foreground and background), frames, ect.
I did a little bit with this stuff once for my SkyNet server, although I didn't use widgets or anything, just kidnda hacked it together. This was was made to be compatible with VT100, which didn't give info like mouse clicks.
Never released it either, but here it is:
Code:
import sys
import os
import time
from threading import Thread, Timer
import socket
TOKENS_PATH = "./tokens"
HACKLOG_PATH = "./hacker_logs"
BORDERCOLOR = '\033[32m'
INVISIBLECOLOR = '\033[31m'
CREDITCOLOR = '\033[36m'
TITLESCOLOR = '\033[94m'
RESETCOLOR = '\033[0m'
TEXTCOLOR = '\033[34m'
SCREEN_WIDTH = 50
SCREEN_HIGHT = 50
class Monitor():
users = {}
logedIn = {}
messageLog = ""
settings = {}
s = socket.socket()
def __init__(self):
self.parseConfig()
self.s.bind(('',int(self.settings["INNER_PORT"])))
def parseConfig(self):
f = open('./settings.ini','r')
for line in f:
setting, value = line.split(" ")
self.settings[setting] = value
def userConnect(self, addr="FAILED"):
self.users[addr] = time.gmtime()
def loginAttempt(self, ip="FAILED", username="FAILED"):
self.logedIn[ip] = 120
def message(self, mess):
self.messageLog += mess
def messageLine(self):
self.messageLog += ",[]"
def tick(self):
for log in self.logedIn:
if(self.logedIn[log] == 0):
self.logedIn[log] = 1
self.logedIn[log] -= 1
self.display()
def clearScreen(self):
print('\033c')
def spacePad(self, string, pad, align='Left'):
string = str(string)
if(len(string) >= pad):
return string[0:pad]
if(align == 'Left'):
spaces = pad - len(string)
output = string
y = 0
while(y < spaces):
output += "#"
y += 1
return output + "#"
if(align == 'Right'):
spaces = pad - len(string)
output = ""
y = 0
while(y < spaces):
output += "#"
y += 1
return output +"#"+ string
if(align == 'Center'):
spaces = pad - len(string)
right = spaces/2
left = spaces/2
y = 0
output = ""
while(y < left):
output += "#"
y += 1
output += string
y = 0
while(y < right):
output += "#"
y += 1
return output
return ""
def display(self):
self.clearScreen()
print(BORDERCOLOR)
topBoarder = '##'
for x in range(0,SCREEN_WIDTH):
topBoarder += "#"
print(topBoarder)
credits = "SkyNet Python Web Server By: 3SidedSquare "
creditline = "#" + INVISIBLECOLOR + "#" + CREDITCOLOR + credits + INVISIBLECOLOR + "#" + BORDERCOLOR + "#"
print(creditline)
print(topBoarder)
x = 0
easyNum = {}
for log in self.logedIn:
easyNum[x] = log
x = x + 1
print(x)
z = 0
ueasyNum = {}
for u in self.users:
ueasyNum[z] = u
z += 1
##ok, so x will hold how many users I have loged in...
titleline = "#" + TITLESCOLOR + self.spacePad("Logged in users", 30, 'Center') + BORDERCOLOR + "#" + TITLESCOLOR + self.spacePad("Frequently hit",21,'Center') + BORDERCOLOR + "#"
print(titleline)
xc = 10
line = ""
while(xc>0):
if(easyNum.get(x,None) != None):
line += BORDERCOLOR + "#" + TEXTCOLOR + self.spacePad(easyNum[x],20,'Left')
line += self.spacePad(logedIn[easyNum[x]],8,'Right')
line += BORDERCOLOR + "#" + TEXTCOLOR
else:
line += BORDERCOLOR + "#" + TEXTCOLOR + self.spacePad("",20,'Left')
line += self.spacePad("",8,'Right')
line += BORDERCOLOR + "#" + TEXTCOLOR
if(ueasyNum.get(x,None) != None):
line += self.spacePad(str(ueasyNum[x])[2:min(17,len(ueasyNum[x]))],15,'Left')
line += self.spacePad(self.users[ueasyNum[x]][5:],4,'Right')
line += BORDERCOLOR + "#"
else:
line += self.spacePad("",15,'Left')
line += self.spacePad("",2,'Left') + BORDERCOLOR + "#"
print(line)
line = ""
xc -= 1
x += 1
print(topBoarder)
ray = self.messageLog.split(",[]")
c = len(ray)
cl = c - 4
while(cl < c):
line = (BORDERCOLOR + "#" + TEXTCOLOR + self.spacePad(ray[cl],49,'Left') + BORDERCOLOR + "#")
print(line)
cl+=1
print(topBoarder)
If you've ever messed with the BIOS options, that is all just characters with background and foreground colors, and some symbols
Spoiler: