Icon 2 Icon 1 Icon 2 Icon 3

Pequena Home

Pequena

Lightweight cross-platform desktop app framework designed for simplicity and speed

Pequena Docs

Prerequisites

Before you begin, there are a few things you'll need to make sure you have installed on your computer.

1. Python

The first is Python. Python is a programming language that is used by many different applications and frameworks, so it's likely that you already have it installed. If not, you can download it from the Python website and follow the installation instructions.

2. Node.js

The second prerequisite is Node.js. Node.js is a JavaScript runtime that is used for building scalable, high-performance applications. Again, you can download Node.js from the official website and follow the installation instructions to get it set up on your machine.

If you're using Windows 10 or higher, you're now ready to go!

3. Microsoft Edge Webview2

If you're using Windows 10 or higher, you're good to go! However, if you're running Windows 7, 8, or 8.1, you'll need to make sure you have the WebView2 framework installed. This framework provides an embedded web browser that is used by Pequena, so it's necessary to have it installed.

To install the WebView2 framework, simply download it from the Microsoft website and follow the installation instructions. Once you have all of these prerequisites in place, you'll be ready to get started with your software development project!

Installation

To download the Pequena, simply use one of these tools

  • bash
  • npm
  • git
  • yarn
  • pnpm
$ sh <(curl some_link)

Hello World!

Once you've installed the framework, you should see a files called main.py and settings.json in your root folder, along with a folder Pequena/. In this foler the virtual python enviroment lives together with the node scripts needed for starting and bundling the application.

Open up the main.py file and you should see the following code:

import Pequena
window = Pequena.init_window()

This code initializes a new window using the Pequena framework. Once you've set up your frontend code, you'll be able to use this code to display your app.

First run will create a virtual environment for Python to achieve minimal size, so it may take a bit longer than subsequent runs.

To run your app, you can use the following command:

$ npm run start

With this basic "Hello World" app up and running, you're ready to start exploring the Pequena framework and building more complex applications.

init_window()

This function initializes a new window using the Pequena framework. It takes no arguments and returns a Window object that you can use to interact with the window.

window = init_window()

expose_function(*functions)

def hello_py():
    print("Hello from python")

Pequena.expose_function(hello_py)

This function exposes one or more functions to be called from your frontend JavaScript code. This can be useful if you need to perform complex calculations or operations on the server side that can't be done in the browser. To use this function, simply pass in one or more Python functions as arguments.

These functions will then be accessible from your JavaScript code using the __Exposed__ object.

__Exposed__.hello_py()

start_window()

This function is used internally by the Pequena framework to start the window loop and handle user input. You don't need to call this function directly, as it is automatically called when you start your app using the npm run start command

on_top

Get or set whether the window is always on top.

window = init_window()

width

Get width of the pequena window.

window.width

height

Get width of the pequena window.

window.height

position

Get x and y coordinates of the pequena window.

window.position

destroy

Get width of the pequena window.

window.destroy()

hide

Hide the window.

window.hide()

minimize

Minimize window.

window.minimize()

move

Move window to a new position.

window.move(x, y)

resize

Resize window.

window.resize(width, height)

restore

Restore minimized window.

window.restore()

set_title

Change the title of the window.

window.set_title()

show

Show the window if it is hidden. Has no effect otherwise.

window.show()

toggle_fullscreen

Toggle fullscreen mode.

window.toggle_fullscreen()

__Node__

In addition to the Python Pequena API, the Pequena framework also provides a way to access "backend" Node.js modules directly from your browser-based JavaScript code. This allows you to leverage the power and functionality of Node.js modules in your web applications.

To access these "backend" Node modules, you can use the __Node__ object provided by Pequena. The Node object acts as a bridge between your browser-based code and the Node.js environment. Currently, a few commonly used Node.js modules, such as fs, child_process, and path, have been implemented and are available through the Node object.

fs

readFile(path)

Reads the content of a file.

__Node__.fs.readFile("database.txt")
writeFile(path, content)

Writes content to a file.

__Node__.fs.writeFile("database.txt", "Hello, World!")
mkdir(path)

Creates a new directory.

__Node__.fs.mkdir("new_directory")
readdir(path)

Lists all files and directories in a directory.

__Node__.fs.readdir("my_directory")
pathExists(path)

Checks if a path exists.

__Node__.fs.pathExists("file.txt")
isfile(path)

Checks if a path is a file.

__Node__.fs.isfile("file.txt")
isdir(path)

Checks if a path is a directory.

__Node__.fs.isdir("my_directory")

path

join(...paths)

Joins multiple paths into a single path.

__Node__.path.join("folder", "file.txt")
basename(path)

Gets the base name of a path.

__Node__.path.basename("/path/to/file.txt")
dirname(path)

Gets the directory name of a path.

__Node__.path.dirname("/path/to/file.txt")
resolve(...paths)

