Skip to main content

A small example package

Project description

PyApplicationFramework

Introduction

The PyApplicationFramework is a set of library wrappers related to application development in Python. This framework allows developers to write a GUI application more simply, with a programming paradigm similar to SwiftUI. The declarative syntax of User Interface markup, inspired by SwiftUI, is one of the critical functionalities in this project.

A Basic "Hello, World!" Code with Explanation

import wx

class HelloWorldFrame(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent)
        self.SetTitle("HelloWorldWindow")
        panel = wx.Panel(self)
        sizer = wx.BoxSizer(wx.VERTICAL)
        text = wx.StaticText(panel, label="Hello, World!")
        sizer.Add(text)
        panel.SetSizer(sizer)

if __name__ == "__main__":
    app = wx.App()
    frame = HelloWorldFrame(None)
    frame.Show()
    app.MainLoop()

The code above creates a simple window with an text "Hello, World!" at the top-left corner of it as shown as the image below: helloworld

The code below written with PyApplicationFramework is a code which shows the same result:

import wx
from pyappframework.ui import Window
from pyappframework.ui.controls import Panel, StaticText

class HelloWorldWindow(Window):
    def __init__(self, *args, **kw):
        super().__init__(*args, **kw)
        self.SetTitle("HelloWorldWindow")

    def body(self) -> Panel:
        return (
            Panel(wx.BoxSizer(wx.VERTICAL))
                .body [[
                StaticText(label="Hello, World!")
            ]]
        )

if __name__ == "__main__":
    app = wx.App()
    frame = HelloWorldWindow()
    frame.Show()
    app.MainLoop()

As you can see, you can recognize the hierarchical structures of the UI, without using external markup language (like XRC), which is still needed to instantiate every single control defined inside of it.

Mutable Values

Mutations of a variable or an attribute defined by class Mutable[]() can be observed by adding an event handler or synchronized to one or more attributes of the views or controls.

import wx
import pyappframework as pyaf
from pyappframework import ui
from pyappframework.ui import controls as ctl

class MutableWindow(ui.Window):
    def __init__(self, *args, **kw):
        self.textbox_value = pyaf.Mutable[str]("Initial value")
        super().__init__(*args, **kw)
        self.SetTitle("MutableWindow")

    def body(self) -> ctl.Panel:
        return (
            ctl.ScrollablePanel(wx.BoxSizer(wx.VERTICAL))
            .body [[
                ctl.StaticText(label=self.textbox_value)
                    .sizer(wx.SizerFlags().Border(wx.TOP | wx.LEFT)),
                ctl.TextCtrl(value=self.textbox_value)
                    .sizer(proportion=0, flag=wx.EXPAND),
                ctl.SearchCtrl(value=self.textbox_value)
                    .sizer(proportion=0, flag=wx.EXPAND),
            ]]
        )

if __name__ == "__main__":
    app = wx.App()
    frame = MutableWindow()
    frame.Show()
    app.MainLoop()

mutable

Default Controls

  • Button
  • CheckBox
  • Choice
  • CollapsiblePanel
  • Control
  • DataViewCtrl
  • Gauge
  • InfoBar
  • ListBox
  • Notebook
  • Panel
  • Plot
  • ScrollablePanel
  • SearchCtrl
  • SplitterWindow
  • StaticBitmap
  • StaticBox
  • StaticLine
  • StaticText
  • TextCtrl
  • ToolBar
  • TreeCtrl
  • WebView

Controls with Additional Requirements

  • GLCanvas (PyOpenGL)
  • Plot (matplotlib)

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

pyappframework-0.0.dev0.tar.gz (216.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyappframework-0.0.dev0-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file pyappframework-0.0.dev0.tar.gz.

File metadata

  • Download URL: pyappframework-0.0.dev0.tar.gz
  • Upload date:
  • Size: 216.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for pyappframework-0.0.dev0.tar.gz
Algorithm Hash digest
SHA256 05f167456ba69a4825c38f3dd939578d80a49ae1d1861b214a587018b113f7d1
MD5 de4d275ce5430bfc7b56c6d9326f5fe0
BLAKE2b-256 112d8f40265bc8a5606dc6edb798899c866bb2f0faa95fd995d54bb493a670f9

See more details on using hashes here.

File details

Details for the file pyappframework-0.0.dev0-py3-none-any.whl.

File metadata

File hashes

Hashes for pyappframework-0.0.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 3100e80ae8045a8f5a64a76444475aa5b7ac403bc8bf86677fcc9f0d3698d840
MD5 1016dbb747ea1c0f14f33084451cf69e
BLAKE2b-256 057703623da14ccdf5adf3593a5508e0728acb7fa40642f691211615f280eb16

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page