pysole is a wrapper for simulating C# console applications on any operating system that supports python.
GPL-3.0 License
This is a limited clone of the official documentation page which can be found at http://treestain.me
Pysole is a graphical console simulation pygame wrapper or in simpler terms, Pysole uses pygame to simulate a text interface, such as Windows powershell or the Linux Console. Initially Pysole was built to emulate .NET Console Applications with their dynamic text and background colouring. However, .NET Console Applications, without the support of mono cannot run on operating systems other then windows. Pysole can run on any os that python and pygame can.
Pysole can also be installed with pip and the PyPi using the following command.
pip install pysole
In order to intergrate your Pysole with your application there is a few steps you must follow. First of all you need to import Pysole. Although it is not necessary you can also import the Colour module, which gives you an enourmouse selection of named colours.
import pysole.console
from pysole.colour import ConsoleColour
Next you must initialise and store a new Console object. The console object can be initialised with two optional values title and icon.
config = {'font': 'font.ttf'}
console = console.Console()
Now that you have an initialised Console object you are now able to read, write, and change the display of the console.
# Console write, writes the text you parse it without a newline at the end of the string.
console.write('Hello World')
# Console write line does the same as write except with a newline at the end.
console.write_line(', this is a console')
# Console clear, clears the frame and removes all text from the console display buffer.
console.clear()
# Console read line returns all the input of a user until they press return.
name = console.read_line('What is your name? ')
# Console read key returns a single user key press.
key = console.read_key()
In order to change the colours of the text and background all that needs to be done is to change the console variables foreground_color and background_color
console.foreground_color = ConsoleColour.red
console.background_color = ConsoleColour.white
# The reset colour method resets the console colours back to the defaults.
console.reset_color()
If you, for whatever reason, need to use audio cue the Console beep method can be used.
console.beep()
To quit pysole and close the window the following statement must be used.
console.quit()
##Colours The ConsoleColour class contains a list of named colours and their RGB values. In order to use this class you must import the colour module.
from pysole.colour import ConsoleColour
print(ConsoleColour.olive_drab)
>>> (107, 142, 45)
Any RGB value in the form of a tuple can be passed as a colour for example:
console.foreground_color = ConsoleColour.navajo_white
Is the exact same as:
console.foreground_color = (255, 222, 173)
To customise the initial Console a configuration dictionary can be added to the Console. An example:
config = {'title': 'Pysole', 'resizeable': True, 'font': 'font.ttf'}
console = console.Console(config)
Here are all the configuration keywords and what values they should be.
'title': [string] # The caption for the window.
'icon': [string] # The icon for the window.
'fps': [int] # Frames per second.
'line_cutoff': [int] # How many lines should be in the buffer at any given time?
'default_background_colour': [ConsoleColour] # The default background colour for the console, used for the reset_colour function as well.
'default_foreground_colour': [ConsoleColour] # The default foreground colour for the console, used for the reset_colour function as well.
'default_width': [int] # Default width of the window.
'default_height': [int] # Default height of the window.
'default_min_width': [int] # The minimum width of the window.
'default_min_height': [int] # The minimum height of the window.
'default_max_width': [int] # The maximum width of the window.
'default_max_height': [int] # The maximum height of the window.
'resizeable': [bool] # Should the window be resizeable?
'beep_sound': [string] # Sound the console plays in the beep method.
'font': [string] # Font for the console to use.
'font_size': [int] # Font size.
##Images
##Authors
Currently the list of authors is very short (1 person)
##Planned features
Here is a list of all the planned features that are potentially going to be implemented as well as they're priority levels.
##Source file overview