Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop 0.5 support, fix some 0.7 deprecations #143

Merged
merged 6 commits into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ os:
- linux
- osx
julia:
- 0.5
- 0.6
- nightly
notifications:
email: false
Expand Down
4 changes: 2 additions & 2 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
julia 0.5
Compat 0.17.0
julia 0.6
Compat 0.48.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.52 for objectid JuliaLang/Compat.jl@02367e6

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good catch, thanks!

Cairo
Graphics 0.1
BinDeps 0.2.2-
Expand Down
21 changes: 11 additions & 10 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using BinDeps
using Compat; import Compat.String
using Compat
using Compat.Libdl

@BinDeps.setup

tcl = library_dependency("tcl",aliases=["libtcl8.6","tcl86g","tcl86t","libtcl","libtcl8.6.so.0","libtcl8.5","libtcl8.5.so.0","tcl85"])
tk = library_dependency("tk",aliases=["libtk8.6","libtk","libtk8.6.so.0","libtk8.5","libtk8.5.so.0","tk85","tk86","tk86t"], depends=[tcl], validate = function(p,h)
is_apple() && (return @compat Libdl.dlsym_e(h,:TkMacOSXGetRootControl) != C_NULL)
Compat.Sys.isapple() && (return Libdl.dlsym_e(h,:TkMacOSXGetRootControl) != C_NULL)
return true
end)

if is_windows()
if Compat.Sys.iswindows()
using WinRPM
provides(WinRPM.RPM,"tk",tk,os = :Windows)
provides(WinRPM.RPM,"tcl",tcl,os = :Windows)
Expand All @@ -21,12 +22,12 @@ provides(AptGet,"tk8.5",tk)
provides(Sources,URI("http://prdownloads.sourceforge.net/tcl/tcl8.6.0-src.tar.gz"),tcl,unpacked_dir = "tcl8.6.0")
provides(Sources,URI("http://prdownloads.sourceforge.net/tcl/tk8.6.0-src.tar.gz"),tk,unpacked_dir = "tk8.6.0")

is64bit = @compat Sys.WORD_SIZE == 64
is64bit = Sys.WORD_SIZE == 64

provides(BuildProcess,Autotools(configure_subdir = "unix", configure_options = [is64bit?"--enable-64bit":"--disable-64bit"]),tcl, os = :Unix)
provides(BuildProcess,Autotools(configure_subdir = "unix", configure_options = [is64bit?"--enable-64bit":"--disable-64bit"]),tk, os = :Unix)
provides(BuildProcess,Autotools(configure_subdir = "unix", configure_options = [is64bit ? "--enable-64bit" : "--disable-64bit"]),tcl, os = :Unix)
provides(BuildProcess,Autotools(configure_subdir = "unix", configure_options = [is64bit ? "--enable-64bit" : "--disable-64bit"]),tk, os = :Unix)

if @compat Sys.WORD_SIZE == 64
if Sys.WORD_SIZE == 64
# Unfortunately the mingw-built tc segfaults since some function signatures
# are different between VC and mingw. This is fixed on tcl trunk. For now,
# just use VC to build tcl (Note requlres Visual Studio Express in the PATH)
Expand All @@ -48,8 +49,8 @@ if @compat Sys.WORD_SIZE == 64
end
end),tk)
else
provides(BuildProcess,Autotools(libtarget = "tcl86.dll", configure_subdir = "win", configure_options = [is64bit?"--enable-64bit":"--disable-64bit","--enable-threads"]),tcl, os = :Windows)
provides(BuildProcess,Autotools(libtarget = "tk86.dll", configure_subdir = "win", configure_options = [is64bit?"--enable-64bit":"--disable-64bit"]),tk, os = :Windows)
provides(BuildProcess,Autotools(libtarget = "tcl86.dll", configure_subdir = "win", configure_options = [is64bit ? "--enable-64bit" : "--disable-64bit","--enable-threads"]),tcl, os = :Windows)
provides(BuildProcess,Autotools(libtarget = "tk86.dll", configure_subdir = "win", configure_options = [is64bit ? "--enable-64bit" : "--disable-64bit"]),tk, os = :Windows)
end

@BinDeps.install @compat(Dict(:tk => :libtk, :tcl=>:libtcl))
@BinDeps.install Dict(:tk => :libtk, :tcl=>:libtcl)
22 changes: 11 additions & 11 deletions examples/manipulate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ using Winston
end


@compat abstract type ManipulateWidget end
abstract type ManipulateWidget end
get_label(widget::ManipulateWidget) = widget.label

type SliderWidget <: ManipulateWidget
mutable struct SliderWidget <: ManipulateWidget
nm
label
initial
Expand All @@ -44,7 +44,7 @@ slider(nm::AbstractString, label::AbstractString, rng::UnitRange, initial::Integ
slider(nm::AbstractString, label::AbstractString, rng::UnitRange) = slider(nm, label, rng, minimum(rng))
slider(nm::AbstractString, rng::UnitRange) = slider(nm, nm, rng, minimum(rng))

type PickerWidget <: ManipulateWidget
mutable struct PickerWidget <: ManipulateWidget
nm
label
initial
Expand All @@ -60,14 +60,14 @@ function make_widget(parent, widget::PickerWidget)
end


picker{T <: AbstractString}(nm::AbstractString, label::AbstractString, vals::Vector{T}, initial) = PickerWidget(nm, label, initial, vals)
picker{T <: AbstractString}(nm::AbstractString, label::AbstractString, vals::Vector{T}) = picker(nm, label, vals, vals[1])
picker{T <: AbstractString}(nm::AbstractString, vals::Vector{T}) = picker(nm, nm, vals)
picker(nm::AbstractString, label::AbstractString, vals::Vector{T}, initial) where {T <: AbstractString} = PickerWidget(nm, label, initial, vals)
picker(nm::AbstractString, label::AbstractString, vals::Vector{T}) where {T <: AbstractString} = picker(nm, label, vals, vals[1])
picker(nm::AbstractString, vals::Vector{T}) where {T <: AbstractString} = picker(nm, nm, vals)
picker(nm::AbstractString, label::AbstractString, vals::Dict, initial) = PickerWidget(nm, label, vals, initial)
picker(nm::AbstractString, label::AbstractString, vals::Dict) = PickerWidget(nm, label, vals, [string(k) for (k,v) in vals][1])
picker(nm::AbstractString, vals::Dict) = picker(nm, nm, vals)

type CheckboxWidget <: ManipulateWidget
mutable struct CheckboxWidget <: ManipulateWidget
nm
label
initial
Expand All @@ -83,7 +83,7 @@ checkbox(nm::AbstractString, label::AbstractString, initial::Bool) = CheckboxWid
checkbox(nm::AbstractString, label::AbstractString) = checkbox(nm, label, false)


type ButtonWidget <: ManipulateWidget
mutable struct ButtonWidget <: ManipulateWidget
label
nm
end
Expand All @@ -93,7 +93,7 @@ button(label::AbstractString) = ButtonWidget(label, nothing)


## Add text widget to gather one-line of text
type EntryWidget <: ManipulateWidget
mutable struct EntryWidget <: ManipulateWidget
nm
label
initial
Expand All @@ -105,7 +105,7 @@ entry(nm::AbstractString) = EntryWidget(nm, nm, "{}")


## Expression returns a plot object. Use names as values
function manipulate(ex::(@compat Union{Symbol,Expr}), controls...)
function manipulate(ex::(Union{Symbol,Expr}), controls...)
widgets = Array(Tk.Widget, 0)

w = Toplevel("Manipulate", 800, 500)
Expand All @@ -127,7 +127,7 @@ function manipulate(ex::(@compat Union{Symbol,Expr}), controls...)
d = Dict() # return Dict of values
vals = get_values(); keys = get_nms()
for i in 1:length(vals)
if !isa(keys[i], @compat Void)
if !isa(keys[i], Nothing)
d[keys[i]] = vals[i]
end
end
Expand Down
6 changes: 1 addition & 5 deletions examples/sketch.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using Tk
if VERSION < v"0.4.0-dev+3275"
using Base.Graphics
else
using Graphics
end
using Graphics

function sketch_window()
w = Window("drawing", 400, 300)
Expand Down
6 changes: 3 additions & 3 deletions examples/test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using Compat; import Compat.String
w = Toplevel("Test window", false)
## pack in tk frame for themed widgets
f = Frame(w)
configure(f, @compat Dict(:padding => [3,3,2,2], :relief=>"groove"))
configure(f, Dict(:padding => [3,3,2,2], :relief=>"groove"))
pack(f, expand=true, fill="both")

## widgets
Expand All @@ -26,11 +26,11 @@ pack_style = ["pack", "grid", "formlayout"][3]

if pack_style == "pack"
map(pack, widgets)
map(u -> pack_configure(u, @compat Dict(:anchor => "w")), widgets)
map(u -> pack_configure(u, Dict(:anchor => "w")), widgets)
elseif pack_style == "grid"
for i in 1:length(widgets)
grid(widgets[i], i, 1)
grid_configure(widgets[i], @compat Dict(:sticky => "we"))
grid_configure(widgets[i], Dict(:sticky => "we"))
end
else
map(u -> formlayout(u, "label"), widgets)
Expand Down
6 changes: 3 additions & 3 deletions examples/workspace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function get_names(m::Module)
end

unique_id(v::Symbol, m::Module) = isdefined(m,v) ? unique_id(eval(m,v)) : ""
unique_id(x) = string(object_id(x))
unique_id(x) = string(objectid(x))

## short_summary
## can customize description here
Expand All @@ -31,8 +31,8 @@ end


negate(x::Bool, val::Bool) = val ? !x : x
const MaybeRegex = Union{Void, Regex}
const MaybeType = Union{Void, DataType}
const MaybeRegex = Union{Nothing, Regex}
const MaybeType = Union{Nothing, DataType}

## get array of names and summaries
## m module
Expand Down
11 changes: 3 additions & 8 deletions src/Tk.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION >= v"0.4.0-dev+6521" && __precompile__(false)
__precompile__(false)

# julia tk interface
# TODO:
Expand All @@ -14,9 +14,8 @@ VERSION >= v"0.4.0-dev+6521" && __precompile__(false)


module Tk
using Base
using Cairo
using Compat; import Compat.String
using Compat

if isfile(joinpath(dirname(@__FILE__),"..","deps","deps.jl"))
include("../deps/deps.jl")
Expand All @@ -26,11 +25,7 @@ end

import Base: ==, bind, getindex, isequal, parent, setindex!, show, string, Text

if VERSION < v"0.4.0-dev+3275"
import Base.Graphics: width, height, getgc
else
import Graphics: width, height, getgc
end
import Graphics: width, height, getgc

import Cairo: destroy

Expand Down
14 changes: 7 additions & 7 deletions src/containers.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
## Types
type Tk_Toplevel <: TTk_Container w::TkWidget; children::Vector{Tk_Widget} end
type Tk_Frame <: TTk_Container w::TkWidget; children::Vector{Tk_Widget} end
type Tk_Labelframe <: TTk_Container w::TkWidget; children::Vector{Tk_Widget} end
type Tk_Notebook <: TTk_Container w::TkWidget; children::Vector{Tk_Widget} end
type Tk_Panedwindow <: TTk_Container w::TkWidget; children::Vector{Tk_Widget} end
mutable struct Tk_Toplevel <: TTk_Container w::TkWidget; children::Vector{Tk_Widget} end
mutable struct Tk_Frame <: TTk_Container w::TkWidget; children::Vector{Tk_Widget} end
mutable struct Tk_Labelframe <: TTk_Container w::TkWidget; children::Vector{Tk_Widget} end
mutable struct Tk_Notebook <: TTk_Container w::TkWidget; children::Vector{Tk_Widget} end
mutable struct Tk_Panedwindow <: TTk_Container w::TkWidget; children::Vector{Tk_Widget} end

==(a::TTk_Container, b::TTk_Container) = isequal(a.w, b.w) && typeof(a) == typeof(b)

Expand All @@ -23,7 +23,7 @@ width(widget::Tk_Toplevel) = parse(Int, winfo(widget, "width"))
height(widget::Tk_Toplevel) = parse(Int, winfo(widget, "height"))
get_size(widget::Tk_Toplevel) = [width(widget), height(widget)]
set_size(widget::Tk_Toplevel, width::Integer, height::Integer) = wm(widget, "geometry", "$(string(width))x$(string(height))")
set_size{T <: Integer}(widget::Tk_Toplevel, widthheight::Vector{T}) = set_size(widget, widthheight[1], widthheight[2])
set_size(widget::Tk_Toplevel, widthheight::Vector{T}) where {T <: Integer} = set_size(widget, widthheight[1], widthheight[2])



Expand Down Expand Up @@ -52,7 +52,7 @@ function set_position(widget::Tk_Toplevel, x::Integer, y::Integer)
p_or_m(x) = x < 0 ? "$x" : "+$x"
wm(widget, "geometry", I(p_or_m(x) * p_or_m(y)))
end
set_position{T <: Integer}(widget::Tk_Toplevel, pos::Vector{T}) = set_position(w, pos[1], pos[2])
set_position(widget::Tk_Toplevel, pos::Vector{T}) where {T <: Integer} = set_position(w, pos[1], pos[2])
set_position(widget::Tk_Toplevel, pos::Tk_Widget) = set_position(widget, Integer[parse(Int, winfo(pos, i)) for i in ["x", "y"]] + [10,10])

update(widget::Tk_Toplevel) = wm(widget, "geometry")
Expand Down
28 changes: 11 additions & 17 deletions src/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ get_path(widget::Canvas) = get_path(widget.c) # Tk.Canvas object

## Coversion of julia objects into tcl strings for inclusion via tcl() call
to_tcl(x) = string(x)
to_tcl(x::Void) = ""
to_tcl(x::Nothing) = ""
has_space = r" "
to_tcl(x::AbstractString) = ismatch(has_space, x) ? "{$x}" : x
type I x::MaybeString end # avoid wrapping in {} and ismatch call.
mutable struct I x::MaybeString end # avoid wrapping in {} and ismatch call.
macro I_str(s) I(s) end
to_tcl(x::I) = x.x == nothing ? "" : x.x
to_tcl{T <: Number}(x::Vector{T}) = "\"" * string(join(x, " ")) * "\""
function to_tcl{T <: AbstractString}(x::Vector{T})
to_tcl(x::Vector{T}) where {T <: Number} = "\"" * string(join(x, " ")) * "\""
function to_tcl(x::Vector{T}) where T <: AbstractString
tmp = join(["{$i}" for i in x], " ")
"[list $tmp ]"
end
Expand Down Expand Up @@ -80,7 +80,7 @@ function configure(widget::Widget, args...; kwargs...)
tcl(widget, "configure", args...; kwargs...)
end

setindex!(widget::Widget, value, prop::Symbol) = configure(widget, @compat Dict(prop=>value))
setindex!(widget::Widget, value, prop::Symbol) = configure(widget, Dict(prop=>value))

## Get values
## cget
Expand Down Expand Up @@ -110,13 +110,7 @@ winfo(widget::Widget, prop::AbstractString) = winfo(widget, prop, nothing)
wm(window::Widget, prop::AbstractString, args...; kwargs...) = tcl("wm", prop, window, args...; kwargs...)


if VERSION >= v"0.6.0-pre.alpha.244"
_slots(m::Method) = (Base.uncompressed_ast(m).slotnames, m.nargs)
elseif VERSION >= v"0.6.0-dev.624"
_slots(m::Method) = (m.source.slotnames, m.nargs)
else
_slots(m::Method) = (m.lambda_template.slotnames, m.lambda_template.nargs)
end
_slots(m::Method) = (Base.uncompressed_ast(m).slotnames, m.nargs)

## Take a function, get its args as array of symbols. There must be better way...
## Helper functions for bind callback
Expand Down Expand Up @@ -164,7 +158,7 @@ function bindwheel(widget::Widget, modifier::AbstractString, callback::Function,
tkargs = string(" ", tkargs)
end
ccb = tcl_callback(callback)
if is_linux()
if Compat.Sys.islinux()
tcl_eval("bind $(path) <$(modifier)Button-4> {$ccb -120$tkargs}")
tcl_eval("bind $(path) <$(modifier)Button-5> {$ccb 120$tkargs}")
else
Expand All @@ -174,7 +168,7 @@ end

## add most typical callback
function callback_add(widget::Tk_Widget, callback::Function)
events = @compat Dict(
events = Dict(
:Tk_Window => "<Destroy>",
:Tk_Frame => nothing,
:Tk_Labelframe => nothing,
Expand Down Expand Up @@ -222,11 +216,11 @@ end
## function after a delay of ms milliseconds. This is started with
## obj.start() and stopped, if desired, with obj.stop(). To restart is
## possible, but first set obj.run=true.
type TclAfter
mutable struct TclAfter
cb::Function
run::Bool
start::Union{Void, Function}
stop::Union{Void, Function}
start::Union{Nothing, Function}
stop::Union{Nothing, Function}
ms::Int

function TclAfter(ms, cb::Function)
Expand Down
2 changes: 1 addition & 1 deletion src/dialogs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ChooseDirectory() = tcl("tk_chooseDirectory")
## Message box
function Messagebox(parent::MaybeWidget; title::AbstractString="", message::AbstractString="", detail::AbstractString="")
args = Dict()
if !isa(parent, Void) args["parent"] = get_path(parent) end
if !isa(parent, Nothing) args["parent"] = get_path(parent) end
if length(title) > 0 args["title"] = title end
if length(message) > 0 args["message"] = message end
if length(detail) > 0 args["detail"] = detail end
Expand Down
4 changes: 2 additions & 2 deletions src/menu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function menu_add(widget::Tk_Menu, rb::Tk_Radio)
end

function tk_popup(widget::Tk_Widget, menu::Tk_Menu)
if is_apple()
if Compat.Sys.isapple()
tcl_eval("bind $(widget.w.path) <2> {tk_popup $(menu.w.path) %X %Y}")
tcl_eval("bind $(widget.w.path) <Control-1> {tk_popup $(menu.w.path) %X %Y}")
else
Expand All @@ -63,7 +63,7 @@ function tk_popup(widget::Tk_Widget, menu::Tk_Menu)
end

function tk_popup(c::Canvas, menu::Tk_Menu)
if is_apple()
if Compat.Sys.isapple()
tcl_eval("bind $(c.c.path) <2> {tk_popup $(menu.w.path) %X %Y}")
tcl_eval("bind $(c.c.path) <Control-1> {tk_popup $(menu.w.path) %X %Y}")
else
Expand Down
Loading