Convert Figma logo to code with AI

flexxui logoflexx

Write desktop and web apps in pure Python

3,321
263
3,321
96

Top Related Projects

19,538

Interactive Data Visualization in the browser, from Python

17,941

Open source UI framework written in Python, running on Windows, Linux, macOS, Android and iOS

Fast data visualization and GUI tools for scientific / engineering applications

Quick Overview

Flexx is a Python-based framework for creating GUI applications that can be deployed as a web application. It allows developers to write their user interface code in Python and have it automatically translated into a web-based interface, making it easy to create cross-platform applications.

Pros

  • Cross-Platform: Flexx applications can be run on any platform that supports a modern web browser, making them highly portable.
  • Python-Centric: Flexx allows developers to use their existing Python skills to build GUI applications, reducing the need to learn additional languages or frameworks.
  • Reactive Design: Flexx uses a reactive programming model, which makes it easier to build responsive and dynamic user interfaces.
  • Deployment Flexibility: Flexx applications can be deployed as standalone web applications or embedded within existing web pages.

Cons

  • Limited Documentation: The Flexx documentation, while improving, can still be sparse in some areas, making it challenging for new users to get started.
  • Performance Concerns: Depending on the complexity of the application, Flexx may not perform as well as native desktop applications, especially for resource-intensive tasks.
  • Smaller Community: Compared to more popular Python GUI frameworks like PyQt or Tkinter, Flexx has a smaller community, which can make it harder to find support and resources.
  • Dependency on Web Technologies: Flexx relies heavily on web technologies like HTML, CSS, and JavaScript, which may be unfamiliar to some Python developers.

Code Examples

Here are a few examples of how to use Flexx:

  1. Creating a Simple Window:
from flexx import flx

class MyWindow(flx.Widget):
    def init(self):
        with flx.VBox():
            self.label = flx.Label(text='Hello, Flexx!')

if __name__ == '__main__':
    app = flx.App(MyWindow)
    app.launch('browser')
    flx.run()
  1. Adding Interactivity:
from flexx import flx

class Counter(flx.Widget):
    def init(self):
        with flx.VBox():
            self.label = flx.Label(text='Count: 0')
            with flx.HBox():
                self.btn_inc = flx.Button(text='+')
                self.btn_dec = flx.Button(text='-')

    @flx.reaction('btn_inc.pointer_click')
    def _inc_count(self, *events):
        self.label.set_text('Count: ' + str(int(self.label.text.split(': ')[1]) + 1))

    @flx.reaction('btn_dec.pointer_click')
    def _dec_count(self, *events):
        self.label.set_text('Count: ' + str(int(self.label.text.split(': ')[1]) - 1))

if __name__ == '__main__':
    app = flx.App(Counter)
    app.launch('browser')
    flx.run()
  1. Using Layouts:
from flexx import flx

class MyApp(flx.Widget):
    def init(self):
        with flx.HBox():
            self.btn1 = flx.Button(text='Button 1')
            self.btn2 = flx.Button(text='Button 2')
            with flx.VBox():
                self.btn3 = flx.Button(text='Button 3')
                self.btn4 = flx.Button(text='Button 4')

if __name__ == '__main__':
    app = flx.App(MyApp)
    app.launch('browser')
    flx.run()

Getting Started

To get started with Flexx, you can follow these steps:

  1. Install Flexx using pip:
pip install flexx
  1. Create a new Python file and import the necessary Flexx modules:
from flexx import flx
  1. Define your application by creating a subclass of flx.Widget or flx.App:
class MyApp(flx.

Competitor Comparisons

19,538

Interactive Data Visualization in the browser, from Python

Pros of Bokeh

  • Bokeh provides a wide range of built-in plot types and customization options, making it a powerful tool for data visualization.
  • Bokeh has a large and active community, with extensive documentation and a wealth of online resources.
  • Bokeh supports interactive and web-based visualizations, allowing users to create interactive dashboards and applications.

Cons of Bokeh

  • Bokeh can have a steeper learning curve compared to Flexx, especially for users new to data visualization.
  • Bokeh's dependency on the Bokeh server can add complexity to deployment and hosting scenarios.
  • Bokeh's performance may not be as optimal as Flexx for certain types of large-scale visualizations.

Code Comparison

Bokeh example:

from bokeh.plotting import figure, show, output_file

# Create a simple line plot
x = [1, 2, 3, 4, 5]
y = [6, 7, 2, 4, 5]

p = figure(title="Simple Line Plot")
p.line(x, y, line_width=2)

output_file("line_plot.html")
show(p)

Flexx example:

from flexx import ui, app

class LineChart(ui.Widget):
    def init(self):
        with ui.VBox():
            self.plot = ui.PlotWidget(
                title="Simple Line Plot",
                xlabel="X", ylabel="Y",
                grid=True, legend="top_left"
            )
            self.plot.add_line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], color="blue", line_width=2)

