MATLAB date selection popup calendar for gui

前端 未结 3 1480
长情又很酷
长情又很酷 2021-01-18 13:46

Does anyone know of a method to display a popup date selection calendar in a MATLAB gui? I know the financial toolbox has a uicalendar function, but unfortunate

3条回答
  •  萌比男神i
    2021-01-18 14:20

    I'd start with the calendar() function which outputs a matrix containing the calendar for any month. I assume you could combine this with a user-clickable interface to retrieve a specific date?

    The following code is really ugly, but could help you get started...

     WINDOW_WIDTH = 300;
     WINDOW_HEIGHT = 200;
    f= figure('Position',[300 300 WINDOW_WIDTH WINDOW_HEIGHT]);
    
     NB_ROWS = 6;
     NB_COLS = 7;
     width = round(WINDOW_WIDTH/NB_COLS);
     height = round(WINDOW_HEIGHT/NB_ROWS);
     buttons = nan(NB_ROWS,NB_COLS);
     dates = calendar();
    
     for row = 1:NB_ROWS
        for col = 1:NB_COLS
           if dates(row,col) == 0
              mydate = '';
           else
              mydate = sprintf('%i', dates(row,col));
           end
           buttons(row,col) = uicontrol('Style', 'PushButton', ...
              'String', mydate, ...
              'Position', [(col-1)*width (NB_ROWS - row)*height width height]);
        end
     end
    

提交回复
热议问题