Complete the configuration environment of eclipse + pydev before configuration. See http://www.cnblogs.com/dflower/archive/2010/05/13/1734522.html
1. Install wxpython 2.8
For example
We recommend that you download Unicode. If you use ANSI, the component title cannot contain Unicode characters, and the Code contains Unicode characters. Note that the installation path cannot contain spaces.
2. Download BOA Constructor
Python has many development environments, that is, IDE. Up to now, BOA constructor is the only one that supports visual development. Using it, you can drag out the control just like using Delphi for rapid development.
The value is http://sourceforge.net/projects/boa-constructor/files/. the maximum value currently is 0.6.1.
Note that the installation path of the BOA constructor cannot contain spaces.
3. Configure BOA Constructor
Open the boa constructor. If you are a Chinese system, the IDE language will change to Chinese. You must change it to English in the tool> language settings menu. If you use a Chinese IDE, an error occurs when opening and saving the file.
Click Tools> Python interpreter chooser to set the directory of python.exe.
Shut down the boa constructor and restart it. The configuration is complete.
You can use BOA constructor to easily design the interface. The specific getting started tutorial is attached at the end.
However, writing code directly in Boa is still quite painful. You can create a project in eclipse first, and then use BOA constructor to design the GUI and save it to the project folder, refresh the file in eclipse to load the designed py file, and then program and debug the file in eclipse.
-------------------------------------------------------- If you are floating, I shake the rootless separation line -------------------------------------------------------
Appendix: getting started with a boa Constructor
1. Create a wx first. in this way, wx is automatically created. frame and BOA constructor are set in this way. I also recommend that you first have an app (without frame) and then call other frames. There are two ways to create a file: Select wx. app under the new panel in the top palette, or select the new wx. app under the File menu in the editor.
In the editor, we can see a * (app1) * and * (frame1) * next to shell and explorer )*. * Indicates that the file has not been saved. Both of these items have sub-panel source, which is code. Okay, let's save it first. You can also save it by using file-save. You can also click the floppy disk icon to save it.
2. Then we can add panel, button or textctrl to the frame ). Frame means a frame. You can add anything to the frame. The first step is to add a "baseboard", usually panel or windows. After adding the "baseboard", the frame is automatically filled up.
Click frame, and then click the frame desinger icon in the editor (the shortcut key is F12). The dark gray small lattice is displayed, and there is a title bar on it, right? This is frame! Now we can drag something into it. All the items that can be dragged in are in the palette on the top. There are many items, such as containers/layout (container/layout), basic controls (basic control), and buttons (button) list controls (list control) and so on.
In containers/layout, select the first icon wx. Panel and click it with the Left click. Well, it becomes pressed. Then click the frame, yeah ~ Added. Why is the frame not full? Don't worry. First click X in the upper right corner to close the frame and then open the frame (F12 forgot ?), Is it full? They are all light gray.
(Turn off and open again-this technique is very important, because it is only in this way that BOA constructor can recognize it. In the future, we will set attributes, adjust the size, and so on. It is best to "turn off and re-open" it)
Place the mouse over the frame, and you can see Panel1 In the title bar. You can see frame1 (or you can save the frame name ). You can also change the name by clicking the left button, and then check the constr attribute page in the Inspector panel. Name is the name. You can click it to modify it. Do not change it to Chinese, French, Japanese, or Korean. It can only be in English! After modification, click recreate selection ). You can also change the position, modify it under position, or modify the size under size, or change the style under style.
(In fact, this still requires wxpython knowledge. Let's take a look at the wxpython in action book. It can be in English)
You can add more items under the props property page under inspector, such as background color (backgroundcolour), Prompt text (tooltipstring), and font. The useful sizer (size manager) is also set below.
You did not find that there is a U in front of the text settings, which is Unicode. This is also because we have installed wxpython-Unicode. You can enter Chinese Characters in some text prompts and the system will automatically convert them to unicdoe codes.
(Unicode is really complicated !! I used to develop it in windows. It's okay, but it's silly to put it in Linux! So if you want to use cross-platform software, take a good look at Unicode)
The evts attribute page under inspector is "Event ". All possible related events are listed below. Mouse events, keyevents, and so on. With these events, you can call other functions and complete other functions (such as drawing, pop-up prompt box, jump to other pages, and so on ). "Event" is very important to wxpython because it is an "event-driven Gui" (you don't understand this part, so remember it, and then understand it in development ).
The objs attribute page under Inspector provides a tree structure to show you what is included. You can select one of them (such as frame1) and view its corresponding constr/props/evts.
3. Next let's add a button. Click "buttons" in the top palette, select the first icon "WX. Button", press it, and then click "Panel" in the frame to see "button1.
Then we can modify the corresponding attributes. Including size, position, display text, style, and so on. Where can I change it? Didn't I tell you that? Change it under inspector on the left.
Why does BOA constructor feel very easy? Because some items can be directly dragged to what you see is what you get. For example, you can use the mouse to change the button size and position.
Other controls are similar. You can try to add various controls. In fact, BOA constructor does not include all the controls in wxpython, but it includes the controls that are basic, common, and common. So we can use BOA constructor to get started with wxpython.
4. Let's add an event ). Do you remember what I said about "event-driven Gui? Let's "Drive" our program.
Click the selected button, click buttonevent under evts of inspector on the left, and wx. evt_button appears on the right. Double-click it. A wx. evt_button -- onbutton1button appears below. Okay. Click the "check mark" above ".
Save the source file. You can see the following figure at the bottom of the source file (under the source panel:
Def onbutton1button (self, event ):
Event. Skip ()
This kind of stuff. Add the code you want before event. Skip (), for example, print u'hahaha', or bring up a prompt panel:
DLG = wx. messagedialog (self, u 'yes ',
U'you got it ~ ',
Wx. OK | wx. icon_information
)
DLG. showmodal ()
DLG. Destroy ()
Or any code.
(Event. Skip () indicates that the event is passed down, so you don't need to delete it)
(The code in the pop-up window above can also be used with BOA constructor to create a wx. Dialog and then call it. But I didn't do this because I think it is more convenient. You will also find something more convenient in the future, and then you will gradually jump out of BOA constructor ............ Of course you can't jump out of the wxpython arms, huh, huh)
5. Now, everything is fine! Click the run applictaion icon on the editor page or press F9. Run your program. Of course, you must run the program only when the app is the selected page. Because the app is a program, the frame is not.
6. Next, we can add other frames, add other controls, and add other modules. Let's go here ......
(I have a small suggestion. You can try to see the help in English for BOA constructor)
The Boa contructor I have found has the following problems:
1. Sometimes BOA constructor fails and can only be forcibly disabled. This is usually caused by program errors. This cannot blame BOA constructor. If you run these programs in idle, it will also be suspended. Sometimes I can only run it in the command line window.
2. BOA constructor cannot be refreshed in real time. You must click the refresh or submit button to see the changes. Yes, that's it. So don't try to add all the things you can think of at one time. Try to add them several times.
3. Chinese directory issues. Source program files cannot be run, saved,