msink / kotlin-libui Goto Github PK
View Code? Open in Web Editor NEWKotlin/Native interop to libui: a portable GUI library
License: MIT License
Kotlin/Native interop to libui: a portable GUI library
License: MIT License
Hello.
I tried to work hello-ktx sample according to README in this project. But it doesn't work and output this error.
Task :samples:controlgallery:linkReleaseExecutableLinux FAILED
/home/komkomh/.konan/dependencies/clang-llvm-6.0.1-linux-x86-64/bin/ld.lld: error: unable to find library -lgtk-3
/home/komkomh/.konan/dependencies/clang-llvm-6.0.1-linux-x86-64/bin/ld.lld: error: unable to find library -lgdk-3
/home/komkomh/.konan/dependencies/clang-llvm-6.0.1-linux-x86-64/bin/ld.lld: error: unable to find library -latk-1.0
/home/komkomh/.konan/dependencies/clang-llvm-6.0.1-linux-x86-64/bin/ld.lld: error: unable to find library -lgio-2.0
/home/komkomh/.konan/dependencies/clang-llvm-6.0.1-linux-x86-64/bin/ld.lld: error: unable to find library -lpangocairo-1.0
/home/komkomh/.konan/dependencies/clang-llvm-6.0.1-linux-x86-64/bin/ld.lld: error: unable to find library -lgdk_pixbuf-2.0
/home/komkomh/.konan/dependencies/clang-llvm-6.0.1-linux-x86-64/bin/ld.lld: error: unable to find library -lcairo-gobject
/home/komkomh/.konan/dependencies/clang-llvm-6.0.1-linux-x86-64/bin/ld.lld: error: unable to find library -lpango-1.0
/home/komkomh/.konan/dependencies/clang-llvm-6.0.1-linux-x86-64/bin/ld.lld: error: unable to find library -lcairo
/home/komkomh/.konan/dependencies/clang-llvm-6.0.1-linux-x86-64/bin/ld.lld: error: unable to find library -lgobject-2.0
/home/komkomh/.konan/dependencies/clang-llvm-6.0.1-linux-x86-64/bin/ld.lld: error: unable to find library -lglib-2.0
e: /home/komkomh/.konan/dependencies/clang-llvm-6.0.1-linux-x86-64/bin/ld.lld invocation reported errors
FAILURE: Build failed with an exception.
My os version is
CentOS Linux release 7.6.1810 (Core)
Please give me a hint. Thanks
With Kotlin 1.3 the support for raspberry
was added (which is a linuxArm32Hfp
plattform).
It would be great to extend the project for this platform.
I already compiled the libui manually and added it, but it should be done directly in this project instead of doing it manualy.
Hi, me again. :)
I've noticed the dispose() method is never called for me in the examples.
I've tried hello-ktx and controlgallery, OS is Manjaro (4.19 Kernel).
The callback from uiOnShouldQuit is never reached.
Even when I dispose the mainWindow manually, I would have expected all children's dispose() method to be called - which was not the case!
I'm not sure if I missed something, or maybe it's a bug?
Andreas
Hi, this is awesome!
Is there an easy way to add kotlin-libui as a dependency when I create a new project, or does kotlin-libui have to be in the parent gradle project?
I found OpenFileDialog very useful and would like to have the same for folders. If you don't have time for it I can try to dig into it.
Can we display links?
When executing an application created with this library on linux, it looks for libcrypt.so.1 which on Arch Linux has been deprecated and replaced with libcrypt.so.2. This issue can be solved simply by creating a symlink, which means theres no compatibility issues requiring the older version of the library, so I would recommend updating the dependency to the newer version.
I noticed in this project's README that you weren't sure about the DSL.
Well, what if we changed the DSL over to Android/Jetbrains Compose? It seems like fun idea because:
expect/actual
to build common interfaces that work across both Android and native desktop.I'm just brainstorming, but I'm hoping to have some time to explore this myself, thought the idea was worth sharing.
https://github.com/msink/kotlin-libui/tree/master/samples/drawtext
Namely I wonder how the text is written, so that it appears like
that. Could the readme there briefly explain how this is done?
I am reading the source code but I am still a kotlin noob so ...
libui/libui.def
-linkerOpts.linux = -L/usr/lib/x86_64-linux-gnu \
+linkerOpts.linux = -L/usr/lib \
Not sure if this can be set automatically to the correct directory on all systems. Maybe just document somewhere that you might need to adjust the value?
How could we choose a file or dir in libui
, or is there any way to achieve this goal?
➜ kotlin-libui git:(master) ./gradlew build
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :libui:compileKonanLibuiLinux_x64 FAILED
Exception in thread "main" java.lang.Error: /tmp/tmp4030171382076881273.c:1:10: fatal error: 'ui.h' file not found
at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:145)
at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.indexDeclarations(Indexer.kt:916)
at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.buildNativeIndexImpl(Indexer.kt:906)
at org.jetbrains.kotlin.native.interop.indexer.NativeIndexKt.buildNativeIndex(NativeIndex.kt:56)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:242)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:36)
at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:88)
at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:18)
FAILURE: Build failed with an exception.
Looks like I am missing a library?
Need to integrate coroutines support from
https://github.com/Kotlin/kotlinx.coroutines/tree/master/native
and add sample similar to timer
but based on coroutines.
This is awesome that you've put this project together and continue to maintain it. I'm trying to think of an easy way to add it to an app, and it's not an easy process. It'd be amazing if this were on maven central so we could pull it naturally as a dependency!
Did you guys have a look at libui-ng yet?
Hi, one more thing ;)
I've seen files like this: https://github.com/msink/kotlin-libui/blob/5f1c615a6fa1ba846fb1e910a76fe26ff44e19cf/samples/table/src/main/resources/andlabs_16x16test_24june2016.png.kt
They look like they are generated from the png file, and I'm interested how you generated them.
Is the generator part of the repo? And is it possible to extract the generation of the files as a step in the gradle-build?
Asked from K/N developers: JetBrains/kotlin-native#1624
I'm trying to run a background task using a worker and display a message when an exception is caught.
Here's a minimal reproducible example:
package example
import kotlin.native.concurrent.TransferMode
import kotlin.native.concurrent.Worker
import libui.ktx.*
fun main() = appWindow("Test", 800, 600) {
vbox {
button("Test") {
action {
Worker.start().execute(TransferMode.UNSAFE, {}) {
MsgBox("This doesn't work")
}
}
}
}
}
That fails with this error when clicking the button:
Uncaught Kotlin exception: kotlin.native.IncorrectDereferenceException: Trying to access top level value not marked as @ThreadLocal or @SharedImmutable from non-main thread
at ThrowIncorrectDereferenceException (0x232c5c)
at kfun:example.$<bridge-UNNN>main$lambda-2$<anonymous>_3_6$<anonymous>_5_8(kotlin.Unit)#internal (0x2485c0)
at _ZN6Worker19processQueueElementEb (0x25d2ac)
at _ZN12_GLOBAL__N_113workerRoutineEPv (0x25d96d)
at (0x7f70ac741422)
at clone (0x7f70ac656bf3)
at ((nil))
Linux x86_64
1.3.72
0.1.7
1.3.5-native-mt
▶ ./gradlew build
Welcome to Gradle 5.5-rc-3!
Here are the highlights of this release:
- Kickstart Gradle plugin development with gradle init
- Distribute organization-wide Gradle properties in custom Gradle distributions
- Transform dependency artifacts on resolution
For more details see https://docs.gradle.org/5.5-rc-3/release-notes.html
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
> Task :buildSrc:compileKotlin
The `kotlin-dsl` plugin applied to project ':buildSrc' enables experimental Kotlin compiler features. For more information see https://docs.gradle.org/5.5-rc-3/userguide/kotlin_dsl.html#sec:kotlin-dsl_plugin
> Task :buildSrc:compileJava NO-SOURCE
> Task :buildSrc:compileGroovy NO-SOURCE
> Task :buildSrc:pluginDescriptors UP-TO-DATE
> Task :buildSrc:processResources NO-SOURCE
> Task :buildSrc:classes UP-TO-DATE
> Task :buildSrc:inspectClassesForKotlinIC UP-TO-DATE
> Task :buildSrc:jar UP-TO-DATE
> Task :buildSrc:assemble UP-TO-DATE
> Task :buildSrc:compileTestKotlin NO-SOURCE
> Task :buildSrc:pluginUnderTestMetadata UP-TO-DATE
> Task :buildSrc:compileTestJava NO-SOURCE
> Task :buildSrc:compileTestGroovy NO-SOURCE
> Task :buildSrc:processTestResources NO-SOURCE
> Task :buildSrc:testClasses UP-TO-DATE
> Task :buildSrc:test NO-SOURCE
> Task :buildSrc:validateTaskProperties UP-TO-DATE
> Task :buildSrc:check UP-TO-DATE
> Task :buildSrc:build UP-TO-DATE
> Configure project :libui
Kotlin Multiplatform Projects are an experimental feature.
publishModeEnabled: false
The Kotlin source set commonTest was configured but not added to any Kotlin compilation. You can add a source set to a target's compilation by connecting it with the compilation's default source set using 'dependsOn'.
See https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#connecting-source-sets
> Task :libui:downloadArchive UP-TO-DATE
> Task :libui:unpackArchive UP-TO-DATE
> Task :libui:cinteropLibuiLinux FAILED
Exception in thread "main" java.lang.UnsatisfiedLinkError: /home/bruno/.konan/dependencies/clang-llvm-6.0.1-linux-x86-64/lib/libclang.so.6.0: libtinfo.so.5: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.prepareTool(main.kt:297)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:176)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:38)
at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:70)
at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:18)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':libui:cinteropLibuiLinux'.
> Process 'command '/usr/lib/jvm/java-8-openjdk/bin/java'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.5-rc-3/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 8s
3 actionable tasks: 1 executed, 2 up-to-date
os: MANJARO linux 5.1.15
Do you plan to support some kind of data-binding?
I think of it in a way that you pass a model object (Observable?) to a TextField, and each time the string is changed, the UI is changed as well.
And, additionally, each time the user types into the TextField, the model object get's changed automatically.
Need to investigate why.
These would be a welcome addition to the DSL, as the tornadofx has them and they're handy
https://github.com/edvin/tornadofx/wiki/Forms
I saw this sample, but it doesn't work for the ComboBox and probably others.
I'm thinking about writing applications that run natively, but also on the JVM.
Is it possible to write one single gui code, using the kotlin-libui syntax ?
Can the kotlin-libui library be extended, so it uses e.g. Tornado-FX, but still provide the same programming interface to the developer?
For now there is almost no documentation, except for autogenerated.
Any contributions will be very helpful.
As Kotlin 1.3.31 now can build for 32-bit windows - I decided just switch windows build to 32-bit, and drop support for 64-bit windows, at least for now.
Do not see any reasons for 64-bit windows executable for simple utilites.
If anyone have significant reasons - please comment here, and I will create new target windows_x64
To migrate - just replace in your build scripts mingwX64
to mingwX86
, and msys2-mingw-w64-x86_64-gcc-7.3.0-clang-llvm-lld-6.0.1
to msys2-mingw-w64-i686-gcc-7.4.0-clang-llvm-6.0.1
.
Gradle should be upgraded to 5.4 - gradle wrapper --gradle-version 5.4 --distribution-type all
So new projects can just use kotlin-libui as a normal dependency
See #7
Not sure if it is macOS only and if it is blocked by upstream. But I couldn't find any issue/info in the upstream libui project.
Right click -> copy works though.
Hi,
I'm using this library to build a desktop project but I need to close the window manually and re-create it later. Now I'm using the ktx library but I cannot find any methods to do this. Are there any methods for me to use in order to close the window? My code is attached below. Thanks.
fun main(args: Array<String>?) {
appMain() // Display the UI and block
// To do some extra work.
}
fun appMain() = appWindow(
title = "Sample",
width = 320,
height = 240
) {
vbox {
button ("Quit") {
action {
// uiControlDestroy
// I tried it but the window closes without continuing the statements in main().
this@appWindow.dispose()
}
}
}
}
Despite two years have passed since the moment when this problem had been outlined for the first time, there is still no documentation.
I'm a newbie to both Kotlin|NAtive and GUI.
I found that I simply cannot do even the simplest things without documents.
Can anybody assist me in providing at least full-functional (and not few simple samples) examples of coding GUI using libui?
I need to build a very simple application:
Thank you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.