#!/usr/bin/python3 title = "Komunikat LinuxCNC" fontsize = 15 import sys import os import configparser import tkinter as tk MessageFilePath = __file__ + "messages.ini" proceed = "Y" if not os.path.isfile(MessageFilePath): instruction = MessageFilePath + " does not exist" proceed = "N" else: if len(sys.argv) == 1: instruction = "M100 was called with no P value" proceed = "N" else: P = sys.argv[1] if len(P) < 7: ps = P else: ps = P[0:len(P) - 7] cfg = configparser.ConfigParser() try: cfg.read(MessageFilePath) instruction = cfg.get("Messages", ps) instruction = instruction.encode("unicode_escape").decode() except configparser.MissingSectionHeaderError: proceed = "N" instruction = "First line of\n" + MessageFilePath + "\nmust be:\n[Messages]" except (configparser.MissingSectionHeaderError, configparser.NoOptionError): proceed = "N" instruction = "There is no message for number\n" + P + "\n in the file\n" + MessageFilePath if instruction == "": instruction = "The message for P" + P + " is blank" proceed = "N" mess = os.linesep + instruction.replace("\n", os.linesep) + os.linesep window = tk.Tk() window.title(title) window.geometry("300x200") msg = tk.Message(window, text=mess, width=1000) msg.config(fg="Black", font=("times", fontsize, "bold")) def close(event): exit(1) window.bind("", close) if proceed == "Y": def go_on(event): exit(0) window.bind("", go_on) def Continue_clicked(): exit(0) btnContinue = tk.Button(window, text="Kontynuuj", command=Continue_clicked, width=60, height=1, font=("Helvetica", "20")) btnContinue.configure(bg="gray") def Stop_clicked(): exit(1) msg.pack() if proceed == "Y": btnContinue.pack() window.mainloop()