Flet integration (modularization) with other Flutter/Dart code - interop

I love the idea of combining the power (and existing libraries) of python with the rich user interfaces of Flutter, however I wonder about how Flet can interact with existing Flutter code-bases.
Specifically, is it possible to incorporate Flet into existing Flutter apps? Can I write a specific business-logic module in Flet (via python) and then access that module via standard Dart/Flutter?
I think such a mechanism would provide a lot of utility for developers, allow for a larger range of (language) expressivity in Flutter apps and make it easier for established codebases to adapt Flet without having to start from scratch.
FYI: I know that Flutter packages for python integration exist (e.g. Chaquopy and Starflut, or just running a custom python-based on-device web-service), but I am intrigued by the more native integration that Flet could afford (less marshalling logic, etc.)

Related

NEAR API with Python

A community member would like to utilise Python to integrate aspects of their application with NEAR. Would it be possible to build an application on NEAR using Python? Can the NEAR API be used with Python?
With NEAR you build on 2 fronts:
"Inside": Contracts (to write code that runs on-chain and changes state in the system)
"Outside": API (to create dApps that communicate with NEAR)
Contracts
We currently support two languages:
Rust (near-sdk-rs)
and AssemblyScript (near-sdk-as)
You can find more examples of contracts written in both of these languages in our NEAR Examples GitHub org, many of which are running live on near.dev
In the future we will support any language that we (or our community) decides to enable from a pretty long list where “enable” means building out the sdk like near-sdk-rs and near-sdk-as linked above.
API
We currently have a JSON RPC API that you can use from any language (including Python) as well as a convenient wrapper for JavaScript developers called near-api-js. Again, we (or our community) can decide to build more convenient wrappers for any other language we want to support, including Go, Java, C#, Python, Ruby, etc
As a side note, if someone in the community is interested in Python specifically, there’s a ton of it currently being used to do things like run tests (nearcore pytest), manage builds (nearcore scripts) and deploy nodes (nearup) as well as simulate some of the on-chain stuff like the Runtime
I use py-near
https://pypi.org/project/py-near/
built-in transactions with FT
fully asynchronous library
good documentation
built-in transfers NEAR/Ft by SMS
multiple RPC node support

How to make a GUI in Julia?

I'm new at programming in Julia and I need to create a GUI.
I've been looking for information and I can't find anything useful. I tried to search information in the Julia official web page, but it seems to be down. I wonder if any of you guys knows where I can find information about it.
This is quite a generic question, but I'll try and layout the environment so that you can make an informed decision based on your needs. You might want to check out this article on 6 Julia Frameworks to Create Desktop GUI’s 🖥 and Web Apps.
If you are developing your code within an [Jupyter/IJulia] notebook, and need very simple interaction, such as a slider to change some input values, the Interact package is the easiest thing to get started with.
To develop full-fledged web UIs, take a look at Escher. Inspired by the Elm, it provides a functional library of UI components. Interactive web UIs are created in 100% Julia. There is no differentiation in code between the client and server sides. The framework handles all of that.
Another web framework worth looking at is Genie, which is based on the traditional MVC design pattern. It also includes an ORM.
Stipple is a reactive UI library for building interactive data applications in pure Julia. It uses Genie.jl (on the server-side) and Vue.js (on the client).
Dash ties modern UI elements like dropdowns, sliders, and graphs directly to your analytical Julia code.
All the above solutions are for creating web user interfaces, accessed via a browser. If you want to create cross-platform desktop apps, but want to work with web technologies (i.e. HTML/CSS/Javascript), use Blink. This is a Julia wrapper around the Electron. You could potentially write a Dash or Stipple application, and wrap it in Blink.jl to create a desktop app.
To create desktop UI applications using the Gtk library, use the Gtk.jl package in Julia. If you are familiar with the Gtk API, it is easy to get started. Note however that there are some significant known issues running GTK.jl on Windows.
If your UI framework of choice is QT, a Julia binding is available via QML.jl
If you are happy painting the buffer yourself and just want a window to render the pixels on the screen, then there is nothing simpler than MiniFB. Note however that this does not give you a widget library -- you are responsible for drawing each and every pixel yourself.
ClmGui.jl is a Julia wrapper around the immediate mode GUI toolkit known as Dear ImGui
And last, but not the least, the venerable Tk framework has a wrapper in Julia. The UI's created using TK are sometimes considered ugly compared with modern aesthetics, but sometimes this is the quickest way to get a window up.
[Edited Jan 2022]
QML.jl
https://github.com/barche/QML.jl
The QML.jl package enables using the QML markup language from the Qt library to build graphical user interfaces for Julia programs. The package follows the recommended Qt practices and promotes separation between the GUI code and application logic. All user-facing code is pure Julia and QML, no C++ knowledge is required to use the package.
There is a new package called Genie. It is a web framework comparable with Django in python. You can create web ui using Genie. Until now (Aug. 2017), the package is functional with some nice demos, the documentation is not quite complete though.

Is it possible to create an application WITHOUT a framework?

