A Python native, OS native GUI toolkit.

Related tags

GUI Developmenttoga
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.

Comments
  • 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
  • Add `dummy` as a known platform, and use it in tests

    Add `dummy` as a known platform, and use it in tests

    Signed-off-by: Bruno Rino [email protected]

    When creating a widget in a TestCase, the factory always needs to be specified, as in:

            self.switch = toga.Switch(self.text,
                                      on_change=self.on_change,
                                      value=self.value,
                                      enabled=self.enabled,
                                      factory=toga_dummy.factory)
    

    My suggestion is to add dummy to the list of know platforms, and manually set the platform in the TestCase subclass. This would avoid the repetitive factory=toga_dummy.factory.

    I tested this against a single widget, and the test passed as intended.

    PR Checklist:

    • [ ] 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 bruno-rino 26
  • "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
  • New Feature: Get a reference to a widget by id

    New Feature: Get a reference to a widget by id

    It is perfectly valid Python to define either a full or partial GUI widget hierarchy in the following way.

        self.content = Box(
            style=Pack(flex=1, direction=COLUMN),
            children=[
                TextInput(
                    id='node_name_input',
                    placeholder='Enter topic name'
                ),
                Box(
                    style=Pack(flex=1),
                    children=[
                        Button(
                            'Ok',
                            on_press=self.on_accept
                        ),
                        Button(
                            'Cancel',
                            on_press=self.on_close
                        )
                    ]
                )
            ]
        )
    

    In this example I subsequently want to get the value of the TextInput box when the 'Ok' button is clicked but because of the way it has been declared I have no immediate reference to it. It would be useful to have a method in the base Window class that mimics the HTML DOM getElementById() that returns a reference to the widget given its 'id'.

    enhancement not-quite-right 
    opened by Bobw147 20
  • 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
  • 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
  • [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
  • Fix bug when switching window content in winform

    Fix bug when switching window content in winform

    Bug Description

    In my application I'm using a single toga.Window and switch its content multiple times instead of opening new windows. In my main box box1 I have button that replace the content of the window with box2, and in box2 I have a "back" button that replace the content of the window back to box1.

    When I'm clicking the button that move from box1 to box2 everything is fine. When I try to got back to to box1 using the "back" button I get a RuntimeError that "Already have a container".

    This is a bug.

    How I fixed it

    When setting the container of a widget in windows, first if the widget already has a container, setting it to None and removing it from Controls. After that, if the new container is not None, setting it.

    This way we can remove boxes from the window and move them back freely.

    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 19
  • Inconsistent behaviour with toga.Selection value attribute between Windows and Android

    Inconsistent behaviour with toga.Selection value attribute between Windows and Android

    Describe the bug

    On Windows, when a selection widget is created with a list containing an empty string (eg: toga.Selection(items=['1','a','','4']) ), the widget returns '' for the "value" attribute.

    On Android, the selection's "value" attribute is set to None if the selection item is an empty string.

    I don't have MacOS, iOS, or Linux devices so I don't know what happens there.

    Steps to reproduce

    1. Create Beeware Project
    2. Go to the app.py file
    3. Create a list "list_1" containing an empty string
    4. Create the base app class with the startup function and setup main box + window
    5. In the startup function, create a selection with the items being that of list_1. Store it as a class attribute for future access.
    6. Define a class function that outputs the selection value via print or info_dialog.
    7. Create Button to call the output function
    8. Add Selector & Button to main box
    9. Compile the code for both Windows and Android & launch them.
    10. Select the empty item of the selector
    11. Press the button
    12. Watch as the devices disagree on the value.

    Expected behavior

    I would expect the selector value attribute to be an empty string as that was what the item was, and that is what the selector widget understands when values are written to it.

    Screenshots

    The source code I used:

    """
    Testing Crashes
    """
    import toga
    class TestLab(toga.App):
        def startup(self):
            main_box=toga.Box()
            self.select=toga.Selection(items=['A','B','0','','1','+','-'])
            main_box.add(self.select)
            main_box.add(toga.Button('Get',on_press=self.valuedump))
            self.main_window=toga.MainWindow(title=self.formal_name)
            self.main_window.content=main_box
            self.main_window.show()
        async def valuedump(self,widget):
            q=self.select.value
            print('GET',q,type(q))
            self.main_window.info_dialog('Selection Value',f'Value: "{q}"\n Type: {type(q)}')
    def main():return TestLab()
    

    On Windows:

    A_val sel_vals Null_val

    On Android:

    Screenshot_20221227-171610 Screenshot_20221227-171624 Screenshot_20221227-171635

    Environment

    Windows 8.1 / Android 11

    • Python version: 3.10.0
      • Briefcase: 3.11
      • Toga: 0.3.0.dev8

    Logs

    Windows: briefcase.2022_12_27-17_09_47.run.log

    Android: briefcase.2022_12_27-17_17_14.run.log

    Additional context

    No response

    bug android 
    opened by IneededAnAccountToDoStuff 1
  • Warnings when running Hello World script

    Warnings when running Hello World script

    Describe the bug

    (.venv) [email protected]:~/st/toga$  cd /home/paul/st/toga ; /usr/bin/env /home/paul/st/toga/.venv/bin/python /home/paul/.vscode/extensions/ms-python.python-2022.20.1/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher 34737 -- /home/paul/st/toga/print.py 
    /home/paul/st/toga/.venv/lib/python3.11/site-packages/toga_gtk/app.py:65: DeprecationWarning: There is no current event loop
      self.loop = asyncio.get_event_loop_policy().get_event_loop()
    /home/paul/st/toga/.venv/lib/python3.11/site-packages/toga_gtk/app.py:40: DeprecationWarning: Gtk.Window.set_wmclass is deprecated
      self.native.set_wmclass(app.interface.name, app.interface.name)
    WARNING: Can't find icon resources/toga; falling back to default icon
    hello
    

    Steps to reproduce

    1. Install the prerequisites and Toga in venv.
    2. Run the script from https://toga.readthedocs.io/en/latest/tutorial/tutorial-0.html.
    3. Click on Help->About First App
    import toga
    
    
    def button_handler(widget):
        print("hello")
    
    
    def build(app):
        box = toga.Box()
    
        button = toga.Button("Hello world", on_press=button_handler)
        button.style.padding = 50
        button.style.flex = 1
        box.add(button)
    
        return box
    
    
    def main():
        return toga.App("First App", "org.beeware.helloworld", startup=build)
    
    
    if __name__ == "__main__":
        main().main_loop()
    

    Expected behavior

    No warnings?

    Screenshots

    No response

    Environment

    • Operating System: Ubuntu 22.04.1
    • Python version: 3.11.1
    • Software versions:
      • Briefcase:
      • Toga: 0.3.0.dev39
      • ...

    Logs

    
    

    Additional context

    No response

    bug first-timers-only linux 
    opened by pauljurczak 5
  • toga Sound

    toga Sound

    What is the problem or limitation you are having?

    I would like to make an app, which plays sound effects on button press the only solution i could find was this.

    Describe the solution you'd like

    a sound playing api, with support for mp3 or wav

    Describe alternatives you've considered

    https://stackoverflow.com/questions/74120614/how-to-play-sound-in-an-android-app-created-by-beeware-using-python

    Additional context

    No response

    enhancement 
    opened by coolcoder613eb 11
  • GTK: app segfaults if unable to connect to display

    GTK: app segfaults if unable to connect to display

    Describe the bug

    This appeared in #1687 when xvfb-run was missing from the Toga testbed CI command. I can also reproduce it locally.

    Steps to reproduce

    Unset the DISPLAY environment variable, then try to run the app:

    $ briefcase dev
    
    [testbed] Starting in dev mode...
    ===========================================================================
    Unable to init server: Could not connect: Connection refused
    Unable to init server: Could not connect: Connection refused
    
    (__main__.py:20685): Gtk-CRITICAL **: 08:59:26.455: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed
    
    (__main__.py:20685): Gtk-CRITICAL **: 08:59:26.460: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed
    
    (__main__.py:20685): Gtk-CRITICAL **: 08:59:26.460: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed
    Fatal Python error: Segmentation fault
    
    Current thread 0x00007ff9f3404740 (most recent call first):
      File "/home/smith/git/beeware/toga/gtk/src/toga_gtk/icons.py", line 14 in __init__
      File "/home/smith/git/beeware/toga/core/src/toga/icons.py", line 77 in __init__
      File "/home/smith/git/beeware/toga/core/src/toga/app.py", line 455 in icon
      File "/home/smith/git/beeware/toga/core/src/toga/app.py", line 330 in __init__
      File "/home/smith/git/beeware/toga/testbed/src/testbed/app.py", line 27 in main
      File "/home/smith/git/beeware/toga/testbed/src/testbed/__main__.py", line 4 in <module>
      File "/home/smith/.pyenv/versions/3.8.12/lib/python3.8/runpy.py", line 87 in _run_code
      File "/home/smith/.pyenv/versions/3.8.12/lib/python3.8/runpy.py", line 97 in _run_module_code
      File "/home/smith/.pyenv/versions/3.8.12/lib/python3.8/runpy.py", line 207 in run_module
      File "<string>", line 1 in <module>
    
    Problem running application 'testbed'
    

    AppImage is much worse because it doesn't give any hint of what the cause of the crash is:

    $ briefcase run
    
    [testbed] Starting app...
    ===========================================================================
    /tmp/.mount_Toga_TpKBh1e/AppRun.wrapped: line 11: 22376 Segmentation fault      "${APPDIR}/usr/bin/python3" -u -s -X utf8 -c "import runpy, sys; sys.path.pop(0); runpy.run_module('${BRIEFCASE_MAIN_MODULE}', run_name='__main__', alter_sys=True)" "$@"
    
    Problem running app testbed.
    

    Expected behavior

    When unable to connect to the display, both run and dev should give an actionable error message, not a segfault, and ideally not a Python traceback either.

    Screenshots

    No response

    Environment

    • Operating System: Debian 10
    • Python version: 3.8
    • Software versions:
      • Briefcase: 0.3.11
      • Toga: 0.3.0dev39

    Logs

    No response

    Additional context

    No response

    bug linux 
    opened by mhsmith 0
  • macOS: Toga windows don't support close or minimize commands

    macOS: Toga windows don't support close or minimize commands

    Describe the bug

    On macOS, Toga apps don't respond to Cmd-W for close or Cmd-M for minimize. They only respond to Cmd-Q for quit.

    I also notice the app doesn’t have a Window menu, which is where those commands would normally appear.

    Steps to reproduce

    • On macOS, run briefcase dev in any app.
    • When the window appears, press Cmd-W or Cmd-M.
    • Computer gives an error sound, and nothing happens.

    Expected behavior

    Toga should support all standard window management commands on each OS.

    Screenshots

    Screenshot 2022-12-13 at 09 32 28

    Environment

    • Operating System: macOS 12.6
    • Python version: 3.11
    • Software versions:
      • Briefcase: 0.3.11
      • Toga: 0.3.0dev39

    Logs

    No response

    Additional context

    No response

    bug macOS 
    opened by mhsmith 0
  • Simplify API for canvas event handlers

    Simplify API for canvas event handlers

    What is the problem or limitation you are having?

    The current implementation of event handlers on toga.Canvas has some interesting quirks.

    1. It allows for a "double click drag"... and I'm not even sure what that would mean.
    2. It is closely bound to a mouse-driven implementation (in particular, it references alt and double click)

    Describe the solution you'd like

    It might make more sense to drop the clicks argument to the event handlers, and have separate events for:

    • on_press and on_alt_press
    • on_activate (i.e., double click) and on_alt_activate
    • on_drag
    • on_release and on_alt_release

    That would make events a lot closer to their "functional" purpose, rather than tying them to a specific implementation (e.g. - what is a double click on a touchscreen?) It would de-emphasize the importance of clicks, especially in the context of drag; and it would put the focus on press/activate, rather than release events.

    The general advice would be to avoid using "alt" press (or, at least, provide different ways of accessing that functionality); this is consistent with the sort of approach taken by the macOS style guide, which allows for "right click" actions, but encourages that to be an interface for "power users".

    This would simplify the winforms and GTK implementations (which currently need to do imml-level stateful tracking of the current click state), and makes the API for mobile canvas less of a band-aid (as we can use long-press or force-press events for "activate").

    Describe alternatives you've considered

    Do nothing. The current API works; it's just not ideal.

    Additional context

    No response

    enhancement 
    opened by freakboy3742 0
Releases(v0.3.0.dev39)
Owner
BeeWare
Write Python. Deploy everywhere.
BeeWare
A tf publisher gui tool for ROS, which publish /tf_static message. The software is based on PyQt5.

tf_publisher_gui for ROS Introduction How to use cd catkin_ws/src git clone https://github.com/yinwu33/tf_publisher_gui.git cd catkin_ws catkin_make s

yinwu33 7 Dec 28, 2022
All you need to learn Tkinter!

Tkinter This repository contains the codes and resources which I used to learn the standard GUI library of Python, Tkinter! Best Tkinter Resources Vid

Samyak Jain 3 May 02, 2022
This is a rip off of the classical iPhone Calculator . This project has been made with PyQT5

iPhoneCalcRIP-OFF This is a rip off of the classical iPhone Calculator . This project has been made with PyQT5

Juss Patel 7 May 01, 2022
An offline python frontend for the QuadVisions Colab Notebook using tkinter.

Visions GUI An offline python frontend for the QuadVisions Colab Notebook using tkinter. It offers basic options and interactively displays the genera

7 Feb 15, 2022
Tkinter calculetor - Tkinter calculetor with python

Tkinter_calculetor required to run py file pip install tkinter

Yasir Arafat 0 Feb 07, 2022
GUI app to read settings and stats from Cloudflare WARP CLI for Linux, and change some settings

warp-cli-gui GUI app to read settings and stats from Cloudflare WARP CLI for Linux, and change some settings. Description Python program that will int

Danie 6 Nov 01, 2022
Basic calculator using Tkinter GUI

Basic calculator using Tkinter GUI

Rogerio Penchel 17 Jan 09, 2022
Awesome examples for my Sun Valley ttk theme!

Sun Valley ttk theme examples This is the examples repo for my stunning Sun Valley ttk theme! Be sure to start and atch this repo, because I will uplo

rdbende 117 Jan 03, 2023
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
HDLG is a modern cross-platform GUI for hdl-dump with Batch installation capabilities.

HDLG is a modern cross-platform GUI for hdl-dump with Batch installation capabilities. Looking for Artwork This project is looking for an Icon an

8 Dec 03, 2022
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
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 5.4k Jan 07, 2023
build GUIs from python functions, using magic.

magicgui: build GUIs from functions, using magic. 📖 Docs Installation magicgui uses qtpy to support both pyside2 and pyqt5 backends. However, you mus

napari 0 Nov 11, 2022
A hotkey manager that runs in the system tray. Uses PySimpleGUI for the GUI and the system tray.

PySimpleHotkey PySimpleHotkey A hotkey manager that runs in the system tray. Uses PySimpleGUI for the GUI and the system tray. Packages Used This proj

PySimpleGUI 20 Nov 14, 2022
Yasb is a highly configurable and hackable taskbar written in python with Qt6.

Yasb: Yet Another Status Bar Yasb is a highly configurable and hackable taskbar written in python with Qt6. This project is still in (very) early deve

Dan 355 Jan 01, 2023
Python script with tkinter that allows you to open a local chat room

Server_chat Python script with tkinter that allows you to open a local chat room To begn you'll have to start the server side script and run it. You w

2 Feb 11, 2022
Custom Widgets For PyQt5

pyqtCuWi Custom Widgets Icon Button Documentation Rank Widget Documentation PopUp OuterRadius PopUp Documentation OuterRadius Documentation Producer:

.CODE 0 Apr 04, 2022
GlobalProtectGUI is a simple tray app to connect, disconnect and monitor globalprotect VPN connection.

Simple GlobalProtectGUI GlobalProtectGUI is simple tray app to connect, disconnect and monitor globalprotect VPN connection. Installation Required bef

Aleksandar Dostic 11 Oct 07, 2022
pyglet is a cross-platform windowing and multimedia library for Python, for developing games and other visually rich applications.

pyglet pyglet is a cross-platform windowing and multimedia library for Python, intended for developing games and other visually rich applications. It

1.3k Jan 01, 2023
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 55 Jan 05, 2023