if __:
    app.launch(LineChart)
17,941

Open source UI framework written in Python, running on Windows, Linux, macOS, Android and iOS

Pros of Kivy

  • Kivy has a larger and more active community, with more resources and support available for developers.
  • Kivy has a wider range of built-in widgets and functionality, making it easier to build complex applications.
  • Kivy has better cross-platform support, with the ability to run on a variety of platforms including Windows, macOS, Linux, Android, and iOS.

Cons of Kivy

  • Kivy has a steeper learning curve, with a more complex API and more advanced concepts to understand.
  • Kivy can be slower and more resource-intensive than Flexx, especially for simple applications.
  • Kivy's development is primarily focused on mobile platforms, which may not be ideal for desktop applications.

Code Comparison

Kivy:

from kivy.app import App
from kivy.uix.button import Button

class MyApp(App):
    def build(self):
        return Button(text='Hello, Kivy!')

if __name__ == '__main__':
    MyApp().run()

Flexx:

from flexx import app, ui

class MyApp(ui.Widget):
    def init(self):
        self.button = ui.Button(text='Hello, Flexx!')

if __name__ == '__main__':
    app.launch(MyApp)
    app.run()

Fast data visualization and GUI tools for scientific / engineering applications

Pros of pyqtgraph

  • Extensive set of plotting and visualization tools for scientific and engineering applications
  • Tight integration with the Qt framework, providing a seamless user experience
  • Highly customizable and flexible, allowing for complex data visualizations

Cons of pyqtgraph

  • Dependency on the Qt framework, which may not be suitable for all use cases
  • Steeper learning curve compared to some other data visualization libraries
  • Limited support for web-based deployment, as it is primarily designed for desktop applications

Code Comparison

PyQtGraph:

import pyqtgraph as pg
from pyqtgraph.Qt import QtGui, QtCore

app = QtGui.QApplication([])
win = pg.GraphicsWindow(title="Basic plotting examples")
win.resize(1000,600)
win.setWindowTitle('pyqtgraph example')

p1 = win.addPlot(title="Basic plot")
p1.plot([1,2,3,4,5], [1,4,9,16,25], pen=(200,200,200), symbol='o', symbolSize=20, symbolBrush=(255,0,0))

Flexx:

from flexx import app, ui

class Example(ui.Widget):
    def init(self):
        with ui.VBox():
            self.label = ui.Label(text='Hello World!')
            self.button = ui.Button(text='Click me!')
            self.button.clicked.connect(self.on_click)

    def on_click(self):
        self.label.text = 'Button clicked!'

if __name__ == '__main__':
    app.launch(Example)
    app.run()

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Flexx

CI Documentation Status PyPI version

Want to stay up-to-date about (changes to) Flexx? Subscribe to the NEWS issue.

Introduction

Flexx is a pure Python toolkit for creating graphical user interfaces (GUI's), that uses web technology for its rendering. Apps are written purely in Python; The PScript transpiler generates the necessary JavaScript on the fly.

You can use Flexx to create (cross platform) desktop applications, web applications, and export an app to a standalone HTML document. It also works in the Jupyter notebook.

The docs are on Readthedocs. the code is on Github.

Example

Click the image below for an interactive example:

demo

Motivation

The primary motivation for Flexx is the undeniable fact that the web (i.e. browser technology) has become an increasingly popular method for delivering applications to users, also for (interactive) scientific content.

The purpose of Flexx is to provide a single application framework to create desktop applications, web apps, and (hopefully someday) mobile apps. By making use of browser technology, the library itself can be relatively small and pure Python, making it widely available and easy to use.

A word of caution

Flexx is very versatile and can be used in different ways. It also makes it easy to mix Python that runs on the server and Python that runs in the browser. This is a powerful feature but this also makes it easy to create code that becomes difficult to maintain. You, the developer, must ensure that Python and PScript code are clearly separated.

Installation

Flexx requires Python 3.5+ and also works on pypy. Further, it depends on:

  • the Tornado library (pure Python).
  • the PScript library (a pure Python flexxui project).
  • the Webruntime library (a pure Python flexxui project).
  • the Dialite library (a pure Python flexxui project).

To install the latest release (and dependencies), use either of:

# Install latest release
pip install flexx

# Install latest from Github
pip install -U https://github.com/flexxui/flexx/archive/master.zip

Or get the bleeding edge with:

  • pip install https://github.com/flexxui/flexx/archive/master.zip

Supported browsers

Flexx aims to support all modern browsers, including Firefox, Chrome and Edge. Internet Explorer version 10 and up should work, but some things may be flaky.

For running desktop apps, it is needed to have Firefox or NW.js installed.

License

Flexx makes use of the liberal 2-clause BSD license. See LICENSE for details.

NPM DownloadsLast 30 Days