def visualizarVehiculos( self ): #Muestro los marcadores con las ubicaciones actualizadas en el mapa ip_request = requests.get('https://get.geojs.io/v1/ip.json') my_ip = ip_request.json()['ip'] #con mi ip obtengo mi geolocalizacion geo_request = requests.get('https://get.geojs.io/v1/ip/geo/' + my_ip + '.json') geo_data = geo_request.json() self.longitudActual = float(geo_data['longitude']) self.latitudActual = float(geo_data['latitude']) self.ids.mapview.center_on( self.latitudActual, self.longitudActual) #mapa centrado en ubicacion actual self.ids.mapview.zoom = 5 mapmarkerpopupUbicacionActual = MapMarkerPopup(lat=self.latitudActual, lon=self.longitudActual, popup_size=(120, 70)) bubbleUbicacionActual = Bubble() labelUbicacionActual = Label(text="[b]Ubicaion actual![/b]", markup=True, halign="center") bubbleUbicacionActual.add_widget(labelUbicacionActual) mapmarkerpopupUbicacionActual.add_widget( bubbleUbicacionActual ) #creo un marcador con etique para saber la ubicacion actual, es de color rojo #self.ids.mapview.center_on(4.795100942698568, -75.6890602859938) #Me centra en la utp. if len(self.listaMarker) > 0: for marker in range(len(self.listaMarker)): self.ids.mapview.remove_widget(self.listaMarker[marker]) self.listaMarker = [ ] #La reseteo para poder meter los mapMarker de los vehiculos actualizados. #Se hace la consulta a la BD para obtener las lat y lon de los vehiculos-----------------------BD self.listaMarker.append(mapmarkerpopupUbicacionActual) #hacer consulta base de datos pos = UbicacionVehiculo.obtenerData(UbicacionVehiculo) for e in pos: mapmarkerpopup = MapMarkerPopup( lat=float(e[1]), lon=float(e[2]), color=(0, 1, 1, 1), popup_size=(120, 70)) #acepta 1,0,1,1 o 0,0,0,1 o 0,1,1,1 bubble = Bubble() label = Label(text="[b]" + Vehiculo.getNamevehiculo(Vehiculo, e[0]) + "[/b]", markup=True, halign="center") bubble.add_widget(label) mapmarkerpopup.add_widget(bubble) self.listaMarker.append(mapmarkerpopup) for i in range(len(pos)): self.ids.mapview.add_widget(self.listaMarker[i])
def markDestination(self, destination): ''' Takes in a parking garage object called destination Gets the location of the destination and places a map marker on top of it Parameters: destination - ParkingGarage object Returns: coords - tuple with the coordinates of the map marker ''' if not isinstance(destination, ParkingGarage): pop = Popup(title="Error", content=Label(text="No Destination Input"), size_hint=(.2, .2)) pop.open() return #Get the coordinates of the destination coder = GoogleGeocoder("AIzaSyDPOAePgFbDCBU0rsOdvWX66C2CPUB2CZM") g = coder.get(destination.getLocation()) coords = (g[0].geometry.location.lat, g[0].geometry.location.lng) #Create a marker that holds information on the parking garage bub = Bubble(size_hint=(None, None), size=(200, 50), arrow_pos='bottom_left') lab = Label(text=(" " + destination.getName()), text_size=(self.width, None)) lab.height = lab.texture_size[1] lab.halign = 'center' bub.add_widget(lab) m1 = MapMarkerPopup(lat=coords[0], lon=coords[1], placeholder=bub) #Mark the map and return the coordinates of the marker self.ids.map1.add_marker(m1) return coords
def build(self): layout = BoxLayout(orientation='vertical') self.mapview = MapView(zoom=7, lat=42.6394, lon=25.057) bubble = Bubble(orientation="horizontal", padding=5) text = "[b]Sample text here[/b]" label = Label(text=text, markup=True, halign="center") bubble.add_widget(label) marker = MapMarkerPopup(id="first", lat=42.6394, lon=25.057, popup_size=('150dp', '100dp')) marker.add_widget(bubble) self.mapview.add_marker(marker) b = BoxLayout(orientation='horizontal', height='52dp', size_hint_y=None) b.add_widget( Button(text="Zoom in", on_press=lambda a: setattr(self.mapview, 'zoom', self. mapview.zoom + 1))) b.add_widget( Button(text="Zoom out", on_press=lambda a: setattr(self.mapview, 'zoom', self. mapview.zoom - 1))) layout.add_widget(b) layout.add_widget(self.mapview) return layout
def init(self): global cl cl = client.Client(False) cl.startClient() global layout, bubbles, printMessages, oldMessages, counter, labels counter = 0 oldMessages = [] printMessages = [] bubbles = [] labels = [] layout = BoxLayout(orientation='vertical') layout.size = (700, 600) layout.pos = (0, 30) layout.spacing = 5 for i in range(19): labels.append(Label()) bubbles.append(Bubble()) bubbles[i].add_widget(labels[i]) printMessages.append(('', 2)) for b in bubbles: layout.add_widget(b) self.add_widget(layout)
def open_bubble_not_set(self, ti_not_set): float_lay = FloatLayout() float_lay.size_hint = None, None float_lay.width = 0 float_lay.height = 0 bubble_not_set = Bubble() bubble_not_set.size_hint = None, None bubble_not_set.width = 80 bubble_not_set.height = 30 bubble_not_set.center_x = ti_not_set.center_x bubble_not_set.center_y = ti_not_set.center_y - 30 bubble_not_set.arrow_pos = 'top_mid' bubble_not_set.background_color = (1, 0, 0, 1) bt_not_set = BubbleButton() bt_not_set.font_size = 12 bt_not_set.text = self.lang['Not_Set'] bubble_not_set.add_widget(bt_not_set) float_lay.add_widget(bubble_not_set) #self.add_widget(bubble_not_set) self.lay_file_asc.add_widget(float_lay) parallel_close = threading.Thread(target=self.close_bubble_not_set, args=(float_lay, )) parallel_close.start()
def _on_dropdown_select(self, instance, data, *largs): self.text = data self.is_open = False #print('select function',self.text) self.func_des = '[color=#ffff00][i][b]' + self.parent.tool_library.read_obj.get_func_des( self.text) + '[/i][/b][/color]' self.set_select_parameter(self.text) if self.bubble is None: self.bubble = Bubble(size_hint=(.3, .2)) self.bubb_layout = AnchorLayout(anchor_x='right', anchor_y='top') def remove_bubble(instance): self.bubb_layout.remove_widget(self.bubble) self.parent.parent.remove_widget(self.bubb_layout) self.bubble = None self.bubb_layout = None self.button = BubbleButton(text=self.func_des, halign='left', valign='middle', text_size=(300, 300), background_color=(0, 0, 1, 1), markup=True) self.button.bind(on_press=remove_bubble) self.bubble.add_widget(self.button) self.bubble.arrow_pos = 'top_mid' self.bubb_layout.add_widget(self.bubble) self.parent.parent.parent.add_widget(self.bubb_layout) else: self.button.text = self.func_des
def test_add_remove_content(self): bubble = Bubble() content = BubbleContent() bubble.add_widget(content) self.render(bubble) bubble.remove_widget(content) self.render(bubble)
def test_add_two_content_widgets_fails(self): from kivy.uix.bubble import BubbleException bubble = Bubble() content_1 = BubbleContent() content_2 = BubbleContent() bubble.add_widget(content_1) with self.assertRaises(BubbleException): bubble.add_widget(content_2)
def test_add_content_with_buttons(self): bubble = Bubble() content = BubbleContent() content.add_widget(BubbleButton(text="Option A")) content.add_widget(BubbleButton(text="Option B")) bubble.add_widget(content) self.render(bubble)
def show_bubble(self) -> None: self.bubb = Bubble(size_hint=(None, None), size=(160, 30), pos_hint={'center_x': .5, 'y': .6}) accuse = BubbleButton(text='Accuse') suspect = BubbleButton(text='Suspect') accuse.bind(on_press=partial(self.hide_bubble, accuse)) suspect.bind(on_press=partial(self.hide_bubble, suspect)) self.bubb.add_widget(accuse) self.bubb.add_widget(suspect) self.ids.empty.add_widget(self.bubb)
def show_bubble(self, bx, by): bubble = Bubble(size_hint=[None, None], size=[20, 20], pos=[bx, by]) bubble.add_widget( BubbleButton(text='WRONG', font_size='10sp', color=[0, 0, 0, 1], size=[6, 3])) bubble.background_color = (255, 0, 0, 1) bubble.arrow_pos = 'bottom_right' self.ids.bbox.add_widget(bubble) Clock.schedule_once(partial(self.remove_bubble, bubble), 1.5)
def show_timer(self): self.dynamic_button = "Pause" bubble = Bubble(size_hint=[None, None], size=[50, 35], pos=[375, 490]) bubble.add_widget( BubbleButton(text='START', font_size='15sp', color=[0, 0, 0, 1], size=[10, 10])) bubble.background_color = (0, 0, 0, 0) self.ids.bbox.add_widget(bubble) Clock.schedule_interval(self.Running_Clock, 1) Clock.schedule_once(partial(self.remove_bubble, bubble), 1)
def mark(position, mapview, marker, result=[]): LAT, LON = position if not result: # m = marker(lat = LAT, lon = LON, source = "Map-Marker-PNG-Pic_3_1.png") bubble = Bubble(orientation="horizontal", padding=5) text = "[b]Self[/b]" label = Label(text=text, markup=True, halign="center") bubble.add_widget(label) m = MapMarkerPopup(lat=LAT, lon=LON, popup_size=(100, 50), source="Map-Marker-PNG-Pic_3_1.png") m.add_widget(bubble) else: place_detail = get_place_details(result["place_id"]) photo = get_photo_html(result) phone = get_phone_number(place_detail) name = result["name"] rating = get_rating(result) # m = marker(lat = LAT, lon = LON) marker has been replaced by mapmarkerpopup bubble = Bubble(orientation="vertical", padding=5) if photo: image = AsyncImage(source=photo, mipmap=True) bubble.add_widget(image) if len(name) > 30: index1 = name.find(",") index2 = name.find(" ", int(len(name) / 2)) if index1 > 15: name = name[:index1] + "\n" + name[index1:] elif index2 > 20: name = name[:index2] + "\n" + name[index2:] text = "[b]" + name + "[/b]\n" + "Phone Number: " + phone + "\n" + "Rating: " + rating label = Label(text=text, markup=True, halign="center") bubble.add_widget(label) m = MapMarkerPopup(lat=LAT, lon=LON, popup_size=(250, 230)) m.add_widget(bubble) marker_list.append(m) mapview.add_marker(m)
def timer_bubble(self, tx1, tx2, clr, fn): bubble = Bubble(size_hint=[None, None], size=[50, 35], pos=[375, 490]) bubble.add_widget( BubbleButton(text="{:02d}:{:02d}".format(tx1, tx2), font_size='15sp', color=[0, 0, 0, clr], size=[10, 10])) bubble.background_color = (0, 0, 0, 0) self.ids.bbox.add_widget(bubble) if fn == "stop": Clock.schedule_once(partial(self.remove_bubble, bubble), 60) if fn == "run": Clock.schedule_once(partial(self.remove_bubble, bubble), 1)
def openbubble(self, buttonfunclist, data=None): if self.bubble: logging.error("Bubble already called") return self.bubble = Bubble(height=30, width=10, pos=self.to_window(self.x, self.y+30), size_hint=(None, None)) for text, func in buttonfunclist: button = BubbleButton(text=text, height=30) self.bubble.width += 10 + len(text)*10 self.call(button, func, data) self.bubble.add_widget(button) root = App.get_running_app().root #self.get_root_window().add_widget(self.bubble, root.canvas) root.add_widget(self.bubble) self.callbackid = root.fbind("on_touch_down", self.touch_grab)
def create_bubble(self, instance, value): if not self.bubble_text: return if self.bubble_callback: self.funbind('mouse_hover', self.bubble_callback) text = self.bubble_text.strip() self.bubble = bubble = Bubble(size_hint=(None, None)) self.bubble_button = bubble_button = BubbleButton(markup=True, text=text) bubble_button.bind(texture_size=lambda obj, size: bubble.setter('size')(bubble, (size[0] + 30, size[1] + 30))) bubble.add_widget(bubble_button) self.bubble_callback = partial(self.show_bubble, self, bubble, self.arrow_pos) # self.bind(mouse_hover=self.bubble_callback) self.fbind('mouse_hover', self.bubble_callback)
def build(self): MainAppWindow = AppBody(orientation='vertical') ToolBar = Bubble(size_hint=[1, .1]) MainAppWindow.add_widget(ToolBar) WorkArea = AnchorLayout() MainAppWindow.add_widget(WorkArea) self.Timer_icon = Timer_icon = HeaderLables(size_hint=[1 / 5, 1]) Timer_icon.img1.source = 'icons8-alarm-clock-96.png' Timer_icon.btn1.bind(on_release=self.GoTOTimer_widget) self.Stopclock_widget = Stopclock_widget = HeaderLables( size_hint=[1 / 5, 1]) Stopclock_widget.img1.source = 'icons8-sport-stopwatch-96.png' Stopclock_widget.btn1.bind(on_release=self.GoTOStopclock_widget) self.Alarm_widget = Alarm_widget = HeaderLables(size_hint=[1 / 5, 1]) Alarm_widget.img1.source = 'icons8-alarm-96.png' Alarm_widget.btn1.bind(on_release=self.GoTOAlarm_widget) self.Cust_widget = Cust_widget = HeaderLables(size_hint=[1 / 5, 1]) Cust_widget.img1.source = 'icons8-star-96.png' Cust_widget.btn1.bind(on_release=self.GoTOCust_widget) self.Settings_widget = Settings_widget = HeaderLables( size_hint=[1 / 5, 1]) Settings_widget.img1.source = 'icons8-settings-96.png' Settings_widget.btn1.bind(on_release=self.GoTOSettings_widget) ToolBar.add_widget(Timer_icon) ToolBar.add_widget(Stopclock_widget) ToolBar.add_widget(Alarm_widget) ToolBar.add_widget(Cust_widget) ToolBar.add_widget(Settings_widget) self.myTimer = Timer_widget() self.myStopClock = StopClockWidget() self.myAM = AM_SM() carousel = Carousel(direction='right') carousel.add_widget(self.myTimer) carousel.add_widget(self.myStopClock) carousel.add_widget(self.myAM) WorkArea.add_widget(carousel) return MainAppWindow
def __init__(self, activity, **kwargs): self.activity = activity super(CalendarButton, self).__init__() self.buttonInstance = Button(size_hint=(1, 1), pos_hint={'center_x':0.5, 'center_y':0.5}, **kwargs) self.buttonInstance.bind(on_release=self.onPressBubble) self.add_widget(self.buttonInstance) self.bubbleInstance = Bubble(size_hint=(None, None), size=(100, 40), pos_hint={'center_x':0.5, 'center_y':0.5}, arrow_pos='bottom_mid') self.bubbleChange = BubbleButton(text='Change', font_size=8) self.bubbleChange.bind(on_release=self.onPressChange) self.bubbleRemove = BubbleButton(text='Remove', font_size=8) self.bubbleRemove.bind(on_release=self.onPressRemove) self.bubbleInstance.add_widget(self.bubbleChange) self.bubbleInstance.add_widget(self.bubbleRemove)
def on_state(self, widget, state): # super(SettingView, self).on_state(**kwargs) if self.state == 'down': bubbleHeight = 50 self.bubble = Bubble(size_hint=(None,None), size=(self.width, bubbleHeight), center_x=self.center_x, y=self.height-bubbleHeight) b1 = BubbleButton(text="-", font_size=40) b1.bind(on_press = self.decr) b2 = BubbleButton(text="+", font_size=40) b2.bind(on_press = self.incr) self.text_size = self.size self.text_size[1] -= 10 self.valign='bottom' self.bubble.add_widget(b1) self.bubble.add_widget(b2) self.add_widget(self.bubble) else: self.remove_widget(self.bubble) self.valign='center' self.dispatch('on_change', self.value)
def showBuuble(self, instance): #if bubble is already clicked if self.bubbleClicked: self.remove_widget(self.bubb) self.bubbleClicked = False #if bubble is not clicked else: self.bubb = Bubble(orientation='horizontal', arrow_pos='bottom_mid') l = playlistManager.getPlaylists() for playlist in l: self.bubb.add_widget( Button(text=playlist, on_press=partial(self.addToPlaylist, playlist, self.title, self.actualSongImage, self.id, self.bubb), size_hint=(.2, .2), size=(200, 200))) self.add_widget(self.bubb) self.bubbleClicked = True
def __init__(self, shp, name, indic, ids, **kwargs): #self.app = App.get_running_app() Widget.__init__(self, **kwargs) #super(Neighbourhood, self).__init__(**kwargs) self.shape = shp self.getshape() self.indic = indic.values self.name = name self.score = 0 self.bubb = Bubble() self.idso = ids with self.canvas: random = randint(0, 10) color = colors[random] cast = '#' + color Color(*get_color_from_hex(cast)) Mesh(fmt=self.vfmt, mode='triangle_fan', indices=self.indices, vertices=self.vertices) self.vrt = [] j = 0 #print("vertices ", len(self.vertices)) for i in range(int(len(self.vertices) / 4)): x = self.vertices[j] y = self.vertices[j + 1] self.vrt.append([x, y]) j = j + 4 Color(*get_color_from_hex("#FFFFFF")) Line(points=self.vrt, width=1)
def _open(self, *args, **kwargs): try: self.remove_widget(self.bubble) self.percentage = self.slider.value del self.bubble, self.slider self.update_icons() except AttributeError: self.bubble = Bubble(orientation="vertical", size=(48, 200)) self.update_bubble_pos() self.bind(pos=self.update_bubble_pos) def on_perc(slider, value): slider.btn.percentage = value label = Label(text=self.label, size_hint_y=None, height=25) self.bubble.add_widget(label) self.slider = Slider(orientation="vertical", min=0, max=100, value=self.percentage) self.slider.btn = self self.slider.bind(value=on_perc) self.bubble.add_widget(self.slider) def on_reset(bbtn, *args, **kwargs): bbtn.slider.value = bbtn.reset_value bbtn = BubbleButton(text=self.reset_text, size_hint_y=None, height=40) bbtn.slider = self.slider bbtn.reset_value = self.reset_value bbtn.bind(on_release=on_reset) self.bubble.add_widget(bbtn) self.add_widget(self.bubble) self.icon = self.icons["close"]
def __init__(self, *args, **kwargs): self.state = ToolState.EMPTY # dimensions of the area where nodes can be placed self.workAreaXDim = 720 self.workAreaYDim = 520 self.workAreaXPos = 40 self.workAreaYPos = 40 # multiple choice bubble menu for node addition self.defaultBubble = Bubble(size_hint=(None, None), size=(250, 40)) self.newComputerButton = Button(text="Nowy komputer") self.newRouterButton = Button(text="Nowy router") self.defaultBubble.add_widget(self.newComputerButton) self.defaultBubble.add_widget(self.newRouterButton) # coordinates of node-button to be placed self.pendingNodePosX = 0 self.pendingNodePosY = 0 # multiple choice bubble menu for node editing/removal self.nodeBubble = Bubble(size_hint=(None, None), size=(250, 40)) self.newConnButton = Button(text="Dodaj połączenie") self.deleteNodeButton = Button(text="Usuń węzeł") self.nodeBubble.add_widget(self.newConnButton) self.nodeBubble.add_widget(self.deleteNodeButton) # reference to button being edited/removed self.pendingNodeRef = Button() # global state - adding connection or not self.isInConnectionMode = False self.netManager = NetworkManager(self.__deleteLine, self.appendLog, self.animatePacket) # define widgets of side panel and add them to window self.sidePanelTabbedPanel = TabbedPanel(do_default_tab=False, size=(200, 600), pos=(800, 0), background_color=(0, 0, 0, 0), tab_width=100) # define widgets of log display and add them to window self.sidePanelLogTab = TabbedPanelItem(text="Symulacja") self.sidePanelLogLayout = GridLayout(cols=1, spacing=10, size_hint=(None, None), size=(200, 550)) self.logField = TextInput(padding=10, readonly=True, size_hint_max_y=None, size_hint=(None, None), size=(190, 550)) self.logField.bind(minimum_height=self.logField.setter('height')) self.sidePanelLogScrollView = ScrollView( size_hint=(None, None), size=(200, 450), scroll_type=['bars'], bar_width=10, bar_inactive_color=[1, 1, 1, .8], bar_color=[0.3, 1, 1, 1]) self.sidePanelLogScrollView.add_widget(self.logField) self.sidePanelLogLayout.add_widget(self.sidePanelLogScrollView) self.sidePanelLogTab.add_widget(self.sidePanelLogLayout) self.sidePanelTabbedPanel.add_widget(self.sidePanelLogTab) # A welcome log self.appendLog('A new workspace has been created.') # define widgets of node edit panel to be added to window later # when a node is selected, add sidePanelNodeTab with the proper tab name to sidePanelTabbedPanel # and fill sidePanelNodeTab with content - interface configuration form self.sidePanelNodeTab = TabbedPanelItem() self.sidePanelNodeLayout = GridLayout(cols=1, spacing=5, size_hint=(None, None), size=(200, 550)) self.sidePanelNodeLayout.bind( minimum_height=self.sidePanelNodeLayout.setter('height')) self.sidePanelNodeScrollView = ScrollView( size_hint=(None, None), size=(200, 550), pos=(800, 0), scroll_type=['bars'], bar_width=10, bar_inactive_color=[1, 1, 1, .8], bar_color=[1, 1, 1, 1]) self.sidePanelNodeTab.add_widget(self.sidePanelNodeScrollView) self.sidePanelNodeScrollView.add_widget(self.sidePanelNodeLayout) # define simulation-related buttons and add them to the window self.toggleSimButton = Button(text="Symuluj") self.addPacketButton = Button(text="Nowy pakiet", on_press=self.on_new_packet) self.stepSimButton = Button(text=">|", on_press=self.on_step) self.playSimButton = Button(text=">") self.simButtonLayout = BoxLayout() self.sidePanelLogLayout.add_widget(self.addPacketButton) self.sidePanelLogLayout.add_widget(self.toggleSimButton) self.sidePanelLogLayout.add_widget(self.simButtonLayout) self.simButtonLayout.add_widget(self.playSimButton) self.simButtonLayout.add_widget(self.stepSimButton) self.packetNodes = [] # set window color Window.clearcolor = (0.7, 0.7, 0.7, 1) super(Demoer, self).__init__(*args, **kwargs) self.add_widget(self.sidePanelTabbedPanel) # create delimiter line around the work area self.canvas.before.add( Line(rectangle=(self.workAreaXPos, self.workAreaYPos, self.workAreaXDim, self.workAreaYDim), width=0.5)) # create background square behind side panel with self.canvas.before: Color(0.3, 0.3, 0.3, 1) Rectangle(pos=(2 * self.workAreaXPos + self.workAreaXDim, 0), size=(200, 600)) Color(1, 1, 1, 1)
def test_add_arbitrary_content(self): from kivy.uix.gridlayout import GridLayout bubble = Bubble() content = GridLayout() bubble.add_widget(content) self.render(bubble)
def ftp_transfer(Screen): """ accessing the global performance data """ # todo: what is going wrong here? global avoid_double_execution if (bool(avoid_double_execution)): # get timestamp timestamp = datetime.datetime.now() # portfolio pandas datastructure # todo: extend # table format # 13 pcs # |timestamp | latitude | longitude | beer | wine | shots | cigarettes | tired | stressed | water | sleep | food | hang_level try: # global table to be stored on server new_table = numpy.array([ timestamp, Screen.lat, Screen.lon, setc.num_beer, setc.num_wine, setc.num_shot, setc.num_cig, setc.num_tired, setc.num_stress, setc.num_water, setc.num_sleep, setc.num_food, setc.hangover_level ], dtype='string') except: tb = traceback.format_exc() print(tb) # filename of global performance data filename = "schlukniktable.csv" # combine global and local table try: # append old table to new table results = numpy.append(new_table, Screen.global_history) # get total number of entries Screen.get_total_entries = len(results) / 13 # prepare graphs Screen.prepareGraphs(Screen) results = results.reshape((len(results) / 13, 13)) # store data as a local csv file numpy.savetxt(filename, results, delimiter=';', fmt=('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')) except: tb = traceback.format_exc() print(tb) # up load to ftp # File FTP transfer # domain name or server ip: ftp = FTP('singing-wires.de') # how to encrypt this? ftp.login(user='******', passwd='Holz0815') ftp.cwd('/html/schluknik') # todo: store as .csv file with open(filename, "a+") as f: ftp.storlines("STOR " + filename, open(filename, 'r')) ftp.quit() # finished ftp connection now fill result computer lat = numpy.array(results)[:, 1].tolist() lon = numpy.array(results)[:, 2].tolist() info_box_beer = numpy.array(results)[:, 12].tolist() # create result screen widget map = MapScreen(name='map') try: # todo: can this be more pythonic?BeerScreen i = 0 # set marker for every entry in table for item in lat: # change this to pop up marker a = Bubble(size=(400, 400)) a.add_widget( Label(text='hangover level ' + str(info_box_beer[i]))) m = MapMarkerPopup(lon=float(lon[i]), lat=float(lat[i]), placeholder=a) map.ids.map.add_marker(m) i = i + 1 Screen.manager.add_widget(map) except: tb = traceback.format_exc() print(tb) # switch to the result screen Screen.manager.current = 'result' avoid_double_execution = False return
def test_no_content(self): bubble = Bubble() self.render(bubble)
def start(self, uuid, market): bubble = Bubble(arrow_pos="right_mid") bubble.add_widget(BubbleButton(text=market)) self.add_widget(bubble, 4)
def lugaresParaUbicacionActual( self): #Los lugares cercanos a mi ubicacion actual me los muestra. for marker in range(len(self.listaMarker)): self.ids.mapview.remove_widget(self.listaMarker[marker]) self.listaMarker = [] CLIENT_ID = '' # your Foursquare ID CLIENT_SECRET = '' # your Foursquare Secret VERSION = '20190717' LIMIT = 50 neighborhood_latitude = self.latitudActual neighborhood_longitude = self.longitudActual radius = 500 url = 'https://api.foursquare.com/v2/venues/explore?&client_id={}&client_secret={}&v={}&ll={},{}&radius={}&limit={}'.format( CLIENT_ID, CLIENT_SECRET, VERSION, neighborhood_latitude, neighborhood_longitude, radius, LIMIT) results = requests.get(url).json() lugares = results['response']['groups'][0]['items'] lugaresCercanos = json_normalize(lugares) filtered_columns = [ 'venue.name', 'venue.categories', 'venue.location.lat', 'venue.location.lng' ] lugaresCercanos = lugaresCercanos.loc[:, filtered_columns] # filter the category for each row lugaresCercanos['venue.categories'] = lugaresCercanos.apply( lambda categorias: categorias, axis=1) # clean columns lugaresCercanos.columns = [ col.split(".")[-1] for col in lugaresCercanos.columns ] self.ids.mapview.center_on( self.latitudActual, self.longitudActual) #mapa centrado en ubicacion actual self.ids.mapview.zoom = 17 mapmarkerpopupUbicacionActual = MapMarkerPopup(lat=self.latitudActual, lon=self.longitudActual, popup_size=(120, 70)) bubbleUbicacionActual = Bubble() labelUbicacionActual = Label(text="[b]Ubicaion actual![/b]", markup=True, halign="center") bubbleUbicacionActual.add_widget(labelUbicacionActual) mapmarkerpopupUbicacionActual.add_widget(bubbleUbicacionActual) self.listaMarker.append(mapmarkerpopupUbicacionActual) #El for es para obtener la ubicacion de los lugares cercanos que necesito, y poner los marcadores for lat, lng, categoria in zip(lugaresCercanos.lat, lugaresCercanos.lng, lugaresCercanos.categories): mapmarkerpopup = MapMarkerPopup(lat=lat, lon=lng, color=(1, 0, 1, 1), popup_size=(300, 70)) bubble = Bubble() label = Label(text=categoria, halign="center") bubble.add_widget(label) mapmarkerpopup.add_widget(bubble) self.listaMarker.append(mapmarkerpopup) for i in range(len(self.listaMarker)): self.ids.mapview.add_widget(self.listaMarker[i])
def test_always_lr_tb(orientation): from kivy.uix.bubble import Bubble b = Bubble(orientation=orientation) assert b._fills_row_first assert b._fills_from_left_to_right assert b._fills_from_top_to_bottom
def show_text(self, text): bubble = Bubble(arrow_pos='top_mid', size_hint=(None, None), size=(200, 100), pos_hint={'x': 0.1, 'y': 0.15}) bubble.background_color = (1, 0, 0, 0.5) bubble.add_widget(Label(text=text)) self.add_widget(bubble) Clock.schedule_once(lambda dt: self.remove_widget(bubble), 1.5)