Skip to content

Commit 32ee8c0

Browse files
committed
Updates for Julia 0.6, drop 0.4 support
1 parent c44f11b commit 32ee8c0

12 files changed

+329
-345
lines changed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ language: julia
22
os:
33
- linux
44
julia:
5-
- 0.4
65
- 0.5
76
- nightly
87
notifications:

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Julia interface to the Tk windowing toolkit.
22

3-
[![Tk](http://pkg.julialang.org/badges/Tk_0.3.svg)](http://pkg.julialang.org/?pkg=Tk&ver=0.3)
4-
[![Tk](http://pkg.julialang.org/badges/Tk_0.4.svg)](http://pkg.julialang.org/?pkg=Tk&ver=0.4)
5-
[![Build Status](https://travis-ci.org/JuliaLang/Tk.jl.svg?branch=master)](https://travis-ci.org/JuliaLang/Tk.jl)
6-
[![Coverage Status](https://coveralls.io/repos/JuliaLang/Tk.jl/badge.svg)](https://coveralls.io/r/JuliaLang/Tk.jl)
3+
[![Tk](http://pkg.julialang.org/badges/Tk_0.5.svg)](http://pkg.julialang.org/?pkg=Tk)
4+
[![Tk](http://pkg.julialang.org/badges/Tk_0.6.svg)](http://pkg.julialang.org/?pkg=Tk)
5+
[![Build Status](https://travis-ci.org/JuliaGraphics/Tk.jl.svg?branch=master)](https://travis-ci.org/JuliaGraphics/Tk.jl)
6+
[![Coverage Status](https://coveralls.io/repos/JuliaGraphics/Tk.jl/badge.svg)](https://coveralls.io/r/JuliaGraphics/Tk.jl)
77

88
The documentation for this package is in the `examples` directory.

REQUIRE

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
julia 0.4
2-
Compat 0.7.20
1+
julia 0.5
2+
Compat 0.17.0
33
Cairo
44
Graphics 0.1
55
BinDeps 0.2.2-

examples/manipulate.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ using Winston
2525
end
2626

2727

28-
abstract ManipulateWidget
28+
@compat abstract type ManipulateWidget end
2929
get_label(widget::ManipulateWidget) = widget.label
3030

3131
type SliderWidget <: ManipulateWidget

examples/workspace.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ short_summary(x) = summary(x)
1515
short_summary(x::AbstractString) = "A string"
1616

1717
## update ids, returning false if the same, true if not
18-
__ids__ = Array(AbstractString, 0)
18+
__ids__ = Vector{AbstractString}(0)
1919
function update_ids(m::Module)
2020
global __ids__
2121
nms = get_names(m)
@@ -31,8 +31,8 @@ end
3131

3232

3333
negate(x::Bool, val::Bool) = val ? !x : x
34-
MaybeRegex = (@compat Union{(@compat Void), Regex})
35-
MaybeType = (@compat Union{(@compat Void), DataType})
34+
const MaybeRegex = Union{Void, Regex}
35+
const MaybeType = Union{Void, DataType}
3636

3737
## get array of names and summaries
3838
## m module

src/containers.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ destroy(widget::Tk_Toplevel) = tcl("destroy", widget)
6464
## Labelframe
6565
Labelframe(parent::Widget, text::AbstractString) = Labelframe(parent, text=text)
6666
get_value(widget::Tk_Labelframe) = cget(widget, "text")
67-
set_value(widget::Tk_Labelframe, text::AbstractString) = configure(widget, @compat Dict(:text=> text))
67+
set_value(widget::Tk_Labelframe, text::AbstractString) = configure(widget, Dict(:text=> text))
6868

6969
## Notebook
7070
function page_add(child::Widget, label::AbstractString)
@@ -132,7 +132,7 @@ function forget(parent::TTk_Container, child::Widget)
132132
end
133133

134134
## grid ...
135-
IntOrRange = (@compat Union{Integer, UnitRange})
135+
IntOrRange = Union{Integer, UnitRange}
136136
function grid(child::Widget, row::IntOrRange, column::IntOrRange; kwargs...)
137137
path = get_path(child)
138138
if isa(row, UnitRange) rowspan = 1 + maximum(row) - minimum(row) else rowspan = 1 end
@@ -211,10 +211,10 @@ parent(w::Tk_Widget) = parent(w.w)
211211
parent(c::Canvas) = parent(c.c)
212212

213213
# For toplevel it's obvious how to wrap it...
214-
function toplevel(w::(@compat Union{TkWidget, Tk_Widget, Canvas}))
214+
function toplevel(w::Union{TkWidget, Tk_Widget, Canvas})
215215
p = parent(w)
216216
pold = p
217-
while !is(p, nothing)
217+
while p !== nothing
218218
pold = p
219219
p = parent(p)
220220
end

src/core.jl

+13-51
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ get_path(widget::Canvas) = get_path(widget.c) # Tk.Canvas object
1616

1717
## Coversion of julia objects into tcl strings for inclusion via tcl() call
1818
to_tcl(x) = string(x)
19-
to_tcl(x::(@compat Void)) = ""
19+
to_tcl(x::Void) = ""
2020
has_space = r" "
2121
to_tcl(x::AbstractString) = ismatch(has_space, x) ? "{$x}" : x
2222
type I x::MaybeString end # avoid wrapping in {} and ismatch call.
@@ -112,55 +112,17 @@ wm(window::Widget, prop::AbstractString, args...; kwargs...) = tcl("wm", prop, w
112112

113113
## Take a function, get its args as array of symbols. There must be better way...
114114
## Helper functions for bind callback
115-
if VERSION > v"0.5-"
116-
function get_args(li::LambdaInfo)
117-
argnames = li.slotnames[1:li.nargs]
118-
if _arg_offset == 0
119-
return argnames
120-
else
121-
return argnames[_arg_offset:end]
122-
end
123-
end
124-
125-
get_args(m::Method) = get_args(m.lambda_template)
126-
get_args(f::Function) = get_args(first(methods(f)).lambda_template)
127-
128-
else
129-
130-
function get_args(li::LambdaStaticData)
131-
e = li.ast
132-
if !isa(e, Expr)
133-
e = Base.uncompressed_ast(li)
134-
end
135-
argnames = e.args[1]
136-
## return array of symbols -- not args
137-
if isa(argnames[1], Expr)
138-
argnames = map(u -> u.args[1], argnames)
139-
end
140-
141-
if _arg_offset == 0
142-
return argnames
143-
else
144-
return argnames[_arg_offset:end]
145-
end
146-
end
147-
148-
function get_args(m::Method)
149-
li = m.func
150-
if !isa(li,LambdaStaticData)
151-
li = li.code
152-
end
153-
get_args(li)
154-
end
155-
156115
function get_args(f::Function)
157-
try
158-
get_args(first(methods(f)).func)
159-
catch e
160-
get_args(f.code)
116+
m = first(methods(f))
117+
@static if VERSION >= v"0.6.0-dev.624"
118+
slots = m.source.slotnames
119+
n = m.nargs
120+
else
121+
slots = m.lambda_template.slotnames
122+
n = m.lambda_template.nargs
161123
end
162-
end
163-
124+
argnames = slots[1:n]
125+
return _arg_offset == 0 ? argnames : argnames[_arg_offset:end]
164126
end
165127

166128
_arg_offset = 0
@@ -189,7 +151,7 @@ end
189151
bind(widget::Canvas, event::AbstractString, callback::Function) = bind(widget.c, event, callback)
190152

191153
## for use with do style
192-
bind(callback::Function, widget::(@compat Union{Widget, Canvas}), event::AbstractString) = bind(widget, event, callback)
154+
bind(callback::Function, widget::Union{Widget, Canvas}, event::AbstractString) = bind(widget, event, callback)
193155

194156
## Binding to mouse wheel
195157
function bindwheel(widget::Widget, modifier::AbstractString, callback::Function, tkargs::AbstractString = "")
@@ -262,8 +224,8 @@ end
262224
type TclAfter
263225
cb::Function
264226
run::Bool
265-
start::(@compat Union{(@compat Void), Function})
266-
stop::(@compat Union{(@compat Void), Function})
227+
start::Union{Void, Function}
228+
stop::Union{Void, Function}
267229
ms::Int
268230

269231
function TclAfter(ms, cb::Function)

src/dialogs.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ChooseDirectory() = tcl("tk_chooseDirectory")
88
## Message box
99
function Messagebox(parent::MaybeWidget; title::AbstractString="", message::AbstractString="", detail::AbstractString="")
1010
args = Dict()
11-
if !isa(parent, (@compat Void)) args["parent"] = get_path(parent) end
11+
if !isa(parent, Void) args["parent"] = get_path(parent) end
1212
if length(title) > 0 args["title"] = title end
1313
if length(message) > 0 args["message"] = message end
1414
if length(detail) > 0 args["detail"] = detail end

src/tkwidget.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function init()
3939
@static if is_windows()
4040
htcl = ccall((:GetModuleHandleA,:kernel32),stdcall,Csize_t,
4141
(Ptr{UInt8},),libtcl)
42-
tclfile = Array(UInt8,260)
42+
tclfile = Vector{UInt8}(260)
4343
len = ccall((:GetModuleFileNameA,:kernel32),stdcall,Cint,
4444
(Csize_t,Ptr{UInt8},Cint),htcl,tclfile,length(tclfile))
4545
if len > 0
@@ -103,7 +103,7 @@ end
103103
type TkWidget
104104
path::String
105105
kind::String
106-
parent::(@compat Union{TkWidget,Void})
106+
parent::Union{TkWidget,Void}
107107

108108
let ID::Int = 0
109109
function TkWidget(parent::TkWidget, kind)
@@ -267,9 +267,9 @@ end
267267

268268
@static if is_apple()
269269
if @compat Sys.WORD_SIZE == 32
270-
typealias CGFloat Float32
270+
const CGFloat = Float32
271271
else
272-
typealias CGFloat Float64
272+
const CGFloat = Float64
273273
end
274274
objc_msgSend{T}(id, uid, ::Type{T}=Ptr{Void}) = ccall(:objc_msgSend, T, (Ptr{Void}, Ptr{Void}),
275275
id, ccall(:sel_getUid, Ptr{Void}, (Ptr{UInt8},), uid))
@@ -368,7 +368,7 @@ function render_to_cairo(f::Function, w::TkWidget, clipped::Bool=true)
368368
return
369369
end
370370
@static if is_windows()
371-
state = Array(UInt8, sizeof(Int)*2) # 8.4, 8.5, 8.6
371+
state = Vector{UInt8}(sizeof(Int)*2) # 8.4, 8.5, 8.6
372372
drawable = jl_tkwin_id(win)
373373
hdc = ccall((:TkWinGetDrawableDC,libtk), Ptr{Void}, (Ptr{Void}, Int, Ptr{UInt8}),
374374
jl_tkwin_display(win), drawable, state)

src/types.jl

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
## Abstract types
2-
abstract Tk_Widget
3-
abstract TTk_Widget <: Tk_Widget ## for ttk::widgets
4-
abstract TTk_Container <: Tk_Widget ## for containers (frame, labelframe, ???)
2+
@compat abstract type Tk_Widget end
3+
@compat abstract type TTk_Widget <: Tk_Widget end ## for ttk::widgets
4+
@compat abstract type TTk_Container <: Tk_Widget end ## for containers (frame, labelframe, ???)
55

6-
Widget = (@compat Union{TkWidget, Tk_Widget, Canvas, AbstractString})
6+
const Widget = Union{TkWidget, Tk_Widget, Canvas, AbstractString}
77

88
## Maybe -- can this be parameterized?
99
## https://groups.google.com/forum/?fromgroups=#!topic/julia-dev/IbbWwplrqlc (takeaway -- this style is frowned upon)
10-
MaybeFunction = (@compat Union{Function, (@compat Void)})
11-
MaybeString = (@compat Union{AbstractString, (@compat Void)})
12-
MaybeStringInteger = (@compat Union{AbstractString, Integer, (@compat Void)}) # for at in tree insert
13-
MaybeVector = (@compat Union{Vector, (@compat Void)})
14-
MaybeWidget = (@compat Union{Widget, (@compat Void)})
15-
MaybeBool = (@compat Union{Bool, (@compat Void)})
10+
const MaybeFunction = Union{Function, Void}
11+
const MaybeString = Union{AbstractString, Void}
12+
const MaybeStringInteger = Union{AbstractString, Integer, Void} # for at in tree insert
13+
const MaybeVector = Union{Vector, Void}
14+
const MaybeWidget = Union{Widget, Void}
15+
const MaybeBool = Union{Bool, Void}

src/widgets.jl

+7-7
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ end
6060
Label(parent::Widget, text::AbstractString, image::Tk_Image) = Label(parent, text=tk_string_escape(text), image=image, compound="left")
6161
Label(parent::Widget, text::AbstractString) = Label(parent, text=tk_string_escape(text))
6262
Label(parent::Widget, image::Tk_Image) = Label(parent, image=image, compound="image")
63-
get_value(widget::(@compat Union{Tk_Button, Tk_Label})) = widget[:text]
64-
function set_value(widget::(@compat Union{Tk_Label, Tk_Button}), value::AbstractString)
63+
get_value(widget::Union{Tk_Button, Tk_Label}) = widget[:text]
64+
function set_value(widget::Union{Tk_Label, Tk_Button}, value::AbstractString)
6565
variable = cget(widget, "textvariable")
6666
(variable == "") ? widget[:text] = tk_string_escape(value) : tclvar(variable, value)
6767
end
@@ -103,7 +103,7 @@ set_items(widget::Tk_Checkbutton, value::AbstractString) = widget[:text] = tk_st
103103
type Tk_Radiobutton <: TTk_Widget
104104
w::TkWidget
105105
end
106-
MaybeTkRadioButton = (@compat Union{Void, Tk_Radiobutton})
106+
MaybeTkRadioButton = Union{Void, Tk_Radiobutton}
107107

108108
function Radiobutton(parent::Widget, group::MaybeTkRadioButton, label::AbstractString)
109109

@@ -125,12 +125,12 @@ set_items(widget::Tk_Radiobutton, value::AbstractString) = configure(widget, tex
125125
type Tk_Radio <: TTk_Widget
126126
w::TkWidget
127127
buttons::Vector
128-
orient::(@compat Union{Void, AbstractString})
128+
orient::Union{Void, AbstractString}
129129
end
130130

131131
function Radio{T<:AbstractString}(parent::Widget, labels::Vector{T}, orient::AbstractString)
132132
n = size(labels)[1]
133-
rbs = Array(Tk_Radiobutton, n)
133+
rbs = Vector{Tk_Radiobutton}(n)
134134
frame = Frame(parent)
135135

136136
rbs[1] = Radiobutton(frame, tk_string_escape(labels[1]))
@@ -314,7 +314,7 @@ get_value(widget::Tk_Progressbar) = round(Int, float(widget[:value]))
314314
set_value(widget::Tk_Progressbar, value::Integer) = widget[:value] = min(100, max(0, value))
315315

316316
## Image
317-
MaybeImage = (@compat Union{Void, Tk_Image})
317+
MaybeImage = Union{Void, Tk_Image}
318318
to_tcl(x::Tk_Image) = x.w
319319

320320
function Image(fname::AbstractString)
@@ -440,7 +440,7 @@ type Tk_Treeview <: TTk_Widget
440440
end
441441
type TreeNode node::AbstractString end
442442
to_tcl(x::TreeNode) = x.node
443-
MaybeTreeNode = (@compat Union{TreeNode, Void})
443+
MaybeTreeNode = Union{TreeNode, Void}
444444

445445
## Special Tree cases
446446

0 commit comments

Comments
 (0)