Add items to popupmenu through code (GUIDE)

11 ビュー (過去 30 日間)
Björn Persson
Björn Persson 2016 年 12 月 28 日
コメント済み: Björn Persson 2016 年 12 月 28 日
Hi. I am not too familiar with GUIDE yet, I just started using it. I want to add items to the popupmenu from a textfile. I found a way to do it using uicontrol(), but then I don't have the same options as I. What I do is:
signalGenerators=importdata('availableSignalGenerators.txt').';
handleToListbox = uicontrol('Style', 'popup','Position', [20 60 200 60], 'String', signalGenerators);
This creates a popup-menu with all the available signal generators listed in availableSignalGenerators.txt. I don't see how I could import entries like this in GUIDE. Please help!

採用された回答

Image Analyst
Image Analyst 2016 年 12 月 28 日
I don't know what this means "I don't have the same options as I."
Anyway, just place a popup on your figure within GUIDE using the toolbar. Then set it's string value:
signalGenerators=importdata('availableSignalGenerators.txt').';
handles.popup1.String = signalGenerators; % If using R2014b or later
% OR
set(handles.popup1.String, 'String', signalGenerators); % R2014a or earlier
You can do that in either the OpeningFcn() or OutputFcn() - both get executed before your GUI is made available to the user.
  1 件のコメント
Björn Persson
Björn Persson 2016 年 12 月 28 日
Perfect, thanks! I just had to modify your code to
handles.popupmenu1.String = signalGenerators;
to match the default values.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by