tdamdouni / pythonista Goto Github PK
View Code? Open in Web Editor NEWCollection of Python Scripts written for Pythonista iOS App
Collection of Python Scripts written for Pythonista iOS App
Find out if there is a way to get around this, please.⤷
It seems when I play the code, and exit it, it does nothing and freeze.
Hey there,
Ngl I thought this was pretty darn cool, so I tried to copy it across to my phone onto Pythonista. However, when I try to run I get the error listed in the title. I will attach visuals:
Not really sure I understand most of this, coding games isn’t something I’ve delved into before. Would really appreciate the help
Need to removed the [ ] and change the font and sizes from every result and change the name on the button. Sorry I’m asking for a lot. Here is my code.
`import random
import ui
def Function():
v = ui.View()
v.background_color = 'white'
v.background_frame = '0, 0, w, h'
for i in range(1,5):
b = ui.Button()
b.frame=(-15+i*70,400,60,70)
b.border_width= 1.5
b.border_color = 'black'
b.title = str(i)
b.background_color='lightgray'
b.action = b_action
v.add_subview(b)
b.tint_color = 'red'
l = ui.Label(
alignment=ui.ALIGN_CENTER,
bg_color='white',
border_color='black',
border_width=1.5,
frame=(50, 100, 100, 50),
name='l')
l.text_font='30'
l.text_color='red'
l.number_of_lines = (2)
l.frame = (13,120,350,180)
v.add_subview(l)
v.present('screen')
def b_action(sender):
x = sender.title
l = sender.superview['l']
if x == '1': l.text = 'Megabucks '+str(factory.factoryLogic ( 1, 46, 6 ) )
elif x == '2': l.text = 'Lucky for Life '+str(factory.factoryLogic (1, 48, 5 ))+str(factory.factoryLogic ( 1, 18, 1 ) )
elif x == '3': l.text = 'Powerball '+str(factory.factoryLogic (1, 69, 5 ))+str(factory.factoryLogic ( 1, 26, 1 ) )
elif x == '4': l.text = 'Mega Millions '+str(factory.factoryLogic (1, 70, 5 ))+str(factory.factoryLogic( 1, 25, 1 ) )
class factory:
def init( self ):
self.a = 0
def factoryLogic( startPosi, endPosi, interateNumber ):
a = random.sample( range( startPosi, endPosi+1 ), interateNumber )
a.sort()
return a
if name == 'main':
Function()
`
Do you have any example of working with sensor (e.g. acelerometer) data for analizying, for example, gait.?
With the IOs 14.2 update the script https://github.com/tdamdouni/Pythonista/blob/master/omz/Rainbow_Editor.py
crashes the pythonista app and generates this error:
The app was terminated due to an Objective-C exception. Details below:
Modifications to the layout engine must not be performed from a background thread after it has been accessed from the main thread.
No time to make a separate pull request for this, but I got the scraper working:
import ui
import time
class Scraper (object):
def __init__(self, url, js = 'document.documentElement.outerHTML'):
self.wv = ui.WebView()
self.wv.delegate = self
self.wv.load_url(url)
self.js = js
self.response = None
def webview_did_finish_load(self, webview):
self.response = webview.eval_js(self.js)
@property
def value(self):
while self.response is None:
time.sleep(0.1)
return self.response
def main():
v = Scraper(url, 'document.documentElement.outerHTML;').value
It is a bit of a hack and probably not all that efficient, but it works perfectly
Gg
Originally posted by @itsMo07 in octocat/Spoon-Knife#22590 (comment)
I made some scripts for Pythonista, too. This is my repo:
https://github.com/GoDzM4TT3O/Pythonista
import random
import ui
import sound
label = ui.Label(name='Label')
label2 = ui.Label(name='Label2')
label3 = ui.Label(name='Label3')
label4 = ui.Label(name='Label4')
def button_tapped(sender):
sound.play_effect('ui:switch4')
'@type sender: ui.Button'
global shows_result
shows_result = False
if shows_result or label.text == 'MB':
label.text = title
if label.text == 'MB':'Megabucks\n\n'+str(self.draw (1, 46, 6))
if label.text == 'MB': label2.text = str(self.draw (1, 23, 1))
class self:
def init(self):
draw(a)
def draw(startPosi, endPosi, interateNumber):
a = random.sample(range(startPosi, endPosi), interateNumber)
a.sort()
return a
def make_button(title):
button = ui.Button(action=button_tapped,
title=title)
return button
button1 = make_button(title='MB')
view = ui.load_view()
view.add_subview(label)
view.add_subview(label2)
view.add_subview(label3)
view.add_subview(label4)
view.add_subview(button1)
ui.load_view('Testing').present('sheet')
Can’t show result on label 1 & 2 any help
The script tries to create a subclass of sk.Scene, but the sk.py module doesn’t contain such a class. sk.py does import * from SKExample.py, but that doesn’t contain it either. It does define SKScene, but that won’t work.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.