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 :

Ajouter un texte affichant l'heure [Débutant]


Sujet :

Interfaces Graphiques

  1. #1
    Membre à l'essai
    Homme Profil pro
    ee
    Inscrit en
    Mars 2017
    Messages
    17
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 26
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : ee

    Informations forums :
    Inscription : Mars 2017
    Messages : 17
    Points : 10
    Points
    10
    Par défaut Ajouter un texte affichant l'heure
    Bonjour

    J'aimerai ajouter un texte a cette interface "Time start" qui va m'indiquer lheure debut avec la fonction 'datestr(now,13)', quelqu'un peut m aider svp


    voici la fonction principale
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    h = CreateDoubleProgressBar('NFTB Scan Progress', 'XY Axes progress', 'Z planes progress','Time start', 'normal');
    et le détail de la fonction c'est sa
    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
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    function f = CreateDoubleProgressBar(maintitle, title1, title2, WindowStyle)
    %% Help
    % Function Calling syntax: 
    % Type 1: With Window style normal (default)
        % handle = CreateDoubleProgressBar(maintitle, title1, title2)
            % where maintitle is the title of the waitbar (string)
            % title1 is the title of progress bar 1 (string)
            % title2 is the title of progress bar 2 (string)
    % 
    % Type 2: With Window style imposed
        % handle = CreateDoubleProgressBar(maintitle, title1, title2, WindowStyle)
            % where maintitle is the title of the waitbar  (string)
            % title1 is the title of progress bar 1 (string)
            % title2 is the title of progress bar 2 (string)
            % WindowStyle is either 'normal' or 'modal' (string)
    %  
    % 
    % Created 
    % Date
     
        if nargin < 3 || nargin > 4
            error('Error in input arguments. Contact EMC Innovation Team for help');
        end
     
        if nargout ~= 1
            error('Error in output arguments. Contact EMC Innovation Team for help');
        end
     
        if ~ischar(maintitle)
            error('First argument (title of the waitbar) must be a string');
        end
     
        if ~ischar(title1)
            error('Second argument (title of the progress bar 1) must be a string');
        end
     
        if ~ischar(title2)
            error('Third argument (title of the progress bar 2) must be a string');
        end
     
        if nargin == 4 && ~ischar(WindowStyle)
            error('Fourth argument (Window style) must be a string');
        end
     
        if nargin == 3
            winstyle = 'normal';
        elseif nargin == 4
            winstyle = WindowStyle;
        end
     
        % Check if winstyle is in correct format
        if strncmp(winstyle, 'modal', 5)
            winstyle = 'modal';
        elseif strncmp(winstyle, 'normal', 6)
            winstyle = 'normal';
        else
            error('Fourth argument (Window style) must be either normal or modal');
        end
     
     
        % Create figure
     
        oldRootUnits = get(0,'Units');
        % Restore the Units safely
        c = onCleanup(@()set(0, 'Units', oldRootUnits));
     
        set(0, 'Units', 'points');
        screenSize = get(0,'ScreenSize');
        delete(c);
     
        axFontSize=get(0,'FactoryAxesFontSize');
     
        pointsPerPixel = 72/get(0,'ScreenPixelsPerInch');
     
        width = 360 * pointsPerPixel;
        height = 75 * pointsPerPixel * 2;
        pos = [screenSize(3)/2-width/2 screenSize(4)/2-height/(2) width height];
     
        f = figure(...
            'Units', 'points', ...
            'BusyAction', 'queue', ...
            'Position', pos, ...
            'Resize','off', ...
            'CreateFcn','', ...
            'NumberTitle','off', ...
            'IntegerHandle','off', ...
            'MenuBar', 'none', ...
            'Tag','DoubleWaitbar',...
            'Interruptible', 'off', ...
            'Name', maintitle, ...
            'WindowStyle', winstyle, ...
            'DockControls', 'off', ...
            'Visible','on');
     
        % Create cancel button by default
        vertMargin = 0;
     
        cancelBtnHeight = 23 * pointsPerPixel;
        cancelBtnWidth = 60 * pointsPerPixel;
        newPos = pos;
        vertMargin = vertMargin + cancelBtnHeight;
        newPos(4) = newPos(4)+vertMargin;
        callbackFcn = 'setappdata(gcbf,''canceling'',1)';
        set( f, 'Position', newPos, 'CloseRequestFcn', callbackFcn );
        cancelButt = uicontrol('Parent',f, ...
            'Units','points', ...
            'Callback', callbackFcn, ...
            'ButtonDownFcn', callbackFcn', ...
            'Enable','on', ...
            'Interruptible','off', ...
            'Position', [pos(3)-cancelBtnWidth*1.4, 7,  ...
            cancelBtnWidth, cancelBtnHeight], ...
            'String','Cancel', ...
            'Tag','TMWWaitbarCancelButton'); 
        cancelBtnCreated = 1;
     
        % Create axes
        colormap([]);
     
        axNorm=[.05 .3 .8 .15];
        axPos1=axNorm.*[pos(3:4),pos(3:4)] + [0 vertMargin+30 0 0];
        axPos2=axNorm.*[pos(3:4),pos(3:4)] + [0 vertMargin-15 0 0];
     
        h1 = axes('Parent', f, ...
            'XLim',[0 100],...
            'YLim',[0 1],...
            'Box','on', ...
            'Units','Points',...
            'FontSize', axFontSize,...
            'Position',axPos1,...
            'XTickMode','manual',...
            'YTickMode','manual',...
            'XTick',[],...
            'YTick',[],...
            'XTickLabelMode','manual',...
            'XTickLabel',[],...
            'YTickLabelMode','manual',...
            'YTickLabel',[],...
            'Visible', 'on', ...
            'NextPlot', 'replace');
     
        tHandle=get(h1,'title');
        oldTitleUnits=get(tHandle,'Units');
        set(tHandle,...
            'Units',      'points',...
            'String',     title1,...
            'Visible',    'on');
     
        tExtent=get(tHandle,'Extent');
        set(tHandle,'Units',oldTitleUnits);
     
        titleHeight=tExtent(4)+axPos1(2)+axPos1(4)+5;
        if titleHeight>pos(4)
            pos(4)=titleHeight;
            pos(2)=screenSize(4)/2-pos(4)/2;
            figPosDirty=true;
        else
            figPosDirty=false;
        end
     
        if tExtent(3)>pos(3)*1.10;
            pos(3)=min(tExtent(3)*1.10,screenSize(3));
            pos(1)=screenSize(3)/2-pos(3)/2;
     
            axPos1([1,3])=axNorm([1,3])*pos(3);
            set(h1,'Position',axPos1);
     
            figPosDirty=true;
        end
     
     
         h2 = axes('Parent', f, ...
            'XLim',[0 100],...
            'YLim',[0 1],...
            'Box','on', ...
            'Units','Points',...
            'FontSize', axFontSize,...
            'Position',axPos2,...
            'XTickMode','manual',...
            'YTickMode','manual',...
            'XTick',[],...
            'YTick',[],...
            'XTickLabelMode','manual',...
            'XTickLabel',[],...
            'YTickLabelMode','manual',...
            'YTickLabel',[],...
            'Visible', 'on');
     
        tHandle=get(h2,'title');
        oldTitleUnits=get(tHandle,'Units');
        set(tHandle,...
            'Units',      'points',...
            'String',     title2,...
            'Visible',    'on');
     
        tExtent=get(tHandle,'Extent');
        set(tHandle,'Units',oldTitleUnits);
     
        titleHeight=tExtent(4)+axPos1(2)+axPos1(4)+5;
        if titleHeight>pos(4)
            pos(4)=titleHeight;
            pos(2)=screenSize(4)/2-pos(4)/2;
            figPosDirty=true;
        else
            figPosDirty=false;
        end
     
        if tExtent(3)>pos(3)*1.10;
            pos(3)=min(tExtent(3)*1.10,screenSize(3));
            pos(1)=screenSize(3)/2-pos(3)/2;
     
            axPos2([1,3])=axNorm([1,3])*pos(3);
            set(h2,'Position',axPos2);
     
            figPosDirty=true;
        end
     
         if figPosDirty
            set(f,'Position',pos);
         end 
     
         % Create a patch in each axis with 0 value
         xpatch = [0 0 0 0];
         ypatch = [0 0 1 1];
     
         p1 = patch(xpatch,ypatch,'r', 'Parent', h1,...
             'EdgeColor','r','EraseMode','none');
         drawnow;     
         setappdata(p1,'waitbar__data__',0)
     
         p2 = patch(xpatch,ypatch,'r', 'Parent', h2,...
             'EdgeColor','r','EraseMode','none');
         drawnow;
         setappdata(p2,'waitbar__data__',0)
     
         % Create a text box to display the progress value
         color1 = 'k'; % Black
         color2 = 'w'; % white
         backgroundcolor = get(f, 'color');
     
         textPos1 = [axPos1(1)+ axPos1(3) + 80, axPos1(2)+26, 50, 20];
         h3 = uicontrol('Parent', f, ...
             'style','text',...
             'string','0 %', ...
             'FontSize', axFontSize,...
             'Position', textPos1, ...
             'Visible', 'on', ...
             'Tag', 'ProgText1', ...
             'BackgroundColor', backgroundcolor);
     
         textPos2 = [axPos2(1)+ axPos2(3) + 80, axPos2(2)+10, 50, 20];
         h4 = uicontrol('Parent', f, ...
             'style','text',...
             'string','0 %', ...
             'FontSize', axFontSize,...
             'Position', textPos2, ...
             'Visible', 'on', ...
             'Tag', 'ProgText2', ...
             'BackgroundColor', backgroundcolor);
     
     
     
    end

  2. #2
    Rédacteur/Modérateur

    Avatar de Jerome Briot
    Homme Profil pro
    Freelance mécatronique - Conseil, conception et formation
    Inscrit en
    Novembre 2006
    Messages
    20 302
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Freelance mécatronique - Conseil, conception et formation

    Informations forums :
    Inscription : Novembre 2006
    Messages : 20 302
    Points : 52 882
    Points
    52 882
    Par défaut
    Ajoute ce bout de code à la fin du programme :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
         textPos3 = [axPos2(1), axPos2(2)-20, 200, 20];
         h5 = uicontrol('Parent', f, ...
             'style','text',...
             'string', ['Start time: ' datestr(now,13)], ...
             'FontSize', axFontSize,...
             'Position', textPos3, ...
             'Visible', 'on', ...
             'Tag', 'ProgText3', ...
             'BackgroundColor', backgroundcolor);
    Images attachées Images attachées  
    Ingénieur indépendant en mécatronique - Conseil, conception et formation
    • Conception mécanique (Autodesk Fusion 360)
    • Impression 3D (Ultimaker)
    • Développement informatique (Python, MATLAB, C)
    • Programmation de microcontrôleur (Microchip PIC, ESP32, Raspberry Pi, Arduino…)

    « J'étais le meilleur ami que le vieux Jim avait au monde. Il fallait choisir. J'ai réfléchi un moment, puis je me suis dit : "Tant pis ! J'irai en enfer" » (Saint Huck)

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

Discussions similaires

  1. Ajouter du texte dans une edit box
    Par raf_gug dans le forum MFC
    Réponses: 10
    Dernier message: 23/05/2013, 10h00
  2. Comment ajouter ce code pour afficher l'heure
    Par makin_toch dans le forum ASP.NET
    Réponses: 11
    Dernier message: 22/04/2011, 16h48
  3. [Système] Afficher un texte toutes les heures
    Par morgan47 dans le forum Langage
    Réponses: 4
    Dernier message: 16/12/2006, 23h39
  4. Ajout de texte dans un fichier
    Par willowII dans le forum Entrée/Sortie
    Réponses: 7
    Dernier message: 24/08/2004, 19h30
  5. [TWebBrowser] Comment ajouter du texte ?
    Par el_diablos dans le forum Composants VCL
    Réponses: 18
    Dernier message: 06/07/2004, 09h17

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