Study notes 6.25-7.10 (all contents are for study use only)

1. Writing launcher scripts about python 6.25

1. Python's timer will only be executed once, and there is no need to cancel it manually.

However, you can cancel the execution of the timer if you manually call timer.cancel() before the timer fires. Canceling the execution of the timer will not cause any problems, but the queued timer tasks will not be executed. If you need to execute the timer task repeatedly, you can consider using a loop or a third-party library such as schedule to implement it.

- A simple example of a loop timer

# 定义定时器到达后需要执行的函数
def fun():
    # 输出字符串aaaa
    print("aaaa")
    # 重新启动定时器
    timer = threading.Timer(5, fun)
    timer.start()

# 定义定时器
timer = threading.Timer(5, fun)
# 启动定时器
timer.start()

2. About the time function

now = time.time() # The calculation is the number of seconds from 0:00:00 on January 1, 1970 to the present

3. Global variable global keyword

def start_Calculating():
    global is_Calculating
    if not is_Calculating:
        program_path = "E:\\yan1\\成品1:学生信息管理系统\\打包后程序\\studentSystem.exe"   # 替换为你的程序路径
        start_program(program_path)
        print("解算程序已启动")
        is_Calculating = True
    else:
        print("解算程序正在运行中")global is_Calculating

The global keyword in this code is used to declare the is_Calculating variable as a global variable. Its role is to tell the Python interpreter that the is_Calculating variable accessed in this function is a variable defined outside the function, rather than a local variable defined inside the function. This allows this function to modify and access the value of the is_Calculating variable, and other functions to access or modify the value of this variable.

2. Notes on QT 6.27

1. Add pictures

(1) First of all, you must add the picture file in the .qrc file, which can be done directly in VS, as shown in the figure

(2) When designing ui in Qdesigner, you must click to select resources (otherwise the pictures cannot be packaged together), as shown in the figure

 (3) There will be no need to repeat the operation of adding resource files in the future, just select the picture directly from the resource file

2. If the imported database has the following garbled characters

 Solution: Modify the data format from the source in the code, the width of the Excel cell, and the width of the table cell in qt

3. Issues related to packaging 6.27

1. Key points about VS and QT packaging:

(1) Compile the program in VS (both Debug and Release are available)

(2) Find the program name.exe file generated in the Debug/Release directory, and copy it to an empty folder under the full English path

(3) Find the qt directory, be sure to pay attention to the qt version and the version of the msvc name, such as:

 (4) Check whether there is windeployqt.exe under this folder, then start cmd under this folder, enter

windeployqt.exe (space) and drag in the program name.exe, press Enter

(5) If some files are missing, an error will be reported, just copy it from the qt library directory

(6) Copy other files such as pictures and databases into the folder where the program name.exe is located

2. Key points about packaging python single files:

(1) You need to use the pyinstaller library without installing it first

(2) Use the pycharm/command line to enter the following command on the command line


# 显示命令行
pyinstaller -F 文件.py


# 隐藏命令行
pyinstaller -w -F fileren.py

(3) In the end, multiple files and folders will be obtained. To run the program, just click the .exe under the dist folder.

4. Computer related issues

1. There can be a maximum of 4,294,967,295 files in a single folder (if a long file name is used, the number will be reduced; if a large file is used, the total capacity must be less than or equal to 256TB)

2. Many functions, such as iis functions, may not be available in the home version system. You need to use the flagship version system. You can directly Baidu and enter the key to complete the upgrade from the home version to the flagship version.

3. The sunflower identification code is bound to the mac address of the computer, and the mac address is assigned by the manufacturer and burned into the network card chip , which is unique. Unless you change the network card hardware of the computer or completely uninstall and reinstall Sunflower to clear the original
configuration file
, the identification code will change

4. Even if the code using VS is packaged, if it is run on another computer, VS must be installed on the computer

5. Solving various problems about iis

1. Error 500.19 error code is 0021, it may be that the software is not fully installed, select it in Programs and Features-Turn Windows features on or off

2. Error 500.19 error code is 0005, you need to find the "Security" tab, set up a new user "everyone", and modify the permissions to allow

3. Error 500.21 has an error module, which needs to be input on the command line. Remember to use the administrator identity

Guess you like

Origin blog.csdn.net/z377989129/article/details/131042435