The list of servers that our project client can see is provided by a text file called IPList.txt, each time the client launches the latest version of IPList.txt from the CDN. Two days before the operation of the students to come up with a small tool requirements, the public testing of the various channels need to provide different IPList.txt, if temporarily add new clothes or modify the old service (hot/crowded/smooth), Time emergency manual modification error prone, hope to have visual tools to modify.
After I had this job, I thought about it and decided to use Python. Python has written a number of small tools, but did not do the GUI, check the information, using a more recommended Wxpython library. The tool logic is very simple, just modify the TXT file, but also spent most of the day, on the one hand, the code pendulum control took a lot of time (Miss MFC's Drag control ...) ), on the other hand, also encountered some problems in character encoding. Lessons learned are as follows:
When using Python to read and write certain encoded format files, be sure to use Codecs.open instead of open.
The lines that are read out use line = Line.replace (' \ r \ n ', ') to remove the newline characters, and then add the last line before writing, so that the middle procedure does not consider newline characters.
Wxpython File selection box returns the path, if it is the root directory of the disk, there will be no ' \ ' delimiter, that is, open the D-Packing directory under the IPList.txt file, the return is "D:list.txt", if you open the D drive under the test directory IPList.txt file, then the return is "D:\Test\IPList.txt". It feels like a bug, but the status quo needs to be handled manually, otherwise the file will not be found when saved.
Overall, the process of developing GUI programs using Wxpytho is satisfactory, with the following tools:
Code: Https://github.com/gns333/IPListTool
Making GUI gadgets with Wxpython