def __init__(self): self.layout = Ui.LinearLayout( background="#ff314859", orientation=Ui.VERTICAL, ) Ui.TextView( self.layout, layout_width=Ui.FILL_PARENT, layout_height="0px", textSize="16dp", text="FullScreenWrapper2 Demo", textColor="#ffffffff", layout_weight=20, gravity=Ui.CENTER, ) self.txt_colorbox = Ui.TextView( self.layout, layout_width=Ui.FILL_PARENT, layout_height="0px", background="#ff000000", layout_weight="60", gravity=Ui.CENTER, ) self.buttonBox = Ui.LinearLayout( self.layout, layout_width=Ui.FILL_PARENT, layout_height="0px", orientation=Ui.HORIZONTAL, layout_weight="20", ) Ui.Button( self.buttonBox, layout_width=Ui.FILL_PARENT, layout_height=Ui.FILL_PARENT, background="#ff66a3d2", text="Random Color", layout_weight=1, textSize="14dp", gravity=Ui.CENTER, # HERE: click callback, auto registered command=self.change_color, ) Ui.Button( self.buttonBox, layout_width=Ui.FILL_PARENT, layout_height=Ui.FILL_PARENT, background="#ff25567b", layout_weight=1, text="Exit", textSize="14dp", gravity=Ui.CENTER, # HERE: call quit() on ui element will quit the current layout command=self.layout.quit, )
def _datetimeLayout(self, master, name, text, command): layout = Ui.LinearLayout( master, layout_width=Ui.FILL_PARENT, layout_height=Ui.WRAP_CONTENT, orientation=Ui.HORIZONTAL, layout_weight=11, ) Ui.TextView( layout, layout_width=Ui.FILL_PARENT, layout_height=Ui.FILL_PARENT, text=text, textColor=color_yellow, textSize="14dp", layout_weight=1, gravity=Ui.CENTER, textStyle=1, ) setattr( self, name, Ui.TextView( layout, layout_width=Ui.FILL_PARENT, layout_height=Ui.FILL_PARENT, textColor=color_white, textSize="14dp", layout_weight=1, gravity=Ui.joinattr(Ui.LEFT, Ui.CENTER_VERTICAL), )) Ui.Button( layout, layout_width=Ui.FILL_PARENT, layout_height=Ui.FILL_PARENT, textColor=color_white, textSize="14dp", layout_weight=1, background=color_light, text="Change", gravity=Ui.CENTER, command=command, ) Ui.LinearLayout( master, layout_width=Ui.FILL_PARENT, layout_height=Ui.WRAP_CONTENT, layout_weight=1, )
def image(self, master, name): layout = Ui.LinearLayout( master, orientation=Ui.HORIZONTAL, ) Ui.ImageView(layout, src='@android:drawable/' + name) Ui.TextView(layout, text=name) return layout
def _block(self, master, color): return Ui.TextView( master, layout_width=Ui.FILL_PARENT, layout_height=Ui.FILL_PARENT, layout_weight=1, gravity=Ui.CENTER, background=color, )
def main(): global view get_keycodes() gui = Ui.DroidUi() view = Ui.TextView(gui, text = 'Press any key', textSize = '40sp', layout_width = Ui.FILL_PARENT, gravity = Ui.CENTER, ) Ui.Button(gui, text = 'Quit', command = gui.quit) gui.reg_event('key', display_event) gui.mainloop()
def __init__(self): Ui.DroidUi.__init__(self) self.layout = Ui.LinearLayout(Ui.ScrollView(self), ) for name in sorted(HTMLColor): color = HTMLColor[name] Ui.TextView( self.layout, layout_width=Ui.MATCH_PARENT, gravity=Ui.CENTER, text='%s: %s' % (name, color), textColor='#%06x' % (0xffffff - int(color[1:], 16), ), background=color, )
def __init__(self): self.about = Ui.TextView( Ui.ScrollView(padding='20dp', background='#ff000000'), text=self.about_text, ) self.game = Game() self.outer = Ui.LinearLayout( Ui.LinearLayout(background='#ff000000'), padding='30dp', background='#3500ffff', layout_height=Ui.FILL_PARENT, ) self.inner = Ui.LinearLayout(self.outer, gravity=Ui.CENTER) Ui.TextView( self.inner, text='Android Sudoku', textSize='20dip', layout_marginBottom='25dip', ) Ui.Button(self.inner, text='Continue', command=self.resume) Ui.Button(self.inner, text='New Game', command=self.play) Ui.Button(self.inner, text='About', command=self.about.mainloop) Ui.Button(self.inner, text='Exit', command=self.inner.quit)
def __init__(self): Ui.DroidUi.__init__(self) self.layout = Ui.LinearLayout( self, layout_width=Ui.FILL_PARENT, layout_height=Ui.FILL_PARENT, background="#ff314859", orientation=Ui.VERTICAL, ) Ui.TextView( self.layout, layout_width=Ui.FILL_PARENT, layout_height=Ui.WRAP_CONTENT, text="Wrapper Demo", textSize="20dp", gravity=Ui.CENTER, textColor=color_yellow, ) self.lst_list = Ui.ListView( self.layout, layout_width=Ui.FILL_PARENT, layout_height="300dp", ) self.buttonBox = Ui.LinearLayout( self.layout, layout_width=Ui.FILL_PARENT, layout_height=Ui.WRAP_CONTENT, orientation=Ui.HORIZONTAL, ) self._button( self.buttonBox, text="Add", background=color_light, command=self.on_but_add_click, ) self._button( self.buttonBox, text="Lookup", background=color_deep, command=self.on_but_lookup, ) self._button( self.buttonBox, text="Exit", background=color_light, command=self.layout.quit, )
def FlashLight(): phone = Ui.Phone() lock = Ui.WakeLock() try: # no screen dim lock.bright() # set max screen brightness, but has no effect old_bright = phone.brightness(255) # show a white black screen gui = Ui.TextView(background='#ffffffff') gui.mainloop('FlashLight') # restore screen brightness phone.brightness(old_bright) finally: lock.release()
def __init__(self): Ui.DroidUi.__init__(self) self.layout = Ui.LinearLayout( self, layout_width=Ui.FILL_PARENT, layout_height=Ui.FILL_PARENT, background=color_bg, orientation=Ui.VERTICAL, ) Ui.TextView( self.layout, layout_width=Ui.FILL_PARENT, layout_height="0px", textSize="20dp", text="Gyro Test", textColor=color_white, layout_weight=19, gravity=Ui.CENTER, ) box1 = self._boxLayout(self.layout) self._block(box1, color_bg) self.txt_top = self._block(box1, color_default) self._block(box1, color_bg) box2 = self._boxLayout(self.layout) self.txt_left = self._block(box2, color_default) self._block(box2, color_bg) self.txt_right = self._block(box2, color_default) box3 = self._boxLayout(self.layout) self._block(box3, color_bg) self.txt_bottom = self._block(box3, color_default) self._block(box3, color_bg) self.reg_event('sensors', self.gyro) # start sensing self.sensing = Ui.Sensing()
def __init__(self): Ui.DroidUi.__init__(self) self.result = None self.curdatetime = datetime.today() self.layout = Ui.LinearLayout( self, layout_width=Ui.FILL_PARENT, layout_height=Ui.FILL_PARENT, background="#ff314859", orientation=Ui.VERTICAL, ) Ui.TextView( self.layout, layout_width=Ui.FILL_PARENT, textSize="20dp", text="Add Screen", textColor=color_white, gravity=Ui.CENTER, layout_weight=15, ) self._datetimeLayout(self.layout, 'add_txt_date', 'Date', self.on_but_datechange_click) self._datetimeLayout(self.layout, 'add_txt_time', 'Time', self.on_but_timechange_click) valueLayout = Ui.LinearLayout( self.layout, layout_width=Ui.FILL_PARENT, layout_height=Ui.WRAP_CONTENT, orientation=Ui.HORIZONTAL, layout_weight=11, ) Ui.TextView( valueLayout, layout_width=Ui.FILL_PARENT, layout_height=Ui.FILL_PARENT, text='Value', textColor=color_yellow, textSize="14dp", layout_weight=1, gravity=Ui.CENTER, textStyle=1, ) self.add_txt_value = Ui.EditText( valueLayout, layout_width=Ui.FILL_PARENT, layout_height=Ui.FILL_PARENT, digits="0123456789", textSize="12dp", layout_weight=1, background=color_white, gravity=Ui.joinattr(Ui.LEFT, Ui.CENTER_VERTICAL), ) Ui.Button( valueLayout, layout_width=Ui.FILL_PARENT, layout_height=Ui.FILL_PARENT, textColor=color_yellow, textSize="14dp", layout_weight=1, background=color_light, text="Save", gravity=Ui.CENTER, command=self.on_but_save_click, ) Ui.TextView( self.layout, layout_width=Ui.FILL_PARENT, layout_height=Ui.WRAP_CONTENT, textSize="10dp", text="Type value or choose below", textColor=color_white, gravity=Ui.CENTER, layout_weight=5, ) buttonBox1 = self._buttonLayout(self.layout) self._valueButton(buttonBox1, 40, color_light) self._valueButton(buttonBox1, 70, color_deep) self._valueButton(buttonBox1, 100, color_light) self._valueButton(buttonBox1, 120, color_deep) buttonBox2 = self._buttonLayout(self.layout) self._valueButton(buttonBox2, 150, color_deep) self._valueButton(buttonBox2, 180, color_light) self._valueButton(buttonBox2, 200, color_deep) self._valueButton(buttonBox2, 250, color_light) buttonBox3 = self._buttonLayout(self.layout) self._valueButton(buttonBox3, 300, color_light) self._valueButton(buttonBox3, 350, color_deep) self._valueButton(buttonBox3, 400, color_light) self._valueButton(buttonBox3, 450, color_deep)
def __init__(self, size=9): self.value = [None] * (size * size) self.size = size self.haverun = False self.table = Ui.RelativeLayout( background=self.back_color, gravity=Ui.CENTER, ) self.array = [] row = [ Ui.TextView( self.table, clickable=Ui.TRUE, command=lambda x=0, y=0: self.click(x, y), layout_width='34dp', layout_height='34dp', background=self.puzzle_back, layout_marginRight='2dp', gravity=Ui.CENTER, ) ] for j in range(1, size): row.append( Ui.TextView( self.table, clickable=Ui.TRUE, command=lambda x=0, y=j: self.click(x, y), layout_width='34dp', layout_height='34dp', background=self.puzzle_back, layout_toRightOf='@id/' + row[j - 1].id, layout_marginRight='2dp', gravity=Ui.CENTER, )) self.array.append(row) for i in range(1, size): row = [ Ui.TextView( self.table, clickable=Ui.TRUE, command=lambda x=i, y=0: self.click(x, y), layout_width='34dp', layout_height='34dp', background=self.puzzle_back, layout_below='@id/' + self.array[i - 1][0].id, layout_marginTop='2dp', gravity=Ui.CENTER, ) ] for j in range(1, size): row.append( Ui.TextView( self.table, clickable=Ui.TRUE, command=lambda x=i, y=j: self.click(x, y), layout_width='34dp', layout_height='34dp', background=self.puzzle_back, layout_alignLeft='@id/' + self.array[0][j].id, layout_alignTop='@id/' + row[0].id, gravity=Ui.CENTER, )) self.array.append(row)