I'm tracking my current battery percent right from the time it was unplugged from time to time.
Sometimes I need to use the device (Windows 10 64 bit) even if it's not fully charge, so sometimes I unplug it at 86%, 95%, 82%, etc. so I need to track it.
I made a script to get the current time and then add it to clipboard so I can paste it somewhere.
Here's the whole code:
from tkinter import *
from urllib import parse
from tkinter import Tk
import tkinter.ttk as ttk
from datetime import datetime
root = Tk()
root.title("Current Time")
root.geometry('250x57+1000+103')
lbl = Label(root, text="Time")
lbl.pack()
def clicked():
d = datetime.now()
print(d.strftime("%I:%M"))
root.clipboard_clear()
root.clipboard_append(d.strftime("%I:%M %p"))
lbl.configure(text= d.strftime("%I:%M %p"))
style = ttk.Style(root)
style.theme_use('clam')
style.configure('TButton', bordercolor="black")
btn = ttk.Button(root, text='Show Current Time', style='TButton', command=clicked, width = 37)
btn.pack()
root.wm_attributes("-topmost", 1)
root.mainloop()
Right now, only "11:41 AM" will be display and appended to clipboard.
I want something like:
def clicked():
d = datetime.now()
batt = root.detect_current_battery()
root.clipboard_clear()
root.clipboard_append(d.strftime("%I:%M %p batt"))
lbl.configure(text= d.strftime("%I:%M %p batt"))
... so that I can get the current time as well as the current battery percent (11:41 AM 86%) and paste it somewhere.
I found this thread but I'm not sure how to use this code:
battery_level=`acpi -b | grep -P -o '[0-9]+(?=%)'`
...to what I'm trying to achieve.