Skip to main content
Emilmart
Associate III
March 4, 2021
Solved

Import/export custom container from code files to an other touchgfx project

  • March 4, 2021
  • 3 replies
  • 1817 views

Hello,

I'd like to export a custom container from a GFX project to an other GFX project.

What's the proper way ?

Thanks.

This topic has been closed for replies.
Best answer by Romain DIELEMAN

Hi,

Is it a custom container made through Designer or through code ? If through Designer then there are no ways to easily share it to another TouchGFX project (working on it). If you have made your custom container through code then you can easily add the corresponding files to your new project. The downside with doing custom containers through code is that you will not be able to see them in the canvas view of TouchGFX Designer (they will appear in the simulator).

I would still recommend creating a custom container through code based on the one you might have made through Designer if you plan on using it in multiple other projects. What I personally do when I work with custom widgets that are not displayed in the canvas view is to add a box widget with the same size as the custom container. I then set it invisible at start up and change the coordinates of my custom container based on the ones of the box.

Something else I do when I know I will use a custom container from another project, and if I have not started my project yet, is to use the "import UI" function in Designer to import the UI of the project with the custom container to the new project. You then need to get rid of the rest. It is not a good workflow but is fine for my projects.

Hope this helps,

/Romain

3 replies

Romain DIELEMAN
Romain DIELEMANBest answer
ST Employee
March 4, 2021

Hi,

Is it a custom container made through Designer or through code ? If through Designer then there are no ways to easily share it to another TouchGFX project (working on it). If you have made your custom container through code then you can easily add the corresponding files to your new project. The downside with doing custom containers through code is that you will not be able to see them in the canvas view of TouchGFX Designer (they will appear in the simulator).

I would still recommend creating a custom container through code based on the one you might have made through Designer if you plan on using it in multiple other projects. What I personally do when I work with custom widgets that are not displayed in the canvas view is to add a box widget with the same size as the custom container. I then set it invisible at start up and change the coordinates of my custom container based on the ones of the box.

Something else I do when I know I will use a custom container from another project, and if I have not started my project yet, is to use the "import UI" function in Designer to import the UI of the project with the custom container to the new project. You then need to get rid of the rest. It is not a good workflow but is fine for my projects.

Hope this helps,

/Romain

Emilmart
EmilmartAuthor
Associate III
March 4, 2021

Hi,

I was thinking about the two methods (code or designer). This help to know that it works like this for now, thanks !

scottSD
Senior III
April 15, 2021

I have done this in the past. It is tedious, but I was able to do it.

I copied the custom container (both the gui_generated container files and the gui container files) files themselves to the new project. Then used a merging tool to merge the custom container text in the TouchGFX project file from the original file to the new project file.

DSwea.1
Associate III
February 5, 2022

I'm running into this issue again myself. I'd already determined that I could use the workaround Romain suggests for "importing" objects from other projects by hand. Since this issue has been discussed here for at least 3 years now (https://community.st.com/s/question/0D50X0000ADEdfxSQD/how-to-reuse-a-custom-container-in-a-new-touchgfx-project), I was hoping that some progress might have been made recently in making it easier to import objects. Yes, doing it by hand works---IF you are very careful when editing the JSON project you're copying to, and IF you have a thorough understanding of the TGFX project structure. But what an extremely tedious method this is for a task that should be fundamental to the application.

As I've become more familiar with TGFX over the past 8-10 months, I've been impressed by the powerful capabilities the environment provides. And I intend to continue to use the application going forward, and would be happy to recommend it to other users.

But it is a real mystery to me that TGFX's creators, who obviously are very skilled and knowledgeable (far more than I, I must admit), would pay so little heed to the important and fundamental concept of reusability, without which we must start from scratch on each new project.

Romain refers to the practice of developing most of your work in code rather than the Designer and using stand-in objects in the Designer to represent the objects that will be replaced when the code runs. This is another work-around that I've come to employ myself. I would, however, comment that every such instance of using this work-around diminishes the value of the Designer by another degree. How I wish that one could create a container object and then be able to parameterize individual instances in the Designer rather than having to do so in code. Once a container has been created, it becomes a black box once used in the Designer---access to its "insides" is only possible from external code.

Romain DIELEMAN
ST Employee
February 7, 2022

Hi,

Thank you for the feedback, we really do read them and take them into account. We are currently working on it and it is our first priority for TouchGFX 4.20. It is more complicated than expected and keeps getting delayed by other features or "urgent" projects unfortunately...

/Romain