You are currently viewing 新功能发布 | TSMaster工具箱集成开发环境系列2-工具箱极简开发流程

New Releases | TSMaster Toolkit IDE Series 2 - Toolkit Minimalist Development Flow

This chapter continues with the second chapter of the TSMaster Toolbox IDE series, Python-based interface design. Let's take a look at how to do minimalist development of the toolkit in the TSMaster environment.

Table of Contents for this article

I. Creating space

1. Check the Python environment for readiness

Open TSMaster, go to Tools-System Information-Python Environment Settings page, in which users can choose the default running environment of Python x86 and x64. The latest version of TSMaster supports x86 version and x64 version, which can be configured according to whether the Python program developed by TSMaster is 32-bit or 64-bit, and you just need to Depending on whether the Python program developed by TSMaster is 32-bit or 64-bit, you just need to configure the corresponding running environment.

We come to the x86 runtime environment configuration box, which by default shows the Python that comes with TSMaster, i.e. version 3.8.5, which shows the full program path.

2. Configuration box button operation

There are 5 buttons on the right side of the configuration box. The 1st button, Select Python Environment, when clicked, will bring up a dialog box where you can select another Python path. For example, if you have installed Python version 3.9 locally, you can completely change TSMaster's Python environment to version 3.9, and you don't need to always use the Python version that comes with TSMaster. After selecting version 3.9 and clicking Open, you can see the prompt that you can use the latest Python interpreter after restarting TSMaster software, just follow the prompts to restart and reopen TSMaster again. go to Tools - System Information - Python Environment Settings, you can see the output of the Python command line, which will show the current version number of the Python and the compile time and other detailed information. time and other details.

The 2nd button, which opens the folder for the Python environment, will bring up the main folder for Python 3.9 when clicked.
The 3rd button, it is to re-install TSMaster support library for the current environment, if TSMaster has been updated with a new version, or the user accidentally deleted the package related files, then you need to go here to install the TSMaster support library. You can click to try, it will show TSMaster support package is installed.
The 4th button, which is the path to restore the default Python interpreter, can be clicked to switch to the initial default, which is Python 3.8.5, in one click.

The 5th button, which is to test if TSMaster's support library is working properly, will print the name of the API function in the support library and other information when clicked. If the test is successful, the TSMaster support library is available.

3. Creating toolbox windows

Open the application, Toolbox Design and Development Environment, the first page is a list of existing toolboxes, click the "+" Add button on the toolbar to create a new toolbox. Enter the name of the toolbox. For example, toolbox, press enter and a new toolbox is created.

Double-click on the toolbox1 line to get to the area of the control code, which defines a class called toolbox1 that inherits from TSMaster's internal toolbox form, TSForm. there is only one line of initialization code, which is to set the Caption, indicating that this is an empty form. Clicking Run at the top, or F9, launches this code and creates an empty toolbox window.

II. Modification of space attributes

Click on the Window button on the toolbar to launch the Interface Designer, and we'll start by implementing a simple function. For example, click the button to change the title bar of the form, to Hello World.

Come to the Controls page, select the first line of the list Button, click, come to the form area, and then click to create a button, the button is in the selected state by default, press F11, or click on the right side of the properties, you will come to the control's Properties tab. The default name of this button is Button1, where there is a Name, change it to btnTitle and change its Caption to Set Title.

If you need to preview the effect, you can go to the Configuration tab of the component window and see that there are two buttons for code generation, the first one generates the Python code only, the second one generates the code and then runs the window at the same time, and if you click on the second button, it will close the current editor.

III. Generating code

1. New property settings

Mainly divided into two pieces of content, the first is the init function, the second is a variety of user-defined to the toolkit code design area, you can see that the empty form of the code added to the window's attribute settings, as well as the creation of buttons and attribute settings and so on. It should be noted that, sandwiched between two lines of green comments in the code is automatically generated and controlled by the form designer, do not recommend that the user to modify their own, because any modification will be followed by the code generation again to cover.

Here, it is recommended that you use a professional editing tool to edit externally, and the recommended tool here is VS Code.

2. Writing event handlers

First, in the initialization function, associate the button click event to an event handler function. We can start by defining this function in our code. For example, below the function body of the init function, go ahead and write def OnSetTitleClick. note, note that the first parameter of a UI event is always sender, the source of the event trigger, so functions of this type generally have at least one parameter.

Next, you need to set self, that is, the Caption of this form in the processing function to Hello World, then this function is written. Finally, we just need to self.btnTitle OnClick event associated with OnSetTitleClick, the code is written.

Back to TSMaster, after clicking on the edit box, we will see that the file will be refreshed to the latest state, then we can press F9 or click on the triangular start button to run the program, click on the triangular start button to run the program, you can see that the title bar of the window changes to Hello World, which is the minimalist design process of the toolbox.

IV. Stand-alone function of the toolbox

Let's go to VS Code and click on the arrow directly on the top right, at this point we can start by minimizing TSMaster, changing the workspace to Trust, and then clicking on the Run button on the top right, and you can see that VS Code directly calls Python and launches the toolkit.

At this point the toolbox window is again running independently from the main TSMaster program, which is the standalone form of the toolbox window. This means that the toolbox window replaces the main TSMaster window as a standalone application, and TSMaster runs in the background, providing all possible support for the Python window, but all of TSMaster's built-in functionality is still available.

About More

Above is this chapter for you to introduce the simple design process of the TSMaster toolbox, more use of tutorials can be viewed on the B station video ~!