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 :

check box puis pushbutton


Sujet :

Interfaces Graphiques

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éprouvé
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    1 002
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2008
    Messages : 1 002
    Par défaut check box puis pushbutton
    Bonjour,

    J'ai 12 vecteurs, j'aimerais grâce a un checkbox pouvoir choisir une ou des voie(s) afin de les mettre à NaN.

    Grace au GUI j'ai fait cette fonction :

    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
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    function varargout = GUIcheckBox(varargin)
    % GUICHECKBOX M-file for GUIcheckBox.fig
    %      GUICHECKBOX, by itself, creates a new GUICHECKBOX or raises the existing
    %      singleton*.
    %
    %      H = GUICHECKBOX returns the handle to a new GUICHECKBOX or the handle to
    %      the existing singleton*.
    %
    %      GUICHECKBOX('CALLBACK',hObject,eventData,handles,...) calls the local
    %      function named CALLBACK in GUICHECKBOX.M with the given input arguments.
    %
    %      GUICHECKBOX('Property','Value',...) creates a new GUICHECKBOX or raises the
    %      existing singleton*.  Starting from the left, property value pairs are
    %      applied to the GUI before GUIcheckBox_OpeningFcn gets called.  An
    %      unrecognized property name or invalid value makes property application
    %      stop.  All inputs are passed to GUIcheckBox_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 GUIcheckBox
     
    % Last Modified by GUIDE v2.5 01-Oct-2010 18:03:20
     
    % Begin initialization code - DO NOT EDIT
    gui_Singleton = 1;
    gui_State = struct('gui_Name',       mfilename, ...
                       'gui_Singleton',  gui_Singleton, ...
                       'gui_OpeningFcn', @GUIcheckBox_OpeningFcn, ...
                       'gui_OutputFcn',  @GUIcheckBox_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 GUIcheckBox is made visible.
    function GUIcheckBox_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 GUIcheckBox (see VARARGIN)
     
    % Choose default command line output for GUIcheckBox
    handles.output = hObject;
     
    % Update handles structure
    guidata(hObject, handles);
     
    % UIWAIT makes GUIcheckBox wait for user response (see UIRESUME)
    % uiwait(handles.figure1);
     
     
    % --- Outputs from this function are returned to the command line.
    function varargout = GUIcheckBox_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 checkbox1.
    function checkbox1_Callback(hObject, eventdata, handles)
    % hObject    handle to checkbox1 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hint: get(hObject,'Value') returns toggle state of checkbox1
     
     
    % --- Executes on button press in checkbox2.
    function checkbox2_Callback(hObject, eventdata, handles)
    % hObject    handle to checkbox2 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hint: get(hObject,'Value') returns toggle state of checkbox2
     
     
    % --- Executes on button press in checkbox3.
    function checkbox3_Callback(hObject, eventdata, handles)
    % hObject    handle to checkbox3 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hint: get(hObject,'Value') returns toggle state of checkbox3
     
     
    % --- Executes on button press in checkbox4.
    function checkbox4_Callback(hObject, eventdata, handles)
    % hObject    handle to checkbox4 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hint: get(hObject,'Value') returns toggle state of checkbox4
     
     
    % --- Executes on button press in checkbox5.
    function checkbox5_Callback(hObject, eventdata, handles)
    % hObject    handle to checkbox5 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hint: get(hObject,'Value') returns toggle state of checkbox5
     
     
    % --- Executes on button press in checkbox6.
    function checkbox6_Callback(hObject, eventdata, handles)
    % hObject    handle to checkbox6 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hint: get(hObject,'Value') returns toggle state of checkbox6
     
     
    % --- Executes on button press in checkbox7.
    function checkbox7_Callback(hObject, eventdata, handles)
    % hObject    handle to checkbox7 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hint: get(hObject,'Value') returns toggle state of checkbox7
     
     
    % --- Executes on button press in checkbox8.
    function checkbox8_Callback(hObject, eventdata, handles)
    % hObject    handle to checkbox8 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hint: get(hObject,'Value') returns toggle state of checkbox8
     
     
    % --- Executes on button press in checkbox9.
    function checkbox9_Callback(hObject, eventdata, handles)
    % hObject    handle to checkbox9 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hint: get(hObject,'Value') returns toggle state of checkbox9
     
     
    % --- Executes on button press in checkbox10.
    function checkbox10_Callback(hObject, eventdata, handles)
    % hObject    handle to checkbox10 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hint: get(hObject,'Value') returns toggle state of checkbox10
     
     
    % --- Executes on button press in checkbox11.
    function checkbox11_Callback(hObject, eventdata, handles)
    % hObject    handle to checkbox11 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hint: get(hObject,'Value') returns toggle state of checkbox11
     
     
    % --- Executes on button press in checkbox12.
    function checkbox12_Callback(hObject, eventdata, handles)
    % hObject    handle to checkbox12 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hint: get(hObject,'Value') returns toggle state of checkbox12
     
     
    % --- 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)
    Mais après ça je vois pas comment faire. En gros après le choix de mes vecteurs (après avoir cocher les checkbox correspondantes), j'aimerais que ceux choisit mettent toutes leurs valeurs à NaN (une fois que j'appuie sur le pushbutton "OK").

    Merci de votre aide.

  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,

    Dans le Callback de ton pushbutton, il faut que tu récupères les valeurs de tes checkbox et qu'en fonction tu mettes les valeurs de tes vecteurs à NaN:

    Exemple pour une checkbox:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    if (get(handles.checkbox1, 'Value') == 1)
        vecteur1 = NaN;
    end
     
    ...
    Duf

    P.S. Le code que tu nous montres ne nous apprend pas grand chose puisqu'il s'agit uniquement du code généré par GUIDE

  3. #3
    Membre éprouvé
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    1 002
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2008
    Messages : 1 002
    Par défaut
    Merci pour ta réponse mais je piges pas vraiment ce que tu veux dire par :
    Citation Envoyé par duf42 Voir le message

    Dans le Callback de ton pushbutton,
    concrètement que signifie "dans" le Callback?

    Merci d'avance.

  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
    Dans la fonction *_Callback (dans ton cas: pushbutton1_Callback)

  5. #5
    Membre éprouvé
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    1 002
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2008
    Messages : 1 002
    Par défaut
    ok ok !
    J'ai fait ça, le problème étant que si je coche le vecteur 1 par exemple, il me le met bien à NaN mais uniquement dans la fonction GUI, une fois retourné dans la fonction principale, le vecteur 1 a ses valeurs initiales.

    fonction principale :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    [...]
    V1 = [4 5 3]
    checkBox
    V1
    [...]
    fonction checkBox

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    [...]
    function pushbutton1_Callback(hObject, eventdata, handles)
    
    if (get(handles.checkbox1, 'Value') == 1)
        V1(:,:) = NaN
    end [...]
    V1(:,: ) = NaN (C'est pas mal déjà même si je m'attendais à un vecteur de NaN de dimension 3*1)

    mais V1 = [4 5 3] comme initialement...mais n'égale pas [NaN NaN NaN], comme je voudrais.

    Merci

  6. #6
    Membre éprouvé
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    1 002
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2008
    Messages : 1 002
    Par défaut
    Bon en faite j'ai l'impression d'avoir rien pigé aux interfaces... j'ai l'impression que mes vecteur ne rentrent pas dans ma fonction checkbox... varagin et varagout ne sont pas des paramètres pour faire entrer n'importe qu'elle variable qui se trouve dans le programme principale et apellé du même nom dans le programme secondaire?

    Merci

Discussions similaires

  1. [XL-2000] Add check box puis lire son etat
    Par maissaab dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 01/11/2012, 11h22
  2. [Javascript] probleme de check box
    Par stomerfull dans le forum Général JavaScript
    Réponses: 1
    Dernier message: 08/02/2006, 08h09
  3. eVC++ 4 : check box transparente
    Par zenetcalme dans le forum MFC
    Réponses: 10
    Dernier message: 29/11/2005, 10h11
  4. cocher tout les check box
    Par Flob dans le forum Balisage (X)HTML et validation W3C
    Réponses: 5
    Dernier message: 17/02/2005, 11h29
  5. [FLASH 5] check box sous Flash 5
    Par Flash5man dans le forum Flash
    Réponses: 7
    Dernier message: 01/09/2004, 09h48

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