tdamdouni / Pythonista

Collection of Python Scripts written for Pythonista iOS App

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Need help I’m new at this.

pelaw24 opened this issue · comments

874C8757-C454-454E-88AF-DBD823A7C46D
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()

 `

Any help will be appreciate

Please post this in the Pythonista App Forum! Thanks.

Auf Pythonista App Forum verwiesen