Matlab GUI elements disappear on newer version of Matlab
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I just upgraded from matlab 2014 to matlab 2022 and a gui i was working on which was fine on matlab 2014 has all it's pushbutton missing and an entire buttongroup missing and other things and i don't really understand why. Here is the difference between the gui in the two versions of matlab :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1201453/image.jpeg)
and here is the gui code if anyone can help : (Am i using outdated code or something like that ?)
function h0=kgui4n
%KGUI4N construction de la boite de dialogue pour KGEXEC4N
%CAVIAR2, © ALSTOM + OL 1999/12-2003/03
blanc=[1 1 1];
gris=blanc*0.75;
global language
global first_time
lg=find(strcmp(getpref('kgexec4','LangGui','fr'),{'fr','en'}));
if (first_time==1)
if(language==1)
lg=1;
else
lg=2;
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% montre la fenêtre si elle existe déjà
hFig=findobj(allchild(0),'Tag','kgui4n');
if ~isempty(hFig), figure(hFig(1)), return, end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%chaines ds ttes les langues
ch00={
'Norme harmonique'
'Harmonic standard'};
ch02={
'Annuler'
'Cancel'};
ch05={
'Choix du gabarit à tracer en superposition sur les spectres'
'Choose harmonic gauge to plot over spectrums'};
ch10={
'Aucune norme en courant '
'None'};
ch20={
'CEI 61000-2-2 (2018)'
'IEC 61000-2-2 (2018)'};
ch21={
'Limite de susceptibilité des équipements BT selon la CEI1000-2-2'
'Susceptibility limit of LV equipments according to IEC1000-2-2'};
ch31={
'Limite en courant selon le contrat Emeraude d''EDF'
'Current limits according to EDF Emeraude agreement (France)'};
ch32={
'Courant souscrit en ampères'
'Courant souscrit en ampères'};
ch41={
'Limite en courant selon la norme britannique G5/3'
'Current limits according to UK G5/3 standard'};
ch43={
'Niveau de tension considéré'
'Voltage level to be considered'};
ch50={
'GB/T 14549 (1993) (Chine)'
'GB/T 14549 (1993) (China)'};
ch51={
'Limite en courant selon la norme chinoise'
'Current limits according to chineese standards'};
ch53={
'Niveau de tension considéré'
'Voltage level to be considered'};
ch54={
'Puissance de court circuit réelle'
'Real short circuit capacity'};
ch55={
'Coefficient de courant'
'Ratio of negotiated capacity'};
ch60={
'Gabarit libre en tension'
'User defined voltage gauge'};
ch61={
'Gabarit quelconque sur les tensions'
'User defined limits for voltages'};
ch63={
'Limite pour tous les rangs entiers à partir de 2 (%)'
'Limit for all integer harmonic orders beginning with 2nd order (%)'};
ch70={
'Gabarit libre en courant'
'User defined current gauge'};
ch71={
'Gabarit quelconque sur les courants'
'User defined limits for currents'};
ch73={
'Limite pour tous les rangs entiers à partir de 2 (A)'
'Limit for all integer harmonic orders beginning with 2nd order (A)'};
ch81={
'Limite en courant selon IEEE519 section 10'
'Current limit according to IEEE519 section 10'};
ch83={
'Niveau de tension considéré'
'Voltage level to be considered'};
ch85={
'Courant maximum IL (A)'
'Maximum load current IL (A)'};
ch87={
'ISC/IL = courant de court-circuit sur courant maximum'
'ISC/IL = Short-circuit current divided by maximum current'};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%figure
h0=figure(...
'Filename','kgui4n.m',...
'Units','characters',...
'DefaultUicontrolUnits','characters',...
'Color',gris,...
'IntegerHandle','off',...
'MenuBar','none',...
'Name',ch00{lg},...
'NumberTitle','off',...
'Position',[100 30 110 25],...
'Resize','on',...
'Tag','NormeDlg',...
'WindowStyle','modal',...
'ToolBar','none');
%titre
uicontrol(h0,'Style','text',...
'BackgroundColor',gris,...
'HorizontalAlignment','center',...
'Position',[10 22 85 1],...
'String',[ch05{lg} ' :']);
%bouton OK
handles.X=0;
handles.button = uicontrol(h0,'Style','pushbutton',...
'BackgroundColor',gris,...
'Position',[27 0.5 16 2],...
'String','OK',...
'Tag','NormeOK',...
'Callback',@buttonCB);
guidata(h0,handles);
%bouton annuler
uicontrol(h0,'Style','pushbutton',...
'BackgroundColor',gris,...
'Callback','close(gcbf)',...
'Position',[51 0.5 16 2],...
'String',ch02{lg});
%bouton aide
uicontrol(h0,'Style','pushbutton',...
'BackgroundColor',gris,...
'Callback','helpwin NormesHarmo',...
'Position',[75 0.5 7 2],...
'String','?');
%Buttongroup1
bg = uibuttongroup(h0,'Visible','on',...
'BackgroundColor',gris);
%Aucune
ra(1) = uicontrol(bg,'Style','radiobutton',...
'BackgroundColor',gris,...
'Position',[5 20 30 1.7],...
'String',ch10{lg},...
'Tag','Norme0');
uicontrol(h0,'Style','text',...
'HorizontalAlignment','left',...
'BackgroundColor',gris,...
'Position',[40 20.35 7 1],...
'String','--',...
'Tag','Param0');
%IEEE519
ra(3) = uicontrol(bg,'Style','radiobutton',...
'Callback',@Scr519,...
'BackgroundColor',gris,...
'Position',[5 18 30 1.7],...
'String','IEEE519 (2022)',...
'Tag','Norme519',...
'TooltipString','Param519-1');
prmsA{3} = uicontrol(h0,'Style','popupmenu',...
'BackgroundColor',blanc,...
'Callback',@Scr519,...
'Position',[40 18 17 1.7],...
'String',['120V-69kV|70-161kV|162kV & +'],...
'Tag','Param519-1',...
'TooltipString',ch83{lg});
prmsA{3}(2)= uicontrol(h0,'Style','edit',...
'BackgroundColor',blanc,...
'HorizontalAlignment','right',...
'Position',[58 18 8 1.7],...
'String','1',...
'Tag','Param519-2',...
'TooltipString',ch85{lg});
uicontrol(h0,'Style','text',...
'BackgroundColor',gris,...
'HorizontalAlignment','left',...
'Position',[66.5 18.35 4 1],...
'String','A');
prmsA{3}(3)=uicontrol(h0,'Style','popupmenu',...
'BackgroundColor',blanc,...
'Position',[71 18 18 1.7],...
'String','Iscr<20|20<Iscr<50|50<Iscr<100|100<Iscr<1k|1000<Iscr',...
'Tag','Param519-3',...
'TooltipString',ch87{lg});
prmsA{3}(4)=uicontrol(h0,'Style','popupmenu',...
'BackgroundColor',blanc,...
'Position',[90 18 17 1.7],...
'String',['6 pulses|12 pulses|18 pulses|24 pulses|30 pulses|36 pulses|42 pulses|48 pulses'],...
'Tag','Param519-4');
%Emeraude
ra(4) = uicontrol(bg,'Style','radiobutton',...
'BackgroundColor',gris,...
'Position',[5 16 30 1.7],...
'String','RTE 15-07-06/Enedis-PRO-RES_50E ',...
'Tag','NormeEm',...
'TooltipString','ParamEm');
prmsA{4}=uicontrol(h0,'Style','popupmenu',...
'BackgroundColor',blanc,...
'HorizontalAlignment','right',...
'Position',[40 16 38 1.7],...
'String',['HTA (1kV<Un<=50kV)|HTB1-HTB2 (50kV<Un<=350kV)|HTB3 (350kV<Un<=500kV) '],...
'Tag','ParamEm',...
'TooltipString',ch32{lg});
prmsA{4}(2)=uicontrol(h0,'Style','edit',...
'BackgroundColor',blanc,...
'HorizontalAlignment','right',...
'Position',[79.5 16 10 1.7],...
'String','1',...
'Tag','ParamEm-2',...
'TooltipString',ch32{lg});
uicontrol(h0,'Style','text',...
'BackgroundColor',gris,...
'HorizontalAlignment','left',...
'Position',[89.5 16.35 4 1],...
'String','A');
prmsA{4}(3)=uicontrol(h0,'Style','edit',...
'HorizontalAlignment','right',...
'BackgroundColor',blanc,...
'Enable','off',...
'Position',[94 16 8 1.7],...
'String','1',...
'Tag','ParamEm-3',...
'Value',1);
uicontrol(h0,'Style','text',...
'BackgroundColor',gris,...
'HorizontalAlignment','left',...
'Position',[102.5 16.35 5 1],...
'String','Coefficient');
%Chine
ra(5) = uicontrol(bg,'Style','radiobutton',...
'BackgroundColor',gris,...
'Position',[5 14 30 1.7],...
'String',ch50{lg},...
'Tag','NormeCh',...
'TooltipString','ParamCh');
prmsA{5}=uicontrol(h0,'Style','popupmenu',...
'BackgroundColor',blanc,...
'Enable','off',...
'Position',[40 14 17 1.7],...
'String',['380V|6kV|10kV|35kV|66kV|110kV|220kV'],...
'Tag','ParamCh',...
'TooltipString',ch53{lg},...
'Value',1);
prmsA{5}(2)=uicontrol(h0,'Style','edit',...
'HorizontalAlignment','right',...
'BackgroundColor',blanc,...
'Enable','off',...
'Position',[57.5 14 8 1.7],...
'String','1',...
'Tag','ParamCh-2',...
'TooltipString',ch54{lg},...
'Value',1);
uicontrol(h0,'Style','text',...
'BackgroundColor',gris,...
'HorizontalAlignment','left',...
'Position',[66 14.35 5 1],...
'String','MVA');
prmsA{5}(3)=uicontrol(h0,'Style','edit',...
'HorizontalAlignment','right',...
'BackgroundColor',blanc,...
'Enable','off',...
'Position',[73 14 8 1.7],...
'String','1',...
'Tag','ParamCh-3',...
'TooltipString',ch55{lg},...
'Value',1);
uicontrol(h0,'Style','text',...
'BackgroundColor',gris,...
'HorizontalAlignment','left',...
'Position',[81.5 14.35 5 1],...
'String','Coefficient');
%gabarit libre en courant
ra(2) = uicontrol(bg,'Style','radiobutton',...
'BackgroundColor',gris,...
'Position',[5 12 34 1.7],...
'String',ch70{lg},...
'Tag','NormeUsrI',...
'TooltipString','ParamUsrI');
prmsA{2}= uicontrol(h0,'Style','edit',...
'BackgroundColor',blanc,...
'Enable','off',...
'HorizontalAlignment','left',...
'Position',[40 12 30 1.7],...
'String','10./[2:50]',...
'Tag','ParamUsrI',...
'TooltipString',ch73{lg});
%Buttongroup2
bg2 = uibuttongroup(h0,'Visible','on',...
'BackgroundColor',gris);
%1000-2-2
rb(1) = uicontrol(bg2,'Style','radiobutton',...
'BackgroundColor',gris,...
'Position',[5 6.5 30 1.7],...
'String',ch20{lg},...
'Tag','Norme1000',...
'TooltipString','Param1000');
prmsB{1}=uicontrol(h0,'Style','popupmenu',...
'Callback',@Scr1000,...
'BackgroundColor',blanc,...
'Position',[40 6.5 23 1.7],...
'String',['réseau public|réseau industriel'],...
'Tag','Param1000');
prmsB{1}(2)=uicontrol(h0,'Style','popupmenu',...
'BackgroundColor',blanc,...
'Position',[65 6.5 23 1.7],...
'String',['LV (Un<=1kV)|MV (1kV<Un<=35kV)|HV (35kV<Un<=230kV)|EHV (230kV<Un)'],...
'Tag','Param1000-2');
prmsB{1}(3)=uicontrol(h0,'Style','edit',...
'HorizontalAlignment','right',...
'BackgroundColor',blanc,...
'Position',[88.5 6.5 8 1.7],...
'String','1',...
'Tag','Param1000-3',...
'Value',1);
uicontrol(h0,'Style','text',...
'BackgroundColor',gris,...
'HorizontalAlignment','right',...
'Position',[97 6.85 5 1],...
'String','Coefficient');
%gabarit libre en tension
rb(2) = uicontrol(bg2,'Style','radiobutton',...
'BackgroundColor',gris,...
'Position',[5 4.5 34 1.7],...
'String',ch60{lg},...
'Tag','NormeUsrV',...
'TooltipString','ParamUsrV');
prmsB{2}=uicontrol(h0,'Style','edit',...
'BackgroundColor',blanc,...
'Enable','off',...
'HorizontalAlignment','left',...
'Position',[40 4.5 48 1.7],...
'String','10./[2:50]',...
'Tag','ParamUsrV',...
'TooltipString',ch63{lg});
%EN 50160
rb(3) = uicontrol(bg2,'Style','radiobutton',...
'BackgroundColor',gris,...
'Position',[5 2.5 30 1.7],...
'String','EN 50160 (2019)',...
'Tag','Norme50160',...
'TooltipString','Param50160');
prmsB{3}=uicontrol(h0,'Style','popupmenu',...
'BackgroundColor',blanc,...
'Position',[40 2.5 17 1.7],...
'String',['LV (230V-1kV)|MV (1-36kV)|HV (36-150kV)|A-dérivation'],...
'Tag','Param50160',...
'Value',1);
prmsB{3}(2)=uicontrol(h0,'Style','edit',...
'HorizontalAlignment','right',...
'BackgroundColor',blanc,...
'Enable','off',...
'Position',[58.5 2.5 8 1.7],...
'String','1',...
'Tag','Param50160-2',...
'Value',1);
uicontrol(h0,'Style','text',...
'BackgroundColor',gris,...
'HorizontalAlignment','left',...
'Position',[67 2.85 5 1],...
'String','Coefficient');
%G5/5
rb(4) = uicontrol(bg2,'Style','radiobutton',...
'BackgroundColor',gris,...
'Position',[5 8.5 30 1.7],...
'String','G5/5 (2020)',...
'Tag','NormeG55',...
'TooltipString','ParamG55');
prmsB{4}=uicontrol(h0,'Style','popupmenu',...
'BackgroundColor',blanc,...
'Position',[40 8.5 23 1.7],...
'String',['Un<=0.4kV|0.4<Un<=25kV|25kV<Un<66kV|66kV<Un<=230kV|Un>230kV'],...
'Tag','ParamG55',...
'TooltipString',ch43{lg});
prmsB{4}(2)=uicontrol(h0,'Style','edit',...
'HorizontalAlignment','right',...
'BackgroundColor',blanc,...
'Enable','off',...
'Position',[63.5 8.5 8 1.7],...
'String','1',...
'Tag','ParamG55-2',...
'Value',1);
uicontrol(h0,'Style','text',...
'BackgroundColor',gris,...
'HorizontalAlignment','left',...
'Position',[72 8.85 5 1],...
'String','Coefficient');
%Aucune
rb(5) = uicontrol(bg2,'Style','radiobutton',...
'BackgroundColor',gris,...
'Position',[5 10.25 30 1.7],...
'String','Aucune norme en tension',...
'Tag','Norme02');
uicontrol(h0,'Style','text',...
'HorizontalAlignment','left',...
'BackgroundColor',gris,...
'Position',[40 10.5 7 1],...
'String','--',...
'Tag','Param02');
0 Kommentare
Akzeptierte Antwort
Jan
am 21 Nov. 2022
The uibuttongroup hides objects, which have been created before in modern Matlab versions.
Set a position of the uibuttongroup's and set the position of the buttons inside relative to the parent location.
You can see the effect by using different background colors for the uibuttongroups and step through the code line by line.
4 Kommentare
Jan
am 21 Nov. 2022
Does it help to define the units?
bg = uibuttongroup('Position',[44 95 215 50]);
r1 = uicontrol(bg,'Style','radiobutton',...
'Position',[8 3 200 20], ...
'Units', 'pixels', ... % <== here
'String','Export des amplitudes et phases',...
'Tag','A&P1',...
'Value',1);
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!