Skip to content

Commit

Permalink
Merge pull request #147 from aviks/as/onepoint
Browse files Browse the repository at this point in the history
Revive project, bring it to the 1.x world
  • Loading branch information
aviks authored Feb 5, 2020
2 parents b2e9baf + 0479590 commit 1ff69f7
Show file tree
Hide file tree
Showing 21 changed files with 335 additions and 299 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
deps/builds
deps/build.log
deps/downloads
deps/src
deps/usr
Expand All @@ -7,3 +8,4 @@ deps/deps.jl
*~
*.jl.cov
*.jl.mem
Manifest.toml
37 changes: 19 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
language: julia
os:
- linux
- osx
julia:
- 0.5
- nightly

dist: xenial
services:
- xvfb

jobs:
include:
- julia: 1.0
os: linux
- julia: 1.3
os: linux
- julia: nightly
os: linux
- julia: 1.0
os: osx
allow_failures:
- julia: nightly

notifications:
email: false
script:
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
- julia -e 'Pkg.clone(pwd())'
- if [ `uname` = "Linux" ]; then
xvfb-run julia -e 'Pkg.build("Tk"); Pkg.test("Tk"; coverage=true)';
elif [ `uname` = "Darwin" ]; then
julia -e 'Pkg.build("Tk"); Pkg.test("Tk"; coverage=true)';
fi
# - xvfb-run julia -e 'Pkg.clone(pwd()); Pkg.build("Tk"); Pkg.test("Tk"; coverage=true)';
after_success:
- julia -e 'cd(Pkg.dir("Tk")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())';
email: false
16 changes: 16 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name = "Tk"
uuid = "4225ea8a-3324-57e7-9ddc-5798a2cb9eab"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
BinDeps = "9e28174c-4ba2-5203-b857-d8d62c4213ee"
Cairo = "159f3aea-2a34-519c-b102-8c37f9878175"
Graphics = "a2bd30eb-e257-5431-a919-1863eab51364"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
WinRPM = "c17dfb99-b4f7-5aad-8812-456da1ad7187"

[compat]
Graphics = "≥ 0.1.0"
julia = "1.0"
6 changes: 0 additions & 6 deletions REQUIRE

This file was deleted.

35 changes: 35 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
environment:
matrix:
- julia_version: 1.0

platform:
- x86 # 32-bit
- x64 # 64-bit

matrix:
allow_failures:
- julia_version: x86



branches:
only:
- master
- /release-.*/

notifications:
- provider: Email
on_build_success: false
on_build_failure: false
on_build_status_changed: false

install:
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))

build_script:
- echo "%JL_BUILD_SCRIPT%"
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"

test_script:
- echo "%JL_TEST_SCRIPT%"
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"
20 changes: 10 additions & 10 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using BinDeps
using Compat; import Compat.String
using 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)
Sys.isapple() && (return Libdl.dlsym_e(h,:TkMacOSXGetRootControl) != C_NULL)
return true
end)

if is_windows()
if Sys.iswindows()
using WinRPM
provides(WinRPM.RPM,"tk",tk,os = :Windows)
provides(WinRPM.RPM,"tcl",tcl,os = :Windows)
Expand All @@ -21,12 +21,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 +48,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
5 changes: 3 additions & 2 deletions examples/process.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
f = "radio.png"
using Base64

function process_file(f)
a = readchomp(`base64 $f`)
"<!-- $f -->\n<img src='data:image/png;base64,$a'></img>"
a = readchomp(`cat $f`)
"<!-- $f -->\n<img src='data:image/png;base64,$(base64encode(a))'></img>"
end

process_file(f)
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
8 changes: 3 additions & 5 deletions examples/test.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
## Example of widgets put into container with change handler assigned

using Tk
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 +25,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 All @@ -41,4 +40,3 @@ change_handler(path,xs...) = println(map(get_value, widgets))
map(u -> callback_add(u, change_handler), widgets)

set_visible(w, true)

19 changes: 9 additions & 10 deletions examples/workspace.jl
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
## simple workspace browser for julia
using Tk, Compat
using Tk

## Some functions to work with a module
function get_names(m::Module)
sort!(map(string, names(m)))
end

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

## short_summary
## can customize description here
short_summary(x) = summary(x)
short_summary(x::AbstractString) = "A string"

## update ids, returning false if the same, true if not
__ids__ = Vector{AbstractString}(0)
__ids__ = Vector{AbstractString}()
function update_ids(m::Module)
global __ids__
nms = get_names(m)
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 All @@ -47,9 +47,9 @@ function get_names_summaries(m::Module, pat::MaybeRegex, dtype::MaybeType, dtype
end
## filter out this type
if dtype != nothing
nms = filter(u -> isdefined(m, Symbol(u)) && negate(isa(eval(m,Symbol(u)), dtype), dtypefilter), nms)
nms = filter(u -> isdefined(m, Symbol(u)) && negate(isa(Base.eval(m,Symbol(u)), dtype), dtypefilter), nms)
end
summaries = map(u -> isdefined(m, Symbol(u)) ? short_summary(eval(m,Symbol(u))) : "undefined", nms)
summaries = map(u -> isdefined(m, Symbol(u)) ? short_summary(Base.eval(m,Symbol(u))) : "undefined", nms)

if length(nms) == length(summaries)
return [nms summaries]
Expand All @@ -75,7 +75,7 @@ scrollbars_add(f, tv)
## add a callback. Here we get the obj clicked on.
callback_add(tv, (path) -> begin
val = get_value(tv)[1]
obj = eval(Main, Symbol(val))
obj = Base.eval(Main, Symbol(val))
println(short_summary(obj))
end)

Expand All @@ -88,4 +88,3 @@ function cb()
end
aft = tcl_after(1000, cb)
aft.start()

Loading

0 comments on commit 1ff69f7

Please sign in to comment.