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 :

Faire varier du texte dans une fenêtre


Sujet :

Interfaces Graphiques

  1. #1
    Candidat au Club
    Profil pro
    Inscrit en
    Octobre 2006
    Messages
    2
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2006
    Messages : 2
    Points : 2
    Points
    2
    Par défaut Faire varier du texte dans une fenêtre
    Bonjour,
    il faut que je fasse une interface surlaquelle se trouve du texte, quand je click sur suivant le texte doit changer. J'avais réussi à le faire avec les variables globales mais on m'a dit que ce n'etait pas bon. Je dois employer le guidata me dit-on.
    mes 3 variables sont "j" pour mon incrément , "manualtxt" qui contien les différents textes et "manual" la variable de la zone de texte.
    Comment inserer ces variables dans un guidata?

    j'emploi 2fonction :
    - la figure avec tout les boutons et les zones de texte
    - la fonction next pour le bouton next qui consiste à incrémenter "j" et selon sa valeur le texte change.

    Merci d'avance de votre aide (je ne suis pas un utilisateur de matlab, c'est mon chef qui me demande de lui faire un program matlab)
    si besoin de plus de renseignements ou le code je peut le donner mais je me suis dit que se serai peut etre un peu lourd dans la page.

    Code figure :
    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
    function tune
    close all
    sizew = 320;
    sizeh = 430;
    border = 20;
    textw = 30;
    texth = 16;
    butth = 20;
    buttw = 70;
    textdx = 20;
    edith = 16;
    editw = 50;
    manualw = 260;
    manualh = 160;
    %%global manualtxt;
    manualtxt = {['Get KP as high as possible but maintain stability.'...
        'Start with KI = 0 and KP = RKP and increase it 20% at a time.'...
        ' Each time you raise KP try to move the system and it has to stay stable.'...
        ' Use set position to move SMART and get position to check if position is right.'...
        ' When you are done click next. Use Update PID before testing.'];
        ['Now move KD up and down to find the quickest stability and quiet system. If KD is to high there'...
        'will be a kind of grinding sound. When you are done with KD you can may be rise KP a little more again.'...
        ' Click next to go to KL. Use Update PID before testing.'];
        ['Start with KI = 0 and KL = 1000. Increase KI until the motor always reaches its target but'...
        ' keep KL at least ten times KI. Then add 30% to KI. Start bringing down KL until it hampers KI and'...
        ' then add 30% to KL. Use Update PID before testing.']};
    %%global j;
    j = 1;
    %%manual = manualtxt{j};
    cbfc = {'next'} 
    fig = figure('Visible', 'off', 'Position', [0 0 sizew sizeh], 'Resize', 'off', 'Name', 'Tuning', 'UserData', 1);
    %% Button : next
    uicontrol('Style', 'pushbutton', 'Callback', cbfc{1}, 'Tag', '#4', 'String', 'next', 'Position', ...
        [sizew - 4 * border - buttw, sizeh - border - 6 * texth - 5 * 24.8, buttw, butth]);
    %% Text : manual
    %%global manual
    manual = uicontrol('Style', 'text', 'HorizontalAlignment', 'left', 'FontSize', 10,'Position', ...
        [sizew / 2 - manualw / 2, border, manualw, manualh],'String', manualtxt{j}, 'BackgroundColor', [0.8, 0.8, 0.8]);
    handles.j = j;
    handles.manualtxt = manualtxt;
    handles.manual = manual;
    guidata(fig, handles);
     
    movegui(fig, 'center');
    set(fig, 'Visible', 'on');
    Code next :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    function next
    %%global j;
    j = j + 1 ;
    if (j == 4)
        j = 3;
    end
    %%global manual;
    %%global manualtxt;
    set(manual, 'String', manualtxt{j})

  2. #2
    Membre éprouvé
    Avatar de rostomus
    Homme Profil pro
    Doctorant électronique et traitement du signal
    Inscrit en
    Décembre 2006
    Messages
    791
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France

    Informations professionnelles :
    Activité : Doctorant électronique et traitement du signal

    Informations forums :
    Inscription : Décembre 2006
    Messages : 791
    Points : 1 205
    Points
    1 205
    Par défaut
    Salut,

    Bon, j'ai jamais utilisé la fonction guidata, j'ai pas encore essayé, mais j'utilise le userdata de la figure.
    et aussi je pense que ca sera mieux de mettre la fonction "next" dans le même fichier que la fonction principale.

    voila, j'ai modifié un peu ton code (les modification sont en rouge):
    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
    function tune
    close all
    sizew = 320;
    sizeh = 430;
    border = 20;
    textw = 30;
    texth = 16;
    butth = 20;
    buttw = 70;
    textdx = 20;
    edith = 16;
    editw = 50;
    manualw = 260;
    manualh = 160;
    %%global manualtxt;
    manualtxt = {['Get KP as high as possible but maintain stability.'...
    'Start with KI = 0 and KP = RKP and increase it 20% at a time.'...
    ' Each time you raise KP try to move the system and it has to stay stable.'...
    ' Use set position to move SMART and get position to check if position is right.'...
    ' When you are done click next. Use Update PID before testing.'];
    ['Now move KD up and down to find the quickest stability and quiet system. If KD is to high there'...
    'will be a kind of grinding sound. When you are done with KD you can may be rise KP a little more again.'...
    ' Click next to go to KL. Use Update PID before testing.'];
    ['Start with KI = 0 and KL = 1000. Increase KI until the motor always reaches its target but'...
    ' keep KL at least ten times KI. Then add 30% to KI. Start bringing down KL until it hampers KI and'...
    ' then add 30% to KL. Use Update PID before testing.']};
    %%global j;
    j = 1;
    %%manual = manualtxt{j};
    
    fig = figure('Visible', 'off', 'Position', [0 0 sizew sizeh], 'Resize', 'off', 'Name', 'Tuning', 'UserData', 1);
    %% Button : next
    uicontrol('Style', 'pushbutton', 'Callback', @next, 'Tag', '#4', 'String', 'next', 'Position', ...
    [sizew - 4 * border - buttw, sizeh - border - 6 * texth - 5 * 24.8, buttw, butth]);
    %% Text : manual
    %%global manual
    manual = uicontrol('Style', 'text', 'HorizontalAlignment', 'left', 'FontSize', 10,'Position', ...
    [sizew / 2 - manualw / 2, border, manualw, manualh],'String', manualtxt{j}, 'BackgroundColor', [0.8, 0.8, 0.8]);
    handles.j = j;
    handles.manualtxt = manualtxt;
    handles.manual = manual;
    guidata(fig, handles);
    
    movegui(fig, 'center');
    set(fig, 'Visible', 'on');
    
    set(fig,'userdata',{j,manual,manualtxt});
    
    function next(obj,event)
    tout=get(gcf,'userdata');
    j=tout{1};
    manual=tout{2};
    manualtxt=tout{3};
    %%global j;
    j = j + 1 ;
    if (j == 4)
    j = 3;
    end
    %%global manual;
    %%global manualtxt;
    set(manual, 'String', manualtxt{j})
    tout{1}=j;
    set(gcf,'userdata',tout);

  3. #3
    Candidat au Club
    Profil pro
    Inscrit en
    Octobre 2006
    Messages
    2
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2006
    Messages : 2
    Points : 2
    Points
    2
    Par défaut
    Merci je vai inspecter ta réponse, mais j'avai trouvé hier soir finalement.
    en fait je met les variables en h.NomVariable, puis apres que j'ai fait sa pour toutes je fait un guidata(fig, h) et pour récuperer je fait h = guidata(1) %car figure 1 et alors j'ai tout mes h.NomVariable dans l'autre fonction.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 2
    Dernier message: 06/05/2012, 18h25
  2. Faire rentrer un texte dans une zone sans scrolbar
    Par jjpopaul dans le forum Langage
    Réponses: 4
    Dernier message: 08/04/2010, 17h14
  3. Faire disparaitre un texte dans une textbox
    Par toinou62 dans le forum Général JavaScript
    Réponses: 2
    Dernier message: 05/10/2007, 11h40
  4. [vb.net 1.1] Faire défilé du texte dans une image
    Par malhivertman1 dans le forum Windows Forms
    Réponses: 1
    Dernier message: 09/11/2006, 16h31
  5. Faire défiler un texte dans une cellule de tableau
    Par Furius dans le forum Général JavaScript
    Réponses: 18
    Dernier message: 01/12/2005, 17h06

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