File: uicontrol.sci

package info (click to toggle)
scilab 5.2.2-9
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 334,832 kB
  • ctags: 52,586
  • sloc: xml: 526,945; ansic: 223,590; fortran: 163,080; java: 56,934; cpp: 33,840; tcl: 27,936; sh: 20,397; makefile: 9,908; ml: 9,451; perl: 1,323; cs: 614; lisp: 30
file content (109 lines) | stat: -rw-r--r-- 3,100 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) ????-2008 - INRIA
//
// This file is distributed under the same license as the Scilab package.
//

function add_list_item()
  if e1<>0&l1<>0 then
  new = get(e1,'String')
  list_item = [list_item  new];
  set(l1,'String',strcat(list_item,'|'));
  list_item=resume(list_item)
  end
endfunction

function myuidialog()
  list_item = ["rouge"  "vert"  "tomate"  "chevre" "Truc"];
  e1=0;l1 =0
  initial=strcat(list_item,'|')

  f = figure("figure_name", "Uicontrols demo",...
      "Position",[50 50 300 330],...
      "BackgroundColor",[0.9 0.9 0.9],...
      "Units", "pixels");
  
  // Remove Scilab menus
  delmenu(f.figure_id, gettext("&File"));
  delmenu(f.figure_id, gettext("&Tools"));
  delmenu(f.figure_id, gettext("&Edit"));
  delmenu(f.figure_id, gettext("&?"));
  
  m=uimenu(f,"label", "Menu");
  // create an item on the menu bar
  m1=uimenu(m,"label", "Launch plot3d1", "callback", "plot3d1()");
  m2=uimenu(m,"label", "Exit figure", "callback", "fin=%t;");
  m3=uimenu(m,"label", "Quit scilab", "callback", "exit");

  fr1= uicontrol(f, "Position"  , [5 5 160 100],...
		 "Style"     , "frame",...
		 "BackgroundColor",[0.9 0.9 0.9]);


  t1 = uicontrol(f, "Position"  , [15 94 60 20],...
		 "Style"     , "text",...
		 "String"    , "an entry box",...
		 "fontsize"  , 10,...
		 "BackgroundColor",[0.9 0.9 0.9]);

  e1 = uicontrol(f, "Position"  , [10 50 150 25],...
		 "Style"     , "edit",...
		 "String"    , "hello",...
		 "BackgroundColor",[1 1 1]);

  b1 = uicontrol(f, "Position"  , [50 10 70 20],...
		 "Style"     , "pushbutton",...
		 "String"    , "add in list",...
		 "callback"  , "add_list_item()" );  

  l1 = uicontrol(f, "Position"  , [180 10 100 150],...
		 "Style"     , "listbox",...
		 "String"    ,  initial,...
		 "BackgroundColor",[1 1 1]);       

  b2 = uicontrol(f, "Position"  , [200 170 70 20],...
		 "Style"     , "pushbutton",...
		 "String"    , "num item",...
		 "callback"  , "disp(get(l1,''value''))");

  b3 = uicontrol(f, "Position"  , [10 170 50 20],...
		 "Style"     , "pushbutton",...
		 "String"    , "Quit",...
		 "FontWeight", "bold",...
		 "BackgroundColor",[0 0.7 1],...
		 "callback"  , "fin=%t");

  fr2= uicontrol(f, "Position"  , [137 128 29 19],...
		 "Style"     , "frame",...
		 "BackgroundColor",[0.9 0.9 0.9]);

  t2 = uicontrol(f, "Position"  , [140 130 25 15],...
		 "Style"     , "text",...
		 "String"    , "50",...
		 "BackgroundColor",[1 1 1]);
  
  s1 = uicontrol(f, "Position"  , [10 130 120 15],..
		 "Style"     , "slider",...
		 "Min"       , 0,...
		 "Max"       , 100,...
		 "Value"     , 50,...
		 "SliderStep", [2 10],...
		 "callback"  , "set(t2,''String'',string(get(gcbo,''Value'')))");
  // Note pour un slider la position de ref est ulp

  p1 = uicontrol(f, "Position"  , [90 170 70 20],...
		 "Style"     , "popupmenu",...
		 "String"    , "popup|item1|item2|item3|toto|truc|bidule");

  fin=%f
  while ~fin
    sleep(1)
    if findobj("label", "Menu")==[] then
      return;
    end
  end
  close(f)

  return
endfunction