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
|
#! /usr/bin/env python
# -*- coding: Latin-1 -*-
import os, sys
from Tkinter import *
class Curseurs(Frame):
def __init__(self, maitre=None):
Frame.__init__(self) # constructeur de la classe parente
# Définition de quelques attributs d'instance :
self.compR, self.compV, self.compB = 0, 0, 0
#composante rouge
Scale(self, length=400, orient=HORIZONTAL, label ='Composante Rouge :',
troughcolor ='dark grey', sliderlength =20,
showvalue =0, from_=0, to=255, tickinterval =25,
command=self.setCompR).pack()
#composante verte
Scale(self, length=400, orient=HORIZONTAL, label ='Composante Verte :',
troughcolor ='dark grey', sliderlength =20,
showvalue =0, from_=0, to=255, tickinterval =25,
command=self.setCompV).pack()
#composante bleue
Scale(self, length=400, orient=HORIZONTAL, label ='Composante Bleue :',
troughcolor ='dark grey', sliderlength =20,
showvalue =0, from_=0, to=255, tickinterval =25,
command=self.setCompB).pack()
def setCompR(self, r):
self.compR = float(r)
self.event_generate('<Control-Z>')
def setCompV(self, v):
self.compV = float(v)
self.event_generate('<Control-Z>')
def setCompB(self, b):
self.compB = float(b)
self.event_generate('<Control-Z>')
class Application(Frame):
"""Application principale"""
def __init__(self, boss =None):
Frame.__init__(self)
self.master.title('Watermarking attacks')
self.can2 = Canvas(self, bg='light grey', height=500,
width=500, borderwidth =2)
self.can2.bind("<Button-1>", self.modif_pixel)
self.can2.pack(side =RIGHT)
self.pack()
def afficherTout(event=None):
lab.configure(text = '%s - %s - %s' % (fra.compR, fra.compV, fra.compB))
def modif_pixel(self, event):
#x = str(event.x)
#y = str(event.y)
#print x,y
fen_curseurs = Tk()
fra = Curseurs(fen_curseurs)
fra.pack(side =TOP)
lab = Label(fen_curseurs, text ='test')
lab.pack()
fen_curseurs.bind('<Control-Z>', self.afficherTout)
fen_curseurs.mainloop()
if __name__ == '__main__':
app = Application()
app.mainloop() |
Partager