我的离子含量
import pywapi
# getting input from the user regarding location
#this will give a dictionary of all cities in the world with this city's name
loc=str.title(input("What is the city you're closest to? "))
print("Searching for ", loc)
loc_id=pywapi.get_location_ids(loc)
#Now we have a dictionary (it seems as standard it returns a maximum of ten key:value pairs. Now to convert it to a list just so I can number the entries and ultimately allow the user select the correct entry easily. (Note, there may be a way to do this without converting the dictionary to a list, but I couldn't find it)
loc_list = [ [k,v] for k, v in loc_id.items() ]
#Now I am going to check if the length of the list is over 1 value (i.e. if there's more than one choice, and if there is, to run a for loop printing each entry with a number
list_leng=len(loc_list)
if list_leng >1:
#fix some value for x and y to be used in the for loop
x=1
y = 0
for l in loc_id:
print (x,loc_list[y])
x = x+1
y=y+1
index_choice=(int(input("Which city do you mean? Enter a choice from 1 to " + str(list_leng) + ": ")))-1
else:
index_choice=0
loc_id=loc_list[index_choice]
print("You selected ",loc_id[1])
loc_id=loc_id[0]
print ("Location ID for "+loc+" is ",loc_id)
def gettt_weather(loc_id):
"""Fetches the weather information from Weather.com using a location stored under the variable loc_id"""
print("Looking up the weather for "+loc)
weather_com_result = pywapi.get_weather_from_weather_com(loc_id,units='metric')
print ("Weather.com says that it is "+ weather_com_result['current_conditions']['text'].lower()+" and", weather_com_result['current_conditions']['temperature']+"°C now in " + loc)
gettt_weather(loc_id)
结果将是 - > http://prntscr.com/h10myc
我希望我的标签结果符合预期 - > http://prntscr.com/h10sk1
这可能吗?我可以在离子选项卡中创建自定义标题吗?
这样,我可以在标题上方添加数字。请帮忙。感谢。
答案 0 :(得分:0)
据我所知,如果不使用自定义的选项卡界面,就无法做到这一点。但是,另一种方法是使用您想要的数字实现tabBadge
属性。例如,
<ion-tabs>
<ion-tab [root]="tab1Root" tabTitle="Home" tabBadge="25" tabIcon="home"></ion-tab>
<ion-tab [root]="tab2Root" tabTitle="Pizza" tabBadge="18" tabIcon="cafe"></ion-tab>
<ion-tab [root]="tab3Root" tabTitle="Contact" tabBadge="49" tabIcon="information-circle"></ion-tab>
</ion-tabs>