Tutorials Challenge (Newbie)

maintainer: LionKimbro (jabber id: LionKimbro@jabber.org)

Abstract: Read tutorials and try things out.

Motivation: Tutorials show you how to do something, then Challenges stretch you further.

Resources:

Challenge

This challenge has N parts:

  1. First Application (Getting Started, Section 5)

  2. Little Editor (Getting Started, Section 6)

  3. blahBlah-blahblah blAHditty-BLAH.

Part 1: A First Application

Create the app in Section 5 of Getting Started.

Change the example to show two frames, instead of one.

If it hangs, kill python, and consider your code...

After it all works, you may want to poke around documentation. What's App do? wxapp Glance at the wxApp documentation to see what it does.

The wxWidgets documentation is a resource to become familiar with. Yes, it's in C++, but it is still very useful. If you've installed on Windows, you may have Start|Programs|wxPython|wxWidgets Reference. This is the same information, but compact and quick.

Under Gentoo Linux you can emerge dev-python/wxpython-docs separately and you get a python app called viewdocs.py and two zip Files in /usr/doc/wxPython-2.4.2.4/docs/. The python app is a help system with the wxWidgets and OGL Reference. There should be packages for other distros, too (most likely called wxpython-docs), but I don't know for sure.

Part 2: Little Editor

Now do Section 6 of Getting Started. Construct the little editor described.

When you get to section 6.2.4 ("More magic"), do what's necessary to hook up the OnOpen method. Run it. Make sure it works.

Now, we have a few changes to make:

Part 3: and then you must BLAH.

Comments

Questions for people who attempted the challenge:

-- LionKimbro 2003-08-10 14:11:30

Cake. It took a couple sittings to finish part 2; no more than an hour in total. Part one was trivially easy. Although, obnoxiously, every time I run wxPython code XP claims that there's an error and (falsely) that python will shut down. I misspelled control.GetValue() when I was writing OnSave, and vaporized the contents of one of my text files. Be careful, kids!

-- [cube]

I don't know about your XP error; I've used Python on WinXP, but don't remember something like that. Glad to hear you finished so quickly! -- LionKimbro 2003-09-03 10:04:33

I also took about 1 hour to finish part 2. I will suggest another change in the small editor: Implement a method OnSaveAs & OnSave. -- drudi

I'm happy to hear it! OnSave was already part of the challenge, but OnSaveAs wasn't- I've added it. Thank you for the feedback!

-- LionKimbro 2003-09-17

Good tutorial so far. It took me about 20 minutes total. I'm familliar with Tkinter, but am just getting started with wxPython. A comprehensive tutorial like what is available for Tkinter would be really helpful, so I may try to add some more stuff here...

-- jweage 2004-01-02

I'm not involved in the writing of the tutorial- just the ObstacleCourse. But I'm happy to hear you'll work on the tutorial..!

Can you tell me which tutorial you found for Tkinter that you really liked? I'm just curious. I like to look at tutorials- especially good ones..!

-- LionKimbro 2004-01-10 19:09:31

I stumbled through this one without too much trouble. About 2 hours filesystem time between helloworld.py and part2status.py, but I was multitasking. After I got Open, Save, and Save As working, I twiddled the idle statusbar so it reflected those actions (Saved filename OK and the like). For Part 3, if you want to stick with the editor code, you could try the ToolBar (I poked at it) or try and get Styled Text working (C++ API docs said Windows Only too often, didn't try it). MDI would probably be too much for this level (newbie). General gripes about the tutorial and wxPy I'll save for my wiki page.

-- AdricNet 2024-11-21 10:20:15

I thought this was an excellent challenge. I'm a newbie Python programmer, and I started on Tkinter, but I only used it for a few days -- I despised the way that dirty tricks constantly had to be used to get GUIs to display properly. Where Tkinter clicked in right away, I had a bit of trouble with wxPython at first -- but, I'm getting a little better every day, and I've found that in the long run, it's easier to get wxPython to do what you want it to do. A few things:

Well, that's about all I have to say. Good work so far guys.

-- Poprocks 2004-03-23 19:12:24

Challenge 2 was simple enough, took about 20 minutes.

-- Pharrisee 2024-11-21 10:20:15

I really love this challenge tutorial. I rewrote the editor in the 2.5 style (import wx). I also disabled the 'Save' and 'Save As' menuitems on startup. On 'Open' or on modification of the Textcontrol content I enable them.

-- RudySchockaert 2024-11-21 10:20:15

Thanks for providing this obstacle course; it's quite helpful for learning. It took about an hour more or less. I had two thoughts:

(1) Is it possible to get the Help menu to appear on the right side of the MenuBar?

(2) I added a cheesy little Set_Title() method so that when the user opens or saves a new file, the title bar updates to reflect the new file name.

-- JeffCagle 2024-11-21 10:20:15

ChallengeTutorials (last edited 2010-07-29 16:18:19 by fl-67-235-186-192)

NOTE: To edit pages in this wiki you must be a member of the TrustedEditorsGroup.