Package: pyfancy
DownloadGo to thereleases
pageand download
the latest (or previous) version.Or use pippip installgit+https://github.com/ilovecode1/Pyfancy-2/Overviewpyfancy is a simple Python library that provides a mechanism for easily
styling text in some terminal environments. Text is styled by chaining
together methods that add escape codes for color modifiers to the text.UsageFormatting using pyfancy all follows the same basic pattern. First,
there is the initializer, which just sets up the pyfancy object. Next is
a chain of function calls that provide text formatting. Finally, there
is a last method chained on which either returns the text string with
format escape codes, or which directly outputs the text using the print
statement / method. (The output methodshouldbe compatible with
Python 2 and 3.)This chain of code looks basically like this:pyfancy().[chainedstatements].output()# To print using print statement / methodpyfancy().[chainedstatements].get()# To get formatted text stringThere are two different ways to use the chained statements. The first is
to provide the text that is to be chained as part of the statement call.
For example, the following prints “Hello, world!” in red:pyfancy().red("Hello, world!").output()However, chained statements are really just modifiers with an optional
text argument. The following example works identically to the previous
example:pyfancy().red().add("Hello, world!").output()Using chained statements, then, allows for modifiers to be stacked:pyfancy().red().bold().add("Hello, world!").output()# orpyfancy().red().bold("Hello, world!").output()# The red() and bold() calls can also be in the opposite order.Of course, there can only be, for example, one color active at a time.
This allows for the creation of multicolored statements:pyfancy().red("Hello").magenta(", ").blue("world!").output()It is also possible to reset all styles, either to get default styling,
or to ensure that styles are reset, using therawmodifier:pyfancy().raw("You walk into a ").red().bold("DANGEROUS").raw(" room.").output()Parsing is a simple, shorter and faster way to use Pyfancy 2. Instead
of:pyfancy().red("Hello").blue(" world!").output()You can do this:pyfancy("{red Hello {blue world!}}").output()For parsing you can also import from a text file:pyfancy().open("import.txt").output()In order to use pyfancy, import the module withfrom pyfancy import *.Types of effectsText EffectBackgroundboldn/adimn/aLight/Darkunderlinedn/an/ablinkingn/an/ablackblack_bgn/aredred_bgdark_redgreengreen_bgdark_greenyellowyellow_bgdark_yellowblueblue_bgdark_bluemagentan/adark_magentacyann/adark_cyann/agray_bglight_graywhiten/an/arainbown/an/amultin/an/an/adark_gray_bgdark_grayn/alight_red_bglight_redn/alight_green_bglight_greenn/alight_yellow_bglight_yellown/alight_blue_bglight_bluen/alight_purple_bglight_purplen/alight_cyan_bglight_cyann/awhite_bgwhiteLicensePyfancy-2 is under the MIT license.ContributorsNote:Because v2 was made in aforkthe contribution graph does not truely reflect the contributions made by the bellow contributers.Project byCosmicWebServicesTheMonsterFromTheDeepjoker314baranskistadjonathan50rogersouzavutondesigncruxicheiroshiccup01Kristinita