Web-gui for Python logs

Logging can help you better understand the flow of a program and discover undesirable behaviour which you might not even consider while developing. Logs give you information about scenarios that an application is going through. You can label this information according to its importance: debug, info, warning and errors. Occurring errors can provide more insights than a stack trace by telling you what the program state was before it arrived at the line of code where the error occurred.

Logs browser in Flask
Logs browser in Flask

Continue reading “Web-gui for Python logs”

FIFO or LIFO – which taxation method to choose?

When you’ve been investing for a longer time, you usually gathered equities (stock, ETFs, crypto-currencies) that you were adding to your portfolio at different prices. When you want to reduce some of these shares from your portfolio, picking which ones you want to sell or picking a computation method which will be used to calculate your gain can make a significant difference in the taxes you owe.

Continue reading “FIFO or LIFO – which taxation method to choose?”

Calculating capital gains using FIFO queue

According to the first-in-first-out (FIFO) valuation method of capital gain, it’s assumed that equities are sold in the order in which they’re bought. In other words, the oldest shares are sold first. A detailed description of this method can be found in many places, e.g. here. In this post, I will focus on the implementation of the FIFO method in Python.

Fifo queue
Continue reading “Calculating capital gains using FIFO queue”

RSI stock screener

Stocks screeners are effective filters when you have a specific idea of the kinds of companies in which you are looking to invest. There are tens of thousands of stocks listed on world exchanges so it’s time-consuming to browse them manually. In this post I will show you have to built your own free stock screener using Python.

Continue reading “RSI stock screener”

Migration from Tkinter to Flask

The most popular library to create GUI in Python is Tkinter, which is a part of standard Python installation. Tkinter is a mature and stable tool, widely ported and relatively easy to learn. However, it is also quite old with many drawbacks, among them, it has a limited set of widgets. Although the simplistic model is easy to learn, Tkinter also becomes cumbersome with more complex interfaces. Above all, it does not support mobile and web application development.

Tkinter window
Tkinter window

Flask GUI
Flask GUI

Continue reading “Migration from Tkinter to Flask”

Tkinter list box with a search filter

Depending on the settings, a list box can be set to allow the user to select only one of the available options or multiple options. If the list is long what often happens if we work with a larger set of data, a filter used to select a few values is a handy addition. Using the filter, you can narrow down the list of values by typing a string of text in the search field above the list. The values that do not match the string are removed from the list. This particular filter needs pressing an ‘enter’ key to start processing the data. In Python Tkinter a list box is represented by Listbox widget.

Continue reading “Tkinter list box with a search filter”

Gutenberg code editor

Wordpress editors are set to build web pages even with no knowledge of HTML principles. The latest editor, Gutenberg, is designed in a way similar to a rather familiar for most users MS Word’s interface. It has various tools for editing texts, adding images with their further adjustments, inserting links, etc. Basically, the working process is intuitive and understandable even if the user has no experience of working with any HTML editor at all. The magic of HTML tags and CSS styles is behind the scene. Any step you proceed in creating a web page is automatically supported by an appropriate HTML code. However, if you have some skills and knowledge in direct coding, it is also possible to use an HTML code viewer that displays the code of the web page you create. It allows you to grasp full control over the HTML code and webpage appearance.

Continue reading “Gutenberg code editor”

GUI as a state machine

When interacting with GUI, a user should be able to supply only valid events at any given time. Thus if an application requires a user to perform event A before event B, the interface should ensure that event B is not possible until event A has been completed. It can be achieved by making certain GUI elements disappear or become disabled.

GUI states
GUI states

Continue reading “GUI as a state machine”