MATLAB Answers

0

gui programticly , issue with uipanel

Aleksander さんによって質問されました 2013 年 6 月 26 日
hi. i have a issue when creating a gui programaticly, the uipanel will not show it`s borders, and also not the title.
the code:
% code
function varargout = multi_tool(varargin)
%ensure this appliction has the only window
close all
clear all
%open the main gui window
try
handles.mainfig = figure('menu','none','toolbar','figure','units','normalized','outerposition',[0 0 1 1])
catch
disp 'error with setting screen size for the application'
end
%determine size of the created figure
set(gcf,'units','pixels')
fig_size = get(gcf,'position')
%create panel to contain the bellow buttons
handles.pan1 = uipanel('parent',handles.mainfig,'BorderType','etchedout','Title','PLEASE SELECT FROM BELLOW OPTION','FontSize',12,'position',[0 0 fig_size(3)*1 fig_size(4)*1])
pan1_size = get(handles.pan1,'position')
%create selection buttons
handles.But1 = uicontrol('parent',handles.pan1,'Style','pushbutton','String','APP LAUNCHER','Position',[pan1_size(3)*0.05 pan1_size(4)*0.88 pan1_size(3)*0.9 pan1_size(4)*0.1])
set(handles.But1, 'callback', {@applauncher, handles})
handles.But2 = uicontrol('parent',handles.pan1,'Style','pushbutton','String','DEBUGING TOOLS','Position',[pan1_size(3)*0.05 pan1_size(4)*0.68 pan1_size(3)*0.9 pan1_size(4)*0.1])
set(handles.But2, 'callback', {@Debuging_Tools, handles})
handles.But3 = uicontrol('parent',handles.pan1,'Style','pushbutton','String','YAW COMPANSATED ROLL/PITCH CALCULATOR','Position',[pan1_size(3)*0.05 pan1_size(4)*0.48 pan1_size(3)*0.9 pan1_size(4)*0.1])
handles.But4 = uicontrol('parent',handles.pan1,'Style','pushbutton','String','HMS, HELIDECK MRU CALCULATOR','Position',[pan1_size(3)*0.05 pan1_size(4)*0.28 pan1_size(3)*0.9 pan1_size(4)*0.1])
end
end

  2 件のコメント

Jan
2013 年 6 月 26 日
clear all on top of a function is a pure waste of time: There cannot be any benefit for deleting formerly created variables, because functions have their own workspace, which is clean and free at the beginning. In addition the brute clearing removes all breakpoints, such that a debugging is impeded massively. Finally removing all loaded functions from the memory requires a time-consuming reloading from the disk. Therefore I recommend, to avoid clear all under all cirdumstances.
Aleksander 2013 年 6 月 26 日
Thanks for the tips, i am a novice when it comes to matlab, so this realy helps :)

サインイン to comment.

1 件の回答

Tom
回答者: Tom
2013 年 6 月 26 日
 採用された回答

It is there, but it's off the screen because of the units: if you set the uipanel Units field to 'Pixels' before you set the position, it should appear

  0 件のコメント

サインイン to comment.



Translated by