def __init__(self, parent_vc=None): global logger super(SyncSelector, self).__init__(parent_vc) self.selected_index = None self.popup_vc = None self.load('sync_selector') self.tableview_sync_selector = self.find_subview_by_name('tableview_sync_selector') self.button_scan = self.find_subview_by_name('button_scan') self.button_sync = self.find_subview_by_name('button_sync') self.button_pyzipista = self.find_subview_by_name('button_pyzipista') self.button_working_copy = self.find_subview_by_name('button_working_copy') self.label_open_repository = self.find_subview_by_name('label_open_repository') self.label_pyzipista = self.find_subview_by_name('label_pyzipista') self.view_working_copy_icon = self.find_subview_by_name('imageview_icon_feature_1') self.view_pyzipista_icon = self.find_subview_by_name('imageview_icon_feature_2') self.view.width = min(ui.get_screen_size()) self.view.height = min(ui.get_screen_size()) image = ui.Image.named(IMAGE_URL_GITSYNCHISTA_ICON) self.find_subview_by_name('imageview_gitsynchista_icon').image = image if pyzipista_support.pyzipista_found(): image = ui.Image.named(IMAGE_URL_PYZIPISTA_ICON).with_rendering_mode(ui.RENDERING_MODE_ORIGINAL) self.view_pyzipista_icon.image = image self.button_pyzipista.image = image image = ui.Image.named(IMAGE_URL_WORKING_COPY_ICON).with_rendering_mode(ui.RENDERING_MODE_ORIGINAL) self.view_working_copy_icon.image = image self.button_working_copy.image = image self.popup_vc = None self.pythonista_app_support = url_scheme_support.UrlSchemeSupport('pythonista')
def __init__(self): super(PopupViewController, self).__init__(None) self.load('popup') self.info_text_view = self.find_subview_by_name('textview_info_text') self.button_view = self.find_subview_by_name('button_close') self.view.width = min(ui.get_screen_size()) self.view.height = min(ui.get_screen_size())
def __init__ (self): global filename global textview filename = 'newfile.txt' self.background_color = '' #Textwell Button textwell_button = ui.ButtonItem() textwell_button.title = 'Textwell' textwell_button.action = self.export_textwell #Copy Button copy_button = ui.ButtonItem() copy_button.title = 'Copy' copy_button.action = self.export_clipboard #Action Button action_button = ui.ButtonItem() action_button.title = 'Action' action_button.tint_color = '#fd0000' action_button.action = self.action self.right_button_items = [copy_button,textwell_button] self.left_button_items = [action_button] textview = self.textview textview.background_color = '#EEE' textview.bordered = 0 w,h = ui.get_screen_size() textview.width = w textview.height = h textview.flex = 'WH' textview.font = ('<system>',18) self.add_subview(textview)
def __init__(self): screen_w, screen_h = ui.get_screen_size() ipad = min(screen_w, screen_h) >= 768 diameter = floor(min(screen_w, screen_h) * 0.9) border = 20.0 if ipad else 12.0 font_size = 70.0 if ipad else 32.0 face_img = self.draw_face(diameter, border, font_size) self.face_sprite = sk.SpriteNode(sk.Texture(face_img)) self.face_sprite.position = self.size[0]/2, self.size[1]/2 self.add_child(self.face_sprite) hand_length = diameter/2 - font_size hand_width = 15 if ipad else 12 second_hand_img = self.draw_hand(hand_width/1.5, hand_length, 'red') minute_hand_img = self.draw_hand(hand_width, hand_length, 'black') hour_hand_img = self.draw_hand(hand_width, hand_length*0.7, 'black') self.second_hand_sprite = sk.SpriteNode(sk.Texture(second_hand_img)) self.second_hand_sprite.anchor_point = (0.5, 0.0) self.minute_hand_sprite = sk.SpriteNode(sk.Texture(minute_hand_img)) self.minute_hand_sprite.anchor_point = (0.5, 0.0) self.hour_hand_sprite = sk.SpriteNode(sk.Texture(hour_hand_img)) self.hour_hand_sprite.anchor_point = (0.5, 0.0) self.face_sprite.add_child(self.hour_hand_sprite) self.face_sprite.add_child(self.minute_hand_sprite) self.face_sprite.add_child(self.second_hand_sprite) self.center_sprite = sk.SpriteNode(sk.Texture(self.draw_center(hand_width*1.5, 'black'))) self.face_sprite.add_child(self.center_sprite)
def __init__(self,fldname,dateval,action=None): self.days = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'] self.width,self.height = ui.get_screen_size() cv = ui.View(name=fldname) cv.frame = (0,95,self.width,255) cv.background_color = 'yellow' cv.border_color = 'yellow' cv.border_width = 2 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 = 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) 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 get_keyboard_frame(self,frame=None): '''get corrected keyboard frame, in the screen coordinates. built in function breaks when in fullscreen, as it reports kbframe relative to a landscape screen''' #TODO: remove dependence on webview, use xaxis/yaxis to determine rotation instead if frame is None: frame=ui.get_keyboard_frame() origin=ui.convert_point((0,0),None,self ) xaxis=ui.convert_point((1,0),None,self ) xaxis=[xaxis[j]-origin[j] for j in (0,1)] yaxis=ui.convert_point((0,1),None,self ) yaxis=[yaxis[j]-origin[j] for j in (0,1)] o=self.__w.eval_js('window.orientation') (w,h)=ui.get_screen_size() if xaxis[0]==1 and yaxis[1]==1 and frame[0]==0: #we are not in fullscreen, just return kbframe fixedframe=frame elif o=='0': fixedframe= frame #ok elif o=='-90': fixedframe= [frame[1], frame[0], h,frame[2]] elif o=='180': fixedframe= [frame[0], h-frame[1]-frame[3], frame[2],frame[3]] #okrqq elif o=='90': fixedframe= [frame[1], w-frame[0]-frame[2],h,frame[2]] else: raise Error('UnexpectedOrientation') return fixedframe
def main(args): if ui.get_screen_size()[0] >= 768: from filenav import full full.main(args) else: from filenav import slim slim.main(args)
def convert_point(point=(0,0),from_view=None,to_view=None): '''fixed convert point for fullscreen application. works for any present type existing function in fullscreen reports relative to portrait TODO: does not work if from_view or to_view has been Transformed''' (w,h)=ui.get_screen_size() #detect what convert_point things rotation is. origin=ui.convert_point((0,0),from_view,to_view ) xaxis=ui.convert_point((1,0),from_view,to_view ) xaxis=[xaxis[j]-origin[j] for j in (0,1)] yaxis=ui.convert_point((0,1),from_view,to_view ) yaxis=[yaxis[j]-origin[j] for j in (0,1)] pt_c=ui.convert_point(tuple(point),from_view,to_view) pt=[0,0] if from_view is not None: pt[0]=( (xaxis[0]==-1)*h + xaxis[0]*pt_c[0] + (yaxis[0]==1)*w - yaxis[0]*pt_c[1]) pt[1] = ( (xaxis[1]==1)*h - xaxis[1]*pt_c[0] + (yaxis[1]==-1)*w + yaxis[1]*pt_c[1]) else: #just get corrected origin, and subtract out origin_offset=RootView.convert_point((0,0),to_view,from_view) pt[0]= point[0] - origin_offset[0] pt[1]= point[1] - origin_offset[1] return tuple(pt)
def _iphone_interface_layout(self): """ Alters the layout to suit an iPhone. Arguments: Specifics: """ try: # first cal calculate proportions based on the golden ratio Proportion = 5 BufferBetweenCampaignListAndContent = 30 Width = ui.get_screen_size()[1] print(Width) ContentWidth = (Width / Proportion) * 4 print(ContentWidth) CampaignListWidth = Width - ContentWidth print(CampaignListWidth) print(Width, ContentWidth, CampaignListWidth) ContentLeft = CampaignListWidth + BufferBetweenCampaignListAndContent self.vwInterface['tblCampaigns'].x = 0 self.vwInterface['tblCampaigns'].width = CampaignListWidth self.vwInterface['segCampaign'].x = ContentLeft self.vwInterface['lblDescription'].x = ContentLeft except: pass
def display_toast(view, help_text, width = 220, height = 110, show_duration=2, fade_duration=0.5, background_colour=(.42, .42, .42), text_colour= (.96, .96, .96), corner_radius=10): w, h = ui.get_screen_size() help_view = ui.View(frame=((w/2)-(width/2),(h/2)-height, width, height)) help_view.background_color = background_colour help_view.corner_radius = corner_radius label = ui.Label() label.text = help_text label.flex = 'H' label.width = help_view.width * 0.9 label.alignment = ui.ALIGN_CENTER label.x = (help_view.width / 2) - (label.width / 2) label.y = (help_view.height / 2) - (label.height / 2) label.number_of_lines = 3 label.text_color = text_colour help_view.add_subview(label) def animation_fade_in(): help_view.alpha = 1.0 def animation_fade_out(): help_view.alpha = 0.0 help_view.alpha = 0.0 view.add_subview(help_view) ui.animate(animation_fade_in, duration=fade_duration) time.sleep(show_duration+fade_duration) ui.animate(animation_fade_out, duration=fade_duration) time.sleep(fade_duration) view.remove_subview(help_view)
def tableview_cell_for_row(self, tableview, section, row): self.width, height = ui.get_screen_size() cell = ui.TableViewCell() cell.bounds = (0, 0, self.width, self.row_height) for i in range(2): self.make_labels(cell, tableview.data_source.items[row][i], i) return cell
def __init__(self, config): self.shape_type_def = {0: 'Null Shape',1: 'Point', 3: 'PolyLine', 5: 'Polygon', 8: 'MultiPoint', 11: 'PointZ', 13: 'PolyLineZ', 15: 'PolygonZ', 18: 'MultiPointZ', 21: 'PointM', 23: 'PolyLineM', 25: 'PolygonM', 28: 'MultiPointM', 31: 'MultiPatch'} #create an image depending on the screen size scr = ui.get_screen_size() * scene.get_screen_scale() self.scr_width = scr[0] self.scr_height = scr[1] - 64.0 #title bar = 64px if len(config) < 5: print 'Error: You need at least 5 parameter (xdelta, ydelta, background color, shape file, shape color)' sys.exit() self.xdelta = config[0] self.ydelta = config[1] self.bgcolor = config[2] self.pixel = 0 self.imagebuffer = None self.drawbuffer = None self.linewidth = 1 self.data = [] for i in range(3, len(config), 2): self.read_file(config[i]) self.color = config[i+1] self.convert_data(config[i]) self.imagebuffer.show()
def __init__(self, pad, *args, **kwargs): #super().__init__(self, *args, **kwargs) self.width = ui.get_screen_size()[0] # width of keyboard = screen self.background_color = 'lightgray'#(0,1,0,0.2) self.h_button = 32 self.pad = pad #================================================ for the fun begin # cable for road self.road = ui.Label() self.road.frame = (0,40,self.width,1) self.road.border_width = 1 self.road.border_color = 'green' self.road.flex = 'W' self.add_subview(self.road) # cable for tramway self.line = ui.Label() self.line.frame = (0,12,self.width,1) self.line.border_width = 1 self.line.border_color = 'gray' self.line.flex = 'W' self.line.hidden = True self.add_subview(self.line) # moving emoji behind buttons self.moving = ui.Button() self.moving.font = ('<system>',self.h_button-4) self.moving.frame = (0,10,self.h_button,self.h_button) self.moving.icons = ['emj:Delivery_Truck', 'emj:Car_1','emj:Car_2', 'emj:Bus', 'emj:Police_Car', 'emj:Railway_Car','emj:Speedboat'] self.moving.action = self.fun self.moving.index = 0 self.add_subview(self.moving) self.update_interval = 0.06 #================================================ for the fun end # build buttons for pad_elem in self.pad: if pad_elem['key'] in ('nul', 'new row'): # free space or new row continue button = ui.Button() # Button for user functionnality button.name = pad_elem['key'] button.background_color = 'white' # or any other color button.tint_color = 'black' button.corner_radius = 5 button.font = ('<system>',self.h_button - 8) button.title = '' if 'title' in pad_elem: button.title = pad_elem['title'] elif 'icon' in pad_elem: button.image = ui.Image.named(pad_elem['icon']).with_rendering_mode(ui.RENDERING_MODE_ORIGINAL) else: button.title = pad_elem['key'] button.action = key_pressed retain_global(button) # see https://forum.omz-software.com/topic/4653/button-action-not-called-when-view-is-added-to-native-view self.add_subview(button) self.layout()
def load(self): # We use a quadratic canvas, so that the same image # can be used in portrait and landscape orientation. w, h = ui.get_screen_size() canvas_size = max(w, h) sv = SketchView(canvas_size, canvas_size) sv.name = 'Sketch Pad' sv.present('fullscreen')
def switch_back(self): global button button = ui.Button(image = ui.Image.named('ionicons-ios7-contact-outline-256')) button.tint_color = 'white' button.flex = 'TR' button.width = button.height = 120 button.y = (ui.get_screen_size()[1]) - (120) button.action = change_character root_view.add_subview(button)
def SetTextFieldPad(tf): tfo = ObjCInstance(tf).textField() # UITextField is subview of ui.TextField # design your keyboard v = MyView(tf) w,h = ui.get_screen_size() if w < h: mode = 'portrait' else: mode = 'landscape' r = w/12 for i in range(1,7): b = ui.Button() b.name = str(i) b.background_color = (1,0,0,0.5) b.tint_color = (1,1,1,0.8) b.font = ('Academy Engraved LET',r*1.2) b.corner_radius = r b.title = b.name x,y = v.settings[mode][b.name] b.frame = (x,y,r*2,r*2) b.TextField = tf # store tf as key attribute needed when pressed b.touch_enabled = False v.add_subview(b) v.width = w v.height = h # view of keyboard retain_global(v) # see https://forum.omz-software.com/topic/4653/button-action-not-called-when-view-is-added-to-native-view tfo.setInputAccessoryView_(ObjCInstance(v)) # attach accessory to textview #print(dir(tfo)) # remove standard keyboard v.height = ui.get_screen_size()[1] vk = ui.View() vk.frame = (0,0,w,0) tfo.setInputView_(ObjCInstance(vk)) # remove undo/redo/paste BarButtons above standard keyboard tfo.inputAssistantItem().setLeadingBarButtonGroups(None) tfo.inputAssistantItem().setTrailingBarButtonGroups(None)
def tableview_cell_for_row(self, tableview, section, row): self.width, height = ui.get_screen_size() cell = ui.TableViewCell() cell.bounds = (0, 0, self.width, self.row_height) for i, name in enumerate(self.nameList): item = tableview.data_source.items[row] text = getattr(item, name) self.make_labels(cell, text, i) return cell
def screen_frames(status_height=24): w, h = ui.get_screen_size() # (1024, 768) on iPad in landscape mode assert w > h, 'This app only works in landscape mode!!' square_side = min(w, h) - status_height # make room for a few lines of status text panel_width = (w - square_side) / 2 center_frame = sk.Rect(panel_width, 0, square_side, square_side) left_frame = sk.Rect(0, 0, panel_width, square_side) right_frame = sk.Rect(panel_width + square_side, 0, panel_width, square_side) status_frame = sk.Rect(0, square_side, w, status_height) return center_frame, left_frame, right_frame, status_frame
def main(): console.clear() # Hide script w, h = ui.get_screen_size() disp = 'full_screen' back = MyView(w, h) back.background_color='white' back.present(disp, hide_title_bar=False) back.process()
def main(): checkKey() view = ui.load_view('Working_Copy_Sync') width, height = ui.get_screen_size() try: if width >= 768: view.present('sheet', hide_title_bar=True) else: view.present(hide_title_bar=True) except KeyboardInterrupt: pass
def __init__(self, source, selected_cb, name='', dark_cells=False, object_type='none', parent=None, theme_manager= None): w, h = ui.get_screen_size() self.frame = (0, 0, w, h) self.name = name self.source = source self.dark_cells = dark_cells self.parent = parent self.object_type = object_type self.picked_asset = None self.selected_cb = selected_cb self.theme_manager = theme_manager self.create_table_view()
def __init__(self): self.name = 'DrawOnImage' self.button_height = 50 self.button_width = 127 width, height = ui.get_screen_size() self.frame = (0,0,width,height) self.touch_enabled = False self.img_portrait = None self.img_landscape = None self.bgview = BackgroundView(self.button_height) #background view (view for image) self.bgview.flex = 'WH' self.bgview.frame = (0,0,width,height) self.bgview.background_color = 'white' self.add_subview(self.bgview) self.scv = ui.ScrollView() #scrollview for buttons self.scv.background_color = 'white' self.scv.frame = (0,0,width,self.button_height) self.scv.content_size = (2000,self.button_height) self.scv.flex = 'W' self.add_subview(self.scv) #just add two lines for each button and don't forget the action method with the same name #config_button(button, name, frame, title) self.scv_btn_quit = ui.Button() self.config_button(self.scv_btn_quit, 'btn_quit', (0,0,self.button_width,self.button_height), 'Quit') self.scv_btn_load = ui.Button() self.config_button(self.scv_btn_load, 'btn_load', (1*self.button_width,0,self.button_width,self.button_height), 'Load') self.scv_btn_save = ui.Button() self.config_button(self.scv_btn_save, 'btn_save', (2*self.button_width,0,self.button_width,self.button_height), 'Save') self.scv_btn_undo = ui.Button() self.config_button(self.scv_btn_undo, 'btn_undo', (3*self.button_width,0,self.button_width,self.button_height), 'Undo') self.scv_btn_color = ui.Button() self.config_button(self.scv_btn_color, 'btn_color', (4*self.button_width,0,self.button_width,self.button_height), 'Color') self.scv_btn_path_width = ui.Button() self.config_button(self.scv_btn_path_width, 'btn_path_width', (5*self.button_width,0,self.button_width,self.button_height), '') self.colors = ['white', 'grey', 'red', 'green', 'blue', 'cyan', 'magenta', 'yellow'] self.color_nr = 2 #red self.path_widths = [3, 6, 12, 24] self.path_w_nr = 1 #6 self.scv_btn_color.tint_color = self.colors[self.color_nr] self.set_button_actions() self.olview = OverlayView(self) self.olview.frame=(0,self.button_height,width,height-self.button_height) self.olview.flex = 'WH' self.olview.color = self.colors[self.color_nr] self.olview.path_width = self.path_widths[self.path_w_nr] self.path_width() self.add_subview(self.olview) self.image = None self.present('full_screen')
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 update(self): import ui x = self.moving.x - 5 if x < -self.moving.width: x = ui.get_screen_size()[0] self.moving.index = self.moving.index+1 if self.moving.index == len(self.moving.icons): self.moving.index = 0 emoji = self.moving.icons[self.moving.index] self.moving.image = ui.Image.named(emoji).with_rendering_mode(ui.RENDERING_MODE_ORIGINAL) self.line.hidden = not (emoji == 'emj:Railway_Car') self.road.border_color = 'blue' if emoji == 'emj:Speedboat' else 'green' self.moving.x = x
def __init__(self, username=None): self.name = self.__class__.__name__ textfield = ui.TextView(name='namefield') textfield.height = 25 textfield.text = self.username = username or self.read_username() self.add_subview(textfield) self.hidden = True self.width = self.height = min(ui.get_screen_size()) self.present('sheet') # somtimes it is good to be self-centered textfield.center = self.center self.hidden = False
def __init__(self, *args, **kwargs): SceneNode.__init__(self, *args, **kwargs) self.t = 0.0 self.dt = 0.0 self.root_layer = None self.touches = {} self.delayed_invocations = [] w, h = ui.get_screen_size() self.size = Size(w, h) self.bounds = Rect(0, 0, w, h) self.presented_scene = None self.presenting_scene = None self.setup_finished = False
def is_iP6p(): iP6p = True min_screen_size = min(ui.get_screen_size()) #print min_screen_size #iphone6 min = 414 #iphone6 max = 736 #iphone5 min = 320 #iphone5 max = 568 if min_screen_size < 414: iP6p = False return iP6p
def classify_asset(asset): mv = ui.View() mv.background_color = "white" im = ui.ImageView() pil_image = asset.get_image() print(pil_image.size) ui_image = asset.get_ui_image() n_squares = 9 d_grid = 15 # % around the digit wim, him = pil_image.size ws, hs = ui.get_screen_size() if (ws / hs) < (wim / him): h = ws * him / wim im.frame = (0, (hs - h) / 2, ws, h) else: w = hs * wim / him im.frame = ((ws - w) / 2, 0, w, hs) print(wim, him, ws, hs) mv.add_subview(im) wi = im.width hi = im.height im.image = ui_image im.content_mode = 1 # 1 mv.frame = (0, 0, ws, hs) mv.present("fullscreen") dx = wim / n_squares dy = him / n_squares d = dx * d_grid / 100 dl = int((wi / n_squares) * d_grid / 100) for ix in range(n_squares): x = ix * dx for iy in range(n_squares): y = iy * dy pil_char = pil_image.crop( (int(x + d), int(y + d), int(x + dx - d), int(y + dy - d))) button = ui.Button() button.frame = ( int(ix * wi / n_squares) + dl, int(iy * hi / n_squares) + dl, int(wi / n_squares) - 2 * dl, int(hi / n_squares) - 2 * dl, ) button.border_width = 1 button.border_color = "red" button.tint_color = "red" ObjCInstance( button).button().contentHorizontalAlignment = 1 # left button.background_image = pil2ui(pil_char) im.add_subview(button) button.title = classify_image(pil_char)["label"]
def setscreen(self): if self.kivy: from kivy.uix.floatlayout import FloatLayout from kivy.core.window import Window self.root = FloatLayout() if (self.xratio == 0) or (self.yratio == 0): from kivy.utils import platform as core_platform if core_platform == 'android': self.screen_size = Window.size else: self.screen_size = (800, 600) self.xratio = self.screen_size[0] / 800.0 self.yratio = self.screen_size[1] / 600.0 Window.size = self.screen_size else: import ui if (self.xratio == 0) or (self.yratio == 0): ss1 = ui.get_screen_size()[0] ss3 = ui.get_screen_size()[1] notoptimal = True while notoptimal: if ss1 % 8 == 0: notoptimal = False else: ss1 -= 1 ss1 = ss1 - 124 ss2 = (ss1 / 4) * 3 if ss2 > ss3: print('yes') ss2 = ss3 - ss2 - ((ss3 - ss2) % 3) ss1 = (ss2 / 3) * 4 self.screen_size = (ss1, ss2) self.xratio = self.screen_size[0] / 800 self.yratio = self.screen_size[1] / 600 self.root = ui.View(frame=(0,0,self.screen_size[0], \ self.screen_size[1]))
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,0,self.width, self.buttonheight)) 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 get_view(download_action, refresh_all_views, delete_action, refresh_stackoverflow_action, theme_manager): w, h = ui.get_screen_size() tv.width = w tv.height = h tv.flex = 'WH' tv.name = 'Stack Overflow Docsets' data = StackOverflowManagementView(download_action, refresh_all_views, delete_action, refresh_stackoverflow_action, theme_manager) tv.delegate = data tv.data_source = data return tv
def __init__(self): w,h = ui.get_screen_size() self.ty = ui.Label() self.ty.text = 'Hello' self.ty.text_color = 'black' self.ty.font = ('<system>', 60) self.ty.frame = (0, 0, w, h*0.25) self.ty.bg_color = 'yellow' self.sv = ui.ScrollView() self.sv.width = w self.sv.height = h*0.25 self.sv.content_size = (2*w, h*0.25) self.sv.add_subview(self.ty) self.add_subview(self.sv)
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 get_view(download_action, refresh_all_views, delete_action, refresh_usercontributed_action, theme_manager): w, h = ui.get_screen_size() tv.width = w tv.height = h tv.flex = 'WH' tv.name = 'User Contributed Docsets' data = UserContributedManagementView(download_action, refresh_all_views, delete_action, refresh_usercontributed_action, theme_manager) tv.delegate = data tv.data_source = data return tv
def __init__(self, *args, **kwargs): SceneNode.__init__(self, *args, **kwargs) self.t = 0.0 self.dt = 0.0 self.fixed_time_step = False self.root_layer = None self.touches = {} self.delayed_invocations = [] w, h = ui.get_screen_size() self.size = Size(w, h) self.bounds = Rect(0, 0, w, h) self.presented_scene = None self.presenting_scene = None self.setup_finished = False
def reload(self): # aviod double call at launch. overhead # can be small, but if loading pics etc. # better to aviod it. if self.screen_size == ui.get_screen_size(): return self.visible_range = [] for v in self.visible_views.values(): self.scrollview.remove_subview(v) self.visible_views = {} w, h = self.bounds[2:] #items_per_row = int(w / self.item_size[0]) items_per_row = self.xcells_per_row() num_rows = math.ceil(len(self.items) / float(items_per_row)) self.scrollview.content_size = (0, num_rows * self.item_size[1]) self.scrollview_did_scroll(self.scrollview) self.screen_size = ui.get_screen_size() #self.cell_buffer[0] self.num_rows = num_rows print('reload')
def get_view(docsets, download_action, refresh_docsets_action, delete_action, refresh_main_view, theme_manager, show_versions_view): w, h = ui.get_screen_size() tv.width = w tv.height = h tv.flex = 'WH' tv.name = 'Docsets' data = DocsetManagementView(docsets, download_action, refresh_docsets_action, delete_action, refresh_main_view, theme_manager, show_versions_view) tv.delegate = data tv.data_source = data return tv
def __init__(self): self.flex = 'WH' global skview z = ui.get_screen_size() self.background_color = '#b3cdff' skview = createSKView(0, 0, z.width, z.height - 64) sz = CGSize(z.width, z.height - 64) scene = createSampleScene(sz) skview.presentScene_(scene) self_objc = ObjCInstance(self) self_objc.addSubview_(skview)
def __init__(self, game=None): self.game = game or ChessGame() self.width, self.height = ui.get_screen_size() if photos.is_authorized(): self.add_subview(self.make_image_view()) center_frame, left_frame, right_frame, status_frame = screen_frames() self.add_subview(self.make_board_scene(self.game, center_frame)) self.make_buttons(left_frame) self.info_view = self.make_right_side_view(right_frame) self.add_subview(self.info_view) self.add_subview(self.make_left_side_view(left_frame)) self.status_view = self.make_status_view(status_frame) self.add_subview(self.status_view) self.present(orientations=['landscape'], hide_title_bar=True)
def demo(): main_view = ui.View() w, h = ui.get_screen_size() main_view.frame = (0, 0, w, h) main_view.name = 'textDemo' scene_view = scn.View(main_view.frame, superView=main_view) scene_view.autoresizingMask = scn.ViewAutoresizing.FlexibleHeight | scn.ViewAutoresizing.FlexibleRightMargin scene_view.antialiasingMode = scn.AntialiasingMode.Multisampling16X scene_view.allowsCameraControl = True scene_view.backgroundColor = 'white' scene_view.scene = scn.Scene() root_node = scene_view.scene.rootNode text_mesh = scn.Text.textWithString('Pythonista', 6.0) text_mesh.flatness = 0.2 text_mesh.chamferRadius = 0.4 text_mesh.font = ('HelveticaNeue-Bold', 18) bbox_min, bbox_max = text_mesh.boundingBox text_width = bbox_max.x - bbox_min.x text_node = scn.Node.nodeWithGeometry(text_mesh) text_node.castsShadow = True text_container = scn.Node.node() text_container.addChildNode(text_node) text_container.position = (0, 40, 0) text_node.position = (-text_width / 2, 0, 0) box = scn.Box(width=150, height=4, length=150, chamferRadius=1) box_node = scn.Node.nodeWithGeometry(box) root_node.addChildNode(box_node) rotate_action = scn.Action.repeatActionForever( scn.Action.rotateBy(0, math.pi * 2, math.pi * 2, 10)) text_container.runAction(rotate_action) root_node.addChildNode(text_container) light_node = scn.Node.node() light_node.position = (0, 105, 5) light_node.rotation = (1, 0, 0, -math.pi / 2) light = scn.Light.light() light.type = 'spot' light.spotOuterAngle = 65 light.castsShadow = True light.shadowSampleCount = 16 light.color = 'cyan' light_node.light = light root_node.addChildNode(light_node) main_view.present(style='fullscreen', hide_title_bar=False)
def main(): if PythonistaVersion >= 3.3: if keyboard.is_keyboard(): v = BrailleKeyboardInputAccessoryViewForTextField() v.custom_keyboard = True keyboard.set_view(v, 'expanded') return # Before Pythonista supporting keyboard or run in Pythonista app w, h = ui.get_screen_size() mv = ui.View() mv.name = 'Test keyboard in Pythonista' mv.background_color = 'white' tf = ui.TextField() tf.text = '' tf.frame = (2, 2, w - 4, 32) mv.add_subview(tf) tfo = ObjCInstance( tf).textField() # UITextField is subview of ui.TextField kv = ui.View() kv.frame = (0, 0, w, min(363, h * (3 / 5))) unused = ' unused, only to simulate height of custom keyboard with Pythonista 3.3' kv.add_subview(ui.Label(frame=(0, 0, w, kv.height / 7), text=unused)) kv.background_color = 'lightgray' frame = (0, kv.height / 7, w, kv.height * 5 / 7) v = BrailleKeyboardInputAccessoryViewForTextField(frame=frame) v.custom_keyboard = False kv.add_subview(v) kv.add_subview( ui.Label(frame=(0, v.y + v.height, w, kv.height / 7), text=unused)) tfo.setInputView_(ObjCInstance(kv)) v.tf = tf v.tfo = ObjCInstance( tf).textField() # UITextField is subview of ui.TextField # view of keyboard retain_global( v ) # see https://forum.omz-software.com/topic/4653/button-action-not-called-when-view-is-added-to-native-view # remove undo/redo/paste BarButtons above standard keyboard tfo.inputAssistantItem().setLeadingBarButtonGroups(None) tfo.inputAssistantItem().setTrailingBarButtonGroups(None) mv.present('full_screen') tf.begin_editing() mv.wait_modal()
def load_textview(self, results): #self.mv = ui.TextView() self.mv = mv.MarkdownView() self.mv.editable = False self.mv.background_color = 'orange' self.mv.width, self.mv.height = ui.get_screen_size() self.mv.font = ('<system-bold>', 15) self.mv.flex = 'HLRTB' self.right_button_items = [] b2 = ui.ButtonItem('Refine Query?', tint_color = 'black') b3 = ui.ButtonItem('Yes', action = self.refine, tint_color = 'green') b4 = ui.ButtonItem('No', action = self.no_refine, tint_color = 'red') self.right_button_items = [b4, b3, b2] self.add_subview(self.mv) self.mv.text = results
def __init__(self, master_view, detail_view): #need to instantiate with master and detail subviews as args. self.touch_enabled=False # using gestures instead self.g=Gestures() self.prev_location=None self.g.add_pan(self,self.did_pan) self.small_screen_size = False self.menu_is_visible = False #used for redrawing with small_screen_size and for slide events self.master = ui.View(frame=(-60,0,320,200), flex='H', touch_enabled=True) #-60 for effect if ui.get_screen_size()[0] < 768 or ui.get_screen_size()[1] < 768: #adjust for smaller screen self.master.width = ui.get_screen_size()[0] - 45 #leave some space to swipe back (..need to test on iphone!) self.small_screen_size = True master_view.width = self.master.width #otherwise it's at the default 100. self.master.add_subview(master_view) self.detail = ui.View(frame=(0,0,100,100), flex='WH', touch_enabled=True) self.detail.add_subview(detail_view) self.add_subview(self.master) self.add_subview(self.detail) self.background_color = 0.4 self.present()
def __init__(self, image): super().__init__(self) x, y = get_screen_size() if x > y: img_view = Label() img_view.text = 'Only in vertical position' img_view.frame = (0, 0, x, 15) else: y /= 4.4 img_view = ImageView() img_view.image = image img_view.frame = (0, 0, x, y) self.add_subview(img_view) self.frame = (0, 0, x, y)
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 init(size, numBombs, name): global v global bombs global isFlag bombs = [] v = ui.View(name=name) v.background_color = '#D3D3D3' x, y = ui.get_screen_size() v.frame = (0, 0, x, y - 60) p = creategrid(size, numBombs, x, y) flag_button.action = flag v.right_button_items = [flag_button] v.present('fullscreen') return v
def __init__(self, game=None): self.game = game or ChessGame() self.width, self.height = ui.get_screen_size() assert self.width > self.height, 'This app only works in landscape mode!!' if photos.is_authorized(): # add a photo as the background image self.add_subview(self.make_image_view()) center_frame, left_frame, right_frame, status_frame = screen_frames() self.add_subview(self.make_left_side_view(left_frame)) self.make_buttons(left_frame) self.add_subview(self.make_board_scene(center_frame)) self.info_view = self.make_right_side_view(right_frame) self.add_subview(self.info_view) self.status_view = self.make_status_view(status_frame) self.add_subview(self.status_view) self.present(orientations=['landscape'], hide_title_bar=True)
def CustomViewController_touchesBegan_withEvent_(_self, _cmd, _touches, event): touches = ObjCInstance(_touches) for t in touches: loc = t.locationInView_(sceneview) sz = ui.get_screen_size() print(loc) # touch の場所次第で終了する global cube_node # jun global root_node global gnum global scene aType, aColor, aSize, aLength, aMatrix = createNodeElementInfo() #cube_geometry = SCNBox.boxWithWidth_height_length_chamferRadius_(0.02, 0.02, 0.02, 0) #cube_geometry.material.lightingModel = LightingModel.PhysicallyBased # 追加したけど動かない Material = SCNMaterial.material() Material.contents = ObjCClass('UIColor').colorWithRed_green_blue_alpha_( aColor[0], aColor[1], aColor[2], aColor[3]) Material.lightingModel = LightingModel.PhysicallyBased if 'sphere' == aType: sphere_geometry = SCNSphere.sphereWithRadius_(aSize) sphere_geometry.setMaterials_([Material]) cube_node.append(SCNNode.nodeWithGeometry_(sphere_geometry)) cube_node[gnum].position = gPosition root_node.addChildNode_(cube_node[gnum]) gnum = gnum + 1 if 'arrow' == aType: sphere_geometry = SCNCone.coneWithTopRadius_bottomRadius_height_( 0, aSize / 5.0, aSize / 2.0) sphere_geometry.setMaterials_([Material]) cube_node.append(SCNNode.nodeWithGeometry_(sphere_geometry)) cube_node[gnum].position = gPosition cube_node[gnum].rotation = aMatrix root_node.addChildNode_(cube_node[gnum]) gnum = gnum + 1 sphere_geometry2 = SCNCapsule.capsuleWithCapRadius_height_( aSize / 20.0, aLength) #sphere_geometry2 = SCNCone.coneWithTopRadius_bottomRadius_height_(0,aSize/10.0,aSize) sphere_geometry2.setMaterials_([Material]) cube_node.append(SCNNode.nodeWithGeometry_(sphere_geometry2)) cube_node[gnum].position = gPosition #cube_node[gnum].setPosition((gPosition.x+aMatrix.x*(0.001), gPosition.y+aMatrix.y*(0.001), gPosition.z+aMatrix.z*(0.001))) cube_node[gnum].rotation = aMatrix root_node.addChildNode_(cube_node[gnum]) gnum = gnum + 1
def main(self): main_view = ui.View() w, h = ui.get_screen_size() main_view.frame = (0,0,w,h) main_view.name = 'MDL import demo' scene_view = scn.View(main_view.frame, superView=main_view) scene_view.autoresizingMask = scn.ViewAutoresizing.FlexibleHeight | scn.ViewAutoresizing.FlexibleWidth scene_view.allowsCameraControl = True scene_view.backgroundColor = 'white' scene_view.rendersContinuously = True scene_view.scene = scn.Scene() root_node = scene_view.scene.rootNode floor_geometry = scn.Floor() floor_node = scn.Node.nodeWithGeometry(floor_geometry) root_node.addChildNode(floor_node) asset = MDLAsset.alloc().initWithURL_(nsurl('Lucy.obj')) mesh = asset.objectAtIndex_(0) lucy_geometry = scn.Geometry.geometryWithMDLMesh(mesh) lucy_node_1 = scn.Node.nodeWithGeometry(lucy_geometry) root_node.addChildNode(lucy_node_1) lucy_node_2 = scn.Node.nodeWithMDLObject(mesh) lucy_node_2.position = (10., 0., 0.) root_node.addChildNode(lucy_node_2) camera_node = scn.Node() camera_node.camera = scn.Camera() camera_node.position = (10., 10., 10.) camera_node.lookAt(root_node.position) root_node.addChildNode(camera_node) light_node = scn.Node() light_node.position = (-20., 20., 20) light = scn.Light() light.type = scn.LightTypeDirectional light.castsShadow = True light.shadowSampleCount = 32 light.color = (.99, 1.0, .86) light_node.light = light light_node.lookAt(root_node.position) root_node.addChildNode(light_node) main_view.present(hide_title_bar=False)
def main(simulation=False): global main_view, contacts_photos #----- Main process ----- console.clear() # Initializations w, h = ui.get_screen_size() disp_mode = 'full_screen' # Hide script main_view = MyView(w, h, simulation) main_view.background_color = 'white' main_view.name = 'Contacts on map' main_view.present(disp_mode, hide_title_bar=False)
def __init__(self): screen_size = ui.get_screen_size() rect = CGRect(CGPoint(0, 0), CGSize(screen_size.w, screen_size.h)) skview = SKView.alloc().initWithFrame_(rect) ObjCInstance(self).addSubview(skview) self.skview = skview scene = DemoScene.sceneWithSize_(rect.size) scene.physicsWorld().setContactDelegate_(scene) print(scene.physicsWorld().contactDelegate()) scene.backgroundColor = UIColor.color(red=0.2, green=0.5, blue=0.2, alpha=1.0) skview.presentScene_(scene) self.scene = scene
def createSKView(x,y,w=0,h=0, debug=True): global skview #print(ui.get_screen_size()) #print(w) #print(h) if w == 0 or h == 0: sz = ui.get_screen_size() w = sz[0] h = sz[1] skview = SKView.alloc().initWithFrame_((CGRect(CGPoint(x, y), CGSize(w,h)))) skview.showsFPS = debug skview.showsNodeCount = debug skview.showsPhysics = debug return skview
def initialize(self): self.flex = 'WH' screen = ui.get_screen_size() # set up the ar scene view delegate methods = [ MyARSCNViewDelegate_renderer_didAdd_for_, MyARSCNViewDelegate_session_didFailWithError_, MyARSCNViewDelegate_renderer_willRenderScene_atTime_ ] protocols = ['ARSCNViewDelegate'] MyARSCNViewDelegate = create_objc_class('MyARSCNViewDelegate', NSObject, methods=methods, protocols=protocols) delegate = MyARSCNViewDelegate.alloc().init() # set up the ar scene view global sceneview sceneview = createARSceneView(0, 0, screen.width, screen.height) global scene sceneview.scene = scene sceneview.setDelegate_(delegate) # set up the custom view controller methods = [ CustomViewController_touchesBegan_withEvent_, CustomViewController_viewWillAppear_, CustomViewController_viewWillDisappear_ ] protocols = [] CustomViewController = create_objc_class('CustomViewController', UIViewController, methods=methods, protocols=protocols) cvc = CustomViewController.alloc().init() cvc.view = sceneview # internal kitchen self_objc = ObjCInstance(self) self_objc.nextResponder().addChildViewController_(cvc) self_objc.addSubview_(sceneview) cvc.didMoveToParentViewController_(self_objc) # here, we try... runARSession(sceneview.session()) setDebugOptions(sceneview)
def newItem(sender): pview = ui.View() ptable = ui.TableView() ptable.flex = "WH" ptable.data_source = ui.ListDataSource([ "New folder", "New file", "Script with ui", "Scene with layers", "Basic scene" ]) ptable.delegate = NDelegate(table) sx, sy = ui.get_screen_size() x, y, w, h = view["nbutton"].frame pos = (x + (sx / 2 - view.width / 2) + w / 2, y + (sy / 2 - view.height / 2) + h) pview.add_subview(ptable) pview.width, pview.height = 300, 150 pview.present("popover", True, pos, True)
def __init__(self): w, h = ui.get_screen_size() self.ty = ui.Label() self.ty.text = "Hello" self.ty.text_color = "black" self.ty.font = ("<system>", 60) self.ty.frame = (0, 0, w, h * 0.25) self.ty.bg_color = "yellow" self.sv = ui.ScrollView() self.sv.width = w self.sv.height = h * 0.25 self.sv.content_size = ( 2 * w, h * 0.25, ) # content width is double wide! with the same width it won't scroll. self.sv.add_subview(self.ty) self.add_subview(self.sv)
def get_view(docsets, indexes, indexSelectCallback, docsetType): tv = ui.TableView() w, h = ui.get_screen_size() tv.width = w tv.height = h tv.flex = 'WH' tv.name = 'PyDoc' data = DocsetIndexView(docsets, indexes, indexSelectCallback, docsetType) tv.delegate = data tv.data_source = data if docsetType == 'docset': tv.name = docsets['name'] elif docsetType == 'cheatsheet': tv.name = docsets.name elif docsetType == 'usercontributed': tv.name = docsets.name return tv
def __init__(self): # Setup SKView screen_size = ui.get_screen_size() rect = CGRect( CGPoint(0, 0), CGSize(screen_size[0], screen_size[1])) skview = SKView.alloc().initWithFrame_(rect) # debug skview.showsFPS = self.debug skview.showsNodeCount = self.debug skview.showsPhysics = self.debug ObjCInstance(self).addSubview(skview) self.skview = skview scene = DemoScene.sceneWithSize_(rect.size) scene.backgroundColor = UIColor.color(red=0.2, green=0.5, blue=0.2, alpha=1.0) skview.presentScene_(scene) self.scene = scene
def get_view(show_docset_management_view, show_cheatsheet_management_view, show_usercontributed_management_view, theme_manager, show_stackoverflow_management_view, websearch_manager, show_transfer_management_view, settings_manager): w, h = ui.get_screen_size() tv.width = w tv.height = h tv.flex = 'WH' tv.name = 'Settings' data = SettingsView(show_docset_management_view, show_cheatsheet_management_view, show_usercontributed_management_view, theme_manager, show_stackoverflow_management_view, websearch_manager, show_transfer_management_view, settings_manager) tv.delegate = data tv.data_source = data return tv
def __init__(self, config): self.shape_type_def = { 0: 'Null Shape', 1: 'Point', 3: 'PolyLine', 5: 'Polygon', 8: 'MultiPoint', 11: 'PointZ', 13: 'PolyLineZ', 15: 'PolygonZ', 18: 'MultiPointZ', 21: 'PointM', 23: 'PolyLineM', 25: 'PolygonM', 28: 'MultiPointM', 31: 'MultiPatch' } #create an image depending on the screen size scr = ui.get_screen_size() * scene.get_screen_scale() self.scr_width = scr[0] self.scr_height = scr[1] - 64.0 #title bar = 64px if len(config) < 5: print( 'Error: You need at least 5 parameter (xdelta, ydelta, background color, shape file, shape color)' ) sys.exit() self.xdelta = config[0] self.ydelta = config[1] self.bgcolor = config[2] self.pixel = 0 self.imagebuffer = None self.drawbuffer = None self.linewidth = 1 self.data = [] for i in range(3, len(config), 2): self.read_file(config[i]) self.color = config[i + 1] self.convert_data(config[i]) self.imagebuffer.show()