-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed a bug and continued the tutorial
- Loading branch information
1 parent
8293077
commit 0b06902
Showing
6 changed files
with
211 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import termuxgui as tg | ||
import sys | ||
import time | ||
import threading | ||
|
||
ret = tg.connect() | ||
if ret == None: | ||
sys.exit() | ||
main, event = ret | ||
|
||
a, t = tg.activity(main) | ||
|
||
root = tg.createlinearlayout(main, a) | ||
|
||
title = tg.createtextview(main, a, "Awesome Title", root) | ||
tg.settextsize(main, a, title, 30) | ||
|
||
contenttext = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." | ||
content = tg.createtextview(main, a, contenttext, root) | ||
|
||
button = tg.createbutton(main, a, "Click here!", root) | ||
|
||
tg.setlinearlayoutparams(main, a, content, 10) | ||
|
||
count = 0 | ||
|
||
# create a thread to handle the events, so we can still exit the program after 5 seconds no matter what | ||
def handleEvents(): | ||
global count | ||
while True: | ||
ev = tg.getevent(event) # waits for events from the gui | ||
if ev["type"] == "click": # checks for click events. We don't need to check the id, as there is only one Button in our example | ||
count = count + 1 | ||
watcher = threading.Thread(target=handleEvents,daemon=True) | ||
watcher.start() | ||
|
||
time.sleep(5) | ||
print("button pressed", count, "times") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import termuxgui as tg | ||
import sys | ||
import time | ||
import io | ||
|
||
image = None | ||
with io.open(sys.argv[1], "rb") as f: | ||
image = f.read() | ||
|
||
ret = tg.connect() | ||
if ret == None: | ||
sys.exit() | ||
main, event = ret | ||
|
||
# specify that the Activity should be started in pip mode | ||
a, t = tg.activity(main,pip=True) | ||
|
||
# create an ImageView and set the image | ||
iv = tg.createimageview(main, a) | ||
tg.setimage(main, a, iv, image) | ||
|
||
time.sleep(5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import termuxgui as tg | ||
import sys | ||
import time | ||
|
||
ret = tg.connect() | ||
if ret == None: | ||
sys.exit() | ||
main, event = ret | ||
|
||
a, t = tg.activity(main) | ||
|
||
# For each View or Layout you create you can specify the id of the parent Layout to create a hiearachy. | ||
# If you don't specify a parent, it will replace the current root View. | ||
# We first create a LinearLayout as our root View. | ||
root = tg.createlinearlayout(main, a) | ||
|
||
# Then we create a TextView that we will use as a title | ||
title = tg.createtextview(main, a, "Awesome Title", root) | ||
|
||
# We set the font size a bit bigger | ||
tg.settextsize(main, a, title, 30) | ||
|
||
|
||
contenttext = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." | ||
# Now we create a TextView for the main content | ||
content = tg.createtextview(main, a, contenttext, root) | ||
|
||
# And we add a Button at the end | ||
|
||
button = tg.createbutton(main, a, "Click here!", root) | ||
|
||
|
||
# Now we give the Layout priority to our content Textview so it is bigger than the Button and the title. | ||
tg.setlinearlayoutparams(main, a, content, 10) | ||
|
||
|
||
|
||
time.sleep(5) |