This python module makes it easy to create text-based, graphical interfaces.
Project description
cmd_window
Description
This Python module makes it easy to create text-based graphical interfaces for various purposes. It includes text boxes, labels, buttons, list boxes, tables, password fields, checkboxes, progress bars, and two types of windows.
Usage
First of all, you have to import the modul.
import cmd_window as cmd
Then you need to define an array for the items. The items in this array will be drawn to the screen.
objects = []
The program can be started with the run(objects) function. You have to pass the array which contains all the objects.
cmd.run(objects)
All objects you can interact with have an ID value. You can select them by using the Page Up key to decrease and the Page Down key to increase the current ID. The ID cannot be the same, and it is recommended to use an increasing order. Having two objects with the same ID can cause issues. The active object will be marked with a "*" on its right side.
For objects that have a value that might be used for something (e.g., Textbox), you should define it as a variable. Some objects use additional keys. You can use the SPACE key to press a button or check a checkbox. Also, for Listboxes and Tables, you can use the arrow keys to select an item, or change the value of Sliders.
textbox1 = Textbox(...)
Later you can get the value of the textbox like this:
text = textbox1.text()
You can stop the program by pressing the "ESC" key.
All objects
Window
A basic window where you can set a title and define how many columns it has. However, the size of the columns cannot be customized.
Window(title: str, sizex: int, sizey: int, boxes: int)
-title: The title of the window
-sizex: The x size of the window
-sizey: Thy y size of the window
-boxes: The number of vertical boxes the -window will be divided into.
Advanced window
An advanced window where you can define how many rows and columns it has, as well as set custom sizes and individual titles for each section.
AdvancedWindow(titles:list, sizesx:list[int], sizesy:list[int], boxesx:int, boxesy:int)
-titles: An array —possibly 2D— that contains all the titles.
-sizesx: An array that contains the width of each column.
-sizesy: An array that contains the height of each row.
-boxesx: The number of columns.
-boxesy: The number of rows.
Label
A simple text element used to display static information. It cannot be interacted with.
Label(text: str, posx: int, posy: int)
-text: Text of the label
-posx: The x position of the label
-posy: The y position of the label
Button
A clickable element that displays custom text and can be activated using the SPACE key.
Button(id:int, text:str, command, posx:int, posy:int)
-id: The id of the button.
-text: The text of the button.
-command: The function that should be called when pressed
-posx: The x position of the button.
-posy: The y position of the button.
Textbox
An input field that allows the user to enter text. It can also be a password field, where the entered characters are hidden. The value can be retrieved and used within the program.
Textbox(id:int, width:int, posx:int, posy:int, ispassword:bool)
-id: The id of the textbox.
-width: The width of the textbox.
-posx: The x position of the textbox.
-posy: The y position of the textbox.
-ispassword: If set to True, the textbox will display "*" characters instead of the entered text, but the value can still be accessed using the .text attribute of the textbox.
Multilinetextbox
An input field that allows the user to enter multiple lines of text. The value can be retrieved and used within the program.
You can use the END key to start a new line.
MultilineTextbox(id: int, width: int, height:int, posx: int, posy: int)
-id: The id of the textbox.
-width: The width of the textbox.
-height: The height of the textbox
-posx: The x position of the textbox.
-posy: The y position of the textbox.
Listbox
A selectable list of items where the user can choose one option. The selected items can be retrieved and used in the program.
The value can be retrieved using the .value attribute.
Listbox(id:int, data:list, posx:int, posy:int)
-id: The id of the listbox.
-data: A list that contains all the options of the listbox.
-posx: The x position of the listbox.
-posy: The y position of the listbox.
Chechbox
A toggleable element that allows the user to select or deselect an option. It has a value of True when checked and False when unchecked.
Checkbox(id:int, text:str, posx:int, posy:int)
-id: The id of the checkbox.
-text: The text of the checkbox.
-posx: The x position of the checkbox.
-posy: The y position of the checkbox.
Table
A grid-like structure that displays data in rows and columns. Each cell can contain text or other elements, and values can be retrieved or modified.
Table(id, data:list[list], columnheaders:list, columnwidths:list, visiblerows:int, posx:int, posy:int)
-id: The id of the table.
-data: A 2D array that contains the data of the table.
-columnheaders: A list containing the headers of the columns.
-columnwidths: A list containing the widths of the columns.
-visiblerow: The maximum number of visible rows.
-posx: The x position of the table.
-posy: The y position of the table.
Slider
An input element that allows the user to select a value from a range by sliding a handle. The value can be adjusted using the left and right arrow keys, and it can be retrieved and modified programmatically.
Slider(id:int, width:int, minvalue:int, maxvalue:int, step:int, posx:int, posy:int)
-id: The id of the slider
-width: The width of the slider that will be drawn.
-minvalue: The minimum value of the slider.
-maxvalue: The maximum value of the slider.
-step: The amount by which the value will increase or decrease.
-posx: The x position of the slider.
-posy: The y position of the slider.
Installation
The module can be downloaded from the github page.
pip install cmd-window
If your using windows, you will need the following package:
pip install windows-curses
On linux you need the original curses package:
pip install curses
Updates
v0.3.3 - 2025.09.25:
- Removed boxesx and boxesy parameter from AdvancedWindow, because it was unnecesary.
- Empty rows are now visible in Tables.
- When scrolling in a Table, now the last row is always visible.
- Table now uses up and down arrows for scrolling
v0.3.0:
- Optimised the code
- Implemented a curses-based terminal interface
- Added window.py to handle the curses window logic
Known issues and bugs
- After exiting the program, any text you type in the terminal is interpreted as a command.
License
MIT License © 2025 Péter Czeglédy
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cmd_window-0.3.3.tar.gz.
File metadata
- Download URL: cmd_window-0.3.3.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1771784b1eca973cac990042bf55f72d943f6526a96f9848fc0c848a24205a3
|
|
| MD5 |
8b0e7604584b18bb58924721c868c411
|
|
| BLAKE2b-256 |
a40cff66ba9c69bf75feae9aab503468c7059cd965b5b7ec436a5f50226d99c4
|
File details
Details for the file cmd_window-0.3.3-py3-none-any.whl.
File metadata
- Download URL: cmd_window-0.3.3-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56579e94f9eedab2ecced7c3101e868d692f55520e956e393b72f2022ebdc47b
|
|
| MD5 |
c5a06374c4ee30fea962de8425b18ea6
|
|
| BLAKE2b-256 |
bdcb15c0ac388179d40beddbb640e568354b4bd6e67bd9c78397989335332e6d
|