I was just thinking. C# has Winforms/WPF, Java has Swing and other frameworks, C++ has QT and so on; is it possible to create an application without using a Framework?
Putting aside the practicality of it, I'm just curious. How would one create an application that Just Works(tm) without needing external frameworks?
Two options come to mind:
Classical Win32 applications written in C. I don't know if standard Windows SDK API also counts as an "external framework" in your book, but that's as low as it gets.
DirectX/OpenGL games written from scratch with your own homebrew framework (not external, right?) There you get to do all the drawing yourself - although again, you use a pretty big library of primitive drawing functions.
If you want even less "framework", you'll have to code your own OS and drivers. :P
C# needs .NET Framework, not WinForms (which is an optional library used by some application). The same with Java.
Unmanaged (native) applications usually use some runtime library - the library of common functions. You can write a native application without any library - the compiler lets you do this, but you will need to (re)write lots of common functions, eg. for string manipulation etc..
Firstly, what is a framework?
Really a framework is just a bunch of code that is provided to you. You could, at least in theory, write the same code yourself. In that case you wouldn't be using a framework.
Your application can only do what the operating system allows it to do. Your program cannot directly manipulate the graphics card for example. So you have to use the APIs of your operating system in order to do anything.
So you are going to be calling into other code. (unless you write your own operating system). You will also being using another framework or api to get stuff done.
Yes. How: in the way that the frameworks you mentioned are implemented.
From a Windows point of view, you would register your window with Windows, then listen to window messages and react as required. Everything would be up to you - from drawing the window to building controls.

How does Qt only use C++ to make custom GUIs for some many platforms?

I don't see how Qt does the low level graphics work, in order to create its own custom GUI look/feel for each platform. Does it utilize each of the platforms APIs or something? I ask because I am really wondering how I could go about creating my own framework in order to make a custom GUI application with a unique graphical look.
"How does QT only use C++ to make custom GUIs for some many platforms?"
"Does it utilize each of the platforms APIs ... ?"
You answered your own question. It makes a common library for developers to write their applications with. The application developers write their application only once, not caring about platform specifics. Then, the library author puts out different versions of the library for each platform, which handles all the specific UI calls. This is called encapsulation:
http://en.wikipedia.org/wiki/Information_hiding#Encapsulation
If you were to write your own such library, you would need to figure out what is common between all of the platforms you target, or figure out what high-level concepts your application would need, and create that abstraction. Then, implement that abstraction for each of the platforms you wanted to support.
Edit:
Also see Juliano's comment. This seems like it might be closer to what you want to do, rather than the question you asked. I'd not re-do the work that Trolltech or the WxWidgets team or the Gtk guys or the Mono people did, if I could possibly avoid it.
The good people at Trolltech (now Nokia) write all the platform specific code for you. Only the interfaces to their library remains the same across platforms. You do have to make sure that you only use their classes and don't make any OS-specific calls.
If you want, you can modify the graphics and the handlers to extend the Qt library and create your own look and feel.
Your Qt application doesn't have to have the plain standard platform graphical look, but there are ways to design unique apps with Qt.
For instance, you can style your application with style sheets: http://doc.qt.io/qt-5/stylesheet.html, or even with a custom QStyle (which is not very easy): http://doc.qt.io/qt-5/qstyle.html
Qt Quick is a new technology we're introducing in the upcoming Qt 4.7 (check out the beta if you're interested). It allows you to easily define custom UI components from simple primitives, with custom animations, state transitions and other effects. See for example http://www.youtube.com/watch?v=8G4U7QWRajg.

How do you port a Cocoa/Mac application to Windows?

How do you port a Cocoa/Mac application to Windows? I mean how would you go about it? Assume the app was written with Objective-C and Cocoa, there's nothing fancy going on, no "engine" that could be factored out, etc.
Rewrite from scratch? I don't think there will be huge overlaps between the Mac and Windows codebases, right?
I have doubts about cocotron.
Its not clear from the cocotron website that cocotron is actually production ready yet. Id suspect that it would be possible to start new app development and use cocotron constantly to maintain and test windows builds on the go.
But to retrofit it into an existing project might be a much larger task. There are also no alternatives to cocotron - other than perhaps gnustep.
The practical approach to cross platform development involves developing the non gui components of your application, once, in C or C++. And then using a cross platform GUI library like QT - which is VERY good at generating and using native UI where possible or faking it where not. Please DO go to qt.nokia.com and download the latest build of QTCreator for windows and mac - See how the same QT application looks and feels very convincingly native on both platforms.
If QT doesn't provide a native enough solution, then you need to develop your GUI twice :- once in Cocoa, and once in Win32. The cocoa GUI would be in objective C of course, the Win32 GUI in C/C++.
Your non gui application code would - written in c++ - not be able to call Objective-C directly, but its not hard to write shim classes, implemented in .mm files - the provide a c++ interface, and wrap access to an objective c object or class.
You are also going to have to come up with an alternative to CoreData on windows - perhaps sqlite? Given that XCode has integrated support for the sqlite framework, and testing multiple code paths is, well, more work - perhaps dropping CoreData in favor of a common layer is a better approach?
The problem with Objective C is its very poor support on any platform that is not OS X. You can attempt to use the Cocotron, but I wouldn't consider it production ready yet.
For portability, a re-write is in order. With judicious use of standard C or C++ for the "core" of the application, you could still implement platform specific GUI code. If you don't like maintaining two GUIs, you can also try a toolkit such as Qt
Depending on which objects and framework you are using for your cocoa app, you might be able to get away with using gnustep, although the end result will probably look very weird to windows users, and the development environment might be a bit difficult to setup at first.
Are you aware of Cocotron? It looks like the project may have gone stale, but it's a good starting point anyway. It's a project to port Core APIs.
If your application is not cleanly separated (ie: a la MVC) then the only solution is a rewrite, I think.

Resources