|
| 1 | +# Poptart.jl 🏂 |
| 2 | + |
| 3 | +<https://github.com/wookay/Poptart.jl> |
| 4 | + |
| 5 | +GUI programming in Julia based on [CImGui.jl](https://github.com/Gnimuc/CImGui.jl) |
| 6 | + |
| 7 | + * ☕️ You can [make a donation](https://wookay.github.io/donate/) to support this project. |
| 8 | + |
| 9 | + |
| 10 | +### Poptart.Desktop |
| 11 | + |
| 12 | + * Button, Slider |
| 13 | + |
| 14 | +```julia |
| 15 | +using Poptart.Desktop # Application Window Button Label Slider didClick |
| 16 | + |
| 17 | +window1 = Window(title="A", frame=(x=10,y=20,width=200,height=200)) |
| 18 | +window2 = Window(title="B", frame=(x=220,y=20,width=200,height=200)) |
| 19 | +app = Application(windows=[window1, window2], title="App", frame=(width=430, height=300)) |
| 20 | + |
| 21 | +button = Button(title="Hello") |
| 22 | +push!(window1.items, button) |
| 23 | + |
| 24 | +label = Label(text="Range:") |
| 25 | +slider1 = Slider(label="slider1", range=1:10, value=5) |
| 26 | +slider2 = Slider(label="slider2", range=1.0:10.0, value=2.0) |
| 27 | +push!(window2.items, label, slider1, slider2) |
| 28 | + |
| 29 | +didClick(button) do event |
| 30 | + @info :didClick event |
| 31 | +end |
| 32 | + |
| 33 | +didClick(slider1) do event |
| 34 | + @info :didClick (event, slider1.value) |
| 35 | +end |
| 36 | + |
| 37 | +didClick(slider2) do event |
| 38 | + @info :didClick (event, slider2.value) |
| 39 | +end |
| 40 | + |
| 41 | +Desktop.exit_on_esc() = true |
| 42 | +Base.JLOptions().isinteractive==0 && wait(app.closenotify) |
| 43 | +``` |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + * InputText |
| 48 | + |
| 49 | +```julia |
| 50 | +using Poptart.Desktop # Application Window InputText Button didClick |
| 51 | + |
| 52 | +window1 = Window() |
| 53 | +app = Application(windows = [window1]) |
| 54 | + |
| 55 | +input1 = InputText(label="Subject", buf="") |
| 56 | +button1 = Button(title = "submit") |
| 57 | +push!(window1.items, input1, button1) |
| 58 | + |
| 59 | +didClick(button1) do event |
| 60 | + @info :didClick (event, input1.buf) |
| 61 | +end |
| 62 | + |
| 63 | +Desktop.exit_on_esc() = true |
| 64 | +Base.JLOptions().isinteractive==0 && wait(app.closenotify) |
| 65 | +``` |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | +* see more examples: [PoptartExamples.jl](https://github.com/wookay/PoptartExamples.jl/tree/master/examples) |
0 commit comments