def generate_wallpaper_and_set(): image = Image.open(config.resource_path('img/base.png')) small = ImageFont.truetype('arial.ttf', 72) large = ImageFont.truetype('arial.ttf', 90) draw = ImageDraw.Draw(image) if config.load_option_from_config('country') != "World": draw.text(xy=(815, 359), text=str( api.get_country_stats( api.get_country_id( config.load_option_from_config('country')))[0]), fill=(255, 255, 255), font=large) draw.text(xy=(490, 680), text=str( api.get_country_stats( api.get_country_id( config.load_option_from_config('country')))[1]), fill=(255, 255, 255), font=small) draw.text(xy=(1265, 680), text=str( api.get_country_stats( api.get_country_id( config.load_option_from_config('country')))[2]), fill=(255, 255, 255), font=small) else: draw.text(xy=(815, 359), text=str(api.get_world_cases()[0]), fill=(255, 255, 255), font=large) draw.text(xy=(490, 680), text=str(api.get_world_cases()[1]), fill=(255, 255, 255), font=small) draw.text(xy=(1265, 680), text=str(api.get_world_cases()[2]), fill=(255, 255, 255), font=small) draw.text(xy=(877, 680), text=strftime("%d-%m\n%H:%M", gmtime()), fill=(255, 255, 255), font=small) image.save(config.resource_path('wallpaper.png')) set_wallpaper_from_file('wallpaper.png')
helpmenu = Menu(menubar, tearoff=0) helpmenu.add_command(label="About", command=about) menubar.add_cascade(label="Help", menu=helpmenu) current_var = StringVar(w) current_var.set( f"Your current country is {config.load_option_from_config('country')}") current = ttk.Label(w, textvariable=current_var) current.pack() country = StringVar(w) country.set("World") # initial value country_list = api.get_country_list() option = ttk.Combobox(w, values=country_list) option.current(country_list.index(config.load_option_from_config('country'))) option.pack(padx=10, pady=10) def confirm(): config.write_option_to_config('country', option.get()) current_var.set( f"Your current country is {config.load_option_from_config('country')}") confirm = ttk.Button(w, text="Change Country", command=confirm) confirm.pack(padx=20) def force_update(): wallpaper.generate_wallpaper_and_set()