1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
#!/usr/bin/env python
# -*- coding:Utf-8 -*-
import sys
import os
from PIL import Image,ImageTk
from Tkinter import *
#Récupère les fichier et vérifie s'ils sont présent
def startannex(send,my_file_name):
#Ret = []
Ret = os.popen(send).readlines()
Ret = str(Ret)
Ret = Ret.strip("[")
Ret = Ret.strip("]")
Ret = Ret.strip("'")
Ret = Ret[:Ret.find('\\')]
return Ret + "/" + my_file_name
def teste_exist_fichier(my_name_file):
#print os.path.abspath(__file__)
if os.path.abspath(os.path.dirname(__file__) + "/" + my_name_file):
return os.path.abspath(os.path.dirname(__file__) + "/" + \
my_name_file)
if os.path.isfile(startannex("pwd", my_name_file)):
return startannex("pwd", my_name_file)
S = sys.argv[0]
F=S[0:len(sys.argv[0])-len(my_name_file)]
if os.path.isfile(F+my_name_file):
return F+my_name_file
if os.path.isfile(os.path.split(__file__)[0] +"/"+my_name_file):
return os.path.split(__file__)[0] +"/"+my_name_file
if os.path.isfile(os.path.split(__file__)[0] +"/"+my_name_file):
return os.path.split(__file__)[0] +"/"+my_name_file
print Lfr[0] + my_name_file
return False
fichierPngcadre=teste_exist_fichier("cadre.png")
if fichierPngcadre == False: sys.exit()
def read_my_file(path_my_file_read):
file=open(path_my_file_read,'r')
convercharset = file.read().decode('utf-8').\
encode(sys.stdout.encoding,'replace')
file.close()
#N_lignes = len(lecture)
return convercharset
def defgeometry(self):
resolution=(self.winfo_screenwidth()/2,self.winfo_screenheight()/2)
appsize=(self.winfo_width()/4,self.winfo_height()/4)
tmpw=((resolution[0] - appsize[0])+15)
tmph=((resolution[1] - appsize[1])-60)
self.geometry('+'+str(tmpw)+'+'+str(tmph))
def startinfo():
self =Tk()
L=800
H=600
H_image=L/2
L_image=H/2
can = Canvas(self, width =L, height =H, bg ='white')
mon_image=ImageTk.PhotoImage(file=fichierPngcadre)
can.create_image(H_image,L_image,image=mon_image)
try:
readme=read_my_file("/home/user/Desktop/python/README.txt")
except:
print "Charset non suporter"
text = Text(self, \
background="white", \
borderwidth=0, \
relief=RAISED, \
foreground = "blue", \
selectforeground="blue")
w=text.insert(END, readme)
scrolltext = text.Scrollbar(can)
text.grid(row=10,column=5)
text.config(yscrollcommand = scrolltext.set)
can.grid(row = 5, rowspan = 20,column =2, columnspan=20, sticky=N)
self.update_idletasks()
defgeometry(self)
self.mainloop()
startinfo() |
Partager