Skip to content

Instantly share code, notes, and snippets.

@Dunnomix
Last active September 26, 2019 03:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dunnomix/8aea18e8103af83ac83ede22deeeeaf9 to your computer and use it in GitHub Desktop.
Save Dunnomix/8aea18e8103af83ac83ede22deeeeaf9 to your computer and use it in GitHub Desktop.
This is a simple python UI for the Bancolombia balance checker. see https://gist.github.com/idontcar3/351776daf2565e7de677a7db0ba08c44
import json
import threading
import os
import requests
import sys
import time
from tkinter import *
from tkinter.ttk import *
# You will need to see this gist also
# https://gist.github.com/idontcar3/351776daf2565e7de677a7db0ba08c44
HOME = os.path.dirname(__file__)
# Main TK object, sometimes called root
window = Tk()
window.title("Bancolombia accounter")
note = Notebook(window)
tab1 = Frame(note)
tab2 = Frame(note)
# Main Tab
# Let's create the widgets that we will use in the call backs below
# since the functions are not defined yet, it will give us an error
lbl1 = Label(tab1, text="Status: ")
lbl1.grid(column=0, row=1)
# this is the actual dynamic status label
status = Label(tab1, text="standby")
# this is how you change label properties
status.config(font=("Helvetica", 20))
status.grid(column=1, row=1, columnspan=2)
# add the frame to the notebook
note.add(tab1, text="Main")
# Config Tab
# Bancolombia Stuff
lbl2 = Label(tab2, text="User: ")
lbl2.grid(column=0, row=0)
user_txt = Entry(tab2, width=10)
user_txt.grid(column=1, row=0)
lbl3 = Label(tab2, text="Password: ")
lbl3.grid(column=2, row=0)
pass_txt = Entry(tab2, width=10, show="*")
pass_txt.grid(column=3, row=0)
# Telegram stuff
lbl4 = Label(tab2, text="Telegram Key: ")
lbl4.grid(column=0, row=1)
telegram_key_txt = Entry(tab2, width=10)
telegram_key_txt.grid(column=1, row=1)
lbl4 = Label(tab2, text="Contact id: ")
lbl4.grid(column=0, row=2)
telegram_contact_txt = Entry(tab2, width=10)
telegram_contact_txt.grid(column=1, row=2)
save_btn = Button(tab2, text="Save")
save_btn.grid(column=4, row=0)
lbl5 = Label(tab2, text="Will be saved in plain text!")
lbl5.grid(column=2, row=1, columnspan=3)
note.add(tab2, text="Config")
note.grid(column=0, row=0)
# populate the entries
config_path = os.path.join(HOME, "config.json")
if not os.path.isfile(config_path):
# make configure enable
CONFIG = {"x-telegram-key": ""}
else:
CONFIG = json.load(open(config_path))
# In order to erase an entry field you need to pass the begining and
# the end of the cursor
user_txt.delete(0, END)
# to write you just pass the begining and the text
user_txt.insert(0, CONFIG["x-bancolombia-user"])
pass_txt.delete(0, END)
pass_txt.insert(0, CONFIG["x-bancolombia-pass"])
telegram_key_txt.delete(0, END)
telegram_key_txt.insert(0, CONFIG["x-telegram-key"])
telegram_contact_txt.delete(0, END)
telegram_contacty_txt.insert(0, CONFIG["x-telegram-contact"])
def save_clicked():
CONFIG["x-bancolombia-user"] = user_txt.get()
CONFIG["x-bancolombia-pass"] = pass_txt.get()
CONFIG["x-telegram-key"] = telegram_key_txt.get()
CONFIG["x-telegram-contact"] = telegram_contact_txt.get()
json.dump(CONFIG, open(config_path, "w"), indent=4)
print("config.json created")
def start_clicked():
msg = "Running..."
status.configure(text=msg, foreground="#5EFF33")
"""
t = threading.Thread(target=get_bancolombia_balance, args=(CONFIG))
t.start()
"""
print("Now you can either beg me to write the function or write it yourself")
print("c ya, https://gist.github.com/idontcar3/351776daf2565e7de677a7db0ba08c44")
def on_closing():
# you can do stuff here
window.destroy()
save_btn.configure(command=save_clicked)
# so finally, the main tab
lbl4 = Label(tab1, text="Launch every: ")
lbl4.grid(column=0, row=0)
launch_time_txt = Spinbox(tab1, values=(5, 10, 25, 60))
launch_time_txt.set(25)
launch_time_txt.grid(column=1, row=0)
lbl5 = Label(tab1, text="minutes")
lbl5.grid(column=2, row=0)
btn2 = Button(tab1, text="Start", command=start_clicked)
btn2.grid(column=3, row=0)
window.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment