Best way to fastly refresh text in a GTK window - gtk3

I am building a GTK window with text that need to be updated, say 10 times per second, every time it receives a data from a GPS.
Which kind of widget should I use?
GTK-label is safe for this kind of operation or are there other more suitable widgets?
Thank you.

You could use a GtkDrawingArea and draw to it using cairo.
That way it could be way higher than 10 drawings/s.
Cairo has native text operations.
You could even design your own widget.
Even if you're using python or any other language that cairo and gtk have bindings for, thanks to "gobject introspection".

Related

Is it possible to get the size of or resize a running program?

I would like to 'overlay' my application on top of another one, which would require me to resize that other program based on the size of mine. I'm currently using Flutter for my (cross-platform) application, and need to resize that other program based on the dimensions of my application.
In Flutter, I start a new process with Process.start("executable path") to start running the 'other program'. This creates a child process, but its window size and positions are not constrainable via my application.
I hope my 'problem' is a bit clear. Is there a way to achieve what I want in:
1: Flutter only (or perhaps another cross-platform framework?)
2: If not, how could I accomplish this using native APIs?

Is it possible to make Flutter 60FPS smooth, no matter how janky and slow my app currently is, using general-purpose and easy-to-use existing tools?

I have a Flutter app which is becoming more and more janky as time goes by and more features are added. Therefore, is there some utility to make it as smooth as 60FPS?
I know there are some official guides here: https://docs.flutter.dev/perf. However, I have tried to optimize and it is still slow. You know, some things just cannot be fast enough, such as long text, dynamic layout, necessary synchronous computations, etc. Especially when entering a new page or scrolling down a ListView. In addition, I have to use brainpower to find out what is slow and optimize when new features are added, so I hope there is some fully automatic thing which I can drop-in replace and forget it and it just works forever.
Disclaimer: I wrote this package and this is a Q&A style StackOverflow answer.
Yes, I have made it: https://github.com/fzyzcjy/flutter_smooth.
No matter how heavy the tree is to build/layout, it will run at (roughly) full FPS, feel smooth, has zero uncomfortable janks, with neglitable overhead. (I have made some benchmark reports here)
As for usage, for common scenarios, add 6 characters ("Smooth") - ListView becomes SmoothListView, MaterialPageRoute becomes SmoothMaterialPageRoute. For complex cases, use SmoothBuilder(builder: ...) and put whatever you want to be smooth inside the builder.
Roughly speaking about the implementation, it is done by submitting extra frames to the rasterizer every ~16ms, without disturbing all existing code. Therefore, the existing app code will almost not even know the existence of this package.
You need to check how do you use widgets, unnecessary rebuilds, some heavy operations when the widget is creating o rebuilding and it’s recommended to use the performance profiler in the devtools.

I am trying to implement a ReverseAnimation (hero animation) in my pageview possibly without using external packages

I have a pageview with 6 pages. In each of these there is the app logo (a png enclosed by hero). I need that, although it is a pageview and the Navigator is not called, the animation is a ReverseAnimation.
I have read that you can use the "coast" package, but I am not able to implement it and, to be honest, I would like to minimize the use of packages.
I apologize for the bad quality of the gifs but I had to compress the files.
I know this is not what you want to hear but I Must say, without using the "coast" package or something similar, implementing what you want is exceedingly difficult. that's exactly why there are packages in the first place. if you faced problems with implementing that package, please post that problem instead.

Using GEGL with GTK 4 for a simple image viewer with pan/zoom support

I need a simple image widget with a support of panning/zooming but unfortunately it appears GTK still does not offer one. I have managed to achieve something similar by using a ScrolledWindow and a Picture backed by a PixBuf (via scaling the PixBuf on demand and a EventControllerMotion to mimic panning), but needless to say that this approach is too slow for smooth zooming on touchpads and uses an insanely high amount of memory due to no tiling.
A suggested approach seems to be using GEGL, but it's not obvious how one is supposed to do that. There seems to be helper libraries for previous versions of GTK (gegl-gtk and gegl-gtk3) but I do not know how one is supposed to use it with GTK 4 applications. And to be honest the documentations are pretty much non-existent.
So I would appreciate some examples/explanations on basics usages of GEGL within GTK (4) applications, or whether if there is a better way.

iPhone application : is-it possible to use a "double" slider to select a price range

I'm working on an iphone application (not web app) and I'd like to build a form asking a user to indicate a price range. Instead of using two text fields, I would prefer to use a double slider to set the minimum and the maximum price. I know that it is possible de use a simple slider (sound control for exemple) but i've never seen a double one. Can anyone help ?
This is not possible without creating a custom control. You'll need to inherit from UIControl or UIView and provide a custom drawRect method. You'll also need to respond to touch and drag events to update the state of the control. I have not done this myself, but I would be prepared for a fairly significant amount of work to get everything to respond and display as expected.
I'm curious as to why you need to have both values specified on a single slider? Why not use two sliders either side-by-side or stacked? It would not require any more input steps than a double slider, and would conform more to standard UI guidelines.
I think you can specify multiple thumbs for a single slider if you subclass UISlider, at least I vaguely remember that being possible in MacOSX. But Code Addict is right, you'll probably be better off using the standard controls - a double-thumbed slider seems like it'd be pretty difficult to deal with in the touchscreen environment.
I built such a control and added it to GitHub so feel free to have a look and if you like the control extend it and contribute.
GitHub page: http://github.com/doukasd/DoubleSlider
Blog post (showing a video of how it works): http://dev.doukasd.com/2010/08/double-slider/