def createView(): main = ui.View(frame=(0, 0, 576, 576)) subpanel = ui.View(frame=(0, 330, 576, 246)) subpanel2 = ui.View(frame=(0, 0, 576, 246)) slider = ui.Slider(frame=(10, 10, 150, 44), name='slider1') slider.stored = True switch1 = ui.Switch(frame=(10, 66, 70, 44), name='switch1') switch1.stored = True switch2 = ui.Switch(frame=(90, 66, 70, 44)) #no name switch2.stored = True switch3 = ui.Switch(frame=(10, 120, 70, 44), name='switch3') #not stored tf1 = ui.TextField(frame=(10, 180, 250, 50), name='textfield') tf1.stored = True main.add_subview(subpanel) subpanel.add_subview(slider) subpanel.add_subview(switch1) subpanel.add_subview(switch2) subpanel.add_subview(switch3) subpanel.add_subview(tf1) slider2 = ui.Slider(frame=(10, 10, 150, 44), name='slider1') slider2.stored = True subpanel2.add_subview(slider2) main.add_subview(subpanel2) return main
def tableview_cell_for_row(self, tableview, section, row): param = self.params[row] name = param.displayName cell = None if name == None or name == '': name = param.name if param.type == 'bool': cell = ui.TableViewCell() cell.selectable = False switch = ui.Switch() switch.name = param.name switch.value = param.value switch.y = cell.center.y - switch.height/2 switch.x = cell.width + switch.width/2 switch.action = self.switch_change cell.add_subview(switch) else: cell = ui.TableViewCell('value1') if not param.value == None: cell.detail_text_label.text = str(param.value) cell.detail_text_label.text_color = self.thememanager.main_text_colour cell.text_label.text = name cell.background_color = self.thememanager.main_background_colour cell.text_label.text_color = self.thememanager.main_text_colour return cell
def make_switch(self, name, x, y, val, action): switch = ui.Switch() switch.name = name switch.frame = (x, y, 51, 31) switch.value = val switch.action = action self.add_subview(switch) self.elements.append(name)
def __make_sw(self, row): self.__sw = ui.Switch() self.__sw.name = self._items[row]['setting'] self.__sw.value = True if self.items[row]['value'] == 'On' else False self.__sw.action = self.__swA self.__sw.y = 10 self.__sw.x = self.tableview.width - 60 self.__tvc.content_view.add_subview(self.__sw)
def loadCellItem(self,cell,app): itemView=ui.View() itemView.width=300 itemView.height=50 res=self.app.appService.getPricesByApp(app) newprice=0; oldprice=0; if(not res.equal(ResultEnum.SUCCESS)): console.hud_alert(res.toString(), 'error', 1.0) newprice=-1; oldprice=-1; else: prices=res.getData() if(len(prices)>1): newprice=prices[-1].getPrice() oldprice=prices[-2].getPrice() else: newprice=oldprice=prices[0].getPrice() pricelabel=SteamPriceLabel(oldprice,newprice) pricelabel.touch_enabled=False starBtn=ui.Button() starBtn.name=app.getAppId() # 利用name属性来记录其对应的app starBtn.width=starBtn.height=40 if(app.getStar()>0): starBtn.background_image=self.imgStar else: starBtn.background_image=self.imgUnStar starBtn.action=self.star_Act autoUpdateBtn=ui.Switch() autoUpdateBtn.name=app.getAppId() # 利用name属性来记录其对应的app autoUpdateBtn.value=app.getAutoUpdate() autoUpdateBtn.tint_color="#0987b4" autoUpdateBtn.action=self.changeAutoUpdate_Act # 设置布局 pricelabel.x,pricelabel.y=0,10 starBtn.x,starBtn.y=pricelabel.x+150,pricelabel.y # 以pricelabel为参考系 autoUpdateBtn.x,autoUpdateBtn.y= starBtn.x+50,starBtn.y+6 # 以starBtn为参考系 itemView.x=self.tableView.width-300 if self.app.width<500: # iPhone竖屏 self.tableView.row_height=70 pricelabel.width=100 pricelabel.x,pricelabel.y=0,10 starBtn.width=starBtn.height=30 starBtn.x,starBtn.y=pricelabel.x+105,pricelabel.y autoUpdateBtn.x,autoUpdateBtn.y= starBtn.x+35,starBtn.y-2 itemView.x,itemView.y=self.tableView.width-230,30 itemView.add_subview(pricelabel) itemView.add_subview(starBtn) itemView.add_subview(autoUpdateBtn) cell.content_view.add_subview(itemView)
def tableview_cell_for_row(self, tableview, section, row): cell = ui.TableViewCell('value1') if row == self.titleRow: cell.text_label.text = 'Title' if self.title.strip(' ') == '': cell.detail_text_label.text = 'Please enter a title' else: cell.detail_text_label.text = self.title elif row == self.inputTypeRow: cell.text_label.text = 'Input Type' if self.inputType == None: cell.detail_text_label.text = 'None' else: cell.detail_text_label.text = self.inputType elif row == self.outputTypeRow: cell.text_label.text = 'Output Type' if self.outputType == None: cell.detail_text_label.text = 'None' else: cell.detail_text_label.text = self.outputType elif row == self.descriptionRow: cell.text_label.text = 'Description' if self.description.strip(' ') == '': cell.detail_text_label.text = 'Please enter a description' else: cell.detail_text_label.text = self.description elif row == self.iconRow: cell.text_label.text = 'Icon' if self.icon.strip(' ') == '': cell.detail_text_label.text = 'Please choose a icon' else: cell.detail_text_label.text = self.icon elif row == self.categoryRow: cell.text_label.text = 'Category' if self.category.strip(' ') == '': cell.detail_text_label.text = 'Please enter a category' else: cell.detail_text_label.text = self.category elif row == self.canHandleListRow: cell.text_label.text = 'Can Handle List' cell.selectable = False switch = ui.Switch() switch.name = 'canHandleList' switch.value = False switch.y = cell.center.y - switch.height / 2 switch.x = cell.width + switch.width / 2 switch.action = self.canHandleListAction cell.add_subview(switch) cell.text_label.text_color = self.thememanager.main_text_colour cell.detail_text_label.text_color = self.thememanager.main_text_colour cell.background_color = self.thememanager.main_background_colour return cell
def __init__(self): self.mysettings = None self.loadsettings() width, height = ui.get_screen_size() self.frame = (0, 0, width, height) self.background_color = 'white' self.switch1 = ui.Switch() self.switch1.x = 50 self.switch1.y = 50 if self.mysettings != None: value = self.mysettings.get("switch1") self.switch1.value = value self.add_subview(self.switch1) self.present('full_screen')
def demo_ChainedTransition(): v1 = ui.View(frame=(0, 0, 500, 500), background_color="pink") v1.add_subview(ui.Button(frame=(100, 100, 300, 20))) v1.subviews[0].title = "Hello! I'm a button" v1.add_subview(ui.Slider(frame=(100, 300, 100, 20))) v2 = ui.View(background_color="lightblue") v2.add_subview(ui.ImageView(frame=(100, 100, 300, 300))) v2.subviews[0].image = ui.Image.named('test:Peppers') v3 = ui.View(background_color="lightgreen") v3.add_subview(ui.Switch(frame=(100, 100, 20, 10))) v3.subviews[0].value = True t1 = ui2.Transition(v1, v2, ui2.TRANSITION_CURL_UP, 1.5) t2 = ui2.Transition(v2, v3, ui2.TRANSITION_FLIP_FROM_LEFT, 1) t3 = ui2.Transition(v3, v1, ui2.TRANSITION_CROSS_DISSOLVE, 1) v1.present("sheet", hide_title_bar=True) ui2.delay(ui2.ChainedTransition(t1, t2, t3).play, 1)
def tableview_cell_for_row(self, tableview, section, row): # Create and return a cell for the given section/row cell = ui.TableViewCell() switch = ui.Switch(name='switch') switch.flex = 'L' switch.x = cell.width - switch.width - 6 switch.y = (cell.height - switch.height) / 2 if section == 0: switch.enabled = False switch.value = self.orders.current[row] else: switch.enabled = not self.orders.already_ordered switch.value = self.orders.next[row] switch.action = functools.partial(self.switch_toggled, row=row) cell.content_view.add_subview(switch) cell.text_label.text = self.orders.label(section, row) return cell
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.update_interval = 1 / 15 self.hand_id = 0 self.name = '右手' self.change_hand_button = ui.ButtonItem(title='change_hand', action=self.change_hand) self.right_button_items = [self.change_hand_button] self.trackpad = trackpad.Trackpad(frame=(0, self.frame.size.height - 250 - 150, 250, 250), flex='LRT', bg_color='blue') self.trackpadclicked_switch = ui.Switch( frame=(0, self.height - 450, 100, 100), flex='LRT', ) self.trigger = ui.Slider(frame=(0, self.height - 150, 100, 30), flex='LRT') self.socketcontroller = socketnetui.controllerUI(flex='RW') self.socketcontroller.width = self.width self.info_label = ui.Label(flex='W', scales_font=True, number_of_lines=0) self.info_label.y = 40 self.arposcontrollui = arpositiontracker.ARTrackerControllerUI( flex='WT', bg_color='red') self.arposcontrollui.width = self.width self.add_subview(self.info_label) self.add_subview(self.socketcontroller) self.add_subview(self.trackpad) self.add_subview(self.trackpadclicked_switch) self.add_subview(self.trigger) self.add_subview(self.arposcontrollui)
def tableview_cell_for_row(self, tableview, section, row): cell = ui.TableViewCell() cell.text_label.text = '' cell.accessory_type = 'disclosure_indicator' sc = ui.SegmentedControl(name=str(row), frame=(57, 4, 215, 29), flex='W', segments=['L', 'R', 'F', 'B'], action=self.switchdr) sc.selected_index = self.items[row][0] colour = ui.View(frame=(275, 3, 31, 31), flex='L', border_width=1, background_color=self.items[row][1]) if not row: cell.content_view.add_subview( ui.Switch(x=3, y=3, value=self.bgactive, action=self.switchbga)) if not self.bgactive: sc.hidden = True for i in sc, colour: cell.content_view.add_subview(i) return cell
def make_switch(x, y, w, h, name=None): switch = ui.Switch(frame=(x, y, w, h)) switch.name = name return switch
# coding: utf-8 # https://forum.omz-software.com/topic/2567/switch-in-ui-module-unresponsive import ui ui.Switch().present('sheet')
def __init__(self, app): self.app = app self.count_apps = 0 self.count_categorys = 0 self.count_stars = 0 self.count_prices = 0 self.count_totalValue = 0 self.cfg_runtimes = 0 self.cfg_notice = 1 self.cfg_downloadimg = 1 self.cfg_log = 1 self.datasize_img = 0 self.datasize_log = 0 self.datasize_database = 0 self.name = "设置" self.flex = "WHRLTB" self.fontcolor_pastal = "#999999" self.fontcolor_deep = "#5a5a5a" self.fontcolor_warnning = "#f41414" self.closeBtn = ui.ButtonItem() self.closeBtn.image = ui.Image.named('iob:close_round_24') self.closeBtn.action = self.app.Close_act self.left_button_items = [self.closeBtn] self.scrollView = ui.ScrollView() self.count_titleLabel = ui.Label() self.count_tableView = ui.TableView() self.countDataSource = CountDataSource(self.app, self) self.count_appsLabel = ui.Label() self.count_starsLabel = ui.Label() self.count_categorysLabel = ui.Label() self.count_runtimesLabel = ui.Label() self.count_pricesLabel = ui.Label() self.count_totalValueLabel = ui.Label() self.count_tableView.add_subview(self.count_runtimesLabel) self.count_tableView.add_subview(self.count_appsLabel) self.count_tableView.add_subview(self.count_starsLabel) self.count_tableView.add_subview(self.count_categorysLabel) self.count_tableView.add_subview(self.count_pricesLabel) self.count_tableView.add_subview(self.count_totalValueLabel) self.scrollView.add_subview(self.count_titleLabel) self.scrollView.add_subview(self.count_tableView) self.setting_titleLabel = ui.Label() self.setting_tableView = ui.TableView() self.settingDataSource = SettingDataSource(self.app, self) self.setting_noticeBtn = ui.Switch() self.setting_downloadBtn = ui.Switch() self.setting_logBtn = ui.Switch() self.setting_tableView.add_subview(self.setting_noticeBtn) self.setting_tableView.add_subview(self.setting_downloadBtn) self.setting_tableView.add_subview(self.setting_logBtn) self.scrollView.add_subview(self.setting_titleLabel) self.scrollView.add_subview(self.setting_tableView) self.clear_titleLabel = ui.Label() self.clear_tableView = ui.TableView() self.clearDataSource = ClaerDataSource(self.app, self) self.datasize_imgLabel = ui.Label() self.datasize_logLabel = ui.Label() self.datasize_sumLabel = ui.Label() self.clear_tableView.add_subview(self.datasize_imgLabel) self.clear_tableView.add_subview(self.datasize_logLabel) self.clear_tableView.add_subview(self.datasize_sumLabel) self.scrollView.add_subview(self.clear_titleLabel) self.scrollView.add_subview(self.clear_tableView) self.info_titleLabel = ui.Label() self.info_tableView = ui.TableView() self.infoDataSource = InfoDataSource(self.app, self) self.scrollView.add_subview(self.info_titleLabel) self.scrollView.add_subview(self.info_tableView) self.copyrightLabel = ui.Label() self.scrollView.add_subview(self.copyrightLabel) self.add_subview(self.scrollView) self.loadData()
def __init__(self,fldname,dateval,action=None, grid=[],*args, **kwargs): ui.View.__init__(self, *args, **kwargs) # here self.firstweekday=0 self.d_clr_none=1.0, 1.0, 1.0, 1.0 self.d_clr_bank=1.0, .0, .0, 1.0 self.d_clr_off=1.0, .64, .16, 1.0 self.bank_total = 0 self.banked_hours = 0 self.enter_offshore = False self.offshore_hours = 0 self.offshore_start=dt.datetime.today() self.offshore_end=dt.datetime.today() calendar.setfirstweekday(calendar.SUNDAY) self.grid=grid self.sum_bank_hours() self.banked_hours=int(self.grid[0][0]) self.days = calendar.weekheader(3).split() self.width,self.height = ui.get_screen_size() #here cv = ui.View(name=fldname) cv.frame = (0,95,self.width,255) cv.background_color = 'yellow' cv.border_color = 'yellow' cv.border_width = 2 # application buttons self.view = cv self.action = action prv_mth = ui.Button(title='<') prv_mth.frame = (5,5,50,25) prv_mth.action = self.prev_pressed self.day_color = prv_mth.tint_color self.view.add_subview(prv_mth) nxt_mth = ui.Button(title='>') nxt_mth.frame = (56,5,50,25) nxt_mth.action = self.next_pressed self.view.add_subview(nxt_mth) label = ui.Label(name='caltitle') self.caldate = dateval #dt.datetime.strptime(dateval,'%d/%m/%Y') self.curdate = dt.datetime.today() label.text = str(self.caldate.strftime('%B %Y')) label.frame = (107,5,200,25) label.alignment = ui.ALIGN_CENTER self.view.add_subview(label) # paystub Banked hours banked_label = ui.Label(name='bankedtitle',text='Bank Hr Paystub:',frame=(5,8*31,150,30)) self.view.add_subview(banked_label) banked_value = ui.TextField(name='bankedval',text=str(self.banked_hours),frame=(155,8*31,100,30), enabled = True, keyboard_type=ui.KEYBOARD_NUMBERS,action=self.banked_val_changed) self.view.add_subview(banked_value) # future banked (offshore) hours offshore_label = ui.Label(name='offshoretitle',text='Future Bank Hr:',frame=(5,9*31,150,30)) self.view.add_subview(offshore_label) offshore_value = ui.TextField(name='offshoreval',text=str(self.offshore_hours),frame=(155,9*31,100,30), enabled = False, keyboard_type=ui.KEYBOARD_NUMBERS) self.view.add_subview(offshore_value) # Bank hours used bank_label = ui.Label(name='banktitle',text='Bank Hr Use:',frame=(5,10*31,150,30)) self.view.add_subview(bank_label) bank_value = ui.TextField(name='bankval',text=str(self.bank_total),frame=(155,10*31,100,30), enabled = False) self.view.add_subview(bank_value) #remaining bank hours bank_remain_label = ui.Label(name='remaintitle',text='Bank Hr Remain:',frame=(5,11*31,150,30)) self.view.add_subview(bank_remain_label) # todo: add a date relative bank remaining field bank_remain_value = ui.TextField(name='remainval',text=str(self.banked_hours + self.offshore_hours -self.bank_total),frame=(155,11*31,100,30), enabled = False) self.view.add_subview(bank_remain_value) # Offshore Hour entry offshore_entry_label = ui.Label(name='offshoretitle',text='Enter Offshore Days:',frame=(5,12*31,200,30)) self.view.add_subview(offshore_entry_label) offshore_switch = ui.Switch(title='y ', frame=(190,12*31,200,30), action = self.offshore_switch) self.view.add_subview(offshore_switch) ''' offshore_entry_start_value = ui.DatePicker(name='offshore_start',frame=(15,12*31,250,60), mode=ui.DATE_PICKER_MODE_DATE,background_color=(.94, 1.0, .87), action=self.offshore_start_action) self.view.add_subview(offshore_entry_start_value) offshore_entry_end_value = ui.DatePicker(name='offshore_end',frame=(15,14*31,250,60), mode=ui.DATE_PICKER_MODE_DATE,background_color=(.94, 1.0, .87), action=self.offshore_end_action) self.view.add_subview(offshore_entry_end_value) offshore_btn = ui.Button(title=' Add to Cal ', frame=(280,14.5*31,200,30), action = self.add_offshore, font=('Arial Rounded MT Bold',15),border_color='black', border_width=2,alignment=ui.ALIGN_CENTER) self.view.add_subview(offshore_btn) ''' today_btn = ui.Button(title='Today') today_btn.frame = (self.width-60,5,50,25) today_btn.action = self.today_pressed self.view.add_subview(today_btn) self.firstdate = dt.date(self.caldate.year,self.caldate.month,1) self.create_buttons() self.draw_calendar()
def __init__(self, title, sections, done_button_title='Done', font=None): self.was_canceled = True #self.was_canceled = False self.shield_view = None self.values = {} self.container_view = _FormContainerView() self.container_view.frame = (0, 0, 500, 500) self.container_view.delegate = self self.view = ui.TableView('grouped') self.view.flex = 'WH' self.container_view.add_subview(self.view) self.container_view.name = title self.view.frame = (0, 0, 500, 500) self.view.data_source = self self.view.delegate = self self.cells = [] self.tf_ramq = 'xxxxxxxxxxxx' self.sections = sections for section in self.sections: section_cells = [] self.cells.append(section_cells) items = section[1] for i, item in enumerate(items): cell = ui.TableViewCell('value1') icon = item.get('icon', None) tint_color = item.get('tint_color', None) if font: cell.text_label.font = font if tint_color: cell.tint_color = tint_color if icon: if isinstance(icon, basestring): icon = ui.Image.named(icon) if tint_color: cell.image_view.image = icon.with_rendering_mode( ui.RENDERING_MODE_TEMPLATE) else: cell.image_view.image = icon title_color = item.get('title_color', None) if title_color: cell.text_label.text_color = title_color t = item.get('type', None) key = item.get('key', item.get('title', str(i))) item['key'] = key title = item.get('title', '') if t == 'segmented': value = item.get('value', '') self.values[key] = value #bgcolor = 0.9 #Set up cell cell.selectable = False cell.text_label.text = title label_width = ui.measure_string( title, font=cell.text_label.font)[0] cell_width, cell_height = cell.content_view.width, cell.content_view.height #cell.background_color= bgcolor #Set up scroll view scroll = ui.ScrollView() scroll_width = max(40, cell_width - label_width - 32) scroll.frame = (cell_width - scroll_width - 8, 1, scroll_width, cell_height - 2) scroll.flex = 'W' #scroll_width = max(40, cell_width - label_width ) #scroll.frame = (cell_width - scroll_width+40, 1, scroll_width, cell_height-2) scroll.shows_horizontal_scroll_indicator = False #scroll.background_color = bgcolor #Set up segment segment = ui.SegmentedControl() choices = item.get('choice', '').split("|") segment.segments = choices if value != '': segment.selected_index = choices.index(value) #segment.value = value segment.name = key segment.action = self.segment_action segment.frame = (0, 0, len(segment.segments) * 65, scroll.height) #Combining SUBVIEWS scroll.content_size = (len(segment.segments) * 65, scroll.height) scroll.add_subview(segment) cell.content_view.add_subview(scroll) elif t == 'photo': value = item.get('value', False) self.values[key] = value cell.text_label.text = title cell.selectable = False photo_button = ui.Button() photo_button.name = key show_photo = ui.Button() show_photo.name = key label_width = ui.measure_string( title, font=cell.text_label.font)[0] cell_width, cell_height = cell.content_view.width, cell.content_view.height ph_width = max(40, cell_width - label_width - 32) photo_button.frame = (cell_width - ph_width - 8, 1, ph_width / 3, cell_height - 2) show_photo.frame = (cell_width - ph_width / 2, 1, ph_width / 2, cell_height - 2) photo_button.flex = 'W' photo_button.background_color = 0.9 show_photo.background_color = 0.95 photo_button.title = 'Take picture' show_photo.title = 'Show picture' cell.content_view.add_subview(photo_button) cell.content_view.add_subview(show_photo) #photo_button.action = self.take_photo photo_button.action = self.photoBooth show_photo.action = self.photo_quicklook elif t == 'switch': value = item.get('value', False) self.values[key] = value cell.text_label.text = title cell.selectable = False switch = ui.Switch() w, h = cell.content_view.width, cell.content_view.height switch.center = (w - switch.width / 2 - 10, h / 2) switch.flex = 'TBL' switch.value = value switch.name = key switch.action = self.switch_action if tint_color: switch.tint_color = tint_color cell.content_view.add_subview(switch) elif t == 'text' or t == 'url' or t == 'email' or t == 'password' or t == 'number': value = item.get('value', '') self.values[key] = value placeholder = item.get('placeholder', '') cell.selectable = False cell.text_label.text = title label_width = ui.measure_string( title, font=cell.text_label.font)[0] if cell.image_view.image: label_width += min(64, cell.image_view.image.size[0] + 16) cell_width, cell_height = cell.content_view.width, cell.content_view.height tf = ui.TextField() tf.name = key if tf.name == 'fname': self.tf_fname = tf if tf.name == 'lname': self.tf_lname = tf if tf.name == 'ramq': self.tf_ramq = tf tf_width = max(40, cell_width - label_width - 32) tf.frame = (cell_width - tf_width - 8, 1, tf_width, cell_height - 2) tf.bordered = False tf.placeholder = placeholder tf.flex = 'W' tf.text = value tf.text_color = '#337097' if t == 'text': tf.autocorrection_type = item.get( 'autocorrection', None) tf.autocapitalization_type = item.get( 'autocapitalization', ui.AUTOCAPITALIZE_SENTENCES) tf.spellchecking_type = item.get('spellchecking', None) if t == 'url': tf.keyboard_type = ui.KEYBOARD_URL tf.autocapitalization_type = ui.AUTOCAPITALIZE_NONE tf.autocorrection_type = False tf.spellchecking_type = False elif t == 'email': tf.keyboard_type = ui.KEYBOARD_EMAIL tf.autocapitalization_type = ui.AUTOCAPITALIZE_NONE tf.autocorrection_type = False tf.spellchecking_type = False elif t == 'number': tf.keyboard_type = ui.KEYBOARD_NUMBERS tf.autocapitalization_type = ui.AUTOCAPITALIZE_NONE tf.autocorrection_type = False tf.spellchecking_type = False elif t == 'password': tf.secure = True tf.clear_button_mode = 'while_editing' tf.name = key tf.delegate = self cell.content_view.add_subview(tf) elif t == 'check': value = item.get('value', False) group = item.get('group', None) if value: cell.accessory_type = 'checkmark' cell.text_label.text_color = cell.tint_color cell.text_label.text = title if group: if value: self.values[group] = key else: self.values[key] = value elif t == 'date' or t == 'datetime' or t == 'time': value = item.get('value', datetime.datetime.now()) if type(value) == datetime.date: value = datetime.datetime.combine( value, datetime.time()) if type(value) == datetime.time: value = datetime.datetime.combine( value, datetime.date.today()) date_format = item.get('format', None) if not date_format: if t == 'date': date_format = '%Y-%m-%d' elif t == 'time': date_format = '%H:%M' else: date_format = '%Y-%m-%d %H:%M' item['format'] = date_format cell.detail_text_label.text = value.strftime(date_format) self.values[key] = value self.ramq_dob = '' cell.text_label.text = title else: cell.selectable = False cell.text_label.text = item.get('title', '') section_cells.append(cell) done_button = ui.ButtonItem(title=done_button_title) done_button.action = self.done_action self.container_view.right_button_items = [done_button]
def __init__(self, *args, **kwargs): height, width = ui.get_screen_size() super().__init__(frame=(0, 0, width, height), background_color='white', name='4-4-4-4', *args, **kwargs) self.sections = [[Cell.Cells(z, w) for w in range(4)] for z in range(4)] for sections_w in self.sections: for section in sections_w: self.add_subview(section) self.player = 1 self.black, self.white = 0, 0 self.history = [] self.scores = [ Score(player, x=750, y=10 + 85 * i) for i, player in enumerate(['●', '○']) ] for score in self.scores: self.add_subview(score) self.scores[0].border_width = 1.5 self.cpu = ui.Switch(x=750, y=220, value=False, action=self.save_config) self.add_subview(self.cpu) self.add_subview( ui.Label(text='CPU', font=('<system>', 42), x=810, y=185)) self.reset = ui.Button(tint_color='black', frame=(750, 310, 160, 60), font=('Source Code Pro', 42), action=self.clear, border_color='black', border_width=1, corner_radius=5, alignment=ui.ALIGN_CENTER) self.reset.title = 'Clear' self.add_subview(self.reset) self.disable(self.reset) self.undo = ui.Button(background_image=ui.Image('iob:ios7_undo_256'), frame=(800, 400, 60, 60), action=self.backward) self.add_subview(self.undo) self.disable(self.undo) self.saveas = ui.Button(tint_color='black', frame=(750, 500, 160, 40), font=('<system>', 28), action=self.write, border_width=1, corner_radius=5, alignment=ui.ALIGN_CENTER) self.saveas.title = 'Save as' self.add_subview(self.saveas) self.loadfrom = ui.Button(tint_color='black', frame=(750, 550, 160, 40), font=('<system>', 28), action=self.read, border_width=1, corner_radius=5, alignment=ui.ALIGN_CENTER) self.loadfrom.title = 'Load from' self.add_subview(self.loadfrom) self.delete = ui.Button(tint_color='red', frame=(750, 640, 160, 40), font=('<system>', 28), action=GameConfig.delete, border_width=1, corner_radius=5, alignment=ui.ALIGN_CENTER) self.delete.title = 'Delete' self.add_subview(self.delete) self.apply_config(GameConfig().load()) self.save_config()
def __init__(self): self.bg_color = '#ffffff' self.name = 'Ins相册批量下载' self.tint_color = 'white' self.refresh = ui.ButtonItem() self.refresh.title = '刷新剪贴板' self.refresh.action = self.refresh_tapped self.right_button_items = [self.refresh] self.clipview = ui.Label() self.clipview.frame = (0, 0, w, 40) self.clipview.number_of_lines = 2 self.clipview.alignment = ui.ALIGN_CENTER self.clipview.text = clip_check() self.username = ui.Label() self.username.frame = (0, 40, w, 40) self.username.font = ('<System-Bold>', 22) self.username.alignment = ui.ALIGN_CENTER self.username.number_of_lines = 2 self.username.text_color = '#d600b7' self.username.text = '等待获取用户信息...' self.userinfo = ui.Label() self.userinfo.frame = (0, 85, w, 40) self.userinfo.font = ('<System>', 18) self.userinfo.alignment = ui.ALIGN_CENTER self.userinfo.text_color = '#5c5c5c' self.userinfo.text = '帖子:0 关注者:0' self.userimg = ui.ImageView() self.userimg.frame = ((w - 220) / 2, 140, 220, 220) self.userimg.image = ui.Image.named('iob:load_d_256') self.userimg.border_width = 1 self.userimg.border_color = '#aab0b0' self.videobutton = ui.Switch() self.videobutton.frame = (210, 395, 50, 40) self.videobutton.tint_color = 'red' self.videobutton.value = False self.videobutton_title = ui.Label() self.videobutton_title.alignment = ui.ALIGN_CENTER self.videobutton_title.frame = ((w - 180) / 2, 390, 100, 40) self.videobutton_title.font = ('<System>', 20) self.videobutton_title.text = '下载视频' self.downbutton = ui.Button() self.downbutton.frame = ((w - 180) / 2, 450, 180, 40) self.downbutton.border_width = 1.2 self.downbutton.border_color = '#b1b1b1' self.downbutton.font = ('<System-Bold>', 20) self.downbutton.title = '下载' self.downbutton.tint_color = 'white' self.downbutton.bg_color = '#1e8173' self.downbutton.corner_radius = 10 self.downbutton.enabled = False self.downbutton.action = downbutton_tapped self.status = ui.Label() self.status.frame = (0, 495, w, 100) self.status.alignment = ui.ALIGN_CENTER self.status.number_of_lines = 0 self.status.font = ('<System-Bold>', 18) self.add_subview(self.clipview) self.add_subview(self.username) self.add_subview(self.userinfo) self.add_subview(self.downbutton) self.add_subview(self.videobutton) self.add_subview(self.videobutton_title) self.add_subview(self.status) self.add_subview(self.userimg)
if not 'L' in self.flex: pass # dont change x elif 'R' in self.flex: #R and L flexing, probably should do this proportionally. instead just keep center fixed self.x = oldframe[0] + oldframe[2] / 2 - self.width / 2 else: #flex l only.. keep right fixed self.x = oldframe[0] + oldframe[2] - self.width if __name__ == "__main__": # few examples import console # set up a view v = ui.View() v.add_subview(ui.Switch(frame=(400, 5, 50, 20), name='switch')) t = ui.Label(frame=(450, 5, 200, 20)) t.text = 'random sizes' v.add_subview(t) f = FlowContainer() v.add_subview(f) v.present('panel') #to set screensize f.flex = 'hw' f.frame = (0, 50, 0, 0) #auto size to fit contents t = ui.Label(frame=(15, 25, 500, 25)) t.text = 'height and width flex' v.add_subview(t)
def __init__(self): self.textfields = {} self.switches = {} self.history = {} screen_width, screen_height = ui.get_screen_size() view = ui.View(frame=(0, 0, screen_width, screen_height), name='Расчет укрытий', background_color='white') height_gen = self.generate_height() scroll_view_width = screen_width * 2 / 3 - 10 scroll_view = ui.ScrollView(frame=(10, 10, scroll_view_width, screen_height - 90), border_width=1, border_color="lightgrey", corner_radius=5) view.add_subview(scroll_view) group_label_width = screen_width * 2 / 3 - 20 option_label_width = screen_width * 2 / 3 - 130 for content in self.content_map: group_label = ui.Label(text=content["header"], font=('<system-bold>', 17), frame=(10, next(height_gen), group_label_width, 30)) scroll_view.add_subview(group_label) for option in content["options"]: height = next(height_gen) name = "{}_{}".format(content["header"], option) switch = ui.Switch(value=False, name=name, action=self.switch_pressed, frame=(10, height, 50, 30)) scroll_view.add_subview(switch) self.switches[name] = switch textfield = ui.TextField(enabled=False, name=name, frame=(70, height, 50, 30)) scroll_view.add_subview(textfield) self.textfields[name] = textfield label = ui.Label(text=option, frame=(130, height, option_label_width, 30)) scroll_view.add_subview(label) scroll_view.content_size = (scroll_view_width, next(height_gen)) controls_x = screen_width * 2 / 3 + 10 controls_width = screen_width * 1 / 3 - 20 result_button = ui.Button(title='Расчет', frame=(controls_x, 10, controls_width, 50), border_width=1, border_color="lightgrey", corner_radius=5, action=self.calculate_pressed, flex="W") result_button.width = controls_width result_button.height = 50 view.add_subview(result_button) self.result_textfield = ui.TextField(enabled=True, name="result", text="", frame=(controls_x, 70, controls_width, 50), flex="W") view.add_subview(self.result_textfield) clear_button = ui.Button(title='Очистить', frame=(controls_x, 180, controls_width, 50), border_width=1, border_color="lightgrey", corner_radius=5, action=self.clear_inputs, flex="W") clear_button.width = controls_width clear_button.height = 50 view.add_subview(clear_button) history_button = ui.Button(title='История', frame=(controls_x, 240, controls_width, 50), border_width=1, border_color="lightgrey", corner_radius=5, action=self.show_history, flex="W") history_button.width = controls_width history_button.height = 50 view.add_subview(history_button) view.present('full_screen', orientations=['portrait'])
headerVal.spellchecking_type = False headerVal.font = (CONSOLEFONT, T1) headerVal.height = headerName.height headerVal.frame = ((w / 2) + PAD, y4, (w - PAD * 2) / 2 - PAD, headerVal.height) y5 = headerName.y + headerName.height + PAD # Follow Redirects redirectsLbl = ui.Label() redirectsLbl.name = 'redirectsLbl' redirectsLbl.text = 'Follow Redirects' redirectsLbl.alignment = ui.ALIGN_RIGHT redirectsLbl.font = (APPFONT, T1) redirectsLbl.height = T1 + T1 / 2 redirectsLbl.frame = (PAD, y5, (w - PAD * 2) / 2, redirectsLbl.height) redirectsSwitch = ui.Switch() redirectsSwitch.name = 'redirectsSwitch' redirectsSwitch.value = True redirectsSwitch.frame = ((w / 2) + PAD, y5, (w - PAD * 2) / 2, redirectsSwitch.height) y6 = redirectsLbl.y + redirectsSwitch.height + PAD # Submit Button goBtn = ui.Button(title='Submit') goBtn.name = 'goBtn' goBtn.font = (APPFONT_BOLD, H2) goBtn.background_color = GREEN goBtn.tint_color = WHITE goBtn.corner_radius = 5 goBtn.height = H2 + H2 / 2 goBtn.width = w / 4
#Setup 3 labels for each station to write S1 = ui.Label(frame=(100, 5, 195, 20), flex='lwh', font=('<System>', 16), alignment=ui.ALIGN_LEFT, name='result_label') S2 = ui.Label(frame=(100, 25, 195, 20), flex='lwh', font=('<System>', 16), alignment=ui.ALIGN_LEFT, name='result_label') S3 = ui.Label(frame=(100, 45, 195, 20), flex='lwh', font=('<System>', 16), alignment=ui.ALIGN_LEFT, name='result_label') eventLog = ui.Label(frame=(100, 65, 195, 20), flex='lwh', font=('<System>', 16), alignment=ui.ALIGN_LEFT, name='result_label') v.add_subview(S1) v.add_subview(S2) v.add_subview(S3) v.add_subview(eventLog) #Selection control for east/west direction = ui.SegmentedControl(frame=(5,5,100,50),segments=["West","East"],felx='lwh', alignment=ui.ALIGN_LEFT, name='directionSelect') v.add_subview(direction) #Voice toggle on UI voice = ui.Switch(frame=(10,65,100,50)) v.add_subview(voice) appex.set_widget_view(v) #Ag # switchSpeed =ui.Switch(frame=10,) #Set default values for previous lane/speed values lastSlowDown = "" lastLane = "" lastSpeed = 0 voice.value = 0 while True: #Write previous GPS before updating and sleeping.
def __init__(self, title, sections, done_button_title='Done'): self.was_canceled = True self.shield_view = None self.values = {} self.container_view = _FormContainerView() self.container_view.frame = (0, 0, 500, 500) self.container_view.delegate = self self.view = ui.TableView('grouped') self.view.flex = 'WH' self.container_view.add_subview(self.view) self.container_view.name = title self.view.frame = (0, 0, 500, 500) self.view.data_source = self self.view.delegate = self self.cells = [] self.sections = sections for section in self.sections: section_cells = [] self.cells.append(section_cells) items = section[1] for i, item in enumerate(items): cell = ui.TableViewCell('value1') icon = item.get('icon', None) tint_color = item.get('tint_color', None) if tint_color: cell.tint_color = tint_color if icon: if isinstance(icon, basestring): icon = ui.Image.named(icon) if tint_color: cell.image_view.image = icon.with_rendering_mode( ui.RENDERING_MODE_TEMPLATE) else: cell.image_view.image = icon title_color = item.get('title_color', None) if title_color: cell.text_label.text_color = title_color t = item.get('type', None) key = item.get('key', item.get('title', str(i))) item['key'] = key title = item.get('title', '') if t == 'switch': value = item.get('value', False) self.values[key] = value cell.text_label.text = title cell.selectable = False switch = ui.Switch() w, h = cell.content_view.width, cell.content_view.height switch.center = (w - switch.width / 2 - 10, h / 2) switch.flex = 'TBL' switch.value = value switch.name = key switch.action = self.switch_action if tint_color: switch.tint_color = tint_color cell.content_view.add_subview(switch) elif t == 'text' or t == 'url' or t == 'email' or t == 'password' or t == 'number': value = item.get('value', '') self.values[key] = value placeholder = item.get('placeholder', '') cell.selectable = False cell.text_label.text = title label_width = ui.measure_string( title, font=cell.text_label.font)[0] if cell.image_view.image: label_width += min(64, cell.image_view.image.size[0] + 16) cell_width, cell_height = cell.content_view.width, cell.content_view.height tf = ui.TextField() tf_width = max(40, cell_width - label_width - 32) tf.frame = (cell_width - tf_width - 8, 1, tf_width, cell_height - 2) tf.bordered = False tf.placeholder = placeholder tf.flex = 'W' tf.text = value tf.text_color = '#337097' if t == 'text': tf.autocorrection_type = item.get( 'autocorrection', None) tf.autocapitalization_type = item.get( 'autocapitalization', ui.AUTOCAPITALIZE_SENTENCES) tf.spellchecking_type = item.get('spellchecking', None) if t == 'url': tf.keyboard_type = ui.KEYBOARD_URL tf.autocapitalization_type = ui.AUTOCAPITALIZE_NONE tf.autocorrection_type = False tf.spellchecking_type = False elif t == 'email': tf.keyboard_type = ui.KEYBOARD_EMAIL tf.autocapitalization_type = ui.AUTOCAPITALIZE_NONE tf.autocorrection_type = False tf.spellchecking_type = False elif t == 'number': tf.keyboard_type = ui.KEYBOARD_NUMBERS tf.autocapitalization_type = ui.AUTOCAPITALIZE_NONE tf.autocorrection_type = False tf.spellchecking_type = False elif t == 'password': tf.secure = True tf.clear_button_mode = 'while_editing' tf.name = key tf.delegate = self cell.content_view.add_subview(tf) elif t == 'check': value = item.get('value', False) group = item.get('group', None) if value: cell.accessory_type = 'checkmark' cell.text_label.text_color = cell.tint_color cell.text_label.text = title if group: if value: self.values[group] = key else: self.values[key] = value elif t == 'date' or t == 'datetime' or t == 'time': value = item.get('value', datetime.datetime.now()) if type(value) == datetime.date: value = datetime.datetime.combine( value, datetime.time()) if type(value) == datetime.time: value = datetime.datetime.combine( value, datetime.date.today()) date_format = item.get('format', None) if not date_format: if t == 'date': date_format = '%Y-%m-%d' elif t == 'time': date_format = '%H:%M' else: date_format = '%Y-%m-%d %H:%M' item['format'] = date_format cell.detail_text_label.text = value.strftime(date_format) self.values[key] = value cell.text_label.text = title else: cell.selectable = False cell.text_label.text = item.get('title', '') section_cells.append(cell) done_button = ui.ButtonItem(title=done_button_title) done_button.action = self.done_action self.container_view.right_button_items = [done_button]
def __init__(self, app): self.app = app self.count_runtimes = 0 self.count_transChartSum = 0 self.count_baiduCommonTransChartUsed = [0, 0, 0] self.count_baiduFieldTransChartUsed = [0, 0, 0] self.setting_lesten = True self.setting_engine = "baidu_common" self.engineDic = {"baidu_common": "百度通用翻译", "baidu_field": "百度领域翻译"} self.baiduapi_appid = "" self.baiduapi_key = "" self.baiduapi_terminology = False self.name = '设置' self.background_color = 'white' self.frame = (0, 0, self.app.width, self.app.height) self.flex = 'WHLRTB' self.closeBtn = ui.ButtonItem() self.closeBtn.image = ui.Image.named('iob:close_round_24') self.closeBtn.action = self.app.CloseAct self.left_button_items = [self.closeBtn] self.scrollView = ui.ScrollView() self.count_titleLabel = ui.Label() self.count_tableView = ui.TableView() self.countDataSource = CountDataSource(self.app, self) self.count_runtimesLabel = ui.Label() self.count_transChartSumLabel = ui.Label() self.count_tableView.add_subview(self.count_runtimesLabel) self.count_tableView.add_subview(self.count_transChartSumLabel) self.scrollView.add_subview(self.count_titleLabel) self.scrollView.add_subview(self.count_tableView) self.setting_titleLabel = ui.Label() self.setting_tableView = ui.TableView() self.settingDataSource = SystemSettingDataSource(self.app, self) self.setting_lestenBtn = ui.Switch() self.setting_tableView.add_subview(self.setting_lestenBtn) self.scrollView.add_subview(self.setting_titleLabel) self.scrollView.add_subview(self.setting_tableView) self.baiduapi_titleLabel = ui.Label() self.baiduapi_tableView = ui.TableView() self.baiduapiDataSource = BaiduAPIDataSource(self.app, self) self.baiduapi_terminologyBtn = ui.Switch() self.baiduapi_tableView.add_subview(self.baiduapi_terminologyBtn) self.scrollView.add_subview(self.baiduapi_titleLabel) self.scrollView.add_subview(self.baiduapi_tableView) self.clear_titleLabel = ui.Label() self.clear_tableView = ui.TableView() self.clearDataSource = ClearDataSource(self.app, self) self.scrollView.add_subview(self.clear_titleLabel) self.scrollView.add_subview(self.clear_tableView) self.info_titleLabel = ui.Label() self.info_tableView = ui.TableView() self.infoDataSource = InfoDataSource(self.app, self) self.scrollView.add_subview(self.info_titleLabel) self.scrollView.add_subview(self.info_tableView) self.copyrightLabel = ui.Label() self.scrollView.add_subview(self.copyrightLabel) self.add_subview(self.scrollView) self.LoadData() self.LoadUI()
def tableview_cell_for_row(self, tv, section, row): sn = SECTIONS[section] info = OPTIONS[sn][row] otype = info["type"] if otype == TYPE_LABEL: cell = ui.TableViewCell("value1") cell.detail_text_label.text = str(info["value"]) else: cell = ui.TableViewCell("default") cell.flex = "" if otype == TYPE_BOOL: switch = ui.Switch() switch.value = _stash.config.getboolean(sn, info["option_name"]) i = (sn, info["option_name"]) callback = lambda s, self=self, i=i: self.switch_changed(s, i) switch.action = callback cell.content_view.add_subview(switch) switch.y = (cell.height / 2.0) - (switch.height / 2.0) switch.x = (cell.width - switch.width) - (cell.width / 20) switch.flex = "L" elif otype == TYPE_CHOICE: seg = ui.SegmentedControl() seg.segments = info["choices"] try: cur = _stash.config.get(sn, info["option_name"]) curi = seg.segments.index(cur) except: curi = -1 seg.selected_index = curi i = (sn, info["option_name"]) callback = lambda s, self=self, i=i: self.choice_changed(s, i) seg.action = callback cell.content_view.add_subview(seg) seg.y = (cell.height / 2.0) - (seg.height / 2.0) seg.x = (cell.width - seg.width) - (cell.width / 20) seg.flex = "LW" elif otype == TYPE_COLOR: b = ui.Button() rawcolor = _stash.config.get(sn, info["option_name"]) color = ast.literal_eval(rawcolor) b.background_color = color b.title = str(color) b.tint_color = ((0, 0, 0) if color[0] >= 0.5 else (1, 1, 1)) i = (sn, info["option_name"]) callback = lambda s, self=self, i=i: self.choose_color(s, i) b.action = callback cell.content_view.add_subview(b) b.width = (cell.width / 6.0) b.height = ((cell.height / 4.0) * 3.0) b.y = (cell.height / 2.0) - (b.height / 2.0) b.x = (cell.width - b.width) - (cell.width / 20) b.flex = "LW" b.border_color = "#000000" b.border_width = 1 elif otype == TYPE_RGB_COLOR: b = ui.Button() rawcolor = _stash.config.get(sn, info["option_name"]) color = ast.literal_eval(rawcolor) rgb255color = int(color[0] * 255), int(color[1] * 255), int( color[2] * 255) b.background_color = color b.title = "#%.02X%.02X%.02X" % rgb255color b.tint_color = ((0, 0, 0) if color[0] >= 0.5 else (1, 1, 1)) i = (sn, info["option_name"]) callback = lambda s, self=self, i=i: self.choose_rgb_color(s, i) b.action = callback cell.content_view.add_subview(b) b.width = (cell.width / 6.0) b.height = ((cell.height / 4.0) * 3.0) b.y = (cell.height / 2.0) - (b.height / 2.0) b.x = (cell.width - b.width) - (cell.width / 20) b.flex = "LW" b.border_color = "#000000" b.border_width = 1 elif otype in (TYPE_STR, TYPE_INT): tf = ui.TextField() tf.alignment = ui.ALIGN_RIGHT tf.autocapitalization_type = ui.AUTOCAPITALIZE_NONE tf.autocorrection_type = False tf.clear_button_mode = "while_editing" tf.text = _stash.config.get(sn, info["option_name"]) tf.delegate = self i = (sn, info["option_name"]) callback = lambda s, self=self, i=i: self.str_entered(s, i) tf.action = callback if otype == TYPE_STR: tf.keyboard_type = ui.KEYBOARD_DEFAULT elif otype == TYPE_INT: tf.keyboard_type = ui.KEYBOARD_NUMBER_PAD tf.flex = "LW" cell.add_subview(tf) tf.width = (cell.width / 6.0) tf.height = ((cell.height / 4.0) * 3.0) tf.y = (cell.height / 2.0) - (tf.height / 2.0) tf.x = (cell.width - tf.width) - (cell.width / 20) elif otype == TYPE_FILE: # incomplete! b = ui.Button() fp = _stash.config.get(sn, info["option_name"]) fn = fp.replace(os.path.dirname(fp), "", 1) b.title = fn i = (sn, info["option_name"]) callback = lambda s, self=self, i=i, f=fp: self.choose_file( s, i, f) b.action = callback cell.content_view.add_subview(b) b.width = (cell.width / 6.0) b.height = ((cell.height / 4.0) * 3.0) b.y = (cell.height / 2.0) - (b.height / 2.0) b.x = (cell.width - b.width) - (cell.width / 20) b.flex = "LWH" elif otype == TYPE_COMMAND: b = ui.Button() b.title = info["display_name"] cmd = info["command"] if isinstance(cmd, string_types): f = lambda c=cmd: _stash(c, add_to_history=False) else: f = lambda c=cmd: cmd() callback = lambda s, self=self, f=f: self.run_func(f) b.action = callback cell.content_view.add_subview(b) b.flex = "WH" b.frame = cell.frame cell.remove_subview(cell.text_label) if otype != TYPE_COMMAND: title = info["display_name"] else: title = "" cell.text_label.text = title return cell
def main(self): # actually you need only to preserve those properties that are needed after the main_view.present call, # in this case the self.morpher. All the other self. prefixes are not needed for the same functionality self.q=queue.PriorityQueue() self.q1=queue.PriorityQueue() self.Eprom=Eprom1() self.sv=scene.SceneView() self.sv.scene=MyScene() self.sv.anti_alias = False self.sv.frame_interval = 1 self.sv.multi_touch_enabled = True self.sv.shows_fps = True self.sv.bg_color=(1,1,1,1) v1width=650 self.view1=ui.View(frame=(256+768-v1width,0,v1width,v1width)) self.messagetext='' self.rbtn1=ui.SegmentedControl(frame=(5.0,340.0,204.0,34.0), segments=('auto','xyz','123','maze'), action= self.rbutton_tapped) self.switch1=ui.Switch(frame=(6.0,34.0,51.0,31.0),action=self.setPin) self.switch1.targetPin=2 self.switch2=ui.Switch(frame=(197,167,51.0,31.0),action=self.setPin) self.switch2.targetPin=21 self.sv.add_subview(self.view1) self.sv.add_subview(self.rbtn1) self.sv.add_subview(self.switch1) self.sv.add_subview(self.switch2) self.keypad1=keypadNode(scale=1.15,radius=150,position=(15,35),anchor_point=(0,0), keytitles=['inc','y','X','Z','dec','z','r/g','x','Y','../_'], on_output_change=self.keypad_output_changed) self.keypad2=keypadNode(scale=1.15,radius=150,position=(15,35),anchor_point=(0,0), keytitles=['1','2','3','4','5','6','7','8','9','0'], orientation=((0,-1),(1,0),), on_output_change=self.keypad_output_changed) self.keypad3=keypadNode(scale=1.15,radius=150,position=(15,35),anchor_point=(0,0), keytitles=['Put\n{NE}','N','E','[NW]\nU','Take\n{SW}','D\n{SE}','[Ctrl]','W','S','{Alt}'], on_output_change=self.keypad_output_changed) scene.LabelNode(position=(-30,-120), anchor_point=(0,0), text='Reset: [Ctrl Alt D]',font=('Helvetica',15),parent=self.keypad3,color='black') self.mode=0 self.key='' self.scene_view = scn.View((0,0,self.view1.frame[2],self.view1.frame[3]), superView=self.view1) self.scene_view.allowsCameraControl = True self.scene_view.scene = scn.Scene() self.scene_view.delegate = self self.root_node = self.scene_view.scene.rootNode self.camera_node = scn.Node() self.camera_node.camera = scn.Camera() self.camera_node.position = (-10,1.5,2) self.camera_node.camera.focalLength=70 self.root_node.addChildNode(self.camera_node) self.origin_node = scn.Node() self.root_node.addChildNode(self.origin_node) self.floor_node=scn.Node(geometry=scn.Floor()) self.floor_node.position=(0,-1.25,0) # self.root_node.addChildNode(self.floor_node) n=4 scale=0.1/n r=3 # self.off_led = scn.Sphere(radius=r*scale) self.off_led = scn.Capsule(capRadius=r*scale,height=3*r*scale) self.off_led.firstMaterial.contents=UIColor.lightGrayColor().CGColor() # off_led.firstMaterial().emission().setColor_(UIColor.greenColor().CGColor()) self.green_led = scn.Capsule(capRadius=r*scale*1.1,height=3*r*scale*1.05) self.green_led.firstMaterial.contents=(UIColor.grayColor().CGColor()) self.green_led.firstMaterial.emission.contents=(UIColor.greenColor().CGColor()) self.red_led = scn.Capsule(capRadius=r*scale*1.1,height=3*r*scale*1.05) self.red_led.firstMaterial.contents=UIColor.grayColor().CGColor() self.red_led.firstMaterial.emission.contents=(UIColor.redColor().CGColor()) self.led_nodes = [[[scn.Node.nodeWithGeometry(self.off_led) for k in range(n)]for j in range(n)]for i in range(n)] self.off_wire = scn.Capsule(capRadius=r*0.25*scale,height=20*(n+0.5)*scale) self.off_wire.firstMaterial.contents=UIColor.lightGrayColor().CGColor() self.pos_wire = scn.Capsule(capRadius=r*0.25*scale,height=20*(n+0.5)*scale) self.pos_wire.firstMaterial.contents=UIColor.lightGrayColor().CGColor() self.pos_wire.firstMaterial.emission.contents=(0.7,0,0)#UIColor.magentaColor().CGColor()) self.neg_wire = scn.Capsule(capRadius=r*0.25*scale,height=20*(n+0.5)*scale) self.neg_wire.firstMaterial.contents=UIColor.lightGrayColor().CGColor() self.neg_wire.firstMaterial.emission.contents=(0,0,0.75)#(UIColor.blueColor().CGColor()) self.wire_nodes=[[[scn.Node.nodeWithGeometry((self.off_wire,self.neg_wire,self.pos_wire)[0]) for j in range(n)]for i in range(n)]for k in range(3)] wireoffset=r*scale for i in range(n): for j in range(n): x=(i-(n-1)/2)*20*scale y=(j-(n-1)/2)*20*scale self.root_node.addChildNode(self.wire_nodes[0][i][j]) self.wire_nodes[0][i][j].setPosition((x+wireoffset,0,y)) self.root_node.addChildNode(self.wire_nodes[1][i][j]) self.wire_nodes[1][i][j].setPosition((x,y-wireoffset,0)) self.wire_nodes[1][i][j].eulerAngles=(math.pi/2,0,0) self.root_node.addChildNode(self.wire_nodes[2][i][j]) self.wire_nodes[2][i][j].setPosition((0,x,y-wireoffset)) self.wire_nodes[2][i][j].eulerAngles=(0,0,math.pi/2) for k in range(n): z=(k-(n-1)/2)*20*scale self.root_node.addChildNode(self.led_nodes[i][j][k]) self.led_nodes[i][j][k].setPosition((x,y,z)) self.led_nodes[i][j][k].eulerAngles=(0.61547970867039,0,math.pi/4) self.index=0 self.oldindex=0 constraint = scn.LookAtConstraint(self.root_node)#(self.sphere_nodes[2][2][2]) constraint.gimbalLockEnabled = True self.camera_node.constraints = constraint self.light_node = scn.Node() self.light_node.position = (100, 0, -10) self.light = scn.Light() self.light.type = scn.LightTypeDirectional self.light.castsShadow = False self.light.color = 'white' self.light_node.light = self.light self.root_node.addChildNode(self.light_node) self.action = scn.Action.repeatActionForever(scn.Action.rotateBy(0, math.pi*2, 0, 10)) self.origin_node.runAction(self.action) self.sv.present(orientations= ['landscape'])
def __init__(self, app, father, obj): self.app = app self.father = father self.obj = obj self.presentPrice = Price("", -1) self.lastPrice = Price("", -1) self.firstPrice = Price("", -1) self.lowestPrice = Price("", -1) self.dates = [] self.prices = [] self.prices_v = [] self.years = [] self.epoch = 0 self.loadData() self.name = "应用详情" self.background_color = "white" self.frame = (0, 0, self.app.width, self.app.height) self.flex = "WHLRTB" self.infoView = ui.View() self.info_inconView = ui.ImageView() self.info_nameLabel = ui.Label() self.info_authorLabel = ui.Label() self.info_categoryLabel = ui.Button() self.info_createtimeLabel = ui.Label() self.info_updatetimeLabel = ui.Label() self.info_starBtn = ui.Button() self.info_storeBtn = ui.Button() self.info_updateBtn = ui.Button() self.info_deleteBtn = ui.Button() self.info_autoupdateLabel = ui.Label() self.info_autoupdateBtn = ui.Switch() self.infoView.add_subview(self.info_inconView) self.infoView.add_subview(self.info_nameLabel) self.infoView.add_subview(self.info_authorLabel) self.infoView.add_subview(self.info_categoryLabel) self.infoView.add_subview(self.info_createtimeLabel) self.infoView.add_subview(self.info_updatetimeLabel) self.infoView.add_subview(self.info_starBtn) self.infoView.add_subview(self.info_storeBtn) self.infoView.add_subview(self.info_updateBtn) self.infoView.add_subview(self.info_deleteBtn) self.infoView.add_subview(self.info_autoupdateLabel) self.infoView.add_subview(self.info_autoupdateBtn) self.priceView = ui.View() self.price_offLabel = SteamPriceLabel(self.lastPrice.getPrice(), self.presentPrice.getPrice()) self.price_normalLabel = PriceLabel("当前价格:", self.presentPrice, 100, 15) self.price_firstLabel = PriceLabel("收藏价格:", self.firstPrice, 100, 15) self.price_lowestLabel = PriceLabel("史低价格:", self.lowestPrice, 100, 15) self.price_TLine_Label = DividingLineLabel(10, 5) self.price_BLine_Label = DividingLineLabel(10, 5) self.priceView.add_subview(self.price_TLine_Label) self.priceView.add_subview(self.price_normalLabel) self.priceView.add_subview(self.price_offLabel) self.priceView.add_subview(self.price_firstLabel) self.priceView.add_subview(self.price_lowestLabel) self.priceView.add_subview(self.price_BLine_Label) self.graphView = ui.View() self.graph_pricePlot = PricePlotView() self.graph_epochBtn = ui.SegmentedControl() self.graphView.add_subview(self.graph_pricePlot) self.graphView.add_subview(self.graph_epochBtn) self.scrollView = ui.ScrollView() self.scrollView.frame = (0, 0, self.width, self.height) self.scrollView.flex = "WHRLTB" self.scrollView.always_bounce_vertical = True self.scrollView.bounces = True self.scrollView.add_subview(self.infoView) self.scrollView.add_subview(self.priceView) self.scrollView.add_subview(self.graphView) self.add_subview(self.scrollView) self.loadUI()
def __init__(self,app,father): self.app=app self.father=father self.count_apps=0 self.count_categorys=0 self.count_stars=0 self.count_prices=0 self.count_totalValue=0 self.cfg_runtimes=0 self.cfg_notice=1 self.cfg_downloadimg=1 self.cfg_log=1 self.datasize_img=0 self.datasize_log=0 self.datasize_database=0 self.name="设置" self.flex="WHRLTB" self.fontcolor_pastal="#999999" self.fontcolor_deep="#4c4c4c" self.fontcolor_warnning="#cf0000" self.scrollView=ui.ScrollView() self.count_titleLabel=ui.Label() self.count_tableView=ui.TableView() self.count_appsLabel=ui.Label() self.count_starsLabel=ui.Label() self.count_categorysLabel=ui.Label() self.count_runtimesLabel=ui.Label() self.count_pricesLabel=ui.Label() self.count_totalValueLabel=ui.Label() self.count_tableView.add_subview(self.count_runtimesLabel) self.count_tableView.add_subview(self.count_appsLabel) self.count_tableView.add_subview(self.count_starsLabel) self.count_tableView.add_subview(self.count_categorysLabel) self.count_tableView.add_subview(self.count_pricesLabel) self.count_tableView.add_subview(self.count_totalValueLabel) self.scrollView.add_subview(self.count_titleLabel) self.scrollView.add_subview(self.count_tableView) self.setting_titleLabel=ui.Label() self.setting_tableView=ui.TableView() self.settingDelegate=SettingDelegate(self.app,self) self.setting_noticeBtn=ui.Switch() self.setting_downloadBtn=ui.Switch() self.setting_logBtn=ui.Switch() self.setting_tableView.add_subview(self.setting_noticeBtn) self.setting_tableView.add_subview(self.setting_downloadBtn) self.setting_tableView.add_subview(self.setting_logBtn) self.scrollView.add_subview(self.setting_titleLabel) self.scrollView.add_subview(self.setting_tableView) self.clear_titleLabel=ui.Label() self.clear_tableView=ui.TableView() self.clearDelegate=ClaerDelegate(self.app,self) self.datasize_imgLabel=ui.Label() self.datasize_logLabel=ui.Label() self.datasize_sumLabel=ui.Label() self.clear_tableView.add_subview(self.datasize_imgLabel) self.clear_tableView.add_subview(self.datasize_logLabel) self.clear_tableView.add_subview(self.datasize_sumLabel) self.scrollView.add_subview(self.clear_titleLabel) self.scrollView.add_subview(self.clear_tableView) self.add_subview(self.scrollView) self.loadData()
#http://trekcore.com/audio/warp/tng_warp4_clean.mp3 #http://trekcore.com/audio/warp/tng_warp_out4.mp3 import requests, sound, ui #download sound effects from the web url_fmt = 'http://trekcore.com/audio/warp/{}.mp3' filenames = 'tng_warp_out4.caf tng_warp4_clean.caf'.split() for filename in filenames: with open(filename, 'w') as out_file: url = url_fmt.format(filename.rstrip('.caf')) out_file.write(requests.get(url).content) sound.load_effect(filename) def warp_action(sender): sound.play_effect(filenames[sender.value]) sw = ui.Switch() sw.action = warp_action view = ui.View(name='Captain Picard Wants Warp Speed') view.add_subview(sw) view.present() sw.center = view.center
# The ui v1 = ui.View(name='PhotosToDropbox') v2 = ui.View(name='PhotosToScale') width, height = ui.get_screen_size() if is_iP6p(): v1.frame = v2.frame = (0, 0, width, height) else: v1.frame = v2.frame = (0, 0, 414, 736) v1.flex = v2.flex = 'WHLRTB' v1.background_color = v2.background_color = 'cyan' # Controls for v1 sw1 = ui.Switch(frame=(269, 172, 51, 31)) sw1.value = True sw1.flex = 'WHLRTB' sw1.action = button_tapped sw1.name = 'toggle_meta' v1.add_subview(sw1) sw2 = ui.Switch(frame=(269, 224, 51, 31)) sw2.value = True sw2.flex = 'WHLRTB' sw2.action = button_tapped sw2.name = 'toggle_geotag' v1.add_subview(sw2) btn1 = ui.Button(frame=(63, 362, 292, 59)) btn1.font = ('<system-bold>', 15)