Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overlay doesn't work without specifying tid #4

Open
cheadrian opened this issue Dec 22, 2023 · 1 comment
Open

Overlay doesn't work without specifying tid #4

cheadrian opened this issue Dec 22, 2023 · 1 comment

Comments

@cheadrian
Copy link

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.

@tareksander
Copy link
Owner

You can try out the new overlay-fix branch I just created and see if that resolves the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants