Commit 592fe665 by mihkevich

add interface for enter command and modify logger (added logs dir and it add to gitignore)

parent 229caa36
/.idea /.idea
/*.log /logs
\ No newline at end of file __pycache__/my_logger.cpython-39.pyc
__pycache__/settings.cpython-39.pyc
.~lock.data.xlsx#
File added
...@@ -5,11 +5,38 @@ import os ...@@ -5,11 +5,38 @@ import os
import sys import sys
import traceback import traceback
import settings import settings
from openpyxl import load_workbook
import tkinter
from tkinter import ttk
class App(tkinter.Tk):
def __init__(self, *args, **kwargs):
tkinter.Tk.__init__(self, *args, **kwargs)
self.grid()
lbl = ttk.Label(self, text="ВВЕДИТЕ КОД НУЖНОЙ ЗАПИСИ", font="Helvetica 32 bold",padding=10).grid(column=0, row=0)
self.command=tkinter.StringVar()
entry = ttk.Entry(self, textvariable=self.command, font="Helvetica 32")
entry.grid(column=1, row=0)
entry.focus()
self.bind("<Return>", self.handle_command)
self.bind("<Escape>", self.handle_esc)
def handle_command(self, arg):
log.info(self.command.get())
log.info(arg)
def handle_esc(self, arg):
log.info(arg)
sys.exit()
try: try:
while True: app = App()
log.info("Hello World ") app.mainloop()
sleep(3) except Exception as e:
except KeyboardInterrupt as e: log.error(log.get_line())
log.info("Stopping...") sys.exit()
\ No newline at end of file
...@@ -6,7 +6,16 @@ import sys ...@@ -6,7 +6,16 @@ import sys
class Log: class Log:
def __init__(self): def __init__(self):
self.logfile = "{}/{}_main.log".format(os.path.dirname(sys.argv[0]), datetime.datetime.now().strftime("%m_%d_%Y %H_%M_%S")) # init log file #
self.exec_dir = os.path.dirname(sys.argv[0])
try:
os.mkdir("{}/logs".format(self.exec_dir))
except FileExistsError as e:
pass
self.logfile = "{}/logs/{}_main.log".format(self.exec_dir, datetime.datetime.now().strftime("%m_%d_%Y %H_%M_%S"))
self.log = logging.getLogger("my_log") self.log = logging.getLogger("my_log")
self.log.setLevel(logging.INFO) self.log.setLevel(logging.INFO)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment