A Python native, OS native GUI toolkit.

Related tags

GUI Development toga
Overview
https://beeware.org/project/projects/libraries/toga/toga.png

Toga

Python Versions Project version Project status License Build Status Codecov Gitter chat room

A Python native, OS native GUI toolkit.

Prerequisites

Minimum requirements

  • Toga requires Python 3. Python 2 is not supported.
  • If you're on macOS, you need to be on 10.10 (Yosemite) or newer.
  • If you're on Linux, you need to have GTK+ 3.10 or later. This is the version that ships starting with Ubuntu 14.04 and Fedora 20. You also need to install the Python 3 bindings and development files for GTK+.
    • Ubuntu 16.04 / Debian 9 sudo apt-get install python3-dev python3-gi python3-gi-cairo libgirepository1.0-dev libcairo2-dev libwebkitgtk-3.0-0 gir1.2-webkit2-3.0
    • Ubuntu 18.04 / Debian 10 sudo apt-get install python3-dev python3-gi python3-gi-cairo libgirepository1.0-dev libcairo2-dev libwebkitgtk-4.0-37 gir1.2-webkit2-4.0
    • Fedora sudo dnf install pygobject3 python3-gobject python3-cairo-devel cairo-gobject-devel gobject-introspection-devel pywebkitgtk
    • Arch / Manjaro sudo pacman -Syu git pkgconf cairo python-cairo pango gobject-introspection gobject-introspection-runtime python-gobject webkit2gtk
  • We're working on Windows support, but not all features and widgets are supported. At a minimum, you'll need Python 3 and .NET Framework 4. This has been tested on Windows 10, but should work on 7 and 8. Pull requests, help and corrections are most welcome.

Quickstart

To get a demonstration of the capabilities of Toga, run the following:

$ pip install --pre toga-demo
$ toga-demo

This will pop up a GUI window with some sample widgets.

Documentation

Documentation for Toga can be found on Read The Docs.

Community

Toga is part of the BeeWare suite. You can talk to the community through:

Contributing

If you'd like to contribute to Toga development, our guide for first time contributors will help you get started.

If you experience problems with Toga, log them on GitHub. If you want to contribute code, please fork the code and submit a pull request.

Issues
  • Add initial Qt backend implementation

    Add initial Qt backend implementation

    Basics only. Qt import included in lib folder. this is a startup for all developers. work in progress

    PR Checklist:

    • [x] All new features have been tested
    • [ ] All new features have been documented
    • [x] I have read the CONTRIBUTING.md file
    • [x] I will abide by the code of conduct
    opened by Ksengine 43
  • Convert Canvas Widget to Use a Drawing Stack

    Convert Canvas Widget to Use a Drawing Stack

    In #319 we discussed that it was desired to remove the callbacks created by using an on_draw handler, and instead push drawing commands to a stack to be drawn with.

    PR Checklist:

    • [X] All new features have been tested
    • [X] All new features have been documented
    • [X] I have read the CONTRIBUTING.md file
    • [X] I will abide by the code of conduct

    Current status: fully implemented

    • [X] Fix tests
    • [X] Further testing with other contexts besides the default one
    opened by danyeaw 36
  • "TypeError: 'ObjCInstance' object is not callable" on macOS High Sierra

    In High Sierra (macOS 10.13), I am unable to use Toga or Toga-demo due to a TypeError. I was able to duplicate this on a fresh install of High Sierra in a VM; when I installed Toga and Toga-demo on a fresh install of Sierra (10.12), Toga and Toga-demo worked with no issues.

    This has similar symptoms as issue https://github.com/pybee/toga/issues/154, but downgrading Rubicon has not solved the problem.

    Details

    Python Installation

    $ uname -a
    Darwin Andrews-Mac.local 17.0.0 Darwin Kernel Version 17.0.0: Thu Aug 24 21:48:19 PDT 2017; root:xnu-4570.1.46~2/RELEASE_X86_64 x86_64
    $
    $ gcc --version
    Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
    Apple LLVM version 9.0.0 (clang-900.0.37)
    Target: x86_64-apple-darwin17.0.0
    Thread model: posix
    InstalledDir: /Library/Developer/CommandLineTools/usr/bin
    $
    $ CFLAGS="-I$(brew --prefix openssl)/include -O3" \
    LDFLAGS="-L$(brew --prefix openssl)/lib" \
    env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install -v 3.6.3
    ...
    Installed Python-3.6.3 to /Users/ame/.pyenv/versions/3.6.3
    $ 
    $ pyenv shell 3.6.3
    $
    $ python -V -V
    Python 3.6.3 (default, Oct  9 2017, 17:43:29) 
    [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)]
    

    Virtualenv

    $ python -m venv .venv
    $
    $ source .venv/bin/activate
    $
    $ pip install toga toga-demo
    Collecting toga
      Downloading toga-0.2.15-py3-none-any.whl
    Collecting toga-demo
      Downloading toga_demo-0.2.15-py3-none-any.whl
    Collecting toga-cocoa; sys_platform == "darwin" (from toga)
      Downloading toga_cocoa-0.2.15-py3-none-any.whl
    Collecting toga-core>=0.2.15 (from toga-cocoa; sys_platform == "darwin"->toga)
      Downloading toga_core-0.2.15-py3-none-any.whl (413kB)
        100% |████████████████████████████████| 419kB 2.6MB/s 
    Collecting rubicon-objc>=0.2.8 (from toga-cocoa; sys_platform == "darwin"->toga)
      Downloading rubicon_objc-0.2.8-py3-none-any.whl
    Collecting colosseum>=0.1.6 (from toga-core>=0.2.15->toga-cocoa; sys_platform == "darwin"->toga)
      Downloading colosseum-0.1.6-py3-none-any.whl
    Installing collected packages: colosseum, toga-core, rubicon-objc, toga-cocoa, toga, toga-demo
    Successfully installed colosseum-0.1.6 rubicon-objc-0.2.8 toga-0.2.15 toga-cocoa-0.2.15 toga-core-0.2.15 toga-demo-0.2.15
    

    First Attempt

    $ toga-demo
    Traceback (most recent call last):
      File "/Users/ame/workspace/org.elgert/toga/.venv/bin/toga-demo", line 11, in <module>
        sys.exit(run())
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_demo/__main__.py", line 5, in run
        main().main_loop()
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/app.py", line 167, in main_loop
        self._startup()
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/app.py", line 95, in _startup
        self._impl = NSApplication.sharedApplication()
    TypeError: 'ObjCInstance' object is not callable
    $ 
    $ python
    Python 3.6.3 (default, Oct  9 2017, 17:43:29) 
    [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from rubicon.objc import *                        
    >>> NSBundle = ObjCClass('NSBundle')           
    >>> NSBundle.mainBundle()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: 'ObjCInstance' object is not callable
    >>> exit()
    

    Downgrade Rubicon

    Rubicon-objc==0.2.7

    $ pip install rubicon-objc==0.2.7
    Collecting rubicon-objc==0.2.7
      Downloading rubicon_objc-0.2.7-py3-none-any.whl
    Installing collected packages: rubicon-objc
      Found existing installation: rubicon-objc 0.2.8
        Uninstalling rubicon-objc-0.2.8:
          Successfully uninstalled rubicon-objc-0.2.8
    Successfully installed rubicon-objc-0.2.7
    $
    $ toga-demo
    Traceback (most recent call last):
      File "/Users/ame/workspace/org.elgert/toga/.venv/bin/toga-demo", line 11, in <module>
        sys.exit(run())
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_demo/__main__.py", line 5, in run
        main().main_loop()
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/app.py", line 167, in main_loop
        self._startup()
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/app.py", line 95, in _startup
        self._impl = NSApplication.sharedApplication()
    TypeError: 'ObjCInstance' object is not callable
    

    Rubicon-objc==0.2.6

    $ pip install rubicon-objc==0.2.6
    Collecting rubicon-objc==0.2.6
      Downloading rubicon_objc-0.2.6-py3-none-any.whl
    Installing collected packages: rubicon-objc
      Found existing installation: rubicon-objc 0.2.7
        Uninstalling rubicon-objc-0.2.7:
          Successfully uninstalled rubicon-objc-0.2.7
    Successfully installed rubicon-objc-0.2.6
    $
    $ toga-demo
    Traceback (most recent call last):
      File "/Users/ame/workspace/org.elgert/toga/.venv/bin/toga-demo", line 7, in <module>
        from toga_demo.__main__ import run
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_demo/__main__.py", line 2, in <module>
        from toga_demo.app import main
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_demo/app.py", line 4, in <module>
        import toga
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga/__init__.py", line 114, in <module>
        set_platform()
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga/__init__.py", line 86, in set_platform
        local_vars['platform'] = importlib.import_module(module_name)
      File "/Users/ame/.pyenv/versions/3.6.3/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/__init__.py", line 2, in <module>
        from .app import *
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/app.py", line 8, in <module>
        from .command import Command, Group
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/command.py", line 3, in <module>
        from .widgets.icon import Icon
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/widgets/icon.py", line 4, in <module>
        from ..libs import NSImage
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/libs/__init__.py", line 1, in <module>
        from .appkit import *
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/libs/appkit.py", line 232, in <module>
        NSColor.declare_class_property('alternateSelectedControlColor')
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/rubicon/objc/objc.py", line 1300, in __getattr__
        raise AttributeError('%s.%s %s has no attribute %s' % (type(self).__module__, type(self).__qualname__, self.objc_class.name, name))
    AttributeError: rubicon.objc.objc.ObjCClass NSColor has no attribute declare_class_property
    

    Rubicon-objc==0.2.4

    $ pip install rubicon-objc==0.2.4
    Collecting rubicon-objc==0.2.4
      Downloading rubicon_objc-0.2.4-py3-none-any.whl
    Installing collected packages: rubicon-objc
      Found existing installation: rubicon-objc 0.2.6
        Uninstalling rubicon-objc-0.2.6:
          Successfully uninstalled rubicon-objc-0.2.6
    Successfully installed rubicon-objc-0.2.4
    $
    $ toga-demo
    Traceback (most recent call last):
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/rubicon/objc/objc.py", line 1274, in __getattr__
        return self.__dict__[name]
    KeyError: 'declare_class_property'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/Users/ame/workspace/org.elgert/toga/.venv/bin/toga-demo", line 7, in <module>
        from toga_demo.__main__ import run
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_demo/__main__.py", line 2, in <module>
        from toga_demo.app import main
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_demo/app.py", line 4, in <module>
        import toga
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga/__init__.py", line 114, in <module>
        set_platform()
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga/__init__.py", line 86, in set_platform
        local_vars['platform'] = importlib.import_module(module_name)
      File "/Users/ame/.pyenv/versions/3.6.3/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/__init__.py", line 2, in <module>
        from .app import *
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/app.py", line 8, in <module>
        from .command import Command, Group
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/command.py", line 3, in <module>
        from .widgets.icon import Icon
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/widgets/icon.py", line 4, in <module>
        from ..libs import NSImage
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/libs/__init__.py", line 1, in <module>
        from .appkit import *
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/libs/appkit.py", line 232, in <module>
        NSColor.declare_class_property('alternateSelectedControlColor')
      File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/rubicon/objc/objc.py", line 1277, in __getattr__
        raise AttributeError('ObjCClass %s has no attribute %s' % (self.name, name))
    AttributeError: ObjCClass NSColor has no attribute declare_class_property
    
    opened by elgertam 23
  • On Linux, window contents are rendered behind a menubar

    On Linux, window contents are rendered behind a menubar

    But only if the menubar wasn't defined in the application code. Here's a slightly modified example code I'm running:

    import toga
    
    def build(app):
        box = toga.Box()
        button = toga.Button('Hello world', on_press=lambda _: print("hello"))
        box.add(button)
        return box
    
    if __name__ == '__main__':
        app = toga.App('First App', 'org.pybee.sample', startup=build)
        app.main_loop()
    

    Here's how it looks like to me:

    image

    Note that the button is behind the menubar (although no menubar was requested in the code). When I click on the menubar (including the Application or Help menu items), the button is being pressed instead.

    I've tried this with a few GTK themes, including Arc-OSX-dark, Mint-X, Redmond and Adwaita, and in every case it behaves this way.

    bug up-for-grabs 
    opened by notpushkin 22
  • Issue running tutorials 1 - 4

    Issue running tutorials 1 - 4

    When I try running the tutorials from the master branch on Ubuntu I get the following error: from toga.style.pack import * ImportError: No module named 'toga.style'

    opened by MRFaria 21
  • Icons

    Icons

    Moved the icons file resolution to the backend for cocoa and winforms.

    Now, backends can get their proprietary file format ('.icns' for cocoa and '.ico') or create icons from '.bmp' or '.png' files. (Although I didn't find a bmp icon file, so I only tested ico and png on winforms.) I also adjusted tests because now core/icon doesn't automatically add '.icns' to the icon filename.

    If this is acceptable, we will need to test and update other backends, too.

    There is an issue about lack of icons in windows in briefcase.

    PR Checklist:

    • [ ] All new features have been tested
    • [x] All new features have been documented
    • [x] I have read the CONTRIBUTING.md file
    • [x] I will abide by the code of conduct
    opened by obulat 20
  • [WIP] Get tutorial 2 working with the winforms backend

    [WIP] Get tutorial 2 working with the winforms backend

    In order to learn some of the internals of toga I've been working at trying to get the winforms backend working for tutorial 2. This involves implementing some new components for the winforms backend:

    • SplitContainer (partially done)
    • Table (done)
    • Command (not started)
    opened by clokep 20
  • Recommend to use pip to install pygobject

    Recommend to use pip to install pygobject

    Recently, pygobject can be installed from pip. So this PR recommends the user to install pygobject through pip.

    It also deletes redundant code that handles different operating systems which was sometimes found to be incorrect.

    Fixes https://github.com/pybee/toga/issues/371

    I am really not sure if I missed any sensitive branches that just needed to be there, I will need some help on that.

    PR Checklist:

    • [x] All new features have been tested
    • [x] All new features have been documented
    • [x] I have read the CONTRIBUTING.md file
    • [x] I will abide by the code of conduct
    opened by SanketDG 20
  • Add TextInput validator

    Add TextInput validator

    Initial implementation of a validator in toga.TextInput in Windows. One can add a validator parameter to the toga.TextInput constructor in order to validate the value. the validator callable should return None if the value is valid and an error message if it is not.

    validator

    closes #909

    PR Checklist:

    • [X] All new features have been tested
    • [X] All new features have been documented
    • [X] I have read the CONTRIBUTING.md file
    • [X] I will abide by the code of conduct
    opened by saroad2 18
  • Use a Travertino-based interface for style operations.

    Use a Travertino-based interface for style operations.

    This PR removes the dependency on Colosseum, in favour of Travertino. Travertino contains only the primitive datatypes and operations for styles, which allows Toga to include a built-in simple style engine (called, for want of a better name, Flow).

    Colosseum will remain a fully CSS compliant style engine, and will extend the interfaces and types defined by Travertino. Travertino and Colosseum will be "Toga independent", dealing purely with laying out boxes on a page. The process of applying that layout to an actual widget is the role of a new class called an "Applicator".

    The "Flow" engine reduces layout to "boxes of boxes", where every box is a row of other boxes, or column of other boxes. Each box can have an intrinsic width and height (either "exactly X", or "at least X"), and may optionally specify an exact width or height as a style. Boxes can also specify a "flex" amount; all the flexes in a row/column are added, and after minimum space allocations have been met, any extra is allocated in proportion to the flex amounts. If a row/column requires more space than is available/allocated, the box will be expanded to the minimum possible size.

    This patch makes one other notable change: Every widget is now expected to have a native object. This fixes the unusual handling of Box objects, which were widgets that didn't have a native object. As well as simplifying code, this has the added benefit of ensuring that methods like "set background color" will always have a widget that is appropriately scoped. The name container has been recycled to mean the "top level widget" (which is what it was really being used for anyway).

    work-in-progress 
    opened by freakboy3742 18
  • Dynamic font loading

    Dynamic font loading

    This PR allows us to include a font file to a Toga project and use the font in the Toga project without needing to install the font on the system.

    The PR includes 3 free fonts from here: https://www.1001freefonts.com/d/4555/endor.zip (ENDOR___.ttf) https://use.fontawesome.com/releases/v5.15.4/fontawesome-free-5.15.4-desktop.zip (Font Awesome 5 Free-Solid-900.otf) https://fonts.google.com/specimen/Roboto (Roboto*.ttf)

    Dynamic font loading should also work on iOS and macOS: https://marco.org/2012/12/21/ios-dynamic-font-loading https://stackoverflow.com/questions/2703085/how-can-you-load-a-font-ttf-from-a-file-using-core-text But the implementation for these platforms are not in this PR. Maybe, someone more savvy with iOS and macOS can add this.

    PR Checklist:

    • [x] All new features have been tested
    • [x] All new features have been documented
    • [x] I have read the CONTRIBUTING.md file
    • [x] I will abide by the code of conduct

    Winforms

    Android

    opened by t-arn 10
  • WIP for further Android Canvas changes

    WIP for further Android Canvas changes

    Summary

    • Add newPath() to Android canvas

    Testing done for newPath

    With this code:

    https://github.com/paulproteus/toganvas/blob/e0094fcc0d8afa227a522eb5dd6893e6326d616e/toganvas/src/toganvas/app.py#L341

    macOS:

    image

    Android before the change:

    image

    Android after the change:

    image

    PR Checklist:

    • [x] All new features have been tested
    • [x] All new features have been documented
    • [x] I have read the CONTRIBUTING.md file
    • [x] I will abide by the code of conduct
    opened by paulproteus 0
  • Load images from ByteArray

    Load images from ByteArray

    I'm trying to send a png image via socket as a ByteArray and then display it in the ImageView. However, it's only possible to load already saved image via path. And because I'm streaming the images (at around 10 FPS), I don't think I have time to save the image. Regardless, this seems like a pretty inconvenient solution, saving the image only to load it right away.

    I want to create a new Image using ByteArray as input.

    enhancement up-for-grabs 
    opened by Insectslayer 1
  • Window position not working

    Window position not working

    Describe the bug Setting the position of toga.MainWindow doesn't seem to have any effect, both in windows and linux.

    To Reproduce

    #sample.py
    import toga
    
    class Sample(toga.App):
        def startup(self):
            self.main_window = toga.MainWindow(title=self.name, position=(300, 200))
    
            self.main_window.content = toga.Box()
            self.main_window.show()
    
    def main():
        return Sample('Sample', 'org.beeware.sample')
    
    
    if __name__ == '__main__':
        main().main_loop()
    

    python -m sample

    Expected behavior The window is displayed at the specified position.

    Actual Result In linux (gtk), it is positioned at (0, 0). In windows, it is positioned at (100, 100), but sometimes also randomly in different positions.

    Environment:

    • Operating System: Debian 10 and Windows 10
    • Python version: 3.8+
    • Software versions:
      • Briefcase: 0.3.5
      • Toga: 0.3.0.dev28
    bug linux windows 
    opened by micyoshua 1
  • Declare `interface` and `impl` attributes as weak properties

    Declare `interface` and `impl` attributes as weak properties

    This PR declares weak properties interface and impl for all Objective-C classes that need references to the interface and implementation layers, respectively.

    This resolves an issue with reference cycles which were previously created on the Objective-C side (interface -> _impl -> native -> _impl -> native ...) which cannot be detected or cleaned up by Python's garbage collection and therefore result in memory leaks.

    This is typically not a problem for toga's example apps since widgets are often created once and then kept alive throughout the lifetime of the app. However, there can be cases where we want to destroy widgets and free any associated memory, for example document-based apps after closing a document, setup dialogs or temporary windows.

    This PR depends on https://github.com/beeware/rubicon-objc/pull/214.

    PR Checklist:

    • [x] All new features have been tested
    • [x] All new features have been documented
    • [x] I have read the CONTRIBUTING.md file
    • [x] I will abide by the code of conduct
    opened by SamSchott 4
  • Why does background color disapper?

    Why does background color disapper?

    Discussed in https://github.com/beeware/toga/discussions/1314

    Originally posted by AlexanderDev06 August 1, 2021 I have a box and that works until I add a button. Please help!!

    def startup(self):
    
            #Boxes
            main_box = toga.Box(style=Pack(direction=COLUMN))
            logoBox = toga.Box(style=Pack(width=SCREEN_WIDTH, height=100))
            buttonBox = toga.Box(style=Pack(width=SCREEN_WIDTH, height=100, background_color='#212121'))
            testBox = toga.Box(style=Pack(width=SCREEN_WIDTH, height=100))
            #Images
            logoImg = toga.ImageView(image=logoImageFile)
            buttonBoxImg = toga.ImageView(image=buttonBoxImageFile)
    
            #Buttons
            button = toga.Button('Click Me', on_press=self.say_hello)
    
    
            #Add Items
            main_box.add(logoBox)
            main_box.add(buttonBox)
            logoBox.add(logoImg)
            buttonBox.add(button)
    
            self.main_window = toga.MainWindow(title=self.formal_name, size=(SCREEN_WIDTH, SCREEN_HEIGHT))
            self.main_window.content = main_box
            self.main_window.content.refresh()
            self.main_window.show()
    

    Another option that would help my work, is being able to stack a button ontop a image

    opened by AlexanderDev06 0
  • implementations should use interface values (vs raw)

    implementations should use interface values (vs raw)

    Describe the bug The code below explodes on iOS and Android (Mac/cocoa must do some casting?).

    It works if the integers are cast via str().

            self.interval_input = toga.TextInput(
                placeholder=2, readonly=True, initial=2
            )
    

    To Reproduce Steps to reproduce the behavior:

    1. Create an app with the code above
    2. briefcase run iOS or briefcase run android
    3. App will crash

    Expected behavior The code above should work.

    Screenshots n/a

    Environment:

    • Operating System: Mac 11.4
    • Python version: 3.8
    • Software versions: briefcase 0.3.5 toga 0.3.0.dev27 toga-cocoa 0.3.0.dev27 toga-core 0.3.0.dev27
    bug 
    opened by aerickson 1
  • Image() path string casting

    Image() path string casting

    Is your feature request related to a problem? Please describe. The Image class (from images.py) does not expect any type for parameter path, this means that pathlib paths, used elsewhere through Beeware does not nicely pass without wrapping said path in a str(pathlib.Path), which sucks and is too many brackets. The rest of the Image class goes on assuming that path is a string, e.g. calling path.startswith('http://'), a string method.

    Describe the solution you'd like Simply update Image's init line to be def __init__(self, path: str): to add automatic casting for os.path objects and pathlib objects alike. You'd really expect a parameter named path to take path objects.

    Describe alternatives you've considered The alternative would be a bigger rework to Image to check the type of path and to convert it accordingly but that's silly when the above does the same thing. Alternative 2 is force users to cast with str() every time but I can't imagine why anyone would want that.

    enhancement 
    opened by CDWimmer 0
  • On Android, the application complains about `AttributeError: 'TextInput' object has no attribute '_validators'`

    On Android, the application complains about `AttributeError: 'TextInput' object has no attribute '_validators'`

    Describe the bug

    I use a field = toga.TextInput() and then use field.validate() inside the on_change callback method, in order to react accordingly. The application seems to work without problems, however when I check the logs via adb logcat -s MainActivity:* stdio:* Python:* then I see the following errors:

    06-25 00:41:56.036 28676 28676 D Python  : Native invocation 511594544624 :: beforeTextChanged
    06-25 00:41:56.036 28676 28676 D Python  : Native invocation done.
    06-25 00:41:56.036 28676 28676 D Python  : Native invocation 511594544624 :: onTextChanged
    06-25 00:41:56.037 28676 28676 D Python  : Native invocation done.
    06-25 00:41:56.037 28676 28676 D Python  : Native invocation 511594544624 :: afterTextChanged
    06-25 00:41:56.037 28676 28676 E Python  : Traceback (most recent call last):
    06-25 00:41:56.037 28676 28676 E Python  :   File "/data/user/0/what.ever.acc_companion/files/python/user_code/app_packages/rubicon/java/api.py", line 45, in dispatch
    06-25 00:41:56.037 28676 28676 E Python  :     val = getattr(pyinstance, method)(*args)
    06-25 00:41:56.037 28676 28676 E Python  :   File "/data/user/0/what.ever.acc_companion/files/python/user_code/app_packages/toga_android/widgets/textinput.py", line 24, in afterTextChanged
    06-25 00:41:56.037 28676 28676 E Python  :     self.interface.on_change(widget=self.interface)
    06-25 00:41:56.037 28676 28676 E Python  :   File "/data/user/0/what.ever.acc_companion/files/python/user_code/app_packages/toga/handlers.py", line 55, in _handler
    06-25 00:41:56.037 28676 28676 E Python  :     result = handler(interface, *args, **kwargs)
    06-25 00:41:56.037 28676 28676 E Python  :   File "/data/user/0/what.ever.acc_companion/files/python/user_code/app/acc_companion/utils.py", line 34, in wrapper
    06-25 00:41:56.037 28676 28676 E Python  :     return func(*args, **kwargs)
    06-25 00:41:56.038 28676 28676 E Python  :   File "/data/user/0/what.ever.acc_companion/files/python/user_code/app/acc_companion/app.py", line 109, in energy_changed
    06-25 00:41:56.038 28676 28676 E Python  :     if field.validate():
    06-25 00:41:56.038 28676 28676 E Python  :   File "/data/user/0/what.ever.acc_companion/files/python/user_code/app_packages/toga/widgets/textinput.py", line 172, in validate
    06-25 00:41:56.038 28676 28676 E Python  :     for validator in self.validators:
    06-25 00:41:56.038 28676 28676 E Python  :   File "/data/user/0/what.ever.acc_companion/files/python/user_code/app_packages/toga/widgets/textinput.py", line 132, in validators
    06-25 00:41:56.038 28676 28676 E Python  :     return self._validators
    06-25 00:41:56.038 28676 28676 E Python  : AttributeError: 'TextInput' object has no attribute '_validators'
    

    The problem seems to be that the on_change callback method is called before the validators are set. I suspect that this on_change callback happens as part of self._create() but I don't see why that would happen or why it is necessary (on Linux I don't observe this behavior); hence I suspect it's a bug.

    To Reproduce Steps to reproduce the behavior:

    1. Create a text input field field = toga.TextInput(on_change=my_callback, validators=['x'.__eq__]) where my_callback is defined as: def my_callback(field): print(field.validate()).
    2. The crucial point here is that field.validate() is called inside the on_change callback (which seems to be invoked when the object is created).

    Expected behavior

    The on_change callback should not be called when the text input object is created.

    Environment:

    • Operating System: Ubuntu 20.04 / Android 10
    • Python version: 3.9
    • Software versions:
    arrow==1.1.0
    binaryornot==0.4.4
    briefcase==0.3.5
    certifi==2021.5.30
    chardet==4.0.0
    click==8.0.1
    cookiecutter==1.7.3
    gbulb==0.6.1
    gitdb==4.0.7
    GitPython==3.1.17
    idna==2.10
    Jinja2==2.11.3
    jinja2-time==0.2.0
    MarkupSafe==2.0.1
    mypy-extensions==0.4.3
    poyo==0.5.0
    pycairo==1.20.1
    PyGObject==3.40.1
    python-dateutil==2.8.1
    python-slugify==5.0.2
    requests==2.25.1
    six==1.16.0
    smmap==4.0.0
    text-unidecode==1.3
    toga-core==0.3.0.dev27
    toga-gtk==0.3.0.dev27
    toml==0.10.2
    travertino==0.1.3
    typed-ast==1.4.1
    typing-extensions==3.7.4.2
    urllib3==1.26.5
    
    bug 
    opened by Dominik1123 2
  • Label's updated text won't be displayed on Android unless

    Label's updated text won't be displayed on Android unless "refresh()" gets called explicitly

    Describe the bug

    I create a label = toga.Label() whose text I then modify dynamically (based on user input). I do this via label.text = '...'. This works on Linux however the updated text won't show on Android. If I explicitly call label.refresh() then the updated text also shows on Android.

    To Reproduce Steps to reproduce the behavior:

    1. Create a text = toga.TextInput() field and a label = toga.Label(). In the text input's on_change method, just copy the current value of the field to the label via label.text = text.value.
    2. When entering text, it won't show on the label on Android unless label.refresh() is called explicitly.

    Expected behavior

    The updated text should show automatically.

    Environment:

    • Operating System: Ubuntu 20.04 / Android 10
    • Python version: 3.9
    • Software versions:
    arrow==1.1.0
    binaryornot==0.4.4
    briefcase==0.3.5
    certifi==2021.5.30
    chardet==4.0.0
    click==8.0.1
    cookiecutter==1.7.3
    gbulb==0.6.1
    gitdb==4.0.7
    GitPython==3.1.17
    idna==2.10
    Jinja2==2.11.3
    jinja2-time==0.2.0
    MarkupSafe==2.0.1
    mypy-extensions==0.4.3
    poyo==0.5.0
    pycairo==1.20.1
    PyGObject==3.40.1
    python-dateutil==2.8.1
    python-slugify==5.0.2
    requests==2.25.1
    six==1.16.0
    smmap==4.0.0
    text-unidecode==1.3
    toga-core==0.3.0.dev27
    toga-gtk==0.3.0.dev27
    toml==0.10.2
    travertino==0.1.3
    typed-ast==1.4.1
    typing-extensions==3.7.4.2
    urllib3==1.26.5
    
    bug 
    opened by Dominik1123 3
Owner
BeeWare
Write Python. Deploy everywhere.
BeeWare
A GUI for designing Python GUI's for PySimpleGUI.

SimpleGUIBuilder A GUI for designing Python GUI's for PySimpleGUI. Installation There is none :) just download the file from a release and run it. Don

Miguel Martins 52 Nov 23, 2021
Learn to build a Python Desktop GUI app using pywebview, Python, JavaScript, HTML, & CSS.

Python Desktop App Learn how to make a desktop GUI application using Python, JavaScript, HTML, & CSS all thanks to pywebview. pywebview is essentially

Coding For Entrepreneurs 34 Oct 8, 2021
A little Python library for making simple Electron-like HTML/JS GUI apps

Eel Eel is a little Python library for making simple Electron-like offline HTML/JS GUI apps, with full access to Python capabilities and libraries. Ee

Chris Knott 4.7k Dec 1, 2021
Turn (almost) any Python command line program into a full GUI application with one line

Gooey Turn (almost) any Python 2 or 3 Console Program into a GUI application with one line Support this project Table of Contents Gooey Table of conte

Chris 15.1k Dec 2, 2021
Build GUI for your Python program with JavaScript, HTML, and CSS

https://pywebview.flowrl.com pywebview is a lightweight cross-platform wrapper around a webview component that allows to display HTML content in its o

Roman 2.6k Nov 30, 2021
Edifice: a declarative GUI library for Python

Edifice is a Python library for building reactive UI, inspired by modern Javascript libraries such as React.

David Ding 78 Nov 25, 2021
A small pomodoro GUI for Windows/Linux created in Python with PyQt5.

Pomodoro A small pomodoro GUI for Windows/Linux created with PyQt5. Features The "Timer" tab allows you to set your desired work and rest times aswell

Burak Martin 74 Nov 22, 2021
My Git GUI version made in Python and Tkinter.

Description My Git GUI version made in Python and Tkinter. How to use Basically, create a folder in your computer, open the software, select the path

Matheus Golzio 4 Oct 10, 2021
Aplicação GUI feita em Python para estudos de cadastro (forms).

Cadastro de DEVs GUI ?? A ideia original veio do repositório do https://github.com/PedroTomazeti nomeado 'Projetos-Independentes-HTML-CSS' Nele há um

Yago Goltara 3 Aug 15, 2021
Delphi's FireMonkey framework as a Python module for Windows, MacOS, Linux, and Android GUI development.

DelphiFMX4Python Delphi's FireMonkey framework as a Python module for Windows, MacOS, Linux, and Android GUI development. About: The delphifmx library

Embarcadero Technologies 30 Dec 3, 2021
Simple GUI python app to show a stocks graph performance. Made with Matplotlib and Tiingo.

stock-graph-python Simple GUI python app to show a stocks graph performance. Made with Matplotlib and Tiingo. Tiingo API Key You will need to add your

Toby 8 Nov 25, 2021
A Url Shortener with GUI made in Python.

Url-Shortener-with-GUI-in-python A Url Shortener with GUI made in Python. To Run this download the zip file and run the main file or Clone this repo.

SidTheMiner 1 Nov 12, 2021
Create shortcuts on Windows to your Python, EXE, Batch files or any other file using a GUI made with PySimpleGUI

shor Windows Shortcut Creation Create Windows Shortcuts to your python programs and any other file easily using this application created using PySimpl

PySimpleGUI 7 Nov 16, 2021
Signin/Signup GUI form using tkinter in python

SignIn-SignUpFormRepo Hello there, I am Shahid and this is the Signin/Signup GUI form using tkinter in python if you want to use avatar images then pa

Shahid Akhtar 1 Nov 9, 2021
LittlePythonGUIGuide - This is a short GUI Guide with python

This is a short GUI Guide with python, learning how to use the simple and easy moduel built into python, named tkinter.

1cy50ng3b0b 1 Nov 21, 2021
GUI Python Auto text bot.

Bagel Text Bot Auto text bot. Written in Python. Contributing Pull requests are welcome. For major changes, please open an issue first to discuss what

Toby 2 Nov 21, 2021
Custom GUI for your Blender add-ons using Dear ImGui

Dear Imgui for Blender Use the infamous Dear ImGui library directly in your Blender scripts! This means custom GUI drawing in your operators: Normally

Elie Michel 58 Nov 12, 2021
A Minimalistic Backup GUI for your Windows, Mac or Linux

BlobBackup is a minimalistic backup utility for your Windows, Mac or Linux computer. With an excellent engine, extensive storage support, and an easy

Bimba Shrestha 154 Nov 25, 2021