Resolves a path into an absolute path.

__Node__.path.resolve("folder", "file.txt")

__Pequena__

The __Pequena__ class is a powerful tool provided by the Pequena framework that allows you to modify and customize the Pequena window directly from your browser-based JavaScript code. This means that you can dynamically update the appearance and behavior of your application's window directly from JavaScript.

getWindowInfo()

Retrieves information about the Pequena window.

__Pequena__.getWindowInfo()

Returns object containing these values:

{
    x: active_window.x,
    y: active_window.y,
    width: active_window.width,
    height: active_window.height
}
minimizeWindow()

Minimizes the Pequena window.

__Pequena__.minimizeWindow()
unminimizeWindow()

Restores the Pequena window from a minimized state.

__Pequena__.unminimizeWindow()
hideWindow()

Hides the Pequena window.

__Pequena__.hideWindow()
unhideWindow()

Shows the hidden Pequena window.

__Pequena__.unhideWindow()
toggleFullscreen()

Toggles the Pequena window between fullscreen and normal mode.

__Pequena__.toggleFullscreen()
moveWindow(x, y)

Moves the Pequena window to the specified coordinates.

__Pequena__.moveWindow(x, y)
resizeWindow(width, height)

Resizes the Pequena window to the specified dimensions.

__Pequena__.resizeWindow(width, height)
setWindowName(name)

Sets the title of the Pequena window.

__Pequena__.setWindowName("My Pequena App")

__Exposed__

The __Exposed__ object serves as a container for all the functions that you choose to expose from Python to the browser. This feature allows you to bridge the gap between your Python backend and your browser-based JavaScript code, enabling seamless communication and interaction between the two.

To expose a function from Python to the browser, you can use the Pequena.expose_functions() method. This method takes a Python function as an argument and makes it accessible from the browser via the __Exposed__ object.

Here's an example of how you can expose a Python function and access it from the browser:

def hello_py():
    print("Hello from Python!")
            
Pequena.expose_functions(hello_py)

In the above example, the hello_py() function is exposed using Pequena.expose_functions(hello_py). This function can now be accessed from the browser using the __Exposed__.hello_py(). syntax.

__Exposed__.hello_py();

When executed, this JavaScript code will trigger the hello_py() function in Python, which will print the message "Hello from Python!".

By exposing functions from Python to the browser, you can leverage the power and capabilities of both Python and JavaScript in your Pequena web application. This allows you to seamlessly integrate backend functionality with frontend interactivity, creating a more dynamic and engaging user experience.

Please note that you can expose multiple functions from Python, and each function will be accessible through the __Exposed__ object using its respective name. Remember to ensure the functions you expose are designed to be safely executed in a browser context and consider any security implications when exposing sensitive functionality.

Settings.json

The settings.json file is a configuration file used by the Pequena framework to define and initialize default settings for the Pequena window. It allows you to specify various properties that define the initial appearance and behavior of the window when your Pequena application starts.

Here is an example of a settings.json file and its properties:

{
    "title": "Hello world!",
    "src": "./client/index.html",
    "width": 800,
    "height": 600,
    "x": "center",
    "y": "center",
    "min_x": 200,
    "min_y": 100,
    "resizable": true,
    "fullscreen": false,
    "hidden": false,
    "frameless": false,
    "easy_drag": true,
    "minimized": false,
    "on_top": false,
    "confirm_close": false,
    "background_color": "#FFFFFF",
    "transparent": false,
    "text_select": false,
    "zoomable": false,
    "draggable": false,
    "debug": false,
    "py_modules":[]
}

These are the default properties that can be changed in the settings.json file.

By customizing the values in the settings.json file, you can ensure that the Pequena window starts with the desired settings, providing a consistent and tailored user experience for your Pequena web application.

npm-scripts

To facilitate the development and deployment of your Pequena application, several useful scripts are available. These scripts streamline the process of starting the window, enabling hot-reloading for efficient development, and building the application into an executable bundle.

npm run start

To facilitate the development and deployment of your Pequena application, several useful scripts are available. These scripts streamline the process of starting the window, enabling hot-reloading for efficient development, and building the application into an executable bundle.

npm run start
npm run dev

Similar to npm run start, this script also starts the Pequena window. However, it provides an additional benefit for developers by enabling hot-reloading functionality. With hot-reloading, any changes made to the source code or frontend files in the client/ directory are automatically detected, triggering a reload of the Pequena window. This feature significantly speeds up the development process, allowing you to see the changes immediately without manually restarting the application.

npm run dev
npm run build

This script is used to build your Pequena application into an executable bundle. It packages all the necessary dependencies, source code, and frontend assets into a standalone executable file. This executable file can then be distributed and run on other machines without the need for a development environment or additional setup.

npm run build

Pequena Info

Changelog

[2.1.1] - 2015-10-06

Full Changelog

Implemented enhancements:
Fixed bugs: