def load_walls(state, base_name, background_file, tile_file, with_collisions=True): """ TODO """ tile_size = screen.get_tile_size(state) int_tile_size = int(tile_size) background_texture = Image(source=background_file).texture walls_texture = Image(source=tile_file).texture for tile_name, origin_xy, collision in tiles_origin_table: full_tile_name = base_name + tile_name wall_texture = walls_texture.get_region( origin_xy[0] * int_tile_size, origin_xy[1] * int_tile_size, int_tile_size, int_tile_size) tile_texture = Texture.create(size=(int_tile_size, int_tile_size), colorfmt='rgba') fbo = Fbo(size=(int_tile_size, int_tile_size), texture=tile_texture) with fbo: Color(1, 1, 1) Rectangle(pos=(0, 0), size=tile_texture.size, texture=background_texture) Rectangle(pos=(0, 0), size=tile_texture.size, texture=wall_texture) fbo.draw() if not with_collisions: collision = None tiles.add_tile_def(state, full_tile_name, tile_texture, collision)
def on_touch_down(self, touch): userdata = touch.ud (w, h) = (FSW,FSH) sc = max(float(w)/FSW,float(h)/FSH) # start collecting points in touch.ud self.canvas.clear gimg = Image(source=GOAL_IMG) self.add_widget(gimg) bimg = Image(source=BALL_IMG) self.add_widget(bimg) (xpos, ypos) = (int(touch.x)-w/2, int(touch.y)-h/2) #bimg.size = (10,10) #(int(60.0*sc), int(60.0*sc)) bimg.pos = (xpos, ypos) #print '{0} and {1}'.format(float(w)/FSW,float(h)/FSH) 2115 #print sc print '{0} and {1}'.format(touch.x, touch.y) #print '{0} and {1}'.format(xpos, ypos) if touch.x > FSW/20 and touch.x < w-FSW/20 and touch.y > h*0.2 and touch.y < h*0.88: print "GOAL!" mimg = Image(source=MSG_IMG) self.add_widget(mimg) #with self.canvas: #Color(1, 1, 1) #d = 60. #Ellipse(pos=(touch.x - d/2, touch.y - d/2), size=(d, d)) return True
def _detect_qrcode_frame(self, instance, camera, data): global data_qr # the image we got by default from a camera is using the NV21 format # zbar only allow Y800/GREY image, so we first need to convert, # then start the detection on the image parameters = camera.getParameters() size = parameters.getPreviewSize() barcode = Image(size.width, size.height, 'NV21') barcode.setData(data) barcode = barcode.convert('Y800') result = self._scanner.scanImage(barcode) if result == 0: self.symbols = [] return # we detected qrcode! extract and dispatch them symbols = [] it = barcode.getSymbols().iterator() while it.hasNext(): symbol = it.next() qrcode = BtmsValidRoot.Qrcode( type=symbol.getType(), data=symbol.getData(), quality=symbol.getQuality(), count=symbol.getCount(), bounds=symbol.getBounds()) symbols.append(qrcode) data_qr = symbol.getData() #self.ids.result_label.text = data_qr self.validate() self.symbols = symbols
def cancel(self): self.root.ids.display.clear_widgets() if not (self.slic == None): img = Image(source=self.slic.filename) img.id = 'disp_img' self.root.ids.display.add_widget(img) self.img_loaded = True
def __load_map_scene(self, map_name): scene_path = os.path.join('resources', 'maps', map_name, 'scene.json') scene_dict = json.load(open(scene_path)) scene_width = 1080 scene_height = 800 layer_list = scene_dict['layers'] first_layer_dict = layer_list[0] pivot_pos = (first_layer_dict['x'], first_layer_dict['y']) for layer_dict in reversed(layer_list[1:]): layer_pos = (layer_dict['x'] - pivot_pos[0], layer_dict['y'] - pivot_pos[1]) layer_size = (layer_dict['w'], layer_dict['h']) layer_name = layer_dict['name'] layer_path = os.path.join('resources', 'maps', map_name, 'images', layer_name + '.png') layer_color = [random(), random(), random(), 1] layer_image = Image(source=layer_path, pos=layer_pos, size=layer_size, pos_hint={}, size_hint=(None, None), color=layer_color) with layer_image.canvas.before: layer_image.bg_rect = Line(rectangle=(layer_pos[0], layer_pos[1], layer_size[0], layer_size[1])) self.add_widget(layer_image) layer_label = Label(text="[color=000000]"+layer_name+"[/color]", pos=layer_pos, size=layer_size, pos_hint={}, size_hint=(None, None), markup=True) self.add_widget(layer_label) layer_label = Label(text="[color=000000]!!!![/color]", pos=(0, 0), pos_hint={}, size_hint=(None, None), markup=True) self.add_widget(layer_label)
def __init__(self, previous, image_set, fragment_list=None, **kwargs): super(GameScreen, self).__init__(**kwargs) # screen we came from, to pass on to game over/victory screen self.previous = previous # set image for the map and prepare it for color selection self.source = image_set.sources["raw"] self.image.imdata = utils.ImageArray.load(self.source) self.image.bind(on_touch_down=self.color_drop) # loads fragments from fragment directory self.f_index = 0 self.fragments = [] if os.path.exists(config.fragment_directory): for f in os.listdir(config.fragment_directory): if fragment_list is None or f in fragment_list: imgpath = os.path.join(config.fragment_directory, f) if os.path.isfile(imgpath): img = Image(source=imgpath) img.bind(on_touch_down=self.im_press) self.fragments.append(img) # cursor options self.cursor_active = False self.cursor_array = self.fragments self.picker = None self.scatter = None self.cutter_event = None # starting values self.completion = 0 self.tree_start = self.tree.height self.forest_color = None self.started = False
def build(self): label = Label(text="Testing going on.") atlas = Atlas("player_sheet.atlas") image1 = Image(allow_stretch=True) image1.texture = atlas["walkleft4"] label.add_widget(image1) return label
def addImage(self, filename): image = Image(source=filename) image.size_hint = None, None image.width = metrics.sp(120) image.height = metrics.sp(120) self.add_widget(image) return
def load(self, path, selection): if not selection[0] == '': self.slic = Slic(selection[0]) self.root.ids.display.clear_widgets() img = Image(source=selection[0]) img.id = 'disp_img' self.root.ids.display.add_widget(img) self.img_loaded = True
def __init__(self, *args, **kwargs): super(Goal, self).__init__(*args, **kwargs) print "__init__ is run" gimg = Image(source=GOAL_IMG) self.add_widget(gimg) gimg.pos = (0,0) #Window.fullscreen = True Window.size = (FSW, FSH)
def _draw_hearts(self): self.clear_widgets() i = 0 while i < (self.max_health / 4): heart = Image(size=(80, 80)) heart.source = 'img/heart-' + str(self.hearts[i]) + '.png' self.add_widget(heart) i += 1
def __init__(self, sheet, **kwargs): Image.__init__(self, **kwargs) self.sheet = sheet self._frame = None self.frame = 0 self.dt = None self.loop_fnc = None self.register_event_type("on_finish")
def handleGoal(self): def go_next_callback(instance): self.popup.dismiss() main.switchLevel() return False if self.isToolOnGoal and self.isPersonOnGoal: if self.activeTool.isGoal and self.activePerson.isGoal: print "FINISHED? ",isFinished while not isFinished: #notwendig, weil sonst 2 mal aufgerufen (touch_events feuern alle 2 mal) global isFinished isFinished = True btnBGSource = '' if currentLevel <= len(levels)-1: btnBGSource = unichr(61518) else: btnBGSource = unichr(61470) box = AnchorLayout(size_hint=(1, 1), anchor_x= "right", anchor_y= "bottom") btn = Button(font_size=100, font_name= 'res/fontawesome-webfont.ttf', text=btnBGSource, background_color = [0,0,0,0.7]) btn.bind(on_press=go_next_callback) #vid = Video(source=self.levelInfos[levelProps[3]], play=True) #box.add_widget(vid) #instead of laggy video insert just an image img = Image(source=self.levelInfos[levelProps[3]]) img.allow_stretch = True box.add_widget(img) imgBtn = Button(font_size=60, font_name= 'res/fontawesome-webfont.ttf', text=btnBGSource, background_color = [0,0,0,0], size_hint= (0.15, 0.15)) imgBtn.bind(on_press=go_next_callback) box.add_widget(imgBtn) def end_of_vid(video, eos): logging.info("endofvid") #video.play=False #not working on android... box.add_widget(btn) #video.unload() #not working on android... #logging.info("video unloaded") def showit(): print "showing video popup" self.popup.open() if self.winSound: self.winSound.play() #vid.bind(loaded=lambda foo,bar: showit()) #vid.bind(eos=lambda video,eos:end_of_vid(video,eos)) self.popup = Popup(content=box,size_hint=(0.8, 0.7),auto_dismiss=False) self.hidePopupTitle(self.popup) showit() Clock.schedule_once(lambda wumpe:box.add_widget(btn), 8)
def __init__(self, idx, name, **kwarg): Image.__init__(self, **kwarg) self.size = poker_width, poker_height self.allow_stretch = True self.keep_ratio = False self.idx = idx self.type = -1 if idx < 48 else (idx - 48) / 20 self.name = name self.selected = False
def display_help_screen(self): # display the help screen on a Popup image = Image(source='graphics/help_screen.png') help_screen = Popup(title='Quick Guide through DEFLECTOUCH', attach_to=self, size_hint=(0.98, 0.98), content=image) image.bind(on_touch_down=help_screen.dismiss) help_screen.open()
def on_check(self, instance, value): sheepimg = Image(source='images/TXT_BRAVO_MOUTONS.png', size_hint=(None, None), size=(300, 150)) self.add_widget(sheepimg) sheepimg.pos = (300, 300) self.button = BtnOk(scenario=self) self.button.center = (630, 270) self.button.button.background_normal = 'images/BUT_OK_UNVALID.png' self.button.button.background_down = 'images/BUT_OK_VALID.png' self.add_widget(self.button)
def question(self, que): self.restore_default() self._question = que if que.is_img: img = Image(source=que.img_path) img.pos = self.pos img.size = self.size self.add_widget(img) else: self.text = que.text
def loadScores(self, obj): app = self self.clear_widgets() helpimg = Image(source = 'assets/help.jpg') back = Button(text = "BACK",font_size = 25) helpimg.add_widget(back) self.add_widget(helpimg) def backfn(obj): self.__init__() back.bind(on_press = backfn) return self
def update_text(self, i): self.y = self.height * i ans = self.answer if ans.is_img: img = Image(source=ans.img_path) img.pos = self.pos img.size = self.size self.add_widget(img) else: self.text = ans.text
def load_font(state, font_name, font_path, font_w, font_h): """ TODO """ font_texture = Image(source=font_path).texture code = 32 for y in xrange(8): for x in xrange(12): texture_name = font_name + "-" + str(code) texture_db.insert(state, texture_name, font_texture.get_region(x * font_w, (7 - y) * font_h, font_w, font_h)) code += 1 state[IDX_STATE_TEXT][font_name] = [font_w, font_h]
def loadhelp(self,obj): app = self x,y = 1280,736 self.root.clear_widgets() helpimg = Image(source = 'assets/help.jpg') back = Button(text = "Got it. Lets Play!",font_size = 25,pos = (x-x*3/8,y/10),size=(x/4,y/8)) helpimg.add_widget(back) self.root.add_widget(helpimg) def backfn(obj): self.startgame(app) back.bind(on_press = backfn) return self.root
def build(self): self.title = "Blackjack" self.parent = Widget() sm = ScreenManager() # set up the screens #splashcreen self.ss = Screen(name = 'splash_screen') splashmenu = SplashScreen() splashmenu.buildUp() self.ss.add_widget(splashmenu) #main menu self.mm = Screen(name = 'main_menu') self.mainmenu = MainMenu() self.mainmenu.buildUp() self.mm.add_widget(self.mainmenu) #add the logo to mainmenu and splashscreen logo = Image(source = 'images/logo.png') logo.width = Window.width/2 logo.height = Window.height/2 logo.x = Window.width/2 - (logo.width-logo.width*.05) logo.y = (Window.height/2 - logo.width/2) self.mm.add_widget(logo) #game screen self.gs = Game(name = 'game') #Add screens to screen manager sm.add_widget(self.ss) sm.add_widget(self.mm) sm.add_widget(self.gs) sm.current = 'main_menu' def check_screen_change(obj): if(self.mainmenu.buttonText == 'Play'): sm.current = 'game' self.gs.start_round() self.mainmenu.bind(on_button_release = check_screen_change) return sm
def resimleriEkle(self, dosyalar): self.root.ids.karinca.clear_widgets() for dosya in dosyalar: if os.path.isfile(dosya): if imghdr.what(dosya): resim=Image(source=dosya) resim.allow_stretch=True resim.keep_ratio=False self.root.ids.karinca.add_widget(resim) if self.root.ids.karinca.slides: self.root.ids.slyat_dugme.disabled=False else: self.root.ids.slyat_dugme.disabled=True
def __init__(self, height: int, **kwargs): super(TopBar, self).__init__(**kwargs) topBack = Image() topBack.color = [0, 0, 0, 1] topBack.width = Window.size[0] topBack.height = height self.add_widget(topBack) self.__grid = GridLayout() self.__grid.cols = 10 self.__grid.rows = 1 self.__grid.width = Window.size[0] self.__grid.height = height self.add_widget(self.__grid)
class Planet(FloatLayout): base_image = ObjectProperty(None) select_overlay = ObjectProperty(None) # TODO: complete this!? shadow_overlay = ObjectProperty(None) # LOGIC logic = ObjectProperty(None) def __init__(self, **kwargs): super(Planet, self).__init__(**kwargs) self.logic = App.get_running_app().logic self.size = (100, 100) # TODO: better way to acquire default textures paths self.base_image = Image( size_hint=(1, 1), pos_hint={'x': 0, 'y': 0}, source='./media/textures/planets/sandyone.png', allow_stretch=True ) self.select_overlay = Image( size_hint=(1.25, 1.25), pos_hint={'x': -0.125, 'y': -0.125}, source='./media/textures/picked/scope.png', allow_stretch=True ) self.add_widget(self.base_image) def on_size(self, instance, value): if self.base_image: self.base_image.size = value if self.select_overlay: newsize = (self.base_image.size[0] * 1.5, self.base_image.size[1] * 1.5) self.select_overlay.size = newsize self.select_overlay.center = self.center def select(self): self.select_overlay.center = self.center self.add_widget(self.select_overlay) def unselect(self): self.remove_widget(self.select_overlay) def set_base_image(self, source): self.base_image.source = source self.base_image.reload()
def create_blob(self, touch): # define a short name for the touch-specific and unique UserDictionary "ud" ud = touch.ud # create the new blob ud['blob'] = Image( source=self.parent.app.config.get('Advanced', 'BlobImage'), color=BLOB_IMAGE_COLOR, allow_stretch=True, size=(self.parent.app.config.getint('Advanced', 'BlobSize'), self.parent.app.config.getint('Advanced', 'BlobSize'))) # set the blobs position right under the finger ud['blob'].x = touch.x - ud['blob'].size[0] / 2 ud['blob'].y = touch.y - ud['blob'].size[1] / 2 self.add_widget(ud['blob'])
def update_preview(self, *args, **kwargs): try: imdata = self.preview_handler.queue.get(False) except queue.Empty: return # textures must be created in the main thread; # this is a limitation in pygame texture = Texture.create_from_data(imdata) if self.preview_widget is None: tilt_max = pkConfig.getint('arduino', 'max-tilt') tilt_min = pkConfig.getint('arduino', 'min-tilt') def on_touch_move(widget, touch): if widget.collide_point(touch.x, touch.y): self.tilt += touch.dpos[1] / 5 if self.tilt < tilt_min: self.tilt = tilt_min if self.tilt > tilt_max: self.tilt = tilt_max value = int(round(self.tilt, 0)) self.arduino_handler.set_camera_tilt(value) self.preview_widget = Image(texture=texture, nocache=True) self.preview_widget.bind(on_touch_move=on_touch_move) self.preview_widget.allow_stretch = True self.preview_widget.size_hint = None, None self.preview_widget.size = (1280, 1024) self.preview_widget.x = (1280 / 2) - (self.preview_widget.width / 2) self.preview_widget.y = -self.preview_widget.height self.layout.add_widget(self.preview_widget) else: self.preview_widget.texture = texture
def _build(self): """Render this task.""" self.info_button = Image( source=self.manyman.settings['task_info_image'], color=(.8, .8, .8, 1), size_hint=(None, None), size=(40, 40) ) self.layout.add_widget(self.info_button) self.label = Label( text="..........", halign='center' ) self.layout.add_widget(self.label) # Initialize the detailed task info popup self.info = InfoPopup( title="%s (%s) - %s on core %d" % \ (self.name, self.tid, self.status, self.core.index), size_hint=(None, None), size=(600, 450) ) self.info.bind(on_show=self.info_show, on_dismiss=self.info_dismiss) # Initialize the performance graphs located in the popup self.cpu_graph = PerfGraph("CPU", container=self) self.mem_graph = PerfGraph("MEM", container=self) self.bind(pos=self.update_graphics_pos, size=self.update_graphics_size) self.update_graphics_pos(self, self.pos) self.update_graphics_size(self, self.size) self.label.text = '%s\nStatus: %s' % (self.name, self.status)
def back_to(self): # Restores the home screen self.lay_center.clear_widgets() self.clear_widgets() self.lay_center_bt.clear_widgets() image_back_ground = Image() image_back_ground.source = 'image/background_ppmt_main.png' button_new_open_close = ButtonNewOpen(new_proj=self.new_project, open_proj=self.open_project) self.add_widget(image_back_ground) self.lay_center_bt.add_widget(button_new_open_close) self.lay_center.add_widget(self.lay_center_bt) self.lay_center.add_widget(self.lay_last_project) self.add_widget(self.lay_center)
def __init__(self, **kwargs): super(AnimatedButton, self).__init__(**kwargs) self.register_event_type('on_press') self.register_event_type('on_release') # borderImage.border by default is ... self.border = (16, 16, 16, 16) # Image to display depending on state self.img = Image( source=self.background_normal, allow_stretch=self.allow_stretch, keep_ratio=self.keep_ratio, mipmap=True) # reset animation if anim_delay is changed def anim_reset(*l): self.img.anim_delay = self.anim_delay self.bind(anim_delay=anim_reset) self.anim_delay = .1 # update self.texture when image.texture changes self.img.bind(texture=self.on_tex_changed) self.on_tex_changed() # update image source when background image is changed def background_changed(*l): self.img.source = self.background_normal self.anim_delay = .1 self.bind(background_normal=background_changed)
def syncron_colas(self): app = App.get_running_app() if not app.is_login: return modal_view_alert('No esta loggeado para \nhacer esta acción', 'Cerrar', Image(source=SOURCE_FAIL, size=(100,100))) def progress_cola(request, current_size, total_size): label.text = "Cargando " + str(round(current_size*100/total_size)) + "%" def update_cola(req, result): view.dismiss() json_data = json.loads(result) #print(json_data) if isinstance(json_data, list): conn = sqlite3.connect(NAME_DATABASE) with conn: cur = conn.cursor() for obj in json_data: cur.execute('INSERT INTO cola VALUES (NULL, "%s", "%s", "%s", %i, %i);' %\ (obj["estacion"], obj["placa"], obj["created_at"], False, True)) cur.execute('INSERT INTO updates VALUES (NULL, "%s");' % self.date_update.isoformat()) conn.close() modal_view_alert('Datos cargados','Cerrar', Image(source=SOURCE_CHECK, size=(100,100))) else: modal_view_alert('Datos no cargados correctamente.\nReintente más tarde','Cerrar', Image(source=SOURCE_CHECK, size=(100,100))) def error_cola(req, result): view.dismiss() modal_view_alert('¡Error!','Cerrar', Image(source=SOURCE_FAIL, size=(100,100))) def failure_cola(req, result): view.dismiss() modal_view_alert('Error de conexión...\nReintente mas tarde','Cerrar', Image(source=SOURCE_FAIL, size=(100,100))) self.date_update = datetime.now() params = urllib.parse.urlencode({'action':'update', 'date':(self.date_update-timedelta(days=DAYS_COUNT)).isoformat() }) conn = sqlite3.connect(NAME_DATABASE) with conn: cur = conn.cursor() cur.execute('SELECT id, update_date FROM updates ORDER BY Datetime(update_date) DESC LIMIT 1') rows = cur.fetchall() if rows: id_date, update_date = rows.pop() params = urllib.parse.urlencode({'action':'update', 'date': update_date}) conn.close() headers = {"Authorization": "Token {0}".format(app.api_token)} req = UrlRequest(URL_ENDPOINT+'?'+params, req_headers= headers, on_success=update_cola, on_progress=progress_cola, on_error=error_cola, on_failure=failure_cola) view = ModalView(size_hint=(None, None), size=(400, 400)) layout = GridLayout(cols=1, padding=10) content = Button( text="Cerrar", size_hint=(None, None), size=(380, 100), valign= 'center') label = Label(text="Esperando respuesta...") layout.add_widget(label) layout.add_widget(content) view.add_widget(layout) content.bind(on_press=view.dismiss) view.open() return view
class PhotoboothWidget(FloatLayout): def __init__(self, **kwargs): super().__init__() super(PhotoboothWidget, self).__init__(**kwargs) self._cam = CameraGphoto2() self.start = Button(text="Maak foto!", pos_hint={'center_x': .5, 'center_y': .5}, size_hint=(.5, .5), font_name='Amatic') self.count = Label(text="", pos_hint={'center_x': .5, 'center_y': .5}, font_size=190, font_name='Amatic') self.retake_picture = Button(text="Nieuwe foto", pos_hint={'bottom': 1, 'left': 1}, size_hint=(.2, .2)) self.print_picture = Button(text="Print foto", pos_hint={'bottom': 1, 'right': 1}, size_hint=(.2, .2)) self.button_arrow = Image(source='images/arrow_flip.png', pos=(100, 0), size_hint=(0.3, 0.3)) self.preview = Image(source="", size_hint=(0.8, 0.8), pos_hint={'center_x': .5, 'center_y': .5}) self.preview.keep_ratio = True self.startup() folder_setup(self) def startup(self): self.clear_widgets() self.add_widget(self.button_arrow) self.add_widget(self.start) self.start.font_name = 'Amatic' self.start.font_size = 250 # self.start.background_disabled_down = '' self.start.background_color = (0, 0, 0, 0) self.start.bind(on_press=self.start_countdown) def start_countdown(self, obj): self.clear_widgets() count_from = 10 self.remove_widget(self.start) self.add_widget(self.count) self.add_widget(self.preview, 98) def count_it(count_from): if count_from == 0: self._cam.setIdle() self.remove_widget(self.count) self.remove_widget(self.preview) self.take_picture() return count_from -= 1 self.count.text = str(count_from) self.pic_preview() count_it(count_from) Clock.schedule_once(lambda dt: count_it(count_from), -1) # count_it(count_from) Clock.schedule_once(lambda dt: count_it(count_from), 0) def start_print(self, obj): Clock.schedule_once(lambda dt: self.startup(), 5) def pic_preview(self): self.preview.texture = self._cam.getPreview() self.preview.reload() def take_picture(self): self.clear_widgets() self._cam.getPicture() image = Image(source=(get_location() + "/" + get_last_pic_name()), pos_hint={'center_x': 0.5, 'center_y': .6}, size_hint=(0.8, 0.8)) self.add_widget(image) self.retake_picture.bind(on_press=self.start_countdown) self.add_widget(self.retake_picture) self.print_picture.bind(on_press=self.start_print) self.add_widget(self.print_picture)
def __init__(self, **kwargs): super().__init__(**kwargs) self.app_ = App.get_running_app() # Get the dates clicked self.model_ = self.app_.calendar_.dates_.model_ # Information to be added self.body = self.model_.printSelectedResults() # Layout arrangementw self.orientation = 'vertical' # Elevators information self.layout_comp = BoxLayout(orientation='horizontal', size_hint=(1, 1)) self.layout_map = BoxLayout(orientation='horizontal', size_hint=(1, 1)) self.img_comp_1 = Image(source='component_1.png', keep_ratio=False, size_hint=(1, 1), allow_stretch=False, mipmap=True) self.img_comp_2 = Image(source='component_2.png', keep_ratio=False, size_hint=(1, 1), allow_stretch=False, mipmap=True) self.layout_comp.add_widget(self.img_comp_1) self.layout_comp.add_widget(self.img_comp_2) self.img_map_1 = Image(source='map_kunshan.png', keep_ratio=False, size_hint=(1, 1), allow_stretch=True) self.img_map_2 = Image(source='map_sh.png', keep_ratio=False, size_hint=(1, 1), allow_stretch=True) self.layout_map.add_widget(self.img_map_1) self.layout_map.add_widget( Label(size_hint=(0.1, 1), text='昆\n山\n地\n区\n电\n梯\n分\n布\n图', font_name=font_name, font_size='20sp', color=(0, 0, 0, 1))) self.layout_map.add_widget(self.img_map_2) self.layout_map.add_widget( Label(size_hint=(0.1, 1), text='上\n海\n地\n区\n电\n梯\n分\n布\n图', font_name=font_name, font_size='20sp', color=(0, 0, 0, 1))) self.layout_fig = BoxLayout(orientation='vertical', size_hint=(1, 0.7)) #self.layout_fig.add_widget(self.layout_comp) self.layout_fig.add_widget(self.layout_map) self.add_widget(self.layout_fig) #self.layout_scroll_lb=Label(text=self.body,size_hint=(1,None)) #self.layout_scroll_lb.height=self.layout_scroll_lb.texture_size[1] #self.layout_scroll=ScrollableLabel(text=self.body) #self.layout_scroll.add_widget(self.layout_scroll_lb) #self.layout1_title=Label(text='以下电梯预测将在30天内发生故障:\n'+self.body,font_name=font_name) #self.layout1_title.size=self.layout1_title.texture_size #self.layout1.add_widget(self.layout1_title) #self.layout1.add_widget(self.layout_scroll) # Plots self.graph_theme = { 'label_options': { 'color': (0, 0, 0, 1), # color of tick labels and titles 'bold': True }, 'tick_color': (0, 0, 0, 1) } # ticks and grid self.graph = Graph(xlabel='Current time', ylabel='Maintenance date', x_ticks_major=5, y_ticks_major=5, y_grid_label=True, x_grid_label=True, padding=5, x_grid=True, y_grid=True, xmin=-0, xmax=31, ymin=-0, ymax=31, **self.graph_theme) self.plot = MeshLinePlot(color=[1, 0, 0, 1]) self.best_maint_dates = joblib.load('mon_best_int_np.asv') self.best_maint_dates = self.best_maint_dates[self.model_.month - 1] self.plot.points = [(x + 1, x + 1 + self.best_maint_dates[x]) for x in range(len(self.best_maint_dates))] self.graph.add_plot(self.plot) self.layout_graph = BoxLayout(orientation='vertical', size_hint=(0.7, 1)) self.layout_graph.add_widget( Label(text='本月最优维保日期随时间变化图', font_name=font_name, size_hint=(1, 0.1), font_size='16sp', color=(0, 0, 0, 1))) self.layout_graph.add_widget(self.graph) # Note for user self.layout_info = BoxLayout(orientation='vertical', size_hint=(0.3, 1)) self.layout_info.add_widget( Label( text= '待预防性维护电梯信息:\n设备编号\n设备所在区域类型\n故障信息\n所在城市\n电梯运行速度\n设备型号\n距离上一次维修天数', font_name=font_name, pos_hint={ 'x': 0.5, 'center_y': .5 }, font_size='16sp', color=(0, 0, 0, 1))) self.layout_note = BoxLayout(orientation='vertical', size_hint=(0.5, 0.8)) self.layout_note.add_widget( Button(on_press=self.on_press, text='输出\n电梯\n信息', font_name=font_name, pos_hint={ 'x': .5, 'y': 1 }, size_hint=(0.4, 0.2), font_size='20sp', color=(0, 0, 0, 1), background_color=color_shadow_blue)) self.layout_graph_note = BoxLayout(orientation='horizontal', size_hint=(1, 0.5)) self.layout_graph_note.add_widget(self.layout_graph) self.layout_graph_note.add_widget(self.layout_info) self.layout_graph_note.add_widget(self.layout_note) self.add_widget(self.layout_graph_note) self.layout2 = BoxLayout(orientation='horizontal', size_hint=(1, .15)) self.add_widget(self.layout2) self.layout2.add_widget( Label(text="请按 'ESC'键或点击窗外以关闭窗口", font_name=font_name, font_size='20sp', color=(1, 0, 0, 1)))
class VideoPage(BoxLayout): orientation = 'vertical' def __init__(self, **kwargs): super().__init__(**kwargs) self.now = datetime.now() self.layout1 = BoxLayout(orientation='horizontal') self.add_widget(self.layout1) self.layout2 = BoxLayout(orientation='vertical') self.layout1.add_widget(self.layout2) self.layout2.add_widget( Label(text="Live Video Streaming", font_size=20, bold=True)) Clock.schedule_interval(self.update_clock, 1) self.timelabel = Label( text=self.now.strftime('%b %d %Y %a %I:%M:%S %p'), font_size=20, bold=True) self.layout2.add_widget(self.timelabel) self.playbutton = Button(text="Play", font_size=20) self.playbutton.bind(on_press=self.playfunction) self.layout2.add_widget(self.playbutton) self.videostream = Image(source='foo.jpg') self.layout1.add_widget(self.videostream) self.returnbutton = Button(text='Return', font_size=20, background_color=(1, 0.3, 0.2, 1), size_hint=(1, 0.2), bold=True) self.returnbutton.bind(on_press=self.returnfunction) self.add_widget(self.returnbutton) def playfunction(self, instance): if (self.playbutton.text == "Play"): self.playbutton.text = 'Stop' client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client_socket.connect((IP, PORT)) send_message('4', client_socket) client_socket.close() Clock.schedule_interval(self.recv, 0.1) else: self.playbutton.text = 'Play' client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client_socket.connect((IP, PORT)) send_message('0', client_socket) client_socket.close() Clock.unschedule(self.recv) def recv(self, dt): client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client_socket.connect((IP, PORT)) send_message('1', client_socket) with open('foo.jpg', 'wb') as file: while True: data = client_socket.recv(1024) if not data: break else: file.write(data) self.videostream.reload() def returnfunction(self, instance): application.screen_manager.current = 'no2' application.screen_manager.transition.direction = 'right' def update_clock(self, *args): self.now = self.now + timedelta(seconds=1) self.timelabel.text = self.now.strftime('%b %d %Y %a\n %I:%M:%S %p')
def build(self): self.title = 'Persimmon' self.background = Image(source='background.png').texture
def fail_login(req, result): modal_view_alert('Error de conexión...\nReintente mas tarde','Cerrar', Image(source=SOURCE_FAIL, size=(100,100)))
def show_property(self, instance, value, key=None, index=-1, *l): # normal call: (tree node, focus, ) # nested call: (widget, prop value, prop key, index in dict/list) if value is False: return content = None if key is None: # normal call nested = False widget = instance.widget key = instance.key prop = widget.property(key) value = getattr(widget, key) else: # nested call, we might edit subvalue nested = True widget = instance prop = None dtype = None if isinstance(prop, AliasProperty) or nested: # trying to resolve type dynamicly if type(value) in (str, str): dtype = 'string' elif type(value) in (int, float): dtype = 'numeric' elif type(value) in (tuple, list): dtype = 'list' if isinstance(prop, NumericProperty) or dtype == 'numeric': content = TextInput(text=str(value) or '', multiline=False) content.bind( text=partial(self.save_property_numeric, widget, key, index)) elif isinstance(prop, StringProperty) or dtype == 'string': content = TextInput(text=value or '', multiline=True) content.bind( text=partial(self.save_property_text, widget, key, index)) elif (isinstance(prop, ListProperty) or isinstance(prop, ReferenceListProperty) or isinstance(prop, VariableListProperty) or dtype == 'list'): content = GridLayout(cols=1, size_hint_y=None) content.bind(minimum_height=content.setter('height')) for i, item in enumerate(value): button = Button(text=repr(item), size_hint_y=None, height=44) if isinstance(item, Widget): button.bind( on_release=partial(self.highlight_widget, item, False)) else: button.bind(on_release=partial(self.show_property, widget, item, key, i)) content.add_widget(button) elif isinstance(prop, OptionProperty): content = GridLayout(cols=1, size_hint_y=None) content.bind(minimum_height=content.setter('height')) for option in prop.options: button = ToggleButton( text=option, state='down' if option == value else 'normal', group=repr(content.uid), size_hint_y=None, height=44) button.bind( on_press=partial(self.save_property_option, widget, key)) content.add_widget(button) elif isinstance(prop, ObjectProperty): if isinstance(value, Widget): content = Button(text=repr(value)) content.bind(on_release=partial(self.highlight_widget, value)) elif isinstance(value, Texture): content = Image(texture=value) else: content = Label(text=repr(value)) elif isinstance(prop, BooleanProperty): state = 'down' if value else 'normal' content = ToggleButton(text=key, state=state) content.bind(on_release=partial(self.save_property_boolean, widget, key, index)) self.content.clear_widgets() if content: self.content.add_widget(content)
class HongBao(PageLayout): def __init__(self, **kwargs): super(HongBao, self).__init__(**kwargs) self.filename = kivy.resources.resource_find( '/mnt/sdcard/com.hipipal.qpyplus/projects/hongbao/hb.jpg') self.init_ui() def add_arrt(self, gridLayout, attr_name, value): gridLayout.add_widget(Label(text=attr_name)) attr_input = TextInput(text=value, multiline=False) gridLayout.add_widget(attr_input) return attr_input def init_ui(self): self.gridLayout = GridLayout(cols=1, spacing=[0, 4]) self.gridLayout1 = GridLayout(cols=2, spacing=[0, 9]) self.color_min_input = self.add_arrt(self.gridLayout1, 'color_min', '20') self.color_max_input = self.add_arrt(self.gridLayout1, 'color_max', '120') self.fangcha_input = self.add_arrt(self.gridLayout1, 'fangcha', '15000') self.up_down_input = self.add_arrt(self.gridLayout1, 'up_down', '8') #self.left_right_input=self.add_arrt(self.gridLayout1,'left_right','0') self.jisuan_btn_a = Button(text='chick_a', ) self.gridLayout1.add_widget(self.jisuan_btn_a) self.jisuan_btn_b = Button(text='chick_b', ) self.gridLayout1.add_widget(self.jisuan_btn_b) self.gridLayout.add_widget(self.gridLayout1) self.jisuan_btn_a.bind(on_press=self.jisuan_a) self.jisuan_btn_b.bind(on_press=self.jisuan_b) self.image_hb = Image(source=self.filename) self.gridLayout.add_widget(self.image_hb) self.floatlayout = FloatLayout() self.fc = FileChooserListView() self.fc.path = '/mnt/sdcard/DCIM/' self.floatlayout.add_widget(self.fc) self.get_file_btn = Button(text='chick_a', size_hint=(0.2, .1), pos=(20, 20)) self.floatlayout.add_widget(self.get_file_btn) self.get_file_btn.bind(on_press=self.get_file) self.add_widget(self.floatlayout) self.add_widget(self.gridLayout) def get_file(self, instance): filename = os.path.join(os.path.dirname(self.filename), os.path.basename(self.fc.selection[0])) print self.fc.selection[0], ' -' * 20 im_tmp = PIL.Image.open(self.fc.selection[0]) w, h = im_tmp.size minx = int(w * 230.0 / 720) maxx = int(w * 487 / 720) miny = int(h * (1280 - 520) / 1280) maxy = int(h * (1280 - 264) / 1280) if h > 1000: im_tmp = im_tmp.crop([minx, miny, maxx, maxy]) im_tmp.save(filename, 'jpeg') self.filename = filename self.floatlayout.opacity = 0 self.updata_image() self.page = 1 print 'filename :', self.filename def remove_line(self, mode='a'): im2 = PIL.Image.open(self.filename) im3 = im2.copy() w2, h2 = im2.size im2_pix = im2.load() im3_pix = im3.load() color_min = int(self.color_min_input.text) color_max = int(self.color_max_input.text) fangcha_max = int(self.fangcha_input.text) up_down = int(self.up_down_input.text) black_in_line = False current_y = 0 for y in range(up_down + 1, h2): x_color_r = 0 x_color_g = 0 x_color_b = 0 for x in range(0, w2): r, g, b = im2_pix[x, y] x_color_r += r x_color_g += g x_color_b += b pingjun_r = x_color_r / w2 pingjun_g = x_color_g / w2 pingjun_b = x_color_b / w2 fangcha_r = 0 fangcha_g = 0 fangcha_b = 0 for x in range(0, w2): r, g, b = im2_pix[x, y] fangcha_r += abs(pingjun_r - r) fangcha_g += abs(pingjun_g - g) fangcha_b += abs(pingjun_b - b) if ( fangcha_r + fangcha_g + fangcha_b ) < fangcha_max and color_min < pingjun_r < color_max and color_min < pingjun_g < color_max and color_min < pingjun_b < color_max: #print y, '****' * 30, ' ', fangcha_r + fangcha_g + fangcha_b, pingjun_r, pingjun_g, pingjun_r if black_in_line == False: current_y = y black_in_line = True for x2 in range(0, w2): if mode == 'a': im3_pix[x2, y] = im2_pix[x2, current_y - 2] else: im3_pix[x2, y] = im2_pix[x2, y - up_down] else: if black_in_line == True: black_in_line = False if mode == 'a': for x2 in range(0, w2): im3_pix[x2, y] = im2_pix[x2, current_y - up_down] #print y, '----' * 30, ' ', fangcha_r + fangcha_g + fangcha_b, pingjun_r, pingjun_g, pingjun_r return im3 def jisuan_a(self, instance): im3 = self.remove_line().resize([600, 600]) filenamea = self.filename.rsplit('.', 1)[0] + 'a.jpg' im3.save(filenamea, 'jpeg') self.updata_image(filenamea) def jisuan_b(self, instance): im3 = self.remove_line('b').resize([600, 600]) filenamea = self.filename.rsplit('.', 1)[0] + 'a.jpg' im3.save(filenamea, 'jpeg') self.updata_image(filenamea) def updata_image(self, filenamea=None): if filenamea is None: filenamea = self.filename image_hb2 = Image(source=filenamea) self.gridLayout.remove_widget(self.image_hb) self.image_hb = image_hb2 self.gridLayout.add_widget(self.image_hb, 0) self.image_hb.reload()
class Screen_Canvas(Screen): background_image = ObjectProperty(Image(source='pline_background.png'))
def syncron_stations(self): app = App.get_running_app() if not app.is_login: return modal_view_alert('No esta loggeado para \nhacer esta acción', 'Cerrar', Image(source=SOURCE_FAIL, size=(100,100))) def progress_stations(request, current_size, total_size): label.text = "Cargando " + str(round(current_size*100/total_size)) + "%" def update_stations(req, result): view.dismiss() json_data = json.loads(result) conn = sqlite3.connect(NAME_DATABASE) with conn: cur = conn.cursor() cur.executemany('INSERT OR REPLACE INTO estacion VALUES (?, ?);', json_data ) cur.execute('SELECT * FROM estacion;') rows = cur.fetchall() if rows: self.manager.get_screen("screen_list").ids.spinner_station.values = [nombre for _, nombre in rows] conn.close() modal_view_alert('Estaciones Actualizadas','Cerrar', Image(source=SOURCE_CHECK, size=(100,100))) def error_stations(req, error): view.dismiss() modal_view_alert('¡Error!','Cerrar', Image(source=SOURCE_FAIL, size=(100,100))) def failure_stations(req, result): view.dismiss() modal_view_alert('Error de conexión...\nReintente mas tarde','Cerrar', Image(source=SOURCE_FAIL, size=(100,100))) #self.manager.get_screen("screen_list").ids.spinner_station.values = ['Hola %i' % i for i in range(20)] params = urllib.parse.urlencode({'action': 'stations'}) headers = {"Authorization": "Token {0}".format(app.api_token)} req = UrlRequest(URL_ENDPOINT+'?'+params, req_headers=headers, on_success=update_stations, on_progress=progress_stations, on_error=error_stations, on_failure=failure_stations) view = ModalView(size_hint=(None, None), size=(400, 400)) layout = GridLayout(cols=1, padding=10) content = Button( text="Cerrar", size_hint=(None, None), size=(380, 100), valign= 'center') label = Label(text="Esperando respuesta...") layout.add_widget(label) layout.add_widget(content) view.add_widget(layout) content.bind(on_press=view.dismiss) view.open() return view
def syncron_subir(self, wait=False): app = App.get_running_app() if not app.is_login: return modal_view_alert('No esta loggeado para \nhacer esta acción', 'Cerrar', Image(source=SOURCE_FAIL, size=(100,100))) headers = { 'Content-type': 'application/json', "Authorization": "Token {0}".format(app.api_token)} def progress_subir(req, cs, ts): label.text = "Cargando " + str(round(cs*100/ts)) + "%" def update_subir(req, result): view.dismiss() json_data = json.loads(result) if json_data['cargado']: conn = sqlite3.connect(NAME_DATABASE) with conn: cur = conn.cursor() cur.execute('UPDATE cola SET up = 1 WHERE up = 0;') conn.close() modal_view_alert('Datos cargados','Cerrar', Image(source=SOURCE_CHECK, size=(100,100))) else: modal_view_alert('Los datos no se cargaron\n correctamente. Reintente más tarde.','Cerrar', Image(source=SOURCE_FAIL, size=(100,100))) def error_subir(req, result): view.dismiss() modal_view_alert('¡Error!','Cerrar', Image(source=SOURCE_FAIL, size=(100,100))) def failure_subir(req, result): view.dismiss() modal_view_alert('Error de conexión...\nReintente mas tarde','Cerrar', Image(source=SOURCE_FAIL, size=(100,100))) view = ModalView(size_hint=(None, None), size=(400, 400)) layout = GridLayout(cols=1, padding=10) content = Button( text="Cerrar", size_hint=(None, None), size=(380, 100), valign= 'center') label = Label(text="Esperando respuesta...") layout.add_widget(label) layout.add_widget(content) view.add_widget(layout) content.bind(on_press=view.dismiss) view.open() conn = sqlite3.connect(NAME_DATABASE) with conn: cur = conn.cursor() cur.execute('SELECT id, estacion, placa, created_at, estado FROM cola WHERE up = 0;') rows = cur.fetchall() if not rows: label.text = "No hay elementos a actualizar" return view data_body = json.dumps([{ 'ie': estacion, 'pl': placa, 'ca': created_at, 'ir': estado } for _id, estacion, placa, created_at, estado in rows ]) req = UrlRequest(URL_ENDPOINT, req_headers=headers, req_body=data_body, on_success=update_subir, on_progress=progress_subir, on_error=error_subir, on_failure=failure_subir) if wait: #while not req.is_finished: # pass req.wait() conn.close() return view
def __init__(self, **kwargs): super(FoodScreen, self).__init__(**kwargs) self.name = "food" if not connected(): self.add_widget(ConnErrorScreen()) return self.scrollView = ScrollView(do_scroll_x=False, do_scroll_y=True, size_hint=(1, .8), id="food_scroll") # Headers self.headers = GridLayout(cols=3, size_hint=(1, .1)) self.headers.add_widget( Label(text="Name", size_hint=(.4, 1), color=[0, 0, 0, 1])) self.headers.add_widget( Label(text="Time until Expiry", size_hint=(.4, 1), color=[0, 0, 0, 1])) self.headers.add_widget( RefreshButton(source=refresh_img, size_hint=(.2, 1))) # MainGrid containing everything self.mainGrid = GridLayout(rows=3) # FoodGrid containing FoodGrid rows containing food items self.foodGrid = GridLayout(cols=3, row_force_default=True, row_default_height=50, size_hint_y=None) for food in food_list: self.foodGrid.add_widget( Label(text=food[0], size_hint=(.4, .2), color=[0, 0, 0, 1])) self.foodGrid.add_widget( Label(text=time_to_expiry(food[1]), size_hint=(.4, .2), color=[0, 0, 0, 1])) if near_expiry(time_to_expiry(food[1])): self.foodGrid.add_widget( Image(source=expiring_img, size_hint=(.2, .2))) elif time_to_expiry(food[1]) == "Expired": self.foodGrid.add_widget( Image(source=expired_img, size_hint=(.2, .2))) else: self.foodGrid.add_widget( Label(text="", size_hint=(.2, .2), color=[0, 0, 0, 1])) # Make sure the height is such that there is something to scroll. self.foodGrid.bind(minimum_height=self.foodGrid.setter('height')) self.scrollView.add_widget(self.foodGrid) # Footer self.footer = GridLayout(cols=3, size_hint=(1, .1)) self.removeButton = Button(text="Remove", size_hint=(.3, 1), color=[0, 0, 0, 1]) self.buzzerButton = BuzzerButton(source=alarm_on_img, size_hint=(.4, 1)) self.buzzerButton.bind(pressed=self.remove_buzzer) self.homeButton = HomeButton(text="Home", size_hint=(.4, 1), color=[0, 0, 0, 1]) self.addButton = AddButton(text="Add new entry", size_hint=(.3, 1), color=[0, 0, 0, 1]) self.footer.add_widget(self.removeButton) if (True in [food[2] for food in food_list]): self.footer.add_widget(self.buzzerButton) else: self.footer.add_widget(self.homeButton) self.footer.add_widget(self.addButton) self.mainGrid.add_widget(self.headers) self.mainGrid.add_widget(self.scrollView) self.mainGrid.add_widget(self.footer) self.add_widget( Image(source=background_img, size_hint=(1, 1), keep_ratio=False, allow_stretch=True)) self.add_widget(self.mainGrid)
class CustomLayout(GridLayout): background_image = ObjectProperty( Image( source='/home/super/CODE/Kivy/kivy-examples/widgets/sequenced_images/data/images/busy-stick-figures-animated.gif', anim_delay=.2))
def build(self): # Set title and icon for the application self.title = 'Grid Maker'; self.icon = "./assets/icon.png"; # Create a Stack layout SL = StackLayout(orientation ='lr-tb', padding=5); SL.spacing = [0, 2]; # First row of the GUI self.imageLabel = Label(text="Image Path:", size_hint=(0.25, 0.075)); self.imageInput = TextInput(multiline=False, size_hint=(0.50, 0.075)); self.browseButton = Button(text ='Browse', size_hint=(0.25, 0.075)); self.browseButton.bind(on_press = self.selectFile); # Second row of the GUI self.rowsLabel = Label(text="Rows:", size_hint=(0.25, 0.075)); self.rowsInput = TextInput(multiline=False, size_hint=(0.25, 0.075), hint_text="10"); self.xOffsetLabel = Label(text="X-offset:", size_hint=(0.25, 0.075)); self.xOffsetInput = TextInput(multiline=False, size_hint=(0.25, 0.075), hint_text="0"); # Third row of the GUI self.columnsLabel = Label(text="Columns:", size_hint=(0.25, 0.075)); self.columnsInput = TextInput(multiline=False, size_hint=(0.25, 0.075), hint_text="10"); self.yOffsetLabel = Label(text="Y-offset:", size_hint=(0.25, 0.075)); self.yOffsetInput = TextInput(multiline=False, size_hint=(0.25, 0.075), hint_text="0"); # Fourth row of the GUI self.bnwLabel = Label(text ='Grayscale', size_hint =(0.166, 0.075)); self.bnwCheckBox = CheckBox(active = False, size_hint =(0.166, 0.075)); self.invertLabel = Label(text ='Invert', size_hint =(0.166, 0.075)); self.invertCheckBox = CheckBox(active = False, size_hint =(0.166, 0.075)); self.binaryLabel = Label(text ='Binary', size_hint =(0.166, 0.075)); self.binaryCheckBox = CheckBox(active = False, size_hint =(0.166, 0.075)); # Fifth row of GUI self.squareLabel = Label(text ='Square', size_hint =(0.25, 0.075)); self.squareCheckBox = CheckBox(active = False, size_hint =(0.25, 0.075)); self.rowPrioLabel = Label(text ='Row priority', size_hint =(0.25, 0.075)); self.rowPrioCheckBox = CheckBox(active = False, size_hint =(0.25, 0.075)); # Disable the checkbox by default # self.rowPrioLabel.disabled = True; # self.rowPrioCheckBox.disabled = True; # Sixth row of the GUI self.thicknessLabel = Label(text="Thickness:", size_hint=(0.25, 0.075)); self.thicknessInput = TextInput(multiline=False, size_hint=(0.25, 0.075), hint_text="1"); self.colorButton = Button(text="Color", size_hint=(0.5, 0.075), background_color =(1, 0, 0, 1)); self.colorButton.bind(on_press = self.colorDialog); # Seventh row of the GUI self.resetButton = Button(text ='Reset', size_hint = (0.5, 0.075)); self.resetButton.bind(on_press = self.resetAll); self.applyButton = Button(text ='Apply', size_hint =(0.5, 0.075)); self.applyButton.bind(on_press = self.apply); # Image canvas at the bottom of the GUI self.outputImage = Image(source ='assets\\welcome.jpg', size_hint = (1, 0.38)); self.disclaimerLabel = Label(text="", size_hint=(1, 0.05)); # Add all the defined widgets accordingly SL.add_widget(self.imageLabel); SL.add_widget(self.imageInput); SL.add_widget(self.browseButton); SL.add_widget(self.rowsLabel); SL.add_widget(self.rowsInput); SL.add_widget(self.xOffsetLabel); SL.add_widget(self.xOffsetInput); SL.add_widget(self.columnsLabel); SL.add_widget(self.columnsInput); SL.add_widget(self.yOffsetLabel); SL.add_widget(self.yOffsetInput); SL.add_widget(self.bnwLabel); SL.add_widget(self.bnwCheckBox); SL.add_widget(self.invertLabel); SL.add_widget(self.invertCheckBox); SL.add_widget(self.binaryLabel); SL.add_widget(self.binaryCheckBox); SL.add_widget(self.squareLabel); SL.add_widget(self.squareCheckBox); SL.add_widget(self.rowPrioLabel); SL.add_widget(self.rowPrioCheckBox); SL.add_widget(self.thicknessLabel); SL.add_widget(self.thicknessInput); SL.add_widget(self.colorButton); SL.add_widget(self.resetButton); SL.add_widget(self.applyButton); SL.add_widget(self.disclaimerLabel); SL.add_widget(self.outputImage); # Return and run the application return SL;
def build(root): root = root.root try: # load the image graph = Image(source='rplot.jpg', size_hint=(10, .4), pos_hint={ 'x': -4.15, 'y': .50 }) pass_image = Image(source='pass.jpg', size_hint=(.25, .25), pos_hint={ 'x': .45, 'y': .60 }) table = Image(source='table.png', size_hint=(10, .4), pos_hint={ 'x': -4.17, 'y': .05 }) image_material = Image(source='image_material.png', size_hint=(10, .4), pos_hint={ 'x': -4.419, 'y': .05 }) # add to the main field root.add_widget(graph) root.add_widget(table) root.add_widget(pass_image) root.add_widget(image_material) except Exception as e: Logger.exception('Pictures: Unable to load ') #labels main_label = Label(text="Hello Engineer", size_hint=(1, .55), pos_hint={ 'x': 0, 'y': .70 }) weight_label = Label( text="Please specify the weight of the tube in Pounds", size_hint=(1, .55), pos_hint={ 'x': -.25, 'y': .60 }) angle1_label = Label(text="Please specify the angle of Tensor 1", size_hint=(1, .55), pos_hint={ 'x': -.25, 'y': .45 }) angle2_label = Label(text="Please specify the angle of Tensor 2", size_hint=(1, .55), pos_hint={ 'x': -.25, 'y': .30 }) material_label = Label(text="Please specify Diameter of the cable", size_hint=(1, .55), pos_hint={ 'x': -.25, 'y': .15 }) #text inputs weight = TextInput(text='', multiline=False, password=False, size_hint=(.4, .10), pos_hint={ 'x': .05, 'y': .75 }) angle1 = TextInput(text='', multiline=False, password=False, size_hint=(.4, .10), pos_hint={ 'x': .05, 'y': .60 }) angle2 = TextInput(text='', multiline=False, password=False, size_hint=(.4, .10), pos_hint={ 'x': .05, 'y': .45 }) material = TextInput(text='', multiline=False, password=False, size_hint=(.4, .10), pos_hint={ 'x': .05, 'y': .30 }) #buttons go_button = Button(text="CALCULATE", size_hint=(.3, .1), pos_hint={ 'x': .05, 'y': .2 }) # Gather the values from the ext box and pass them to the matrix # calculation, after that the value of the forces return def calculate_break_point(forces, material): materials = { 13: 20.4, 16: 30.6, 18: 38.5, 19: 42.9, 22: 57.2, 25.4: 75.8, 26: 79.3, 28: 91.6, 30: 105, 32: 119 } ton = 2000 try: for force in forces: if abs(float( forces[0])) > materials[float(material)] * ton: print "BREAKS" print "\nMax tension to break:" print materials[float(material)] * ton print " \nCurrent tension:" print abs(float(forces[0])) pass_image.source = 'breaks.jpg' pass_image.reload() else: print "PASS" print "\nMax tension to break:" print materials[float(material)] * ton print " \nCurrent tension:" print abs(float(forces[0])) pass_image.source = 'pass.jpg' pass_image.reload() except Exception as e: Logger.exception('Material does not exist') def callback(instance): forces = [] print('The button is being pressed') if {weight.text and angle1.text and angle2.text and material.text}: # execute the process process = Popen([ "./main", weight.text, angle1.text, angle2.text, material.text ], stdout=PIPE) (output, err) = process.communicate() exit_code = process.wait() print(output) for line in output.splitlines(): if "Force" in line: forces.append(line.split(":")[1].strip()) print forces calculate_break_point(forces, material.text) # reload the image graph.reload() go_button.bind(on_press=callback) #add to frame root.add_widget(main_label) root.add_widget(weight) root.add_widget(angle1) root.add_widget(angle2) root.add_widget(material) root.add_widget(weight_label) root.add_widget(angle1_label) root.add_widget(angle2_label) root.add_widget(material_label) root.add_widget(go_button)
def error_login(req, error): modal_view_alert('¡Error!','Cerrar', Image(source=SOURCE_FAIL, size=(100,100)))
def build(self): self.texture = Image(source='mtexture1.png').texture self.texture.wrap = 'repeat' self.texture.uvsize = (8, 8) return Builder.load_string(kv)
def on_seat_source(self, *args): self.texture_ = Image(source=self.seat_source).texture
class TrackMap2(FloatLayout): longs = ListProperty() lats = ListProperty() coordshint = ObjectProperty([]) points = ObjectProperty([50, 800, 70, 1000]) coordstuple = ObjectProperty(()) coords = ListProperty([]) color = ListProperty([1, 1, 0, 1]) wid = NumericProperty(3) trackfile = ("./assets/track.txt") im = Image() index = NumericProperty(0) def __init__(self, **kwargs): super(TrackMap2, self).__init__(**kwargs) earth_radius = 6367116 #print(self.pos,self.size) file = open(self.trackfile, "r") # used to approximate x and y coords to 1:1 aspect ratio f = 1 maxx = 0 minx = 0 maxy = 0 miny = 0 c = 0 for line in file: i = line.split(',')[0:2] self.coords.append(list(utm.from_latlon(float(i[1]), float(i[0])))) #print(self.coords) #print(list(utm.from_latlon(float(i[1]), float(i[0])))) try: if f: maxx = self.coords[0][0] minx = self.coords[0][0] maxy = self.coords[0][1] miny = self.coords[0][1] f = 0 if self.coords[c][0] > maxx: maxx = self.coords[c][0] if self.coords[c][0] < minx: minx = self.coords[c][0] if self.coords[c][1] > maxy: maxy = self.coords[c][1] if self.coords[c][1] < miny: miny = self.coords[c][1] c += 1 except Exception as e: print(e) file.close() #print(self.canvas.before.x) for i in self.coords: self.coordshint.append((i[0] - minx) / (maxx - minx)) self.coordshint.append((i[1] - miny) / (maxy - miny)) self.coordstuple = tuple(self.coordshint) #print(self.coordshint) #print(self.coordshint) Clock.schedule_once(self.render, 0.1) #print(Window.height, Window.width) #print(self.width,self.height) #print(self.x,self.y) def render(self, dt): self.points = [ (self.pos[0] + self.width * self.coordshint[i]) if i % 2 == 0 else (self.pos[1] + self.height * self.coordshint[i]) for i in range(len(self.coordshint)) ] #print(self.points) self.canvas.add(Line(points=self.points, width=1))
def build(self): Get_CloudWatch_Graphs() self.CloudWatch_Remote = BoxLayout(orientation='vertical') self.Control_Bar = BoxLayout(orientation='horizontal', size_hint=(1, 0.05)) # self.Begin_Time_Slider = \ # Slider_Extended(min=-24, max=-1, value=-24, step=1, size_hint=(0.40, 1)) # self.Begin_Time_Slider.bind(value=self.on_begin_time_value_change) # self.Begin_Time_Slider.bind(on_release=self.update) # self.Begin_Time_Label = \ # Label(text=(str(int(round(self.Begin_Time_Slider.value))) + "H"), # size_hint=(0.05, 1)) self.Period_Label = Label(text=(str(self.Period_Value) + "H"), size_hint=(0.05, 1)) # self.Control_Bar.add_widget(self.Begin_Time_Label) self.Control_Bar.add_widget(self.Period_Label) # self.Control_Bar.add_widget(self.Begin_Time_Slider) for button_idx, button_value in enumerate([120, 96, 72, 48, 24, 20, 16, 12, 8, 6, 5, 4, 3, 2, 1]): period_button = Button(text=str(button_value)) period_button.font_size = 14 period_button.size_hint = (0.0375, 1) period_button.bind(on_press=partial(self.on_set_period, button_idx, button_value)) self.Period_Buttons.append(period_button) self.Control_Bar.add_widget(period_button) button_refresh = Button(text="Refresh", size_hint=(0.075, 1)) button_refresh.font_size = 14 button_refresh.bind(on_press=self.update) self.Control_Bar.add_widget(button_refresh) for button_idx, button_value in enumerate([-72, -48, -36, -24, -12, -10, -8, -6, -5, -4, -3, -2, -1, 0]): # -96, end_button = Button(text=str(button_value)) end_button.font_size = 14 end_button.size_hint = (0.0375, 1) end_button.bind(on_press=partial(self.on_set_period_end, button_idx, button_value)) self.Period_End_Buttons.append(end_button) self.Control_Bar.add_widget(end_button) # self.End_Time_Slider = \ # Slider_Extended(min=-23, max=0, value=0, step=1, size_hint=(0.40, 1)) # self.End_Time_Slider.bind(value=self.on_end_time_value_change) # self.End_Time_Slider.bind(on_release=self.update) # self.End_Time_Label = \ # Label(text=(str(int(round(self.End_Time_Slider.value))) + "H"), # size_hint=(0.05, 1)) self.Period_End_Label = Label(text=(str(self.Period_End_Value) + "H"), size_hint=(0.05, 1)) # self.Control_Bar.add_widget(self.End_Time_Slider) # self.Control_Bar.add_widget(self.End_Time_Label) self.Control_Bar.add_widget(self.Period_End_Label) if (cw_remote_duplex_layout): self.Upper_Widget_Box = BoxLayout(orientation='vertical', size_hint=(1, 0.475)) self.Lower_Widget_Box = BoxLayout(orientation='vertical', size_hint=(1, 0.475)) self.Upper_Widget_Box.add_widget(Image(texture=ci_widget_image_list[0].texture)) self.Lower_Widget_Box.add_widget(Image(texture=ci_widget_image_list[1].texture)) self.CloudWatch_Remote.add_widget(self.Upper_Widget_Box) self.CloudWatch_Remote.add_widget(self.Control_Bar) self.CloudWatch_Remote.add_widget(self.Lower_Widget_Box) elif (len(widget_descriptor_list) > 1): self.Carousel_Widget = Carousel(direction='bottom') for ci_widget_image in ci_widget_image_list: self.Carousel_Widget.add_widget(Image(texture=ci_widget_image.texture)) self.CloudWatch_Remote.add_widget(self.Control_Bar) self.CloudWatch_Remote.add_widget(self.Carousel_Widget) else: self.Upper_Widget_Box = BoxLayout(orientation='vertical', size_hint=(1, (2 * 0.475))) self.Upper_Widget_Box.add_widget(Image(texture=ci_widget_image_list[0].texture)) self.CloudWatch_Remote.add_widget(self.Control_Bar) self.CloudWatch_Remote.add_widget(self.Upper_Widget_Box) if (cw_remote_refresh_interval_seconds >= 1): Clock.schedule_interval(self.update, cw_remote_refresh_interval_seconds) return self.CloudWatch_Remote
def __init__(self, **kwargs): super(MDRaisedButton).__init__(**kwargs) super().__init__(**kwargs) self.i = Image() self.incoming = MDFillRoundFlatButton() self.msg = MDFillRoundFlatButton() self.incoming_text = MDLabel() self.text_msg = MDLabel() self.Box = MDBoxLayout() self.count = 0 self.count_the_length = 0 self.screen = MDGridLayout( cols=1, rows=2, md_bg_color=hex8("#00ffff"), size_hint=[1, 1]) self.size = [1, 1] self.Scroll = ScrollView() self.Scroll.scroll_type = ["content", "bars"] self.Scroll.bar_color = hex8("#000000") self.Scroll.bar_width = "5dp" self.text = TextInput( font_name="Default.ttf", size_hint=[1, 1], font_size=23, multiline=False) self.button = MDRaisedButton( size_hint=[0.124, 0.124], font_name="Arial", on_press=lambda message:self.send_it(self.text.text)) self.button.md_bg_color = hex8("#ff00ff") self.button.text = "send" self.button.text_color = hex8("#000000") self.Top = MDGridLayout( cols=2, rows=1, md_bg_color=hex8("#00ffff"), size_hint_x=1, size_hint_y=1, minimum_height=20) self.Container = MDBoxLayout( md_bg_color=hex8("#00ffff"), orientation="vertical", width=self.screen.width, height=self.screen.height) self.Bot = MDBoxLayout( md_bg_color=hex8("##00ffff"), orientation="vertical", width=self.screen.width, height=self.screen.height) self.bottom = MDGridLayout( cols=2, rows=1, md_bg_color=hex8("#00ffff"), width=200, height=200, size_hint=[.07, .07]) self.bottom.add_widget(self.text) self.bottom.add_widget(self.button) self.Top.add_widget(self.Container) self.Top.add_widget(self.Bot) self.Scroll.size = [self.screen.width, self.screen.height] self.Scroll.add_widget(self.Top) self.screen.add_widget(self.Scroll) self.screen.add_widget(self.bottom) self.add_widget(self.screen)
def send_operation(self, operation: str) -> None: img_source = self.button_image(operation) self.parent.children[2].add_middle(Image(source=img_source))
class SeatBase(ButtonBehavior, FloatLayout): """the base class for any plane seat""" seat_source = StringProperty('') # path to the source of the seat image texture_ = Image( source='resources/seatmap-seat.png' ).texture # the background texture of the seat containing the image seat_size = ListProperty( [45, 33] ) # the size of the seat on the source image in pixels, this says nothing about the actual widget size small = BooleanProperty( False ) # if True; the width of the seat on the source image will be less seat_color = ListProperty([]) # seat color in rgba format seat_color_hex = StringProperty( '#00a1de' ) # opional, seat color in hex. Although the default color is set as hex. seat_number = StringProperty('2B') # the seat number displayed on the seat font = StringProperty( 'resources/FRANKGO.ttf') # font used for the seat label orientation = OptionProperty( 'horizontal', options=['horizontal', 'vertical']) # the orientation the seat should be placed in texture_coords = ListProperty( [0, 0, 0, 0, 0, 0, 0, 0] ) # the texture coordinates of the source image, defining which part of the source image should be used. label_orientation = DictProperty({ 'center_x': .45, 'center_y': .52 }) # the position of the label relative to the seat disabled = BooleanProperty( False) # if True; the seat will be disabled. E.g. if already booked. sched_text = None # will call the clock to schedule the :meth: set_texture_size def __init__(self, **kwargs): super(SeatBase, self).__init__(**kwargs) self.sched_text = Clock.schedule_once( lambda dt: self.set_texture_size()) self.bind(size=self.sched_text) self.bind(orientation=self.sched_text) self.bind(small=self.sched_text) self.register_event_type('on_seat_color_hex') self.register_event_type('on_seat_source') self.on_seat_color_hex() def on_seat_source(self, *args): self.texture_ = Image(source=self.seat_source).texture def on_seat_color_hex(self, obj=None, hex_color=None): # if a hex color is set, convert it to the rgba space self.seat_color = get_color_from_hex( hex_color if hex_color else self.seat_color_hex) def set_texture_size(self, *args): # set the texture coordinates if self.small: self.seat_size = [45, 31] else: self.seat_size = [45, 33] nx = (self.texture_.width - float(self.seat_size[0])) / self.texture_.width ny = (self.texture_.height - float(self.seat_size[1])) / (2 * self.texture_.height) nr = 1 nt = 1 - ny if self.orientation == 'horizontal': self.texture_coords = [nx, ny, nr, ny, nr, nt, nx, nt] self.label_orientation = {'center_x': .45, 'center_y': .52} if self.width < self.height: self.width, self.height = self.height, self.width elif self.orientation == 'vertical': self.texture_coords = [nr, ny, nr, nt, nx, nt, nx, ny] self.label_orientation = {'center_x': .5, 'center_y': .52} if self.width > self.height: self.width, self.height = self.height, self.width
def build(self): self.from_move = None self.to_move = None self.chessboard = ChessBoard() self.analysis_board = ChessBoard() self.squares = [] self.use_engine = False self.last_touch_down_move = None self.last_touch_up_move = None parent = BoxLayout(size_hint=(1, 1)) grid = GridLayout(cols=8, rows=8, spacing=0, size_hint=(1, 1)) for i, name in enumerate(SQUARES): bt = Image(allow_stretch=True) bt.sq = i bt.name = name # bt.border = [0,0,0,0] if i in light_squares: bt.sq_color = "l" bt.background_down = "img/empty-l.png" # bt.background_color=[1,1,1,1] else: bt.sq_color = "d" bt.background_down = "img/empty-d.png" # bt.background_color=[0,0,0,0] # print i # bt.bind(on_press=self.callback) bt.bind(on_touch_down=self.touch_down_move) bt.bind(on_touch_up=self.touch_up_move) # bt.bind(on_touch_up=self.touch_move) grid.add_widget(bt) self.squares.append(bt) b = BoxLayout(size_hint=(0.15, 0.15)) ## Spacers # b.add_widget(Button(spacing=1)) # b.add_widget(Button(spacing=1)) # b.add_widget(Button(spacing=1)) # Move control buttons # back_bt = Button(markup=True) # # back_bt.background_normal="img/empty-l.png" # back_bt.text="[color=ff3333]Back[/color]" # back_bt.bind(on_press=self.back) # b.add_widget(back_bt) # save_bt = Button(markup=True) #fwd_bt.background_normal="img/empty-d.png" save_bt.text = "[color=3333ff]Save[/color]" # save_bt.text="Save" save_bt.bind(on_press=self.save) b.add_widget(save_bt) # b.add_widget(Button(spacing=10)) # b.add_widget(Button(spacing=10)) # b.add_widget(Button(spacing=10)) # grid.add_widget(b) # board_box.add_widget(grid) # board_box.add_widget(b) # fen_input = TextInput(text="FEN", focus=True, multiline=False) # def on_fen_input(instance): # self.chessboard.setFEN(instance.text) # self.refresh_board() ## print 'The widget', instance.text # # fen_input.bind(on_text_validate=on_fen_input) ## self._keyboard.bind(on_key_down=self._on_keyboard_down) # # # b.add_widget(fen_input) settings_bt = Button(markup=True, text='Setup') settings_bt.bind(on_press=self.go_to_settings) b.add_widget(settings_bt) # self.root.current='settings' parent.add_widget(grid) info_grid = GridLayout(cols=1, rows=4, spacing=1, size_hint=(0.3, 1), orientation='vertical') info_grid.add_widget(b) self.game_score = ScrollableLabel('New Game', ref_callback=self.go_to_move) info_grid.add_widget(self.game_score) self.engine_score = ScrollableLabel( '[ref=engine_toggle]Analysis[/ref]', ref_callback=self.add_eng_moves) info_grid.add_widget(self.engine_score) info_grid.add_widget(Button(text="Text")) parent.add_widget(info_grid) self.refresh_board() platform = kivy.utils.platform() self.uci_engine = None if self.is_desktop(): self._keyboard = Window.request_keyboard(self._keyboard_closed, self) self._keyboard.bind(on_key_down=self._on_keyboard_down) self.start_engine_thread() sm = ScreenManager(transition=SlideTransition()) board_screen = Screen(name='main') board_screen.add_widget(parent) sm.add_widget(board_screen) settings_screen = SettingsScreen(name='settings') settings_screen.add_widget(self.generate_settings()) sm.add_widget(settings_screen) return sm
def __init__(self, **kwargs): super(UVicMuse, self).__init__(**kwargs) self.press_search_txt = "Search for a list of Available Muses" self.btn_color = (204 / 256, 213 / 256, 216 / 256, 1) self.txt_color = kivy.utils.get_color_from_hex("#5a636c") self.chbx_color = kivy.utils.get_color_from_hex("#0f0f0f") # self.txt_color = kivy.utils.get_color_from_hex("#F8B195") self.muses = [] self.sock = None self.muse = None self.did_connect = False self.udp_address = "" self.connected_address = "" self.muse_backend = 'bgapi' self.host_address = 'localhost' self.backend = Backend(self.muse_backend) self.current_muse_id = 0 # Create UVic Muse Logo DATA_PATH = pkg_resources.resource_filename('uvicmuse', 'docs/') self.img = Image(source=os.path.join(DATA_PATH, 'Header.png'), allow_stretch=True) # Initiate Labels self.status_label = Label(text="Press Search to Look For Nearby Muse", color=self.txt_color, font_size='16sp', pos_hint={ 'x': 0.033, 'y': .2 }, size_hint=(1.0, 1.0), halign="left", valign="middle") self.status_label.bind(size=self.status_label.setter('text_size')) # with self.canvas: # # Color(133 / 256, 169 / 256, 204 / 256) # Rectangle() # self.canvas = RectWidg(size_hint=(1.0, 0.5), pos_hint={'x': 0.2, 'y':0.75}) # self.canvas.add(Color(133 / 256, 169 / 256, 204 / 256)) # Footer # self.canvas.add(Color(14 / 256, 35 / 256, 102 / 256)) # self.canvas.add(Rectangle(size=(750, 32), pos=(0, 0 + 0))) self.sensors_title = Label(text="Sensors", color=self.txt_color, font_size='18sp', bold=True, valign='middle', halign='center', pos_hint={ 'x': -0.29, 'y': -.18 }) self.LSL_title = Label(text="Lab Streaming", color=self.txt_color, font_size='18sp', bold=True, pos_hint={ 'x': +0.0, 'y': -.18 }) self.LSL2_title = Label(text="Layer (LSL)", color=self.txt_color, font_size='18sp', bold=True, pos_hint={ 'x': +0.0, 'y': -.215 }) self.filter_title = Label(text="Filters", color=self.txt_color, font_size='18sp', bold=True, pos_hint={ 'x': +0.3, 'y': -.18 }) self.about_button = Button(text="About Us", size_hint=(.15, .0060), pos_hint={ 'x': 0.84, 'y': .022 }, background_color=self.btn_color, on_release=self.about) self.reset_button = Button(text="Reset Kernel", size_hint=(.15, .0060), pos_hint={ 'x': 0.01, 'y': .022 }, background_color=(241 / 256, 148 / 256, 163 / 256, 1), on_release=self.reset) self.search_button = Button(text="Search", size_hint=(.15, .07), pos_hint={ 'x': 0.82, 'y': .6 }, background_color=self.btn_color, on_press=self.update_status_search, on_release=self.search) # Initiate Buttons and bind press and release to functions self.connect_button = Button(text="Connect", size_hint=(.15, .07), pos_hint={ 'x': 0.82, 'y': .5 }, background_color=self.btn_color, on_release=self.connect, on_press=self.on_connect_press) self.stream_button = Button(text="Start Stream", size_hint=(.15, .07), pos_hint={ 'x': 0.82, 'y': .4 }, background_color=self.btn_color, on_release=self.stream) # self.LSL_label = Label(text="LSL", color=self.txt_color, font_size='14sp') self.EEG_label = Label(text="EEG", color=self.txt_color, font_size='14sp', pos_hint={ 'x': -0.3455, 'y': -.22 }, halign='center') self.PPG_label = Label(text="PPG", color=self.txt_color, font_size='14sp', pos_hint={ 'x': -0.2355, 'y': -.22 }, halign='center') self.ACC_label = Label(text="ACC", color=self.txt_color, font_size='14sp', pos_hint={ 'x': -0.3455, 'y': -.32 }, halign='center') self.GYRO_label = Label(text="GYRO", color=self.txt_color, font_size='14sp', pos_hint={ 'x': -0.2355, 'y': -.32 }, halign='center') self.lowpass_label = Label(text="Lowpass", color=self.txt_color, font_size='16sp', pos_hint={ 'x': 0.25, 'y': -.235 }, halign='left', valign='middle') self.notch_label = Label(text="Notch (60Hz)", color=self.txt_color, font_size='16sp', pos_hint={ 'x': 0.25, 'y': -.30 }, halign='left', valign='middle') self.highpass_label = Label(text="Highpass", color=self.txt_color, font_size='16sp', pos_hint={ 'x': 0.25, 'y': -.365 }, halign='left', valign='middle') # initiate List with max height self.list_box = Spinner(text=self.press_search_txt, values='', size_hint=(0.77, 0.07), pos_hint={ 'x': 0.03, 'y': .6 }, background_color=self.btn_color) self.list_box.dropdown_cls.max_height = self.list_box.height * 1.6 # Initiate Checkbox's self.LSL_checkbox = CheckBox(active=True, size_hint_y=0.02, size_hint_x=0.02, pos_hint={ 'x': 0.49, 'y': +.18 }, color=self.chbx_color) self.EEG_checkbox = CheckBox(active=True, size_hint_y=0.02, size_hint_x=0.02, pos_hint={ 'x': 0.144, 'y': +.23 }, color=self.chbx_color) self.PPG_checkbox = CheckBox(active=False, size_hint_y=0.02, size_hint_x=0.02, pos_hint={ 'x': 0.254, 'y': +.23 }, color=self.chbx_color) self.ACC_checkbox = CheckBox(active=False, size_hint_y=0.02, size_hint_x=0.02, pos_hint={ 'x': 0.144, 'y': +.13 }, color=self.chbx_color) self.GYRO_checkbox = CheckBox(active=False, size_hint_y=0.02, size_hint_x=0.02, pos_hint={ 'x': 0.254, 'y': +.13 }, color=self.chbx_color) self.lowpass_checkbox = CheckBox(active=False, size_hint_y=0.02, size_hint_x=0.02, pos_hint={ 'x': 0.82, 'y': 0.5 - .245 }, color=self.chbx_color) self.notch_checkbox = CheckBox(active=True, size_hint_y=0.02, size_hint_x=0.02, pos_hint={ 'x': 0.82, 'y': 0.5 - 0.31 }, color=self.chbx_color) self.highpass_checkbox = CheckBox(active=False, size_hint_y=0.02, size_hint_x=0.02, pos_hint={ 'x': 0.82, 'y': 0.5 - 0.375 }, color=self.chbx_color) # Initiate textbox's to enter text self.lowpass_text = TextInput(font_size='14sp', pos_hint={ "x": 0.85, "y": 0.5 - .264 }, size_hint=(0.07, 0.05), multiline=False, text='30', write_tab=False, halign='center', background_color=(204 / 256, 213 / 256, 216 / 256, 1)) self.highpass_text = TextInput(font_size='14sp', pos_hint={ "x": 0.85, "y": 0.5 - 0.394 }, size_hint=(0.07, 0.05), multiline=False, text='0.1', write_tab=False, halign='center', background_color=(204 / 256, 213 / 256, 216 / 256, 1)) # add widgets that have been initiated to frame self.add_widget(self.img) # self.add_widget(self.canvas) self.add_widget(self.about_button) self.add_widget(self.reset_button) self.add_widget(self.search_button) self.add_widget(self.connect_button) self.add_widget(self.stream_button) self.add_widget(self.status_label) self.add_widget(self.lowpass_text) self.add_widget(self.highpass_text) self.add_widget(self.EEG_label) self.add_widget(self.PPG_label) self.add_widget(self.ACC_label) self.add_widget(self.GYRO_label) self.add_widget(self.LSL_checkbox) self.add_widget(self.EEG_checkbox) self.add_widget(self.PPG_checkbox) self.add_widget(self.ACC_checkbox) self.add_widget(self.GYRO_checkbox) self.add_widget(self.lowpass_label) self.add_widget(self.highpass_label) self.add_widget(self.lowpass_checkbox) self.add_widget(self.highpass_checkbox) # self.add_widget(self.lowpass_cutoff) # self.add_widget(self.highpass_cutoff) self.add_widget(self.notch_checkbox) self.add_widget(self.notch_label) self.add_widget(self.list_box) self.add_widget(self.sensors_title) self.add_widget(self.filter_title) self.add_widget(self.LSL_title) self.add_widget(self.LSL2_title) # Adjust positions of widgets that have been added to the frame self.img.pos_hint = {'x': 0, 'y': 0.7} self.img.size_hint = (1, 0.3) # self.status_label.pos = (-155, 120) # self.EEG_label.pos = (-263, -150) # self.PPG_label.pos = (-160, -150) # self.ACC_label.pos = (-263, -200) # self.GYRO_label.pos = (-158, -200) # self.LSL_checkbox.pos = (355, 110) # self.EEG_checkbox.pos = (104, 122) # self.PPG_checkbox.pos = (210, 122) # self.ACC_checkbox.pos = (104, 71) # self.GYRO_checkbox.pos = (210, 71) # # self.notch_label.pos = (128, -190) # self.lowpass_label.pos = (140, -150) # self.highpass_label.pos = (140, -230) # self.lowpass_checkbox.pos = (570, 142) # self.highpass_checkbox.pos = (570, 63) # self.notch_checkbox.pos = (570, 102) # self.lowpass_cutoff.pos = (235, -150) # self.highpass_cutoff.pos = (235, -230) # self.sensors_title.pos = (-213, -125) # self.LSL_title.pos = (-10, -125) # self.LSL2_title.pos = (-12, -142) # self.filter_title.pos = (200, -125) # initial state self.PPG_checkbox.disabled = True self.LSL_checkbox.disabled = True self.EEG_checkbox.disabled = True self.ACC_checkbox.disabled = True self.GYRO_checkbox.disabled = True self.notch_checkbox.disabled = True self.lowpass_checkbox.disabled = True self.highpass_checkbox.disabled = True self.highpass_text.disabled = True self.lowpass_text.disabled = True self.stream_button.disabled = True self.connect_button.disabled = True
def error_stations(req, error): view.dismiss() modal_view_alert('¡Error!','Cerrar', Image(source=SOURCE_FAIL, size=(100,100)))
def main_menu(): #Window.fullscreen=True Window.clearcolor = (1, 140.0 / 255, 15.0 / 255, 0) Menu = BoxLayout(orientation='vertical') title = Label(text='Trages', markup=True, bold=True, color=(79.0 / 255, 15.0 / 255, 204.0 / 255, 0), font_name='RAVIE.ttf', font_size='100dp', y=Window.height / 2 - 25, x=-Window.width / 2 + 100, size_hint=(1, 0.3)) Menu.add_widget(title) root = Accordion(orientation='vertical') ButtonChildren = Button(text='Press here for children education', size_hint=(1, 0.3)) ButtonChildren.bind(on_press=go_children) s1 = 'This version of software\n is a new method of \nteaching children.\n It allows one to make \nlearning process \nmore interactive and \nsimple due to gaming form.' LabelChildren = Label(text=s1, font_name='RAVIE.ttf', font_size='20dp', max_lines=4, shorten=True, color=(113.0 / 255, 17.0 / 255, 150.0 / 255, 1)) BoxLayoutChildren = BoxLayout(orientation='horizontal') BoxLayoutChildren2 = BoxLayout(orientation='vertical') BoxLayoutChildren2.add_widget(LabelChildren) BoxLayoutChildren2.add_widget(ButtonChildren) ImageChildren = Image(source='childeduc.bmp') BoxLayoutChildren.add_widget(ImageChildren) BoxLayoutChildren.add_widget(BoxLayoutChildren2) children = AccordionItem(title='Children Education') children.add_widget(BoxLayoutChildren) ### ButtonGame = Button(text='Press here for testing', size_hint=(1, .3)) ButtonGame.bind(on_press=go_game) s2 = 'This version of software\n is a new method of \ntesting children.\n It allows one to make \ntesting process \nmore interactive and \nsimple due to gaming form.' LabelGame = Label(text=s2, font_name='RAVIE.ttf', font_size='20dp', max_lines=4, shorten=True, color=(113.0 / 255, 17.0 / 255, 150.0 / 255, 1)) BoxLayoutGame = BoxLayout(orientation='horizontal') BoxLayoutGame2 = BoxLayout(orientation='vertical') BoxLayoutGame2.add_widget(LabelGame) BoxLayoutGame2.add_widget(ButtonGame) ImageGame = Image(source='forgame.bmp') BoxLayoutGame.add_widget(ImageGame) BoxLayoutGame.add_widget(BoxLayoutGame2) game = AccordionItem(title='Game!') game.add_widget(BoxLayoutGame) ### BoxLayoutInfo = BoxLayout(orientation='horizontal') ImageInfo = Image(source='command.jpg') BoxLayoutInfo.add_widget(ImageInfo) LabelInfo = Label( text= 'We are command from \nN.Novgorod,Russia.\nWe are Max and Anna.\nWe want to help \ndeaf-mute people,\nso we created\n this application.', font_size='25dp', font_name='RAVIE.ttf', color=(113.0 / 255, 17.0 / 255, 150.0 / 255, 1)) BoxLayoutInfo.add_widget(LabelInfo) info = AccordionItem(title='About us') info.add_widget(BoxLayoutInfo) ButtonExit = Button(text='Exit') ButtonExit.bind(on_press=go_exit) ButtonExit.size_hint = (1, .1) #rexit=AccordionItem(title='Exit') #rexit.add_widget(ButtonExit) root.add_widget(children) root.add_widget(game) root.add_widget(info) #root.add_widget(rexit) root.current = children Menu.add_widget(root) Menu.add_widget(ButtonExit) return Menu
def build(self): Get_CloudWatch_Graphs() self.CloudWatch_Remote = BoxLayout(orientation='vertical') self.Control_Bar = BoxLayout(orientation='horizontal', size_hint=(1, 0.05)) self.Begin_Time_Slider = \ Slider_Extended(min=-24, max=-1, value=-24, step=1, size_hint=(0.40, 1)) self.Begin_Time_Slider.bind(value=self.on_begin_time_value_change) self.Begin_Time_Slider.bind(on_release=self.update) self.Begin_Time_Label = \ Label(text=(str(int(round(self.Begin_Time_Slider.value))) + "H"), size_hint=(0.05, 1)) self.Control_Bar.add_widget(self.Begin_Time_Label) self.Control_Bar.add_widget(self.Begin_Time_Slider) button_refresh = Button(text="Refresh", size_hint=(0.1, 1)) button_refresh.bind(on_press=self.update) self.Control_Bar.add_widget(button_refresh) self.End_Time_Slider = \ Slider_Extended(min=-23, max=0, value=0, step=1, size_hint=(0.40, 1)) self.End_Time_Slider.bind(value=self.on_end_time_value_change) self.End_Time_Slider.bind(on_release=self.update) self.End_Time_Label = \ Label(text=(str(int(round(self.End_Time_Slider.value))) + "H"), size_hint=(0.05, 1)) self.Control_Bar.add_widget(self.End_Time_Slider) self.Control_Bar.add_widget(self.End_Time_Label) if (cw_remote_duplex_layout): self.Upper_Widget_Box = BoxLayout(orientation='vertical', size_hint=(1, 0.475)) self.Lower_Widget_Box = BoxLayout(orientation='vertical', size_hint=(1, 0.475)) self.Upper_Widget_Box.add_widget( Image(texture=ci_widget_image_list[0].texture)) self.Lower_Widget_Box.add_widget( Image(texture=ci_widget_image_list[1].texture)) self.CloudWatch_Remote.add_widget(self.Upper_Widget_Box) self.CloudWatch_Remote.add_widget(self.Control_Bar) self.CloudWatch_Remote.add_widget(self.Lower_Widget_Box) elif (len(widget_descriptor_list) > 1): self.Carousel_Widget = Carousel(direction='bottom') for ci_widget_image in ci_widget_image_list: self.Carousel_Widget.add_widget( Image(texture=ci_widget_image.texture)) self.CloudWatch_Remote.add_widget(self.Control_Bar) self.CloudWatch_Remote.add_widget(self.Carousel_Widget) else: self.Upper_Widget_Box = BoxLayout(orientation='vertical', size_hint=(1, (2 * 0.475))) self.Upper_Widget_Box.add_widget( Image(texture=ci_widget_image_list[0].texture)) self.CloudWatch_Remote.add_widget(self.Control_Bar) self.CloudWatch_Remote.add_widget(self.Upper_Widget_Box) if (cw_remote_refresh_interval_seconds >= 1): Clock.schedule_interval(self.update, cw_remote_refresh_interval_seconds) return self.CloudWatch_Remote
def error_subir(req, result): view.dismiss() modal_view_alert('¡Error!','Cerrar', Image(source=SOURCE_FAIL, size=(100,100)))
def failure_subir(req, result): view.dismiss() modal_view_alert('Error de conexión...\nReintente mas tarde','Cerrar', Image(source=SOURCE_FAIL, size=(100,100)))