Open Raj2032 opened 2 years ago
The biggest problem for you would be that there is no rust library for Termux:GUI at the moment, so you would have to write that yourself. Have a look at the protocol and feel free to ask me if you have any questions. That also helps me to know if the protocol documentation is detailed enough for someone else to implement it.
Thanks mate @tareksander :)
The biggest problem for you would be that there is no rust library for Termux:GUI at the moment
Is C at least supported?
Because I know that Rust has C interop support.
I also wanted to know what would I specifically have to do to get it to work with Termux GUI?
Are there any chances that pygame would work with termuxgui?
Not out-of-the-box, but it can in theory work with anything where you can access the pixel buffer. You can create a RGBA888 buffer in pygame and after drawing each frame you can copy the contents into a buffer that is shared with the plugin that then displays it. It's easier if the library supports drawing into an arbitrary buffer in memory, so you can instruct it to directly draw into the shared buffer. I also want to support sharing an GLES buffer in the future so the data doesn't have to be copied to and from graphics memory. There is a part in the python bindings tutorial that shows how to draw with a library and it uses python SDL bindings as an example.
Thank you. :]
Please, tell me what I'm doing wrong. I'm trying to add TabLayout. I have code like this
with tg.Connection() as c: a = tg.Activity(c) tab_list = ['tab1', 'tab2', 'tab3'] tab = tg.TabLayout(a) tab.setlist(tab_list)
But when I run it, it shows black screen. I'm new to coding, thanks
Please, tell me what I'm doing wrong. I'm trying to add TabLayout. I have code like this
with tg.Connection() as c: a = tg.Activity(c) tab_list = ['tab1', 'tab2', 'tab3'] tab = tg.TabLayout(a) tab.setlist(tab_list)
But when I run it, it shows black screen. I'm new to coding, thanks
Do you have some sort of blocking or event loop after that code? I can't reproduce the black screen. My code is:
import termuxgui as tg
import sys
with tg.Connection() as c:
a = tg.Activity(c)
tl = tg.TabLayout(a)
tl.setlist(["tab 1", "tab 2", "tab 3"])
for ev in c.events():
if ev.type == tg.Event.destroy and ev.value["finishing"]:
sys.exit()
print(ev.type, ev.value)
I have not event loop, but when I tried your code, nothing has changed, I still have a black screen.
UPD: it freezes after tl = tg.TabLayout(a) No code after this line can be executed
I tried restarting my phone and reinstalling the app, no effect
Do things other than a TabLayout work? Are you sure you have version 0.1.4 of the app? The symptom of code after that not executing should be from the python code expecting an answer from the plugin, but the plugin doesn't answer because the command from the code is unknown. That should really only happen if the code uses a feature not present in the plugin.
I'm sure, termux:gui is 0.1.4 version. LinearLayout, ImageView, Button, Horizontal and NestedScrollView, SwipeRefreshLayout, TextView and Buffer working normally.
Jast checked, it can detect screen on/off events, presented in 0.1.4
Can you upload the output of logcat -d
after running your script? I think the plugin log messages should also be in there. Maybe there was an error in the plugin.
So, any ideas? Please)
You can try the following script, which runs the event loop in a separate thread. If you see an event printed with "invalidMethod", that means a feature (in this case setlist for TabLayout) isn't present in the plugin, which should really only occur when the plugin is outdated.
import termuxgui as tg
import threading
import sys
with tg.Connection() as c:
def evloop():
for ev in c.events():
print(ev.type, ev.value)
threading.Thread(target=evloop).start()
a = tg.Activity(c)
tl = tg.TabLayout(a)
tl.setlist(["tab 1", "tab 2", "tab 3"])
Nothing like "invalidMethod"
I reinstalled python plagin and app, nothing has changed.
What Android version do you have? When you quit the python script with ctrl + c, there should be a stack trace, can I see that?
Android 11 miui 12.5.2
The code for TabLayout is there in 0.1.4 and there were no Exceptions in the logcat...
I started a build from the latest source, maybe the problem is already fixed. Install the plugin from here and try again. If that still doesn't work, I have no idea. I'll add much more logging for 1.0, so I can probably diagnose the problem when 1.0 is finished.
Thanks a lot, now it is working!
Another question, how can I specify color for TextView?
Tried in hex tv.settextcolor('#ff0000')
but activity ends after that
You need an event loop or wait with time.sleep() so the activity doesn't end, see the Python tutorial. Also the color format is RGBA (as a number and not a string), so 0xaabbggrr.
It ended even if there was an event loop. But after applying the correct color format, everything works as it should. Thank you, thank you very much
Hello It is impossimble to use termuxgui python plugin inside proot, right?
It should work if you allow proot to keep /data/data/com.termux mounted and keep the PATH. It only needs to access the am binary from the termux environment in PATH. Should work in proot-distro by default.
By default this doesnt work. When I'm trying import module, rises ModuleNotFoundError, after installing module, rises RuntimeError: Plugin doesn't have the same UID. How can I keep /data/data/com.termux mounted and keep the PATH? I know only --termux-home flag, that mounts home dir.
The uid error is because proot emulates a root user. Try getting the uid used by termux and set proot to use that.
@Raj2032 The C library is now mostly done: https://github.com/tareksander/termux-gui-c-bindings
Hi, I have some questions regarding this project.
conrod
oriced
GUI library. Is it easily portable totermux-gui
?termux-gui
) would I be able to scroll using the touch screen?