Skip to content

Instantly share code, notes, and snippets.

@annaleighsmith
Created December 12, 2021 17:13
Show Gist options
  • Save annaleighsmith/e3daaa70a2c384fc25a12372fb7cb48d to your computer and use it in GitHub Desktop.
Save annaleighsmith/e3daaa70a2c384fc25a12372fb7cb48d to your computer and use it in GitHub Desktop.
import ui
w, h = ui.get_screen_size()
view = ui.View(name= 'Flex', bg_color='black',frame=(0,0,w,h))
total_rows = 10
total_columns=3
class CreateUIObject():
def __init__(self, obj_name, obj_type, row_num, col_num,text_str):
self.name = name
self.obj_name = obj_name
self.row_num = row_num
self.col_num = col_num
self.text_str = text_str
self.x_point = w/total_columns*col_num
self.y_point = h/total_rows*row_num
self.color = color
self.w_obj = w/total_columns
self.h_obj = h/total_rows
def create_label(self):
new_obj = ui.Label(name=self.obj_name,bg_color=self.color,frame=(self.x_point,self.y_point,self.w_obj, self.h_obj)),
new_obj.text=self.text_str
view.add_subview(new_obj)
label1 = CreateUIObject('test label', 'label', 0, 0, 'hello')
label1.create_label()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment