Display GUI component In Ignition dynamically using Python/Jython Script - python

Currently I am showing a number of user-defined GUI components (templates) (let's give it a name: signal) in some of my main windows. Those GUI components are spread around the windows and are quite a lot in number (>50 per window) and I have multiple of such windows.
I have created all those windows using Ignition GUI and so far they are done... but... Now, there is a requirement to make whatever signal is displayed in the GUI window to be shown in a list of GUI.
My questions are:
How to obtain list of GUI component (template) of the same type (signal) using Ignition Python/Jython Script?
How to get its custom properties (such as customDisplayName)
How to draw the GUI component (template) dynamically?
As of now, it is possible for me to drag and drop components (making exact copy of the displayed signals) in the container list I use to display the signal template. But since it is possible for new signal to be added in the GUI, I am looking for a more automated solution (if there is any).

Ignition supports obtaining of the GUI components by .components from the container type component using Jython script.
So in the end, the implementation of my solution for this question was:
for comp in rootcontainer.components: #looping through every component in the root container
if 'MySignal' in comp.name: #check the name of the component, see if it matches
#do the logic here

Related

Change the position of specific buttons at GtkHeaderBar?

I am creating a desktop recording program, I am designing the interface using Glade, and I am using GtkHeaderBar and client-side decoration.
This is what I have as an example: Example interface
My question is: How can I move the about button - for example - to be after the title text, so that I get 3 buttons before the title, and 1 after it, just like GNOME applications?
I Googled and got to gtk-decoration-layout, but couldn't find a real way to use it (Seems it will be system-wide if used).
gtk-decoration-layout is for the minimize/maximize/close buttons. You want pack_end() instead of pack_start(). If you're using glade, it'll be under the Packing tab when you select the given child.

Build complex layout in a dynamic list/grid

I'm building a simple app with python3 and GTK3.0 looking for the correct element for display a layout like the following image
I need display N items this items are load from a database (can be 1000+) and can change (insert, delete, update, etc.) and each item have a complex layout inside (labels, buttons, etc.)
How I can build a layout with a list/grid that dynamically changes.
I've read about GtkTreeView and GtkCellRenderer but i dont know how and other people recommend use GtkBox but how handle a model and update dynamically like ListView/CursorAdapter in android or ListView/Bindings in C#/WPF.
documentation of GTK 3.0 is really poor and does not explain how to extend a widget. another point that the documentation does not explain or at least I have not seen is how to reuse the same element, how to make good use of the resources (memory) when dealing with lots of elements, for example I created a series of widget in glade and I can not use N times. also not possible to create items that are not windows. everything should be within a window. as I can create a different arbitrary element of a window that can be reused.
please when you point me any of the above points, this has an example code can be C #, Python or C + + but it is important to have an example
I've just create a project called 'sqlite-browser' using python3 and gtk. When you display a large number of records in a database, you can use treeview, and add a pager (limit 100/200 records each page). Maybe this project can help you. And here it is: https://github.com/LiuLang/sqlite-browser
This is screenshot:

How can I get the main window's handle in Python?

In python, I enumerate top-level windows through EnumWindows, and also I enumerate the processes through EnumProcesses.
Then in the python script, I put all the window handles which belongs to the same pid into one list (I did this through GetWindowThreadProcessId).
Later I found out something: there are 3 window handles which belong to notepad.exe, but I only open one text file.
Why?
Besides, I tried to set the text window as the foreground window through SetForegroundWindow, I passed the three window handles to this function, and two work.
How could this be ?
Processes sometimes create invisible windows for their own purposes. You should ignore them (use IsWindowVisible function).
To investigate this kind of things your best friend is Spy++, that comes with several versions of Visual Studio, if you can get it.
According to it, notepad.exe creates three top-level windows:
The visible main window, class name "Notepad", overlapped.
A hidden, disabled, pop-up window, class name "MSCTFIME UI", caption "M".
Another hidden, disabled, pop-up window, class name "IME", caption "Default IME".
The two hidden windows are used internally by notepad to implement the IME (Input Method Editor), the GUI to type complex scripts.
Many programs create top-level hidden windows for a lot of things. For what you intend, you can ignore them all and use only the visible ones.

Tell windows which monitor to display dialogs on

I've got a program which is using multiple monitors. The program is showing special visualizations on the second monitor. At one point, the program uses windows shell functions to send files to the recycle bin. However, when it does this, the delete confirmation dialog comes on top of my visualization. This is particularly problematic, as when the mouse is on the second monitor, my program uses mouse hooks to capture all mouse input, so the user cannot even click the confirmation dialog.
Is it possible to somehow tell Windows to only place dialog boxes on a particular display?
I'm using python, though if I have to call C WinAPI functions that shouldn't be a problem
which function are you using to send the files to the recycle bin? if you use SHFileOperation you can pass a parent HWND. perhaps make that an invisible WS_EX_TOOLWINDOW window on the other monitor.
i would expect the API, treating that window as a parent, would center relative to that window, but i haven't tried it.
depending on which version of Windows you are targeting, there used to be a capability to create desk bands that 'dock' to the sides of the screen. this automatically gets factored into the area returned as rcWork by GetMonitorInfo and should prevent dialogs from overlapping this space. There might be another way to declare that a region is "in use" in a way that declares space off-limits, but I don't know of it so it probably doesn't exist...
the ugly and crude thing you could do is poll and move the dialog yourself, but if this is any kind of widely deployed or commercial app that would likely cause more harm than good.

making a python gui for ffdshow

I was thinking that for a learning project for myself, I would try to make a GUI for ffdshow on linux, using tkinter. Wanted to make sure this project would be feasible first, before I get halfway through and run into something that cant be done in python.
Basic idea is to have a single GUI window with a bunch of drop down boxes that have the various presets (like format or bitrate), as well as a text box where a custom number can be entered if applicable. Then when all the options are selected, the user hits the Start button on the GUI and it shows a progress little bar with a percentage. All the options selected would just send the relevant selections as cli arguments for ffdshow, and begin the conversion progress (essentially turning all the user's input into a single perfect cli command).
Is all this doable with python and tkinter? and is it something that a relative newb with only very basic tkinter experience could pull off with books and other python resources?
Thanks
That is precisely the type of thing that python and Tkinter excel at. And yes, a relative newbie can easily do a task like that.

Categories