PDF-Embanner/pdfembannersrc/help.py

64 lines
2.3 KiB
Python

# -*-coding:utf-8 -*
import tkinter as tk
import logging
logger = logging.getLogger()
class Interface(tk.Toplevel):
"""
Help window
"""
def __init__(self, parent, **kwargs):
tk.Toplevel.__init__(self, parent)
self.transient(parent)
self.grab_set()
self.title("PDF Embanner : help and credits")
self.geometry("700x300")
self.protocol("WM_DELETE_WINDOW", self.close)
self.bind("<Escape>", self.close)
self.bind("<Return>", self.close)
self.f = tk.Frame(self)
self.f.pack(fill=tk.BOTH)
self.f.columnconfigure(0, weight=1)
self.f.rowconfigure(0, weight=1)
# Création de nos widgets
vsb = tk.Scrollbar(self.f, orient=tk.VERTICAL)
vsb.grid(row=0, column=1, sticky=tk.N+tk.S)
hsb = tk.Scrollbar(self.f, orient=tk.HORIZONTAL)
hsb.grid(row=1, column=0, sticky=tk.W+tk.E)
c = tk.Canvas(self.f,yscrollcommand=vsb.set, xscrollcommand=hsb.set)
c.grid(row=0, column=0, sticky=tk.W+tk.E+tk.N+tk.S)
vsb.config(command=c.yview)
hsb.config(command=c.xview)
self.frame_text = tk.Frame(c)
self.frame_text.columnconfigure(0, weight=1)
i=0
with open('pdfembannersrc/help.md', 'r') as f:
for l in f.readlines():
if(l[0]=='#'):
if(l[1]=='#'):
if(l[2]=='#'):
tk.Label(self.frame_text, text=l[3:-1], font=(None, 15)).grid(row=i, column=0, sticky=tk.W)
else:
tk.Label(self.frame_text, text=l[2:-1], font=(None,18)).grid(row=i, column=0, sticky=tk.W)
else:
tk.Label(self.frame_text, text=l[1:-1], font=(None, 23)).grid(row=i, column=0, sticky=tk.W)
else:
tk.Label(self.frame_text, text=l[:-1]).grid(row=i, column=0, sticky=tk.W)
i+=1
c.create_window(0, 0, window=self.frame_text, anchor=tk.NW)
self.frame_text.update_idletasks()
c.config(scrollregion=c.bbox("all"))
self.bouton_close = tk.Button(self.f, text="Close", command=self.close)
self.bouton_close.grid(row=2, column=0, sticky=tk.E)
def close(self, *args):
self.destroy()