ruby-iup 0.1.0-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +3 -0
- data/MANIFEST +8 -0
- data/MIT-LICENSE +18 -0
- data/README +12 -0
- data/Rakefile +85 -0
- data/doc/README +10 -0
- data/doc/build_install.txt +74 -0
- data/examples/README +16 -0
- data/examples/ctrl/cbox.rb +220 -0
- data/examples/ctrl/checkboard.rb +33 -0
- data/examples/ctrl/degrade.rb +76 -0
- data/examples/ctrl/example1.rb +53 -0
- data/examples/ctrl/example2.rb +39 -0
- data/examples/ctrl/iupcolorbar.rb +95 -0
- data/examples/ctrl/iupcolorbrowser.rb +45 -0
- data/examples/ctrl/iupdial.rb +117 -0
- data/examples/ctrl/iupgauge.rb +242 -0
- data/examples/ctrl/iupgetcolor.rb +8 -0
- data/examples/ctrl/iupgetparam.rb +62 -0
- data/examples/ctrl/iupglcanvas.rb +172 -0
- data/examples/ctrl/iupmask.rb +13 -0
- data/examples/ctrl/iupmatrix.rb +39 -0
- data/examples/ctrl/iupplot2.rb +601 -0
- data/examples/ctrl/iuptabs.rb +22 -0
- data/examples/ctrl/iuptree.rb +190 -0
- data/examples/ctrl/iupval.rb +71 -0
- data/examples/ctrl/numbering.rb +46 -0
- data/examples/ctrl/sample.rb +166 -0
- data/examples/dlg/iupalarm.rb +16 -0
- data/examples/dlg/iupfiledlg.rb +19 -0
- data/examples/dlg/iupgetfile.rb +19 -0
- data/examples/dlg/iuplistdialog.rb +26 -0
- data/examples/dlg/iupmessage.rb +5 -0
- data/examples/dlg/iupscanf.rb +17 -0
- data/examples/elem/iupbutton.rb +180 -0
- data/examples/elem/iupcanvas.rb +29 -0
- data/examples/elem/iupcanvas2.rb +114 -0
- data/examples/elem/iupcanvas3.rb +52 -0
- data/examples/elem/iupdialog.rb +67 -0
- data/examples/elem/iupdialog2.rb +25 -0
- data/examples/elem/iupfill.rb +51 -0
- data/examples/elem/iupframe.rb +25 -0
- data/examples/elem/iuphbox.rb +68 -0
- data/examples/elem/iupimage.rb +113 -0
- data/examples/elem/iupitem.rb +60 -0
- data/examples/elem/iuplabel.rb +57 -0
- data/examples/elem/iuplist.rb +41 -0
- data/examples/elem/iuplist2.rb +125 -0
- data/examples/elem/iupmenu.rb +32 -0
- data/examples/elem/iupmultiline.rb +24 -0
- data/examples/elem/iupmultiline2.rb +156 -0
- data/examples/elem/iupradio.rb +32 -0
- data/examples/elem/iupseparator.rb +81 -0
- data/examples/elem/iupsubmenu.rb +85 -0
- data/examples/elem/iuptimer.rb +36 -0
- data/examples/elem/iuptoggle.rb +110 -0
- data/examples/elem/iupvbox.rb +87 -0
- data/examples/elem/iupzbox.rb +60 -0
- data/examples/elem/mdisample.rb +377 -0
- data/examples/elem/progressbar.rb +280 -0
- data/examples/elem/scrollbar.rb +66 -0
- data/examples/elem/tray.rb +90 -0
- data/examples/func/iupgetattribute.rb +32 -0
- data/examples/func/iupidle.rb +48 -0
- data/lib/iup.so +0 -0
- data/ruby-iup.gemspec +26 -0
- data/test/test_ruby_iup.rb +25 -0
- metadata +132 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'iup'
|
3
|
+
|
4
|
+
|
5
|
+
def create()
|
6
|
+
cells = Iup.Cells()
|
7
|
+
|
8
|
+
cells.draw_cb = lambda {|h,i,j,xmin,xmax,ymin,ymax,cnv|
|
9
|
+
if (((i%2)!=0 && (j%2)!=0) || (((i+1)%2)!=0 && ((j+1)%2)!=0))
|
10
|
+
cnv.CanvasSetForeground(Cd::WHITE)
|
11
|
+
else
|
12
|
+
cnv.CanvasSetForeground(Cd::BLACK)
|
13
|
+
end
|
14
|
+
cnv.CanvasBox(xmin, xmax, ymin, ymax)
|
15
|
+
|
16
|
+
Iup::DEFAULT
|
17
|
+
}
|
18
|
+
cells.width_cb = lambda {|h,j| 50 }
|
19
|
+
cells.height_cb = lambda {|h,i| 50 }
|
20
|
+
cells.nlines_cb = lambda {|h| 8 }
|
21
|
+
cells.ncols_cb = lambda {|h| 8 }
|
22
|
+
|
23
|
+
return cells
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
cells = create()
|
28
|
+
dlg = Iup.Dialog(cells,:rastersize=>"440x480",:title=>"IupCells")
|
29
|
+
|
30
|
+
dlg.ShowXY(Iup::CENTER,Iup::CENTER)
|
31
|
+
Iup.MainLoop
|
32
|
+
dlg.Destroy
|
33
|
+
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'iup'
|
3
|
+
|
4
|
+
|
5
|
+
def create()
|
6
|
+
cells = Iup.Cells()
|
7
|
+
cells.mouseclick_cb = lambda {|h,b,m,i,j,x,y,r|
|
8
|
+
puts("CLICK: #{b}: (#{i}, #{j})")
|
9
|
+
Iup::DEFAULT
|
10
|
+
}
|
11
|
+
|
12
|
+
cells.draw_cb = lambda {|h,i,j,xmin,xmax,ymin,ymax,cnv|
|
13
|
+
xm = (xmax + xmin) / 2
|
14
|
+
ym = (ymax + ymin) / 2
|
15
|
+
buffer = 0.chr * 64
|
16
|
+
|
17
|
+
return Iup::DEFAULT if (i == 1 && j == 2)
|
18
|
+
return Iup::DEFAULT if (i == 2 && j == 1)
|
19
|
+
return Iup::DEFAULT if (i == 2 && j == 2)
|
20
|
+
return Iup::DEFAULT if (i == 5 && j == 6)
|
21
|
+
return Iup::DEFAULT if (i == 6 && j == 5)
|
22
|
+
return Iup::DEFAULT if (i == 6 && j == 6)
|
23
|
+
|
24
|
+
if (i == 1 && j == 1)
|
25
|
+
cnv.CanvasSetForeground(Cd::WHITE)
|
26
|
+
else
|
27
|
+
cnv.CanvasSetForeground(Cd.EncodeColor(
|
28
|
+
(i*20),(j*100),(i+100)))
|
29
|
+
end
|
30
|
+
cnv.CanvasBox(xmin, xmax, ymin, ymax)
|
31
|
+
cnv.CanvasTextAlignment(Cd::CENTER)
|
32
|
+
cnv.CanvasSetForeground(Cd::BLACK)
|
33
|
+
buffer = "(#{i}, #{j})"
|
34
|
+
cnv.CanvasText( xm, ym, buffer)
|
35
|
+
|
36
|
+
Iup::DEFAULT
|
37
|
+
}
|
38
|
+
|
39
|
+
cells.width_cb = lambda {|h,j| (50+j*1.5).to_i }
|
40
|
+
cells.height_cb = lambda {|h,i| (30+i*1.5).to_i }
|
41
|
+
cells.nlines_cb = lambda {|h| 7 }
|
42
|
+
cells.ncols_cb = lambda {|h| 7 }
|
43
|
+
cells.hspan_cb = lambda {|h,i,j|
|
44
|
+
return 2 if (i == 1 && j == 1)
|
45
|
+
return 2 if (i == 5 && j == 5)
|
46
|
+
1
|
47
|
+
}
|
48
|
+
cells.vspan_cb = lambda {|h,i,j|
|
49
|
+
return 2 if (i == 1 && j == 1)
|
50
|
+
return 2 if (i == 5 && j == 5)
|
51
|
+
1
|
52
|
+
}
|
53
|
+
cells.scrolling_cb = lambda {|h,i,j|
|
54
|
+
puts("SCROLL: (#{i}, #{j})");
|
55
|
+
Iup::DEFAULT
|
56
|
+
}
|
57
|
+
cells.boxed = 'NO'
|
58
|
+
cells.rastersize = "395x255"
|
59
|
+
|
60
|
+
return cells
|
61
|
+
end
|
62
|
+
|
63
|
+
cells = create()
|
64
|
+
box = Iup.Vbox([cells])
|
65
|
+
box.margin = "10x10"
|
66
|
+
|
67
|
+
dlg = Iup.Dialog(box)
|
68
|
+
dlg.title = "IupCells"
|
69
|
+
dlg.rastersize = "350x250"
|
70
|
+
dlg.ShowXY(Iup::CENTER,Iup::CENTER)
|
71
|
+
Iup.MainLoop
|
72
|
+
dlg.Destroy
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'iup'
|
3
|
+
|
4
|
+
img_bits1 = [
|
5
|
+
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,
|
6
|
+
1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,
|
7
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1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
36
|
+
2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
|
37
|
+
]
|
38
|
+
|
39
|
+
|
40
|
+
bt = Iup.Button(:title=>"Test",:expand=>'YES')
|
41
|
+
box = Iup.Sbox(:elem=>bt,:direction=>'SOUTH',:color=>'0 0 255')
|
42
|
+
|
43
|
+
ml = Iup.MultiLine(:expand=>'YES')
|
44
|
+
vbox = Iup.Vbox([box, ml])
|
45
|
+
|
46
|
+
lb = Iup.Label(:title=>"Label",:expand=>'YES')
|
47
|
+
dg = Iup.Dialog(Iup.Hbox([vbox, lb]))
|
48
|
+
|
49
|
+
dg.Show
|
50
|
+
|
51
|
+
Iup.MainLoop
|
52
|
+
dg.Destroy
|
53
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'iup'
|
3
|
+
|
4
|
+
def createtree()
|
5
|
+
tree = Iup.Tree(:size=>'80x80',:expand=>'YES',:font=>'COURIER_NORMAL_10',:name=>'Figures')
|
6
|
+
tree.addbranch='3D'
|
7
|
+
tree.addbranch='2D'
|
8
|
+
tree.addleaf1='trapeze'
|
9
|
+
tree.addbranch1='parallelogram'
|
10
|
+
tree.addleaf2='diamond'
|
11
|
+
tree.addleaf2='square'
|
12
|
+
tree.addbranch4='triangle'
|
13
|
+
tree.addleaf5='scalenus'
|
14
|
+
tree.addleaf5='isoceles'
|
15
|
+
tree.addleaf5='equilateral'
|
16
|
+
tree.value='6'
|
17
|
+
tree.addexpanded='NO'
|
18
|
+
return tree
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
tree = createtree()
|
23
|
+
sbox = Iup.Sbox(:elem=>tree,:direction=>'EAST')
|
24
|
+
|
25
|
+
cv = Iup.Canvas(:expand=>'YES')
|
26
|
+
|
27
|
+
ml = Iup.MultiLine(:expand=>'YES')
|
28
|
+
sbox2 = Iup.Sbox(:elem=>ml,:direction=>'WEST')
|
29
|
+
|
30
|
+
vbox = Iup.Hbox([sbox, cv, sbox2])
|
31
|
+
|
32
|
+
lb = Iup.Label(:title=>"This is a label",:expand=>'NO')
|
33
|
+
sbox3 = Iup.Sbox(:elem=>lb,:direction=>'NORTH')
|
34
|
+
dg = Iup.Dialog(Iup.Vbox([vbox, sbox3]))
|
35
|
+
|
36
|
+
dg.Show
|
37
|
+
Iup.MainLoop
|
38
|
+
dg.Destroy
|
39
|
+
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'iup'
|
3
|
+
|
4
|
+
|
5
|
+
cdcanvas = nil
|
6
|
+
|
7
|
+
repaint_cb = lambda do |h,posx,posy|
|
8
|
+
return Iup::DEFAULT if cdcanvas==nil
|
9
|
+
|
10
|
+
cdcanvas.CanvasActivate()
|
11
|
+
cdcanvas.CanvasClear()
|
12
|
+
|
13
|
+
cdcanvas.CanvasBegin(Cd::FILL)
|
14
|
+
cdcanvas.CanvasVertex(50,50)
|
15
|
+
cdcanvas.CanvasVertex(150,50)
|
16
|
+
cdcanvas.CanvasVertex(100,150)
|
17
|
+
cdcanvas.CanvasEnd()
|
18
|
+
|
19
|
+
Iup::DEFAULT
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
cb = Iup.Colorbar()
|
24
|
+
cb.rastersize = "70x"
|
25
|
+
cb.expand = "VERTICAL"
|
26
|
+
cb.num_parts = 2
|
27
|
+
cb.show_secondary = "YES"
|
28
|
+
cb.preview_size = 60
|
29
|
+
cb.squared = "NO"
|
30
|
+
|
31
|
+
cnvs = Iup.Canvas()
|
32
|
+
cnvs.action = repaint_cb
|
33
|
+
|
34
|
+
# Sets size, mininum and maximum values, position and size of the thumb
|
35
|
+
# of the horizontal scrollbar of the canvas
|
36
|
+
cnvs.rastersize = "200x300"
|
37
|
+
|
38
|
+
cb.select_cb = lambda do |h,cell,type|
|
39
|
+
ri,gi,bi = h["CELL#{cell}"].scan(/\d+/)
|
40
|
+
cd_color = Cd.EncodeColor(ri.to_i,gi.to_i,bi.to_i)
|
41
|
+
|
42
|
+
cdcanvas.CanvasActivate()
|
43
|
+
if (type==Iup::PRIMARY)
|
44
|
+
cdcanvas.CanvasSetForeground(cd_color)
|
45
|
+
else
|
46
|
+
cdcanvas.CanvasSetBackground(cd_color)
|
47
|
+
end
|
48
|
+
repaint_cb.call(nil,0,0)
|
49
|
+
|
50
|
+
Iup::DEFAULT
|
51
|
+
end
|
52
|
+
|
53
|
+
cb.cell_cb = lambda do |h,cell|
|
54
|
+
ri,gi,bi = h["CELL#{cell}"].scan(/\d+/)
|
55
|
+
res = Iup.GetColor(Iup::MOUSEPOS, Iup::MOUSEPOS)
|
56
|
+
if res
|
57
|
+
r,g,b = res
|
58
|
+
str = "#{r} #{g} #{b}"
|
59
|
+
cdcanvas.CanvasActivate()
|
60
|
+
cdcanvas.CanvasSetForeground(Cd.EncodeColor(r,g,b))
|
61
|
+
repaint_cb.call(nil,0,0)
|
62
|
+
return str
|
63
|
+
end
|
64
|
+
nil
|
65
|
+
end
|
66
|
+
|
67
|
+
cb.switch_cb = lambda do |h,primcell,seccell|
|
68
|
+
cdcanvas.CanvasActivate()
|
69
|
+
fgcolor = cdcanvas.CanvasForeground(Cd::QUERY)
|
70
|
+
cdcanvas.CanvasSetForeground(Cd.CanvasBackground(Cd::QUERY))
|
71
|
+
cdcanvas.CanvasSetBackground(fgcolor)
|
72
|
+
repaint_cb.call(nil,0,0)
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
# Creates a dialog with a vbox containing the canvas and the colorbar.
|
77
|
+
dlg = Iup.Dialog(Iup.Hbox([cnvs,cb]))
|
78
|
+
|
79
|
+
# Sets the dialog's title, so that it is mapped properly
|
80
|
+
dlg.title = "IupColorbar"
|
81
|
+
|
82
|
+
# Maps the dialog. This must be done before the creation of the CD canvas
|
83
|
+
dlg.Map
|
84
|
+
|
85
|
+
# Creates a CD canvas of type CD_IUP
|
86
|
+
cdcanvas = Cd.CreateCanvas(Cd.CD_IUP, cnvs)
|
87
|
+
|
88
|
+
# Shows dialog on the center of the screen
|
89
|
+
dlg.Show
|
90
|
+
|
91
|
+
# Initializes IUP main loop
|
92
|
+
Iup.MainLoop
|
93
|
+
|
94
|
+
dlg.Destroy
|
95
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'iup'
|
3
|
+
|
4
|
+
|
5
|
+
text_red = Iup.Text()
|
6
|
+
text_green = Iup.Text()
|
7
|
+
text_blue = Iup.Text()
|
8
|
+
|
9
|
+
clrbrwsr_drag_cb = lambda do |h,r,g,b|
|
10
|
+
text_red.value = r
|
11
|
+
text_green.value = g
|
12
|
+
text_blue.value = b
|
13
|
+
Iup.LoopStep
|
14
|
+
|
15
|
+
Iup::DEFAULT
|
16
|
+
end
|
17
|
+
|
18
|
+
clrbrwsr = Iup.ColorBrowser()
|
19
|
+
clrbrwsr.drag_cb = clrbrwsr_drag_cb
|
20
|
+
clrbrwsr.change_cb = clrbrwsr_drag_cb
|
21
|
+
|
22
|
+
# Creates a vbox */
|
23
|
+
vbox = Iup.Vbox([
|
24
|
+
Iup.Fill(),
|
25
|
+
text_red,
|
26
|
+
Iup.Fill(),
|
27
|
+
text_green,
|
28
|
+
Iup.Fill(),
|
29
|
+
text_blue,
|
30
|
+
Iup.Fill()
|
31
|
+
])
|
32
|
+
|
33
|
+
# Creates an hbox */
|
34
|
+
hbox_final = Iup.Hbox([clrbrwsr, Iup.Fill(), vbox])
|
35
|
+
|
36
|
+
# Creates a dialog */
|
37
|
+
dlg = Iup.Dialog(hbox_final,:title=>"IupColorBrowser")
|
38
|
+
|
39
|
+
# Shows dialog in the center of the screen */
|
40
|
+
dlg.ShowXY(Iup::CENTER, Iup::CENTER)
|
41
|
+
|
42
|
+
# Initializes IUP main loop */
|
43
|
+
Iup.MainLoop
|
44
|
+
|
45
|
+
dlg.Destroy()
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'iup'
|
3
|
+
|
4
|
+
lbl_h = Iup.Label(:title=>"0",:alignment=>"ACENTER",:size=>"30x")
|
5
|
+
lbl_v = Iup.Label(:title=>"0",:alignment=>"ACENTER",:size=>"30x")
|
6
|
+
lbl_c = Iup.Label(:title=>"0",:alignment=>"ACENTER",:size=>"30x")
|
7
|
+
|
8
|
+
|
9
|
+
dial_v = Iup.Dial(:type=>"VERTICAL",:unit=>"DEGREES",:size=>"100x100")
|
10
|
+
dial_h = Iup.Dial(:type=>"HORIZONTAL",:density=>0.1)
|
11
|
+
dial_c = Iup.Dial(:type=>"CIRCULAR")
|
12
|
+
|
13
|
+
dlg = Iup.Dialog(
|
14
|
+
Iup.Hbox([
|
15
|
+
Iup.Fill(),
|
16
|
+
Iup.Vbox([
|
17
|
+
Iup.Frame(
|
18
|
+
Iup.Vbox([
|
19
|
+
Iup.Hbox([
|
20
|
+
Iup.Fill(),
|
21
|
+
dial_v,
|
22
|
+
Iup.Fill()
|
23
|
+
]),
|
24
|
+
Iup.Hbox([
|
25
|
+
Iup.Fill(),
|
26
|
+
lbl_v,
|
27
|
+
Iup.Fill()
|
28
|
+
])
|
29
|
+
])
|
30
|
+
),
|
31
|
+
Iup.Fill(),
|
32
|
+
Iup.Frame(
|
33
|
+
Iup.Vbox([
|
34
|
+
Iup.Hbox([
|
35
|
+
Iup.Fill(),
|
36
|
+
dial_h,
|
37
|
+
Iup.Fill()
|
38
|
+
]),
|
39
|
+
Iup.Hbox([
|
40
|
+
Iup.Fill(),
|
41
|
+
lbl_h,
|
42
|
+
Iup.Fill()
|
43
|
+
])
|
44
|
+
])
|
45
|
+
),
|
46
|
+
Iup.Fill(),
|
47
|
+
Iup.Frame(
|
48
|
+
Iup.Vbox([
|
49
|
+
Iup.Hbox([
|
50
|
+
Iup.Fill(),
|
51
|
+
dial_c,
|
52
|
+
Iup.Fill()
|
53
|
+
]),
|
54
|
+
Iup.Hbox([
|
55
|
+
Iup.Fill(),
|
56
|
+
lbl_c,
|
57
|
+
Iup.Fill()
|
58
|
+
])
|
59
|
+
])
|
60
|
+
),
|
61
|
+
Iup.Fill()
|
62
|
+
]),
|
63
|
+
Iup.Fill()
|
64
|
+
])
|
65
|
+
)
|
66
|
+
dlg.title = "IupDial"
|
67
|
+
|
68
|
+
printdial = lambda do |c,a,color|
|
69
|
+
case c['type']
|
70
|
+
when 'VERTICAL'
|
71
|
+
label = lbl_v
|
72
|
+
when 'HORIZONTAL'
|
73
|
+
label = lbl_h
|
74
|
+
when 'CIRCULAR'
|
75
|
+
label = lbl_c
|
76
|
+
end
|
77
|
+
|
78
|
+
if label
|
79
|
+
label.title = "%.3g" % a
|
80
|
+
label.bgcolor = color
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
mousemove = lambda do |c,a|
|
85
|
+
printdial.call(c, a, "0 255 0")
|
86
|
+
Iup::DEFAULT
|
87
|
+
end
|
88
|
+
|
89
|
+
button_press = lambda do |c,a|
|
90
|
+
printdial.call(c, a, "255 0 0")
|
91
|
+
Iup::DEFAULT
|
92
|
+
end
|
93
|
+
|
94
|
+
button_release = lambda do |c,a|
|
95
|
+
printdial.call(c, a,nil)
|
96
|
+
Iup::DEFAULT
|
97
|
+
end
|
98
|
+
|
99
|
+
dial_v.button_press_cb = button_press
|
100
|
+
dial_c.button_press_cb = button_press
|
101
|
+
dial_h.button_press_cb = button_press
|
102
|
+
|
103
|
+
dial_v.button_release_cb = button_release
|
104
|
+
dial_c.button_release_cb = button_release
|
105
|
+
dial_h.button_release_cb = button_release
|
106
|
+
|
107
|
+
dial_v.mousemove_cb = mousemove
|
108
|
+
dial_c.mousemove_cb = mousemove
|
109
|
+
dial_h.mousemove_cb = mousemove
|
110
|
+
|
111
|
+
# Shows dialog in the center of the screen */
|
112
|
+
dlg.ShowXY(Iup::CENTER, Iup::CENTER)
|
113
|
+
|
114
|
+
# Initializes IUP main loop */
|
115
|
+
Iup.MainLoop
|
116
|
+
|
117
|
+
dlg.Destroy
|