【问题标题】:Matlab GUI Design Optical Effects (Transition)Matlab GUI 设计光学效果(过渡)
【发布时间】:2012-02-13 16:24:14
【问题描述】:

我设计了一个带有 uitabs 的 GUI。我想在更改所选选项卡时实现平滑过渡(光学效果)。为此,我编写了以下回调:

function SelectionChangeCbk(src,evt) 
  oldTab = evt.OldValue;
  newTab = evt.NewValue;
  set([oldTab,newTab],'Visible','off');
  drawnow;
  pause(2);
  set(newTab,'Visible','on');


  end

但是,我可以获得我的目标,因为这不起作用(我有两个选项卡。更改之前选择的选项卡称为 oldTab,更改后选择的新选项卡称为 newTab。我希望在更改时从 oldTab 到 newTab,首先 oldTab 和 newTab 变得不可见,然后等待两秒钟,newTab 才出现)。

我已经尝试过WindowAPI 应用程序,但它只适用于图形句柄。

P.D.:这是完整的代码:

 function AA
  fh = figure('Units','characters','Position',[-200.2 -77 214.8 46.154],...
      'Menu','none','Toolbar','none','NumberTitle','off');
  movegui(fh,'center');
  warning off MATLAB:uitabgroup:OldVersion  % turn off warning
  htab = uitabgroup('Parent',fh,'BackgroundColor','k',...
      'SelectionChangeCallback',@SelectionChangeCbk);
  th1 = uitab('parent',htab,'title','Tab#1');
  hPan1 = uipanel(th1,'title','Panel1','Units','characters',...
      'Position',[27.24 27.163 217.92 13.038],'BorderType','line',...
      'ForegroundColor','w','BackgroundColor','k');
  uicontrol(hPan1,'Style','text','String','Text#1',...
      'Units','normalized','Position',[0.117 0.617 0.208 0.128],...
      'ForegroundColor','w','BackgroundColor','k');
  uicontrol(hPan1,'Style','edit','String','300','Units',...
      'normalized','Position',[0.354 0.623 0.228 0.128],...
      'ForegroundColor','k','BackgroundColor','w');
  uicontrol(hPan1,'Style','text','String','Text#2',...
      'Units','normalized','Position',[0.156 0.248 0.166 0.128],...
      'ForegroundColor','w','BackgroundColor','k');
  uicontrol(hPan1,'Style','edit','String','1000','Units',...
      'normalized','Position',[0.354 0.259 0.228 0.128],...
      'ForegroundColor','k','BackgroundColor','w');
  hPan2 = uipanel(th1,'title','Panel2','Units',...
      'characters','Position',[27.24 7 217.92 13.038],...
      'ForegroundColor','w','BackgroundColor','k','BorderType','line');
  uicontrol(hPan2,'Style','text','String',...
      'Text#3','Units','normalized',...
      'Position',[0.112 0.632 0.215 0.128],'ForegroundColor',...
      'w','BackgroundColor','k');
  uicontrol(hPan2,'Style','edit','String','100','Units',...
      'normalized','Position',[0.354 0.618 0.228 0.148],'ForegroundColor',...
      'k','BackgroundColor','w');
  uicontrol(hPan2,'Style','text','String','Text#4',...
      'Units','normalized','Position',[0.171 0.248 0.15 0.128],'FontSize',...
      9,'ForegroundColor','w','BackgroundColor','k');
  uicontrol(hPan2,'Style','edit','String','100','Units',...
      'normalized','Position',[0.354 0.235 0.228 0.148],...
      'ForegroundColor','k','BackgroundColor','w');
  th2 = uitab('parent',htab,'title','Tab#2','Units',...
      'characters');
  hPan3 = uipanel(th2,'title','Panel3','Units','characters',...
      'Position',[4.248 24.462 217.552 16.923],'ForegroundColor','w',...
      'BackgroundColor','k');
  hPan31 = uipanel(hPan3,'title','Panel 3.1','Units','normalized',...
      'Position',[0.017 0.13 0.496 0.816],'ForegroundColor','w',...
      'BackgroundColor','k','BorderType','line');
  uicontrol(hPan31,'Style','text','String','Text311','Units',...
      'normalized','Position',[0.079 0.711 0.34 0.171],'FontSize',9,...
      'ForegroundColor','w','BackgroundColor','k');
  uicontrol(hPan31,'Style','edit','String','1000',...
      'Units','normalized','Position',...
      [0.455 0.8 0.242 0.099],'ForegroundColor','k',...
      'BackgroundColor','w');
  uicontrol(hPan31,'Style','edit','String','1000',...
      'Units','normalized','Position',[0.455  0.451 0.241 0.133],...
      'ForegroundColor','k','BackgroundColor','w');
  uicontrol(hPan31,'Style','text','String','Label','Units','normalized',...
      'Position',[0.741 0.437 0.101 0.151],'ForegroundColor',...
      'w','BackgroundColor','k');
  uicontrol(hPan31,'Style','edit','String','4','Units',...
      'normalized','Position',[0.862 0.458 0.1 0.133],'ForegroundColor',...
      'k','BackgroundColor','w');
  hPan32 = uipanel(hPan3,'title','Panel 3.2','Units',...
      'normalized','Position',[0.53 0.13 0.231 0.816],...
      'ForegroundColor','w','BackgroundColor','k','BorderType',...
      'line');
  uicontrol(hPan32,'Style','text','String','TEXT34',...
      'Value',0,'Units','normalized','Position',[0.094 0.483 0.443 0.133],...
      'FontSize',9,'ForegroundColor','w','BackgroundColor','k');
  uicontrol(hPan32,'Style','edit','String','10',...
      'Units','normalized','Position',[0.63 0.47 0.275 0.133],'FontSize',...
      9,'ForegroundColor','k','BackgroundColor','w');
  hPan33 = uipanel(hPan3,'title','Panel 3.3','Units',...
      'normalized','Position',[0.778 0.13 0.205 0.816],...
      'ForegroundColor','w','BackgroundColor','k','BorderType','line');
  uicontrol(hPan33,'Style','text','String','TEXT34',...
      'Value',0,'Units','normalized','Position',[0.094 0.483 0.443 0.133],...
      'FontSize',9,'ForegroundColor','w','BackgroundColor','k');
  uicontrol(hPan33,'Style','edit','String','10',...
      'Units','normalized','Position',[0.63 0.47 0.275 0.133],'FontSize',...
      9,'ForegroundColor','k','BackgroundColor','w');
  hPan4 = uipanel(th2,'title','Panel 4','Units','characters',...
      'Position',[4.248 0.831 264.228 27],'ForegroundColor','w',...
      'BackgroundColor','k');
  hPan41 = uipanel(hPan4,'title','Panel 4.1','Units','normalized',...
      'Position',[0.012 0.521 0.3 0.48],'ForegroundColor','w',...
      'BackgroundColor','k','BorderType','line');
  uicontrol(hPan41,'Style','text','String','TEXT34',...
      'Value',0,'Units','normalized','Position',[0.094 0.483 0.443 0.133],...
      'FontSize',9,'ForegroundColor','w','BackgroundColor','k');
  uicontrol(hPan41,'Style','edit','String','10',...
      'Units','normalized','Position',[0.63 0.47 0.275 0.133],'FontSize',...
      9,'ForegroundColor','k','BackgroundColor','w');
  % Subpanel "Intervalo de análisis"
  hPan42 = uipanel(hPan4,'title','Panel 4.2','Units',...
      'normalized','Position',[0.012 0.02 0.3 0.48],'ForegroundColor','w',...
      'BackgroundColor','k','BorderType','line');
  uicontrol(hPan42,'Style','text','String','TEXT34',...
      'Value',0,'Units','normalized','Position',[0.094 0.483 0.443 0.133],...
      'FontSize',9,'ForegroundColor','w','BackgroundColor','k');
  uicontrol(hPan42,'Style','edit','String','10',...
      'Units','normalized','Position',[0.63 0.47 0.275 0.133],'FontSize',...
      9,'ForegroundColor','k','BackgroundColor','w');
  hPan43 = uipanel(hPan4,'title','Panel 4.3',...
      'Units','normalized','Position',[0.324 0.02 0.261 0.98],...
      'ForegroundColor','w','BackgroundColor','k','BorderType','line');
  uicontrol(hPan43,'Style','text','String','TEXT34',...
      'Value',0,'Units','normalized','Position',[0.094 0.483 0.443 0.133],...
      'FontSize',9,'ForegroundColor','w','BackgroundColor','k');
  uicontrol(hPan43,'Style','edit','String','10',...
      'Units','normalized','Position',[0.63 0.47 0.275 0.133],'FontSize',...
      9,'ForegroundColor','k','BackgroundColor','w');
  hPan44 = uipanel(hPan4,'title','Panel 4.4',...
      'Units','normalized','Position',[0.597 0.02 0.391 0.98],...
      'ForegroundColor','w','BackgroundColor','k','BorderType','line');
  uicontrol(hPan44,'Style','text','String','TEXT34',...
      'Value',0,'Units','normalized','Position',[0.094 0.483 0.443 0.133],...
      'FontSize',9,'ForegroundColor','w','BackgroundColor','k');
  uicontrol(hPan44,'Style','edit','String','10',...
      'Units','normalized','Position',[0.63 0.47 0.275 0.133],'FontSize',...
      9,'ForegroundColor','k','BackgroundColor','w');

  function SelectionChangeCbk(src,evt) 
  oldTab = evt.OldValue;
  newTab = evt.NewValue;
  set([oldTab,newTab],'Visible','off');
  drawnow;
  pause(2);
  set(newTab,'Visible','on');


  end
  end

【问题讨论】:

  • “但是,我可以得到我的目标(这不起作用)”是什么意思?
  • 您不想要一些柔和的过渡,而不仅仅是暂停吗?
  • 很抱歉解释不当。非常感谢您的评论。

标签: user-interface matlab tabs look-and-feel


【解决方案1】:

我不会使用uitabgroup。它没有被记录,它的行为是未定义的。相反,请考虑使用 Matlab Central 中的 GUI Layout toolbox 包。顺便说一句,可见性是通过将面板移动到屏幕上看不到的较远位置来处理的(如 (-100000,-100000) ) - 它似乎比设置可见性更强大。

无论如何,没有简单的方法可以在 Matlab GUI 中实现平滑的淡入/淡出过渡,至少没有文档记录。

【讨论】:

  • 非常感谢您的回答和链接。
猜你喜欢
  • 2011-09-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多