Does this help?
import console
def restart():
print("Restarting")
console.alert("Game Over", "Do you want to start a new game?", "OK")
# Cancel throws an interrupt so no need
# to check the result
restart()
Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Does this help?
import console
def restart():
print("Restarting")
console.alert("Game Over", "Do you want to start a new game?", "OK")
# Cancel throws an interrupt so no need
# to check the result
restart()
@ZinoSama, if you want to do a lot of little animations, you could take a look at scripter (blows dust off the link). With it, you can have several simultaneous and long-running animations without having to worry about the UI thread.
An example of a button click handler running a counter to 100:
@script
def start(sender):
label = sender.superview["label1"]
set_value(label, "text", range(1, 101), lambda count: f"Count: {count}")
While it would be an intriguing and feasible project to wrap the Pythonista UI components in PySimpleGUI, it would still not be trivial, and I am afraid the results might not meet the needs of most user groups.
For students, taking a course exercise and trying to run it on Pythonista could very easily fail due to unsupported syntax, given that Pythonista runs the now-unsupported Python 3.6.
For Pythonista users, given that a lot of the power of Pythonista is in its access to iPhone-native functionality, it is very unlikely that an existing significant piece of code would run anywhere else.
Thinking of your requirements, if PySimpleGUI really runs reliably on the web, the students with iPads could maybe use repl.it to run the code, sync code with GitHub, and do the editing on Pythonista.
You probably already have all the materials built around PySimpleGUI. Otherwise I would suggest you to take a look at flet, which has the benefit of running a native or web Flutter app without additional platform-specific wrappers.
@cvp, have been following along again now that the update emails work again. Thank you, or anyone else who might have made that happen.
And if you just need the text directly:
from bs4 import BeautifulSoup
html = '''
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Title</title>
<style type="text/css">
/* CSS styles here... */
</style>
</head>
<body>
<h1>Hello</h1>
</body>
</html>
'''
soup = BeautifulSoup(html, "html5lib")
# Strip empty lines and extra white space
text = '\n'.join(
line.strip() for line in soup.text.splitlines()
if line.strip()
)
print(text)
There’s also a library you could install to get a nicer text representation as markdown, where h1 titles are underlined etc.
@cvp, thanks! Have been hacking more on the laptop lately.
@rb, if we are talking something like a photo with rectangles, you could also use the iOS Vision framework, see here.
I have a Python implementation lying around somewhere, let me know if that seems interesting.
@rb, are the rectangles exactly "squared" or can they be in any position in the image? Are the rectangles solid colour and the background another colour, or is the background (say) white with (say) black rectangular outlines? Do you know what the colours are or can they be anything?
@cvp, impressive! Know how hard these seemingly simple things can be.
@samsonantony, as one possible building block. here is ObjC code that can be used to save a video clip slowed down without audio:
https://stackoverflow.com/questions/17296999/how-to-do-slow-motion-video-in-ios
@Robert_Tompkins, I have the same issue, and no workaround.
@talns100, as others have pointed out, int
is a quick way to get the number. Always a good idea to wrap it in try ... except ValueError
though, to either set a default or give the user some guidance on what you expected to receive.
Usually, if all I want is an int, I prefer to use int(round(float(input())))
, just to be that little bit more tolerant of users who input 1.0
, for example.
@Steven11, on MacBook, would recommend PyCharm. Community edition is free, and the ease of navigating in the code is just something you cannot live without once you get used to it. Can be a bit heavy on the machine, though.
@cvp, sure, there’s pros and cons, and @ihf’s use case should provide some guidance here.
But you can have a TextView that resizes to fit the paragraph, and TableView rows that also resize to their contents.
@cvp, true, if you have an external keyboard. iPhone keyboard does not even have a tab key. 😁
@cvp, suggestion: use TableView for easy reordering, swipe left & right to change outline level.
Copying would need extra support, though.
@cvp, thanks, really nice if so. I remember some of my earlier attempts being somewhat hit and miss.
@Andy_Y, is your script by any chance called motion.py
? If yes, change the name, restart Pythonista to be sure, and try again.
@margusch: "build a application which gets triggered via shortcuts daily"
Good to note that it will (probably) not happen in the background on a locked device, so this would in effect be more like a reminder and an easier way for you to start the process.