Git Product home page Git Product logo

termux-gui-python-bindings's Introduction

Termux:GUI Python Bindings

A Python library to interact with the Termux:GUI plugin.

See here for a tutorial and here for using the more object-oriented subpackage.

There is also documentation generated from the docstrings.

Installing and updating:

Just use pip install termuxgui to install from pypi.

License

The license is the Mozilla Public License 2.0.
TL;DR: You can use this library in your own projects, regardless of the license you choose for it. Modifications to this library have to be published under the MPL 2.0 (or a GNU license in some cases) though.

termux-gui-python-bindings's People

Contributors

suletta-majo avatar tareksander avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

termux-gui-python-bindings's Issues

termux:gui not installed?

Hello,
I try to run the hello world example with termux 117 and termux-gui 0.1.4 and pythonbinding 0.1.3, armv8l Android.

94@localhost ~
╰─➤ python helloworld.py
Traceback (most recent call last):
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/termuxgui/connection.py", line 36, in init
main = mainss.accept()[0]
File "/data/data/com.termux/files/usr/lib/python3.10/socket.py", line 293, in accept
fd, addr = self._accept()
TimeoutError: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/data/data/com.termux/files/home/hello.py", line 5, in
with tg.Connection() as c:
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/termuxgui/connection.py", line 62, in init
raise RuntimeError("Could not connect to Termux:GUI. Is the plugin installed?")
RuntimeError: Could not connect to Termux:GUI. Is the plugin installed?


You mentioned something about building termux from source, right? Do I really have to?

Checkbox view.checked does not return the state of the checkbox

thescreen = tg.Activity(connection,canceloutside=False)
layout = tg.LinearLayout(thescreen, horizdivide)

testcheckbox = tg.Checkbox(thescreen,"speak",layout,False)

testbutton = tg.Button(thescreen, "configuration", layout)
testbutton.setlinearlayoutparams(0)
testbutton.setheight(tg.View.WRAP_CONTENT)

for eventmanager in connection.events():

	if eventmanager.type == tg.Event.click and eventmanager.value["id"] == testbutton:
		print (f"test checkbox state: {testcheckbox.checked}")

testcheckbox.checked does not change according to whether the checkbox is checked or not. In the example above, it always returns false.

[Problem] How do I get ID for button item?

I'm using Python to create a thing similar to a soft keyboard, and tried to use for xxx in xxx function to create button items, but I don't know how to get their id after I've created it.

Compatibility with proot

I would like to use termux-gui from arch linux running in proot in Termux.
However there is some problem with UID checking of connection socket.

More precisely. Function _check_user in begin of connection.py file don't working properly.
Value of getuid() refer to current user of arch in proot, but socket uid is uid of android user (Termux application).
The rest of application (the part I try) work very good even behind proot.

Maybe easy fix of this problem will be adding some possibility how to tell what
is right UID of Termmux app (for example thought environment variables).

Overlay doesn't work without specifying `tid`

When creating an overlay activity without specifying TID, there's an error about unpack.
Python 3.11.6, termuxgui 0.1.6 running on Android 12, MIUI 14.

The code that is not working as expected:

import termuxgui as tg
import time

def main():
    with tg.Connection() as connection:
        activity = tg.Activity(connection, overlay=True)
        tv = tg.TextView(activity, "Hello world!")
        time.sleep(10)

if __name__ == "__main__":
    main()

Error:

Traceback (most recent call last):
  File "/data/data/com.termux/files/home/mergebot/bot_gui_overlay.py", line 11, in <module>
    main()
  File "/data/data/com.termux/files/home/mergebot/bot_gui_overlay.py", line 6, in main
    activity = tg.Activity(connection, overlay=True)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/termuxgui/activity.py", line 29, in __init__
    self.aid, tid = self.c.send_read_msg({"method": "newActivity", "params": params})
    ^^^^^^^^^^^^^
TypeError: cannot unpack non-iterable int object

Adding a random tid to the tg.Activity makes the overlay to appear and fix the problem

activity = tg.Activity(connection, tid=123, overlay=True)

The overlay activity isn't documented in the TUTORIAL.md and would be useful.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.