def __init__(self): switches = ui.SegmentedControl(frame=(50, 700, 300, 29)) switches.segments = ['Starred', 'Unread', 'All Items'] switches.selected_index = 1 switches.action = segment_action self.list = getGroups() self.tv = ui.TableView() self.tv.name = view_type + ' Groups' self.tv.delegate = self self.tv.data_source = self nv = ui.NavigationView(self.tv) nv.name = app_name sync_button = ui.ButtonItem() sync_button.title = '🔄' sync_button.tint_color = 'red' sync_button.action = sync_action nv.left_button_items = [sync_button] feed_button = ui.ButtonItem() feed_button.title = 'Feed' feed_button.tint_color = 'green' feed_button.action = feed_action group_button = ui.ButtonItem() group_button.title = 'Group' group_button.tint_color = 'blue' group_button.action = group_action nv.right_button_items = [feed_button, group_button] nv.add_subview(switches) nv.present('fullscreen')
def make_segcontr(self, name, segments, x, y, width, height): segcontr = ui.SegmentedControl() segcontr.name = name segcontr.segments = segments segcontr.selected_index = 0 segcontr.frame = (x, y, width, height) self.view.add_subview(segcontr) self.elements.append(name)
def make_segmented_control(self, segments): seg = ui.SegmentedControl() seg.action = self.layout seg.background_color = 'white' seg.flex = 'W' seg.height = 40 seg.segments = segments seg.selected_index = 0 seg.width = self.bounds[2] # .w return seg
def show_morpheus(sender): #wh = ui.get_screen_size() #f=(0,0,wh[0],wh[1]) f=(0,0,350,650) tabs = ['All', 'Outpt', 'Inpt', 'Inactive'] extra_tabs= ui.SegmentedControl() extra_tabs.segments = ['To See', 'Seen'] extra_tabs.name = 'todaytab' items_toAdd = [{'title':'Patient', 'object':Patient()}, {'title':'Act', 'object':Act()}] Morpheus(Patient, items_toAdd, frame = f, tabs_contents = tabs, extra_data = extra_tabs)
def get_view(self, dbpath, tablename): self.schema_v = ui.TableView('grouped') self.data_v = ui.TableView() schema_view = self.schema_v data_view = self.data_v dbo = tableobjectsview(dbpath, tablename) self.ov = dataobjectview(dbpath, tablename) w, h = ui.get_screen_size() schema_view.name = tablename schema_view.data_source = dbo schema_view.delegate = dbo data_view.name = tablename data_view.data_source = self.ov data_view.delegate = self.ov seg = ui.SegmentedControl() seg.segments = ['Schema', 'Data'] seg.selected_index = 0 seg.action = self.test seg.width = w / 3 seg.x = w / 2 - (seg.width / 2) seg.y = seg.height / 2 self.pbutton.y = seg.y self.nbutton.y = seg.y self.pbutton.x = seg.x - (seg.width / 2) self.nbutton.x = seg.x + seg.width self.pbutton.width = seg.width / 2 self.nbutton.width = seg.width / 2 self.pbutton.hidden = True self.nbutton.hidden = True self.pbutton.action = self.prev self.nbutton.action = self.next self.nbutton.enabled, self.pbutton.enabled = self.ov.initial_button_config( ) t = ui.View(frame=(0, 0, w, h)) t.background_color = (0.92, 0.92, 0.95) t.width = w t.height = h schema_view.width = w schema_view.height = t.height * 0.9 schema_view.y = 2 * seg.height data_view.width = w data_view.height = t.height * 0.9 data_view.y = 2 * seg.height data_view.hidden = True schema_view.hidden = False self.schema_v = schema_view self.data_v = data_view t.add_subview(self.schema_v) t.add_subview(self.data_v) t.add_subview(seg) t.add_subview(self.pbutton) t.add_subview(self.nbutton) return t
def makeHistoryToggleButtonObj (): # Progress Button toggleButton = ui.SegmentedControl (name = 'toggleButton', action = viewHistory ) #toggleButton.height = 50 toggleButton.width = 150 #searchButton.corner_radius = 6 toggleButton.segments =['Last week', 'All time'] toggleButton.center = (deviceWidth/2, deviceHeight/7*3) toggleButton.bg_color = '#f6f6f6' toggleButton.tint_color = '#ff2765' toggleButton.alpha = 0 return toggleButton
def __init__(self,tablist=[], frame=(0,0)+ui.get_screen_size()): '''takes an iterable of Views, using the view name as the tab selector. empty views sre just given generic names''' self.tabcounter=0 #unique counter, for name disambiguation self.buttonheight=30 #height of buttonbar #setup button bar self.tabbuttons=ui.SegmentedControl(frame=(0,-5,self.width, self.buttonheight+5),bg_color='white') self.tabbuttons.action=self.tab_action self.tabbuttons.flex='W' self.tabbuttons.segments=[] self.add_subview(self.tabbuttons) for tab in tablist: self.addtab(tab)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.control = ui.SegmentedControl(flex='LR') self.control.y = 4 self.control.action = self.select_subview self.add_subview(self.control) self.display_subviews = [] self.add_button = ui.ButtonItem('Add', action=view1_source.add_feed_url) #self.left_button_items = [self.add_button] self.edit_button = ui.ButtonItem('Edit', action=self.set_editing) #self.right_button_items = [self.edit_button] self.done_button = ui.ButtonItem('Done', action=self.unset_editing)
def __init__(self, search_phrases, favcat_nums_titles, **kwargs): self.favcat_nums_titles = favcat_nums_titles self.background_color = 'white' self.update_interval = 0.1 self.width = kwargs.get('width', 603) self.height = kwargs.get('height', 44 * 4 + 10 + 29) tableview1 = ui.TableView(frame=(0, 0, self.width, 44 * 4), name='tableview1') self.add_subview(tableview1) self.lds = ui.ListDataSource(items=search_phrases) self['tableview1'].data_source = self.lds self['tableview1'].delegate = self.lds segmentedcontrol1 = ui.SegmentedControl( frame=(2, 44 * 4 + 10, self.width - 4, 29), name='segmentedcontrol1', segments=['Home', 'Watched', 'Favorites', 'Downloads'], action=self.show_aso) self.add_subview(segmentedcontrol1)
def popup_menu(self): popup = ui.View(name='menu', frame=(0, 0, 320, 500)) toolbar = ui.View(frame=(-5, 0, 330, 100), name='toolbar') toolbar.border_width = 0.5 toolbar.border_color = '#B2B2B2' label = ui.Label() label.text = 'Bookmarks' label.alignment = ui.ALIGN_CENTER label.frame = (0, 0, 320, 50) label.name = 'title' segment_ctrl = ui.SegmentedControl(name='segctrl') segment_ctrl.segments = ['Bookmarks', 'History'] segment_ctrl.width = 170 segment_ctrl.center = popup.center segment_ctrl.y = label.height segment_ctrl.selected_index = 0 segment_ctrl.action = self.bookmarks_or_history button = ui.Button() button.frame = (segment_ctrl.x * 3.5, segment_ctrl.y, 60, 30) button.font = ('<system>', 15) button.title = 'Clear' button.name = 'clear' button.action = self.clear_history button.hidden = True toolbar.add_subview(label) toolbar.add_subview(segment_ctrl) toolbar.add_subview(button) popup.add_subview(toolbar) data_source = ui.ListDataSource(sorted(self.bookmarks.keys())) popup.add_subview( self.list_bookmarks_and_history(data_source, width=320, height=toolbar.superview.height - toolbar.height, y=toolbar.height, name='bookmarks')) x, y = self['controlpanel']['bookmarks'].center popup.present('popover', popover_location=(x, y), hide_title_bar=True)
def __init__ (self): self.name = '书单' self.tags = ui.SegmentedControl() self.tags.frame = (-10,0,w+20,30) self.tags.bg_color = 'white' self.tags.tint_color = '#f99157' self.tags.segments = ('本周最热','最新发布','收藏最多') self.tags.selected_index = 0 self.tags.action = self.tags_tapped self.list = ui.TableView() self.list.bg_color = '#f5f9f0' self.list.frame = (0,30,w,h-143) self.list.row_height = 100 self.list.data_source = BookListDataSource() self.list.delegate = BookListDelegate() self.top_button = ui.Button() self.top_button.name = 'top' self.top_button.frame = (325,250,40,40) self.top_button.tint_color = 'green' self.top_button.image = ui.Image.named('typb:Up') self.top_button.border_width = 1 self.top_button.border_color = 'green' self.top_button.corner_radius = 20 self.top_button.action = self.button_tapped self.down_button = ui.Button() self.down_button.name = 'down' self.down_button.frame = (325,295,40,40) self.down_button.tint_color = 'green' self.down_button.image = ui.Image.named('typb:Down') self.down_button.border_width = 1 self.down_button.border_color = 'green' self.down_button.corner_radius = 20 self.down_button.action = self.button_tapped self.add_subview(self.tags) self.add_subview(self.list) self.add_subview(self.top_button) self.add_subview(self.down_button) root_view.view.push_view(self)
def __init__(self): self.present() self.name = 'SegNav' seg = ui.SegmentedControl() seg.action = self.seg_view_action seg.background_color = 'white' seg.flex = 'W' seg.height = 40 seg.segments = 'even', 'odd' seg.selected_index = 0 # set the highlight seg.width = self.bounds.w self.add_subview(seg) x, y, w, h = self.bounds self.table_view = ui.TableView() self.table_view.data_source = ui.ListDataSource(range(0, 42, 2)) self.table_view.flex = 'WH' self.table_view.frame = x, y + seg.height, w, h - seg.height self.add_subview(self.table_view)
def __init__(self, width=340, height=180): self.ds = None self.dsrow = None self.width = width self.height = height self.add_subview( ui.Button(name='bb', frame=(0, 0, 72, 32), title='Back', image=ui.Image.named('iob:ios7_arrow_back_24'), action=self.unload)) self.add_subview( ui.Label(name='lt', center=(self.width // 2, 16), flex='LR', text='', font=('<system>', 19), alignment=1)) self.add_subview( ui.SegmentedControl(name='sc', frame=(0, 42, 232, 30), segments=['RGB', 'HSV'], selected_index=0, action=self.upd)) self.add_subview( ui.TextField(name='thex', frame=(238, 40, 102, 30), action=self.upd)) for i in range(3): self.add_subview( ui.Slider(name='s' + str(i), frame=(0, 78 + 34 * i, 196, 34), continuous=True, action=self.upd, value=1)) self.add_subview( ui.TextField(name='t' + str(i), frame=(196, 78 + 34 * i, 42, 34), font=('<system>', 14), action=self.upd, value=1)) self.add_subview(ui.View(name='res', frame=(238, 78, 102, 102)))
def __init__(self): # Init self.views = [] self.curview = None self.root = ui.View(name="Multipanel") self.close = ui.Button() self.close.name = "close" self.close.enabled = False self.close.image = ui.Image.named("ionicons-close-round-32") self.close.action = self.close_tapped self.root.add_subview(self.close) self.close.frame = self.root.width - 32, 0, 32, 32 self.close.flex = "LB" self.tabs = ui.SegmentedControl() self.tabs.name = "tabs" self.tabs.enabled = False self.tabs.selected_index = -1 self.tabs.segments = [PLACEHOLDER_TEXT] self.tabs.action = self.segment_changed self.root.add_subview(self.tabs) self.tabs.frame = 0, 0, self.root.width - self.close.width, self.tabs.height self.tabs.flex = "WB" self.placeholder = ui.View() self.placeholder.background_color = "lightgray" self.ph_label = ui.Label() self.ph_label.font = ("<system-bold>", 24) self.ph_label.text_color = "gray" self.ph_label.text = "No View Selected" self.placeholder.add_subview(self.ph_label) self.ph_label.size_to_fit() self.ph_label.center = self.placeholder.center self.ph_label.flex = "TBLR" self.update_view()
def add(sender): global rows rows += 1 y = 32*(rows-1)+10*rows sc = ui.SegmentedControl() sc.segments = 'PAB' sc.frame = (215, y, 69, 32) sc.flex = 'LR' sc.name = f'sc{rows}' sc.action = search v.add_subview(sc) tf = ui.TextField() tf.placeholder = 'search term' tf.frame = (6, y, 106, 32) tf.flex = 'TF' tf.name = f'tf{rows}' tf.action = search v.add_subview(tf) adb = ui.Button() adb.title = '+' adb.frame = (294, y, 37, 32) adb.flex = 'LB' adb.name = f'add{rows-1}' adb.action = add v.add_subview(adb) sub = ui.Button() sub.title = '-' sub.frame = (332, y, 37, 32) sub.flex = 'LB' sub.name = f'sub{rows-1}' sub.action = delete v.add_subview(sub) v['tv'].y += 42
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 init_webbrowser(self): web = self['webview'] web.load_url('https://omz-forums.appspot.com/pythonista') web.delegate = self def init_size(self): # initialize with correct size when landscape orientation = ui.WebView(frame=(0,0,100,200)).eval_js('window.orientation') if orientation in (-90, 90): self.frame = (0, 0, self.height, self.width) def did_load(self): self.init_buttons() self.init_webbrowser() self.init_addressbar() self.init_size() self.flex = 'WH' self.bookmarks = self.load_bookmarks() self.history = self.load_history() self.addressbar_is_editing = False self.webpage_has_loaded = False self.favourite_images = {True :ui.Image.named('ionicons-ios7-star-32'), False:ui.Image.named('ionicons-ios7-star-outline-32')} def save_history(self, filename=filename_history): with open(filename, 'w') as f: url = self.get_url() if url in self.history: self.history.remove(url) self.history.append(url) f.seek(0) pickle.dump(self.history, f) def clear_history(self, sender, filename=filename_history): with open(filename, 'w') as f: self.history = [] f.seek(0) pickle.dump(self.history, f) sender.superview.superview['history'].data_source.items = self.history sender.superview.superview['history'].reload() def save_bookmark(self, filename=filename_bookmarks): with open(filename, 'w') as f: url = self.get_url() title = self.get_title() or self.parse_url(url) self.bookmarks[title] = url f.seek(0) json.dump(self.bookmarks, f, indent=4) self['controlpanel']['favourite'].image = self.favourite_images[True] def remove_bookmark(self, title=None, filename=filename_bookmarks): with open(filename, 'w') as f: title = title or self.get_title() del self.bookmarks[title] f.seek(0) json.dump(self.bookmarks, f, indent=4) self['controlpanel']['favourite'].image = self.favourite_images[False] def popup_menu(self): popup = ui.View(name='menu', frame=(0, 0, 320, 500)) toolbar = ui.View(frame=(-5, 0, 330, 100), name='toolbar') toolbar.border_width = 0.5 toolbar.border_color = '#B2B2B2' label = ui.Label() label.text = 'Bookmarks' label.alignment = ui.ALIGN_CENTER label.frame = (0, 0, 320, 50) label.name = 'title' segment_ctrl = ui.SegmentedControl(name='segctrl') segment_ctrl.segments = ['Bookmarks', 'History'] segment_ctrl.width = 170 segment_ctrl.center = popup.center segment_ctrl.y = label.height segment_ctrl.selected_index = 0 segment_ctrl.action = self.bookmarks_or_history button = ui.Button() button.frame = (segment_ctrl.x*3.5, segment_ctrl.y, 60, 30) button.font = ('<system>', 15) button.title= 'Clear' button.name = 'clear' button.action = self.clear_history button.hidden = True toolbar.add_subview(label) toolbar.add_subview(segment_ctrl) toolbar.add_subview(button) popup.add_subview(toolbar) data_source = ui.ListDataSource(sorted(self.bookmarks.keys())) popup.add_subview(self.list_bookmarks_and_history(data_source, width=320,height=toolbar.superview.height-toolbar.height, y=toolbar.height, name='bookmarks')) x, y = self['controlpanel']['bookmarks'].center popup.present('popover', popover_location=(x, y), hide_title_bar=True) def bookmarks_or_history(self, sender): toolbar = sender.superview if sender.selected_index == 0: toolbar['clear'].hidden = True toolbar['title'].text = 'Bookmarks' data_source = ui.ListDataSource(sorted(self.bookmarks.keys())) tv = self.list_bookmarks_and_history(data_source, width=320, height=toolbar.superview.height-toolbar.height, y=toolbar.height, name='bookmarks') toolbar.superview.remove_subview(toolbar.superview['history']) else: toolbar['clear'].hidden = False toolbar['title'].text = 'History' data_source = ui.ListDataSource(self.history[::-1]) tv = self.list_bookmarks_and_history(data_source, width=320, height=toolbar.superview.height-toolbar.height, y=toolbar.height, name='history') toolbar.superview['bookmarks'].hidden=True toolbar.superview.remove_subview(toolbar.superview['bookmarks']) sender.superview.superview.add_subview(tv) def list_bookmarks_and_history(self, data_source, **kwargs): tv = ui.TableView() tv.data_source = data_source tv.delegate = self for k, v in kwargs.items(): setattr(tv, k, v) return tv def show_more_menu(self): popup = ui.TableView() popup.width = 250 popup.height = 500 popup.name = 'More' popup.data_source = popup.delegate = self button = self['controlpanel']['more'] popup.present('popover', popover_location=(button.x, button.y+button.height)) def button_tapped(self, sender): if sender.name == 'favourite': if self.get_url() in self.bookmarks.values(): self.remove_bookmark() else: self.save_bookmark() elif sender.name == 'bookmarks': self.popup_menu() elif sender.name == 'more': self.show_more_menu() else: eval("self['webview'].{}()".format(sender.name)) def tableview_number_of_rows(self, tableview, section): if tableview.name == 'Bookmarks': return len(self.bookmarks) elif tableview.name == 'More': return 1 def tableview_cell_for_row(self, tableview, section, row): if tableview.name == 'Bookmarks': cell = ui.TableViewCell() cell.text_label.text = sorted(self.bookmarks.keys())[row] cell.image_view.image = ui.Image.named('ionicons-ios7-bookmarks-outline-32') cell.image_view.tint_color = '#66CCFF' return cell elif tableview.name == 'More': cell = ui.TableViewCell() cell.text_label.text = 'Settings' cell.image_view.image = ui.Image.named('ionicons-wrench-32') return cell @ui.in_background def tableview_did_select(self, tableview, section, row): if tableview.name == 'bookmarks': url = self.bookmarks[sorted(self.bookmarks.keys())[row]] self.load_url(url) tableview.superview.close() elif tableview.name == 'history': url = tableview.data_source.items[row] tableview.superview.close() self.load_url(url) elif tableview.name == 'More': tableview.close() console.hud_alert('No settings yet...', 'error', 1) def tableview_can_delete(self, tableview, section, row): return True def tableview_delete(self, tableview, section, row): item = sorted(self.bookmarks.keys())[row] self.remove_bookmark(item) tableview.reload() def textfield_did_begin_editing(self, textfield): self.addressbar_is_editing = True self.set_url() self['controlpanel']['reload'].hidden = True def textfield_did_end_editing(self, textfield): self.addressbar_is_editing = False self['controlpanel']['reload'].hidden = False self.set_url() def textfield_should_return(self, textfield): url = self['controlpanel']['addressbar'].text self.load_url(url) textfield.end_editing() return True def webview_did_start_load(self, webview): self.webpage_has_loaded = False def webview_did_finish_load(self, webview): if not self.addressbar_is_editing: self.set_url() self.webpage_has_loaded = True page_is_bookmarked = unicode(self.get_url()) in self.bookmarks.values() self['controlpanel']['favourite'].image = self.favourite_images[page_is_bookmarked] self.save_history()
def segment2(sender): console.alert('Segment 2 Has been selected') def segment_action(sender): seg_name = sender.segments[sender.selected_index] console.alert(seg_name + ' has been selected') def segment_action(sender): selection = sender.selected_index if selection == 0: segment1(sender) elif selection == 1: segment2(sender) view = ui.View() segview = ui.SegmentedControl() segview.segments = ['seg1', 'seg2'] segview.action = segment_action view.add_subview(segview) view.present() @ui.in_background def popup(): console.alert("hello") popup()
# The ui v = ui.View() v.width, v.height = ui.get_screen_size() if is_iP6p(): v.frame = (0, 0, v.width, v.height) else: v.frame = (0, 0, 414, 736) v.flex = 'WHLRTB' v.background_color = 'cyan' sc1 = ui.SegmentedControl(frame=(32, 146, 350, 42)) sc1.segments = ('Date', 'Time', 'Both') # Default to 'Both' date and time sc1.selected_index = 2 sc1.border_width = 2 sc1.corner_radius = 10 sc1.tint_color = 'black' sc1.background_color = 'yellow' sc1.flex = 'WHLRTB' sc1.action = seg1_selected v.add_subview(sc1) sc2 = ui.SegmentedControl(frame=(32, 196, 350, 42)) sc2.segments = ('12 Hr Clock', '24 Hr Clock') # Default to 12 hr clock sc2.selected_index = 0
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): self.width, self.height = ui.get_screen_size() # Accomodate varying screen sizes...flex property of controls will allow size adjustments. if is_iP6p(): self.frame = (0, 0, self.width, self.height) else: # Flex property will adjust frame dimensions for all controls on smaller devices with main frame set at iPhone 6 max. self.frame = (0, 0, 414, 736) self.background_color = 'orange' self.flex = 'WHLRTB' b1 = ui.ButtonItem('Quit', action=self.cancel, tint_color='black') self.left_button_items = [b1] self.sc = ui.SegmentedControl(frame=(20, 30, 380, 50)) self.tf1 = ui.TextField(frame=(20, 130, 380, 50)) self.tf2 = ui.TextField(frame=(70, 240, 275, 50)) self.lb1 = ui.Label(frame=(70, 80, 275, 50)) self.lb2 = ui.Label(frame=(70, 190, 275, 50)) self.lb3 = ui.Label(frame=(20, 195, 380, 125)) self.iv1 = ui.ImageView(frame=(55, 350, 300, 300)) #self.iv2 = ui.ImageView(frame = (55, 350, 125, 50)) self.iv2 = ui.ImageView(frame=(55, 602, 125, 50)) self.sc.segments = ('Search Movies-TV', 'Search Person') self.sc.bordered = True self.sc.border_width = 2 self.sc.background_color = 'cyan' self.sc.tint_color = 'black' self.sc.corner_radius = 10 self.sc.flex = "WHLRTB" # Default to a title search self.sc.selected_index = 0 self.sc.action = seg1_selected self.tf1.bordered = False self.tf1.background_color = 'cyan' self.tf1.corner_radius = 10 self.tf1.font = ('<system-bold>', 16) self.tf1.flex = "WHLRTB" self.tf1.clear_button_mode = 'while_editing' self.tf1.delegate = self # Displays keyboard #self.tf1.begin_editing() self.tf2.bordered = False self.tf2.background_color = 'cyan' self.tf2.corner_radius = 10 self.tf2.font = ('<system-bold>', 16) self.tf2.flex = 'WHLRTB' self.tf2.clear_button_mode = 'while_editing' self.tf2.keyboard_type = ui.KEYBOARD_NUMBER_PAD self.lb1.alignment = ui.ALIGN_CENTER self.lb1.text = 'Movie-TV Series Title:' self.lb1.name = 'text_field' self.lb1.font = ('<system-bold>', 18) self.lb1.flex = 'WHLRTB' self.lb2.alignment = ui.ALIGN_CENTER self.lb2.text = "Release Year If Known:" self.lb2.font = ('<system-bold>', 18) self.lb2.flex = 'WHLRTB' self.lb3.alignment = ui.ALIGN_JUSTIFIED msg = 'Searches on people can take 15-20 seconds or more depending on the amount of info available.' # Allow multiple lines self.lb3.number_of_lines = 0 self.lb3.text = msg self.lb3.hidden = True self.lb3.font = ('<system-bold>', 15) # Use color when testing for proper sizing & placement of label #self.lb3.background_color = 'cyan' self.lb3.flex = 'WHLRTB' # Image files need to be in the same directory as this script self.iv1.image = ui.Image.named('movie_camera.gif') self.iv1.flex = 'WHLRTB' self.iv2.image = ui.Image.named('tmdb_logo.png') self.iv2.flex = 'WHLRTB' # Load controls into ui self.add_subview(self.sc) self.add_subview(self.tf1) self.add_subview(self.tf2) self.add_subview(self.lb1) self.add_subview(self.lb2) self.add_subview(self.lb3) self.add_subview(self.iv1) self.add_subview(self.iv2)
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()
pre_cmap_array = (255*(arrx - numpy.min(arrx))/numpy.ptp(arrx)).astype(int) cm = matplotlib.cm.get_cmap('jet') post_cmap_array = numpy.uint8(numpy.rint(cm(pre_cmap_array)*255))[:, :, :3] cmap_img = Image.fromarray(post_cmap_array) cmap_img.save(chosen_pic_colormap_image_buffer, format = 'PNG') chosen_pic_image.save(chosen_pic_photo_image_buffer, format = 'PNG') rgbData = chosen_pic_photo_image_buffer.getvalue() chosen_pic_depth_image_buffer = io.BytesIO() chosen_pic_depth_image.save(chosen_pic_depth_image_buffer, format = 'PNG') depthData = chosen_pic_depth_image_buffer.getvalue() s = Server() s.start_server() modeSelector = ui.SegmentedControl(alpha = 0, corner_radius = 5) modeSelector.segments = ('Mesh' , 'Wireframe', 'Point Cloud') modeSelector.selected_index = 0 modeSelector.action = modeSelect textureSelector = ui.SegmentedControl(alpha = 0, corner_radius = 5) textureSelector.segments = ('Photo' , 'Colormap') textureSelector.selected_index = 0 textureSelector.action = textureSelect closeButton = ui.Button(title = 'Close', alpha = 0, background_color = 'black', tint_color = 'white', corner_radius = 5) closeButton.action = close_button depthSourceLabel = ui.Label(text = 'Depth Source: ' + depthSource, font = ('<system>', 14), alignment = ui.ALIGN_CENTER, alpha = 0, text_color = 'black') cameracontrol = ui.WebView(apha = 0, corner_radius = 15) cameracontrol.delegate = debugDelegate()
tf_carb_per_100.height = 35 tf_carb_per_100.keyboard_type = ui.KEYBOARD_NUMBERS tf_carb_per_100.border_width = 1 # Label: выбор расчета lb_option = ui.Label() lb_option.text = ' 2. Выберите расчет:' lb_option.x = 0 lb_option.y = 75 lb_option.height = 35 lb_option.width = screen_width lb_option.alignment = ui.ALIGN_LEFT lb_option.border_width = 1 # SegmentedControl: выбор расчета sc_option = ui.SegmentedControl() sc_option.enable = True sc_option.x = 0 sc_option.y = 110 sc_option.width = screen_width sc_option.height = 50 sc_option.segments = 'Сколько ХЕ в Х грамм?', 'Сколько гр.прод. на Х ХЕ?' sc_option.border_width = 1 # Label: во что пересчитываем lb_param_to = ui.Label() lb_param_to.text = ' 3. ' lb_param_to.x = 0 lb_param_to.y = 160 lb_param_to.height = 35 lb_param_to.width = screen_width
view.background_color = 'white' markdown_prev = ui.ButtonItem(title='Markdown Preview', action=markdown_prev, enabled=True) view.right_button_items = [markdown_prev] #Title Field title_field = ui.TextField() title_field.frame = 5,8,600,30 title_field.corner_radius = 5 title_field.bordered = True title_field.border_color = '#999999' title_field.border_width = 1 title_field.placeholder = 'Title of Post (Required)' view.add_subview(title_field) #Post Type sc = ui.SegmentedControl() sc.segments = ['General','Share Code','Question'] sc.enabled = True sc.selected_index = 0 sc.frame = 615,8,400,30 view.add_subview(sc) #Label post_label = ui.Label() post_label.frame = 5,45,250,30 post_label.text = "Edit your post:" view.add_subview(post_label) #Post Draft Box post_edit_box = ui.TextView() post_edit_box.frame = 5,80,1014,620
def __init__(self, persons: List["Person"]): self.persons = persons self.now = datetime.now() self.name = "Attestion de déplacement" self.flex = "WH" self.background_color = 'white' y = CONTROLS_VERTICAL_MARGIN self.reason_selector = ui.SegmentedControl( y=y, width=300, segments=REASONS_TITLES, selected_index=4) y += CONTROLS_HEIGHT + CONTROLS_VERTICAL_MARGIN self.generated_label1 = ui.Label( text=f"Créé à : {self.now.strftime('%Hh%M')} - ") self.generated_label1.size_to_fit() self.generated_label1.y = ( y + (CONTROLS_HEIGHT - self.generated_label1.height) / 2) self.generated_textfield = ui.TextField( y=y, width=50, height=CONTROLS_HEIGHT, keyboard_type=ui.KEYBOARD_NUMBER_PAD, placeholder="0", delegate=self) self.generated_label2 = ui.Label( text=" min") self.generated_label2.size_to_fit() self.generated_label2.y = ( y + (CONTROLS_HEIGHT - self.generated_label1.height) / 2) y += CONTROLS_HEIGHT + CONTROLS_VERTICAL_MARGIN self.start_label1 = ui.Label() self.start_textfield = ui.TextField( y=y, width=50, height=CONTROLS_HEIGHT, keyboard_type=ui.KEYBOARD_NUMBER_PAD, placeholder="0") self.start_label2 = ui.Label( text=" min") self.start_label2.size_to_fit() self.start_label2.y = y + (CONTROLS_HEIGHT - self.start_label2.height) / 2 y += CONTROLS_HEIGHT + CONTROLS_VERTICAL_MARGIN self.separator_line = ui.View( y=y, height=1, border_width=1, border_color=SEPARATOR_COLOR) y += 1 self.tableview = ui.TableView( y=y, data_source=self, delegate=self) self.busy = BusyView() for view in [self.reason_selector, self.start_label1, self.start_textfield, self.start_label2, self.generated_label1, self.generated_textfield, self.generated_label2, self.separator_line, self.tableview, self.busy]: self.add_subview(view)
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 input_alert(self, title='', message='', input='', ok_button_title='ok', hide_cancel_button=False): #first, cover up view #then from threading import Timer print(threading.enumerate()) from thread import interrupt_main self.e.clear() for s in self.subviews: self.remove_subview(s) if self.superview: dim = ui.View(frame=(0, 0, self.superview.width, self.superview.height), bg_color=(0.5, 0.5, 0.5, 0.75)) inputbox = ui.View() inputbox.width = 300 inputbox.corner_radius = 10 inputbox.bg_color = 'white' inputbox.border_color = 'black' inputbox.center = (dim.width / 2, dim.height / 2) titlelabel = ui.Label() titlelabel.text = title titlelabel.alignment = ui.ALIGN_CENTER titlelabel.font = ('<system-bold>', 14) titlelabel.size_to_fit() titlelabel.y = 10 titlelabel.x = 0 messagelabel = ui.Label() messagelabel.text = message messagelabel.alignment = ui.ALIGN_CENTER messagelabel.font = ('<system>', 12) messagelabel.x = 0 messagelabel.y = titlelabel.height + titlelabel.y messagelabel.size_to_fit() inputfield = ui.TextField() inputfield.text = input inputfield.font = ('<system>', 12) inputfield.height = titlelabel.height * 1.5 inputfield.x = 0.1 * inputbox.width inputfield.y = messagelabel.height + messagelabel.y inputfield.width = .8 * inputbox.width inputfield.corner_radius = 0 inputfield.border_width = 1 inputfield.action = self.input_action buttons = ui.SegmentedControl() buttons.corner_radius = 0 buttons.height = 30 buttons.segments = ('Cancel', 'Ok') buttons.width = titlelabel.width = messagelabel.width = inputbox.width buttons.width += 10 buttons.x -= 5 buttons.y = inputfield.y + inputfield.height + 10 buttons.action = self.button_action inputbox.height = buttons.y + buttons.height - 1 dim.add_subview(inputbox) inputbox.add_subview(titlelabel) inputbox.add_subview(messagelabel) inputbox.add_subview(inputfield) inputbox.add_subview(buttons) self.superview.add_subview(dim) self.bring_to_front() dim.bring_to_front() self.width = dim.width self.height = dim.height def check_if_onscreen(): if not self.on_screen: self.e.set() else: Timer(0.25, check_if_onscreen).start() check_if_onscreen() self.e.wait() self.superview.remove_subview(dim) if not hide_cancel_button and buttons.selected_index == 0: rtnvalue = None self.width = 1 self.height = 1 interrupt_main() self.e.set() else: rtnvalue = inputfield.text self.width = 1 self.height = 1 return rtnvalue
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]
#Buildling out view info. v = ui.View(frame=(0, 0, 300, 110)) #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