IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Interfaces Graphiques Discussion :

Callback d'un bouton


Sujet :

Interfaces Graphiques

  1. #1
    Nouveau membre du Club
    Inscrit en
    Avril 2009
    Messages
    6
    Détails du profil
    Informations forums :
    Inscription : Avril 2009
    Messages : 6
    Par défaut Callback d'un bouton
    Salut,

    C'est mon premier Sujet sur le forum et j'espère pas le dernier

    Bon je suis étudiant en informatique & Multimédia et j'ai un projet sur matlab qui est de réaliser un projet avec une interface graphique permettant le choix des images et l'application de différent filtres et bruits.

    Mon problème en ce moment c'est comment insérer du code sur un bouton dans GUI c'est a dire quand on clique dessus ça fait appel a une fonction ou Quitter !! enfin sa fera une action

    Aider moi dans les brefs délai.

    Merci

  2. #2
    Expert confirmé
    Avatar de duf42
    Homme Profil pro
    Formateur en informatique
    Inscrit en
    Novembre 2007
    Messages
    3 111
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France

    Informations professionnelles :
    Activité : Formateur en informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2007
    Messages : 3 111
    Par défaut
    Bonjour,

    Pour commencer tu devrais lire ceci:
    Introduction à la programmation d'interfaces graphiques

    et celà:
    Développement efficace d'interfaces graphiques

    Ensuite pour qu'on puisse t'aider, il faudrait que tu nous montres ce que tu as commencer à coder et où se situe précisément ton problème ou ton erreur (avec le message correspondant).

    Bonne journée,
    Duf

  3. #3
    Nouveau membre du Club
    Inscrit en
    Avril 2009
    Messages
    6
    Détails du profil
    Informations forums :
    Inscription : Avril 2009
    Messages : 6
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    92
    93
    94
    95
    function varargout = untitled1(varargin)
    % UNTITLED1 M-file for untitled1.fig
    %      UNTITLED1, by itself, creates a new UNTITLED1 or raises the existing
    %      singleton*.
    %
    %      H = UNTITLED1 returns the handle to a new UNTITLED1 or the handle to
    %      the existing singleton*.
    %
    %      UNTITLED1('CALLBACK',hObject,eventData,handles,...) calls the local
    %      function named CALLBACK in UNTITLED1.M with the given input arguments.
    %
    %      UNTITLED1('Property','Value',...) creates a new UNTITLED1 or raises the
    %      existing singleton*.  Starting from the left, property value pairs are
    %      applied to the GUI before untitled1_OpeningFunction gets called.  An
    %      unrecognized property name or invalid value makes property application
    %      stop.  All inputs are passed to untitled1_OpeningFcn via varargin.
    %
    %      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
    %      instance to run (singleton)".
    %
    % See also: GUIDE, GUIDATA, GUIHANDLES
     
    % Edit the above text to modify the response to help untitled1
     
    % Last Modified by GUIDE v2.5 28-Apr-2009 10:56:00
     
    % Begin initialization code - DO NOT EDIT
    gui_Singleton = 1;
    gui_State = struct('gui_Name',       mfilename, ...
                       'gui_Singleton',  gui_Singleton, ...
                       'gui_OpeningFcn', @untitled1_OpeningFcn, ...
                       'gui_OutputFcn',  @untitled1_OutputFcn, ...
                       'gui_LayoutFcn',  [] , ...
                       'gui_Callback',   []);
    if nargin && ischar(varargin{1})
        gui_State.gui_Callback = str2func(varargin{1});
    end
     
    if nargout
        [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
    else
        gui_mainfcn(gui_State, varargin{:});
    end
    % End initialization code - DO NOT EDIT
     
     
    % --- Executes just before untitled1 is made visible.
    function untitled1_OpeningFcn(hObject, eventdata, handles, varargin)
    % This function has no output args, see OutputFcn.
    % hObject    handle to figure
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    % varargin   command line arguments to untitled1 (see VARARGIN)
     
    % Choose default command line output for untitled1
    handles.output = hObject;
     
    % Update handles structure
    guidata(hObject, handles);
     
    % UIWAIT makes untitled1 wait for user response (see UIRESUME)
    % uiwait(handles.figure1);
     
     
    % --- Outputs from this function are returned to the command line.
    function varargout = untitled1_OutputFcn(hObject, eventdata, handles) 
    % varargout  cell array for returning output args (see VARARGOUT);
    % hObject    handle to figure
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Get default command line output from handles structure
    varargout{1} = handles.output;
     
     
    % --- Executes on button press in pushbutton1.
    function pushbutton1_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton1 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
     
    % --- If Enable == 'on', executes on mouse press in 5 pixel border.
    % --- Otherwise, executes on mouse press in 5 pixel border or over pushbutton1.
    function pushbutton1_ButtonDownFcn(hObject, eventdata, handles)
    % hObject    handle to pushbutton1 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
     
    % --- Executes on key press with focus on pushbutton1 and no controls selected.
    function pushbutton1_KeyPressFcn(hObject, eventdata, handles)
    % hObject    handle to pushbutton1 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    Je veux savoir comment insérer du code dans le bouton pour que lorsqu'on clique dessus il fait un effet de filtre sur l'image choisie

  4. #4
    Expert confirmé
    Avatar de duf42
    Homme Profil pro
    Formateur en informatique
    Inscrit en
    Novembre 2007
    Messages
    3 111
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France

    Informations professionnelles :
    Activité : Formateur en informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2007
    Messages : 3 111
    Par défaut
    Il faut ajouter le code dans la fonction liée au Callback de ton bouton (pushbutton1_Callback)

    Citation Envoyé par dragon_clubiste Voir le message
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    92
    93
    94
    function varargout = untitled1(varargin)
    % UNTITLED1 M-file for untitled1.fig
    %      UNTITLED1, by itself, creates a new UNTITLED1 or raises the existing
    %      singleton*.
    %
    %      H = UNTITLED1 returns the handle to a new UNTITLED1 or the handle to
    %      the existing singleton*.
    %
    %      UNTITLED1('CALLBACK',hObject,eventData,handles,...) calls the local
    %      function named CALLBACK in UNTITLED1.M with the given input arguments.
    %
    %      UNTITLED1('Property','Value',...) creates a new UNTITLED1 or raises the
    %      existing singleton*.  Starting from the left, property value pairs are
    %      applied to the GUI before untitled1_OpeningFunction gets called.  An
    %      unrecognized property name or invalid value makes property application
    %      stop.  All inputs are passed to untitled1_OpeningFcn via varargin.
    %
    %      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
    %      instance to run (singleton)".
    %
    % See also: GUIDE, GUIDATA, GUIHANDLES
    
    % Edit the above text to modify the response to help untitled1
    
    % Last Modified by GUIDE v2.5 28-Apr-2009 10:56:00
    
    % Begin initialization code - DO NOT EDIT
    gui_Singleton = 1;
    gui_State = struct('gui_Name',       mfilename, ...
                       'gui_Singleton',  gui_Singleton, ...
                       'gui_OpeningFcn', @untitled1_OpeningFcn, ...
                       'gui_OutputFcn',  @untitled1_OutputFcn, ...
                       'gui_LayoutFcn',  [] , ...
                       'gui_Callback',   []);
    if nargin && ischar(varargin{1})
        gui_State.gui_Callback = str2func(varargin{1});
    end
    
    if nargout
        [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
    else
        gui_mainfcn(gui_State, varargin{:});
    end
    % End initialization code - DO NOT EDIT
    
    
    % --- Executes just before untitled1 is made visible.
    function untitled1_OpeningFcn(hObject, eventdata, handles, varargin)
    % This function has no output args, see OutputFcn.
    % hObject    handle to figure
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    % varargin   command line arguments to untitled1 (see VARARGIN)
    
    % Choose default command line output for untitled1
    handles.output = hObject;
    
    % Update handles structure
    guidata(hObject, handles);
    
    % UIWAIT makes untitled1 wait for user response (see UIRESUME)
    % uiwait(handles.figure1);
    
    
    % --- Outputs from this function are returned to the command line.
    function varargout = untitled1_OutputFcn(hObject, eventdata, handles) 
    % varargout  cell array for returning output args (see VARARGOUT);
    % hObject    handle to figure
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    
    % Get default command line output from handles structure
    varargout{1} = handles.output;
    
    
    % --- Executes on button press in pushbutton1.
    function pushbutton1_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton1 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    
    disp('Click on button')
    
    function pushbutton1_ButtonDownFcn(hObject, eventdata, handles)
    % hObject    handle to pushbutton1 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    
    
    % --- Executes on key press with focus on pushbutton1 and no controls selected.
    function pushbutton1_KeyPressFcn(hObject, eventdata, handles)
    % hObject    handle to pushbutton1 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    Je veux savoir comment insérer du code dans le bouton pour que lorsqu'on clique dessus il fait un effet de filtre sur l'image choisie

  5. #5
    Nouveau membre du Club
    Inscrit en
    Avril 2009
    Messages
    6
    Détails du profil
    Informations forums :
    Inscription : Avril 2009
    Messages : 6
    Par défaut
    je n'ai pû aboutir a rien
    SVP faites moi un exemple un bouton qui fait un bruit sur une image

  6. #6
    Expert confirmé
    Avatar de duf42
    Homme Profil pro
    Formateur en informatique
    Inscrit en
    Novembre 2007
    Messages
    3 111
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France

    Informations professionnelles :
    Activité : Formateur en informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2007
    Messages : 3 111
    Par défaut
    Ton problème vient-il de la programmation du bouton ou du bruit sur l'image?

    Quel code as-tu utilisé et quelles sont les erreurs que tu as?

  7. #7
    Nouveau membre du Club
    Inscrit en
    Avril 2009
    Messages
    6
    Détails du profil
    Informations forums :
    Inscription : Avril 2009
    Messages : 6
    Par défaut

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    function varargout = projet(varargin)
    % PROJET M-file for projet.fig
    %      PROJET, by itself, creates a new PROJET or raises the existing
    %      singleton*.
    %
    %      H = PROJET returns the handle to a new PROJET or the handle to
    %      the existing singleton*.
    %
    %      PROJET('CALLBACK',hObject,eventData,handles,...) calls the local
    %      function named CALLBACK in PROJET.M with the given input arguments.
    %
    %      PROJET('Property','Value',...) creates a new PROJET or raises the
    %      existing singleton*.  Starting from the left, property value pairs are
    %      applied to the GUI before projet_OpeningFunction gets called.  An
    %      unrecognized property name or invalid value makes property application
    %      stop.  All inputs are passed to projet_OpeningFcn via varargin.
    %
    %      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
    %      instance to run (singleton)".
    %
    % See also: GUIDE, GUIDATA, GUIHANDLES
     
    % Copyright 2002-2003 The MathWorks, Inc.
     
    % Edit the above text to modify the response to help projet
     
    % Last Modified by GUIDE v2.5 04-May-2009 09:43:41
     
    % Begin initialization code - DO NOT EDIT
    gui_Singleton = 1;
    gui_State = struct('gui_Name',       mfilename, ...
                       'gui_Singleton',  gui_Singleton, ...
                       'gui_OpeningFcn', @projet_OpeningFcn, ...
                       'gui_OutputFcn',  @projet_OutputFcn, ...
                       'gui_LayoutFcn',  [] , ...
                       'gui_Callback',   []);
    if nargin && ischar(varargin{1})
        gui_State.gui_Callback = str2func(varargin{1});
    end
     
    if nargout
        [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
    else
        gui_mainfcn(gui_State, varargin{:});
    end
    % End initialization code - DO NOT EDIT
     
     
    % --- Executes just before projet is made visible.
    function projet_OpeningFcn(hObject, eventdata, handles, varargin)
    % This function has no output args, see OutputFcn.
    % hObject    handle to figure
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    % varargin   command line arguments to projet (see VARARGIN)
     
    % Choose default command line output for projet
    handles.output = hObject;
     
    % Update handles structure
    guidata(hObject, handles);
     
    % UIWAIT makes projet wait for user response (see UIRESUME)
    % uiwait(handles.figure1);
     
     
    % --- Outputs from this function are returned to the command line.
    function varargout = projet_OutputFcn(hObject, eventdata, handles) 
    % varargout  cell array for returning output args (see VARARGOUT);
    % hObject    handle to figure
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Get default command line output from handles structure
    varargout{1} = handles.output;
     
     
    % --- Executes on slider movement.
    function slider1_Callback(hObject, eventdata, handles)
    % hObject    handle to slider1 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hints: get(hObject,'Value') returns position of slider
    %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
     
     
    % --- Executes during object creation, after setting all properties.
    function slider1_CreateFcn(hObject, eventdata, handles)
    % hObject    handle to slider1 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    empty - handles not created until after all CreateFcns called
     
    % Hint: slider controls usually have a light gray background, change
    %       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.
    usewhitebg = 1;
    if usewhitebg
        set(hObject,'BackgroundColor',[.9 .9 .9]);
    else
        set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
    end
     
     
    % --- Executes on slider movement.
    function slider2_Callback(hObject, eventdata, handles)
    % hObject    handle to slider2 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hints: get(hObject,'Value') returns position of slider
    %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
     
     
    % --- Executes during object creation, after setting all properties.
    function slider2_CreateFcn(hObject, eventdata, handles)
    % hObject    handle to slider2 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    empty - handles not created until after all CreateFcns called
     
    % Hint: slider controls usually have a light gray background, change
    %       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.
    usewhitebg = 1;
    if usewhitebg
        set(hObject,'BackgroundColor',[.9 .9 .9]);
    else
        set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
    end
     
     
    % --- Executes on button press in pushbutton1.
    function pushbutton1_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton1 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
     
    % --- Executes on button press in pushbutton2.
    function pushbutton2_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton2 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
     
    % --- Executes during object creation, after setting all properties.
    function pushbutton2_CreateFcn(hObject, eventdata, handles)
    % hObject    handle to pushbutton2 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    empty - handles not created until after all CreateFcns called
     
     
    % --- Executes during object creation, after setting all properties.
    function uipanel1_CreateFcn(hObject, eventdata, handles)
     
    % hObject    handle to uipanel1 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    empty - handles not created until after all CreateFcns called
    Voilà par exemple quand on clique sur SALT &pepper on a cette fonction

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    I=imread(‘BOATS_LUMI.BMP’) ; % image bateau en niveaux de gris
    IB = imnoise(I,'salt & pepper'); % image bruitée
    figure(1)
    subplot(1,2,1)
    subimage(I)
    title(‘Image originale’)
    subplot(1,2,2)
    subimage(IB)
    title(‘Image bruitée’)
    Autre chose comment charger les images par bouton(SVP regader l'image

  8. #8
    Expert confirmé
    Avatar de duf42
    Homme Profil pro
    Formateur en informatique
    Inscrit en
    Novembre 2007
    Messages
    3 111
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France

    Informations professionnelles :
    Activité : Formateur en informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2007
    Messages : 3 111
    Par défaut
    Essaie par exemple d'ajouter ton code dans la fonction pushbutton1_Callback, est-ce que c'est celà que tu cherches?

Discussions similaires

  1. une Callback pour deux groupes de boutons ?
    Par Twice22 dans le forum GTK+ avec C & C++
    Réponses: 0
    Dernier message: 04/05/2013, 22h19
  2. Classe Bouton avec callback
    Par flow10000 dans le forum Langage
    Réponses: 8
    Dernier message: 07/10/2012, 01h40
  3. [Débutant] Callback-radio bouton-Push bouton
    Par Allaedine dans le forum Interfaces Graphiques
    Réponses: 4
    Dernier message: 09/03/2012, 20h53
  4. Récupération donnée dans le callback d'un bouton
    Par stick25 dans le forum Interfaces Graphiques
    Réponses: 4
    Dernier message: 15/03/2010, 10h55
  5. problème de handle dans le callback d'un bouton
    Par ZeFMG dans le forum Interfaces Graphiques
    Réponses: 3
    Dernier message: 04/11/2008, 11h48

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo