Ene Uran 638 Posting Virtuoso

My Vista install takes absolutely forever to reboot. So I only reboot when I have critical system updates that are being enforced by IT (I'd run it naked as well, but IT again enforces restrictions on that). Seems to avoid the problem satisfactorily, if not ideal.

I just timed a typical reboot on my Vista machine and it took 9 minutes (plus some change). Enough time to go to the Starbucks on the corner and return with a foamed latte.

Ene Uran 638 Posting Virtuoso

Just to add to shibby's very nice explanation:

# passing a class variable to other classes

class C1(object):
    def __init__(self):
        print("in class C1")
        # self makes mc1 available to the class instance
        self.mc1 = 77

class C2(object):
    mc2 = 88
    def __init__(self):
        print("in class C2")
        # create an instance of C1 within C2 (shibby's example)
        ac1 = C1()
        # now access mc1 using this instance
        print(ac1.mc1)  # 77
        # show C2's own variable
        print(self.mc2)  # 88
        
class C3(C1):
    """C3 inherits C1"""
    mc3 = 99
    def __init__(self):
        print("in class C3")
        # make C1 part of C3's self
        C1.__init__(self)
        print(self.mc1)  # 77
        # show C3's own variable
        print(self.mc3)  # 99

# create instances of class C2 and class C3
ac2 = C2()
ac3 = C3()

"""
my display -->
in class C2
in class C1
77
88
in class C3
in class C1
77
99
"""
Ene Uran 638 Posting Virtuoso

Thanks AD! My dad had an LP of Victor Borge with this sketch on it! Very amusing!

Ene Uran 638 Posting Virtuoso

Spirits are not ghosts!
Spirits are part of the spiritual world that is part of each being.

Ene Uran 638 Posting Virtuoso

Did you have a bad day?

Ene Uran 638 Posting Virtuoso

Wonder if goats make good programmers?

Ene Uran 638 Posting Virtuoso

Q: "Are you going to Frank's funeral?"
A: "Why should I? He is not going to mine."

Ene Uran 638 Posting Virtuoso

Who gets viruses? You have to try hard to get viruses on Windows. Stop pirating software, then you won't get viruses.

You try to tell the rest of us that it is a copy protection scheme? Be real. The internet is a good source of the ugly beasts.

Now the question is, who writes them and why?

Ene Uran 638 Posting Virtuoso

Well each brewery does employ their own Brew Master that checks the brew on a daily basis, and ensures the quality.

I have tasted too much beer that was so bad, that it makes you wonder what the qualifications for such a Brew Master are.

In English pubs, ale is ordered by pints or quarts. So when customers got unruly, the bartender used to yell at them to mind their own pints and quarts and settle down. Hence the phrase "mind your own P's and Q's".

Ene Uran 638 Posting Virtuoso

Raspberry ice cream. Yummy!

Ene Uran 638 Posting Virtuoso

Just imagine a time when all the killing will be done by robots that are controlled by someone as far waway as the other side of the Earth. Already a US military person can leave his wife and kids in a nice subdivision home, drive a short distance to an airbase to kill a few Iraqis for the fun of it, not even leaving the ground.

I can see the time this job is given to a computer.

Ene Uran 638 Posting Virtuoso

I wouldn't walk through a cemetery in the middle of the night!
Hollywood loves to scare people with ghost stories/movies.

Ene Uran 638 Posting Virtuoso

Let's get a little playful and display a text in rainbow colors:

# use wxPython's wx.richtext.RichTextCtrl
# to create rainbow colored text

import wx
import wx.richtext

class MyFrame(wx.Frame):
    def __init__(self, parent, title, rainbow_text):
        wx.Frame.__init__(self, parent, -1, title, size=(560, 220))
        self.SetBackgroundColour("white")
        
        self.rich = wx.richtext.RichTextCtrl(self, -1, value="")
        self.rich.BeginFontSize(40)
        for c, colour in rainbow_text:
            self.rich.BeginTextColour(colour)
            self.rich.WriteText(c)
            self.rich.EndTextColour()


rainbow = ['red', 'coral', 'yellow', 'green', 'blue']

text = """
 Welcome to fabulous
        Las Vegas"""

# create a list of (char, colour) tuples
rainbow_text = []
ix = 0
for c in text:
    if c.isalpha():
        colour = rainbow[ix]
        if ix < len(rainbow)-1:
            ix += 1
        else:
            ix = 0
    else:
        colour = 'white'
    rainbow_text.append((c, colour))

app = wx.App(0)
title = 'Rainbow Text'
MyFrame(None, title, rainbow_text).Show()
app.MainLoop()
Ene Uran 638 Posting Virtuoso

Write a function that groups a large number into thousands. For instance
123456789 --> 123,456,789
or
1234567.89 --> 1,234,567.89

Ene Uran 638 Posting Virtuoso

The pygame.KEYDOWN event figures this one out, just put it into an if statement.

Ene Uran 638 Posting Virtuoso

Tkinter has some nice pop-up dialogs that can also be used for regular console programs. Here is an example to use if you want to get a filename from a pop-up window. It works with Python2x or Python3x, just read the comments:

# use Tkinter's file dialog window to get
# a file name with full path, you can also use
# this to get filenames for a console program
# askopenfilename() gives one selected filename

# with Python25 use ...
#import Tkinter as tk
#from tkFileDialog import askopenfilename

# with Python30 use ...
import tkinter as tk
from tkinter.filedialog import askopenfilename

root = tk.Tk()
# show askopenfilename dialog without the Tkinter window
root.withdraw()

# default is all file types
file_name = askopenfilename()

print(file_name)
Ene Uran 638 Posting Virtuoso

You are making good progress on your own!

Here is a typical example for some widgets you are interested in:

# a wxPython example for label widgets (wx.StaticText) 
# and an entry or edit widget (wx.TextCtrl)

import wx

class MyFrame(wx.Frame):
    def __init__(self, parent, mytitle):
        # -1 = wx.ID_ANY (wxPython will pick a unique id value)
        wx.Frame.__init__(self, parent, -1, mytitle, 
            pos=(100, 150), size=(300, 150))
        self.SetBackgroundColour("yellow")

        s = "Enter your name below:"
        label = wx.StaticText(self, -1, s)
        self.edit = wx.TextCtrl(self, -1, value="") #, size=(200, 20))
        # respond to enter key when focus is on self.edit
        self.edit.Bind(wx.EVT_TEXT_ENTER, self.onEnter)
        self.result = wx.StaticText(self, -1)

        # position your widgets using a box sizer
        # (line up in a vertical stack)
        # wx.ALL --> widget has specified border on all sides
        # wx.EXPAND --> widget will expand to fit resized frame
        sizer_v = wx.BoxSizer(wx.VERTICAL)
        sizer_v.Add(label, 0, flag=wx.ALL|wx.EXPAND, border=4)
        sizer_v.Add(self.edit, 0, flag=wx.ALL|wx.EXPAND, border=4)
        sizer_v.Add(self.result, 0, flag=wx.ALL|wx.EXPAND, border=8)
        self.SetSizer(sizer_v)
        
        # put the cursor in the edit widget
        self.edit.SetFocus()
        
    def onEnter(self, event):
        """the enter key has been pressed in self.edit"""
        name = self.edit.GetValue()
        s = "You entered the name: " + name
        self.result.SetLabel(s)
        

app = wx.App(0)
MyFrame(None, 'testing wx.TextCtrl').Show()
app.MainLoop()
Ene Uran 638 Posting Virtuoso

Well, wxPython is a very powerful GUI toolkit, well worth learning. It's parent is wxWindows written in C++, this will show up in some of the manuals. A lot of people on this forum use it, so you should get lots of help. Just keep asking questions.

Ene Uran 638 Posting Virtuoso

Beer was the national drink of ancient Egypt. The pharoahs even appointed a "royal chief beer inspector" to protect its quality.

I don't think there is such a person in the US.

Ene Uran 638 Posting Virtuoso

Imagine a planet where all the beings live by unbiased rules and pay their fair taxes.

Ene Uran 638 Posting Virtuoso

Genetically altered grain for instance could create something like a misfolded protein called a prion. This was the agent that caused mad-cow-disease in the brains of cows and other animals and then spread to humans. It is more hideous than the flu because it takes several years to develop and the prions are not destroyed by cooking. With the ever increasing population, there is pressure to improve grain yields by genetic means.

Just trying to be cheerful!

Something like that, where you mix old fashioned greed and modern science could very well spell disaster! A new Hollywood movie is born!

Ene Uran 638 Posting Virtuoso

Here is an example without a titlebar and showing fullscreen:

# wx.Frame with no title bar and showing fullscreen
# modified from vegaseat's example

import wx

def exit(event):
    frame.Close(True)

app = wx.App(0)
# create a window, no-parent, -1 is default ID, style with no titlebar
frame = wx.Frame(parent=None, id=-1, pos=(50,100), size=(300,200), 
    style=wx.MINIMIZE_BOX)
frame.SetBackgroundColour('green')
frame.ShowFullScreen(True, style=wx.FULLSCREEN_ALL)

# provide exit for a frame without titlebar
quit = wx.Button(frame, id=-1, label='Exit', pos=(0, 0))
quit.Bind(wx.EVT_BUTTON, exit)

# show the window
frame.Show(True)

# start the event loop
app.MainLoop()
Ene Uran 638 Posting Virtuoso

Use this to clear the screen on a console program:

import sys
# on Windows
os.system("CLS") 
# on Linux
os.system('clear')

Also for my taste avoid using globals, they can get you into conflicts. You can generally pass them to and from functions in the arguments.

Do you want to use wxPython because you want to learn it? The Tkinter GUI toolkit is somewhat simpler to use, but then getting into GUI programming is somewhat of a steep learning curve anyway.

Ene Uran 638 Posting Virtuoso

Here is an example of module psyco:

# time a function using time.time()
# also uses Psyco JIT i386 compiler to speed up code 
# typical result: 1.6 sec with Psyco, 5.3 sec without
# for Python25 on Windows download psyco-1.6.win32-py25.exe
# from http://psyco.sourceforge.net/

import time

def print_timing(func):
    """
    create a timing decorator function
    for relatively slow functions
    use
    @print_timing 
    just above the function you want to time
    """
    def wrapper(*arg):
            t1 = time.time()
            res = func(*arg)
            t2 = time.time()
            fs = '%s took %0.3f ms'
            print( fs % (func.__name__, (t2-t1)*1000) )
            return res
    return wrapper

@print_timing
def primes(n):
    """ 
    returns a list of prime numbers from 2 to < n 
    using a sieve algorithm
    """
    if n < 2:  
        return []
    elif n == 2: 
        return [2]
    s = range(3, n+2, 2)
    mroot = n ** 0.5
    half = (n + 1)/2
    i = 0
    m = 3
    while m <= mroot:
        if s[i]:
            j = (m * m - 3)/2
            s[j] = 0
            while j < half:
                s[j] = 0
                j += m
        i = i + 1
        m = 2 * i + 3
    return [2]+[x for x in s if x]


if __name__ == '__main__':
    print("without psyco")
    prime_list = primes(10000000)

    print( '-'*30)

    # import Psyco JIT compiler/optimizer if available
    try:
        import psyco
        psyco.full()
        print("with psyco")
    except ImportError:
        print("module psyco not used ...")
    prime_list = primes(10000000)

"""
my output -->
without psyco
primes took 5326.000 ms
------------------------------
with psyco
primes took 1616.000 ms
"""
Ene Uran 638 Posting Virtuoso

This line:
if float(path_value) == float(line1000[0]):
will give you major headaches, since floats are usually off by very small values and are such not always equal.

Use the function fuzzy_equals for that:

def fuzzy_equals(a, b, delta=0.000001):
    """
    used for comparison of floating point numbers a and b
    """
    return -delta < a-b < delta

Also Python has a nice profiler available to check the efficiency of a give function. Use something like this:

import cProfile

def order_nodes(path_value):
    ...
    ...

cProfile.run("order_nodes()")
...
...

The many calls using function float() will make you suffer!

Also, what is the call "order_slab_nodes(path_value)"?

Last not least check into module psyco. It gives major speed improvements as it compiles to native 386 machine code rather than Python bytecode.

Ene Uran 638 Posting Virtuoso

A small Python/PyQT4 utility program to find out what kind of fonts your computer has:

# bring up a font dialog with PyQT4
# show the selected font using a sample text

import sys
# hopefully no namespace conflicts
from PyQt4.QtCore import *
from PyQt4.QtGui import *

class FontDialog(QWidget):
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self.setGeometry(10, 100, 250, 110)
        self.setWindowTitle('QFontDialog')

        hbox = QVBoxLayout()

        button = QPushButton('Font Dialog')
        self.connect(button, SIGNAL('clicked()'), self.showDialog)
        
        # the label autosizes to the text
        text = "The quick brown fox jumps over the lazy dog"
        self.label = QLabel(text)
        self.label.move(130, 20)
        
        self.edit = QTextEdit()

        hbox.addWidget(button)
        hbox.addWidget(self.label)
        hbox.addWidget(self.edit)
        self.setLayout(hbox)

    def showDialog(self):
        font, ok = QFontDialog.getFont()
        if ok:
            # display the label's text in the selected font
            self.label.setFont(font)
        # display the font name in the edit box for copying
        self.edit.append(QFontInfo(font).family())


app = QApplication(sys.argv)
fd = FontDialog()
fd.show()
app.exec_()

Save the code as pqt_FontLister.pyw

Ene Uran 638 Posting Virtuoso

An example how to use the QPainter to create a wallpaper background:

# a simple window using PyQT 
# using a canvas with a texture/wallpaper background

import sys
# pray for minimal namespace conflicts
from PyQt4.QtCore import *
from PyQt4.QtGui import *

class MyForm(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        # setGeometry(x_pos, y_pos, width, height)
        self.setGeometry(100, 150, 350, 300)
        self.setWindowTitle("Creating a Canvas Wallpaper")
        
    def paintEvent(self, event):
        """create a painting canvas"""
        painter = QPainter()
        painter.begin(self)
        painter.setRenderHint(QPainter.Antialiasing)
        # use the brush for a texture/wallpaper background
        # supply a background image file you have (add needed path)
        painter.setBrush(QBrush(QPixmap("BG_GoldSwirl.gif")))
        painter.drawRect(event.rect())
        
        # optionally write something in the wallpaper
        # (check the fonts available on your computer)
        painter.setFont(QFont('Freestyle Script', 48))
        painter.drawText(50, 160, "Hello World!")
        
        painter.end()


app =  QApplication(sys.argv)
form = MyForm()
form.show()
app.exec_()
Ene Uran 638 Posting Virtuoso

I got PyQT4 istalled and working on my Vista computer. Here is an example of my first program:

# display a bunch of random circles using PyQT4

import random
import sys
# pray for minimal namespace conflicts
from PyQt4.QtCore import *
from PyQt4.QtGui import *

class DrawPoints(QWidget):
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        # setGeometry(x_pos, y_pos, width, height)
        self.setGeometry(200, 200, 400, 400)
        self.setWindowTitle('Draw random Circles')

    def paintEvent(self, event):
        painter = QPainter()
        painter.begin(self)
        # pen sets the edge color of the circles
        painter.setPen(Qt.black)
        w = self.size().width()
        h = self.size().height()
        # draw 150 circles of random sizes, locations and colors
        for i in range(150):
            # color uses red, green, blue values (0 to 255)
            r = random.randint(0, 255)
            g = random.randint(0, 255)
            b = random.randint(0, 255)
            # brush sets the fill color of the circles
            painter.setBrush(QBrush(QColor(r, g, b)))
            # get center coordinates x,y of the circle
            x = random.randint(1, w-1)
            y = random.randint(1, h-1)
            # get the radius of the circle
            radius = random.randint(5, 80)
            # to draw circles match the radius
            painter.drawEllipse(QPoint(x, y), radius, radius)

        painter.end()


app = QApplication(sys.argv)
dp = DrawPoints()
dp.show()
app.exec_()
Ene Uran 638 Posting Virtuoso

Carbon is actually a fairly rare element. Elements like silicon, aluminum and iron are much more common. So yes, the robot would have a much better chance to survive once given enough intelligence. The robot could eventually reach the idea that there is no sense to waste that precious carbon on humans and their food.

Ene Uran 638 Posting Virtuoso

*TEST* *TEST* Has the KING truly been unbanned again? Muhahahaa.

Let me guess, you must be from Texas?

Ene Uran 638 Posting Virtuoso

If your Bush style American way-of-life is huge unemployment, you can have it for yourself.

Ene Uran 638 Posting Virtuoso

Only if you carry it in your 1 quart plastic bag, and you divide it into several 3 ounce bottles.

Hehe, right on!

Now I wonder how much antimatter it would take to theoretically blow up the Vatican? Maybe it's just the size of pinhead?

Ene Uran 638 Posting Virtuoso

Wonder if you can get past airport security with a suitcase full of antimatter?

Ene Uran 638 Posting Virtuoso

Q: "When will Microsoft make a product that doesn't sugg?"
A: "When they start making vacuum cleaners."


Q: "What did Bill's wife say to him on their wedding night?"
A: "Now I know why you named your company Microsoft!"

Ene Uran 638 Posting Virtuoso

For the second year running Python has been selected as the Language of the Year by Linux users:

Linux Users' Programming Languages of the Year 2008
PHP        115   13.36%
Perl        72    8.36%
Python     226   26.25%
Ruby        46    5.34%
C          114   13.24%
C++        129   14.98%
Java       106   12.31%
Lisp         9    1.05%
Erlang       4    0.46%
Smalltalk    1    0.12%
Haskell     11    1.28%
C#          19    2.21%
Lua          4    0.46%
COBOL        3    0.35%
Scheme       2    0.23%
OCaml        0    0%

Total voters:  8611 (all Linux users)

Source:
http://www.linuxquestions.org/questions/2008-linuxquestions.org-members-choice-awards-83/programming-language-of-the-year-695662/

Ene Uran 638 Posting Virtuoso

Expanding on jrcagle post:

import shutil

source_file = r"C:\Python25\Atest\Bull\shutil_test.txt"
destination = r"C:\Python25\Atest\Bull\Test"

# this copies the source file to the destination directory
# the destination directory has to exist
# if the filename already exists there, it will be overwritten
# access time and last modification time will be updated
# the same filename is used
shutil.copy(source_file, destination)

destination2 = r"C:\Python25\Atest\Bull\Test\shutil_test2.txt"
# similar to above,
# but the new specified filename is used
shutil.copy(source_file, destination2)

destination3 = r"C:\Python25\Atest\Bull\Test\shutil_test3.txt"
# similar to above,
# but the new specified filename retains the original file dates
shutil.copy2(source_file, destination3)
iamthwee commented: love the paths! +18
Ene Uran 638 Posting Virtuoso

Starting with and empty string, you have to build up your code string in the loop, and then write it to the file outside the loop:

def encode(): 
    mess = raw_input ("Enter message:")
    joinnum = ""
    for i in mess:
        nummess = ord (i) * 2 * 7 + 3
        stringnum = str(nummess)
        joinnum += stringnum + ","
    
    print(joinnum)  # for testing only
    outfile = open ("encodemess.txt", "w")
    outfile.write (joinnum)
    outfile.close()


encode()
Ene Uran 638 Posting Virtuoso

You may want to take a look at __slots__

Ene Uran 638 Posting Virtuoso

You got to give us your code.

Ene Uran 638 Posting Virtuoso

Oui, before I forget, take a look at the wx.RichTextCtrl example by Snee in the 'Starting wxPython' thread, that seems to be simpler for your purposes:
http://www.daniweb.com/forums/post763339-103.html

Here is a simple example:

# a simple sign using wx.richtext.RichTextCtrl()

import wx
import wx.richtext as rt

class MyFrame(wx.Frame):
    def __init__(self, parent, mytitle, mysize):
        wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle, size=mysize)
        self.SetBackgroundColour("white")
        
        rich = rt.RichTextCtrl(self, wx.ID_ANY, value="")
        # default is black text
        rich.BeginFontSize(26)
        rich.BeginBold()
        rich.WriteText(" You are in ")
        rich.BeginTextColour('red')
        rich.WriteText("danger ")
        rich.EndTextColour()
        rich.WriteText("at that spot!")
        rich.EndBold()
        rich.EndFontSize()
        rich.WriteText("\n\n        The management")
        

app = wx.App()
mytitle = 'A wx.RichTextCtrl Sign'
width = 600
height = 140
# create the MyFrame instance and show the frame
MyFrame(None, mytitle, (width, height)).Show()
app.MainLoop()
Ene Uran 638 Posting Virtuoso

To my knowledge you cannot selectively color text with the simple wx.TextCtrl widget, for that you need the wx.StyledTextCtrl widget.

Ene Uran 638 Posting Virtuoso

Do you have to maintain the position in the second file?
What would a line of data in that file look like?

Ene Uran 638 Posting Virtuoso

My advice, don't use the Python Shell for programming, use an editor. The Python Shell interative interpreter is only for very short tests. It is basically there to confuse beginners and discourage them from using Python. :)

Ene Uran 638 Posting Virtuoso

There are a flock of badly written and rather outdated Python books on the market. I would go for some of the free online books.

Swaroop C.H. has rewritten his excellent beginning Python tutorial for Python30:
http://www.swaroopch.com/notes/Python_en:Table_of_Contents

How to Think Like a Computer Scientist - Learning with Python
written by a college professor, a high school teacher, and a professional programmer:
http://www.thinkpython.com
Foreword by David Beazley, University of Chicago:
http://www.greenteapress.com/thinkpython/html/foreword.html
http://www.ibiblio.org/obp/thinkCSpy/

Above updated: "Think like a Python Programmer" (PDF format):
http://greenteapress.com/thinkpython/thinkPP.pdf

Ene Uran 638 Posting Virtuoso

Just to add to scru's point: Being able to re-use code is an extremely important but sometimes overlooked feature of programming. Its main value is not saving time, but eliminating bugs.

That is, if the code for CD works provably correctly (or testably correct even), then a DVD class built on top of it will be solid so long as DVD doesn't muck with the internals.

Jeff

Case in point are Python's own modules, thoroughly tested and optimized. You can inherit any of those classes into your own class and customize from there.

Ene Uran 638 Posting Virtuoso

I know Python introspection feature are powerful, what I can't seem to figure out is how to get the name of the current class.

Example:

class Foo:
   def bar(self):
        print(classname)

Then my output should be Foo. Bonus points if I can get which module it resides in too.
Thanks!

The Python module inspect should contain your desired functions.

Ene Uran 638 Posting Virtuoso

Even the IDLE that comes with Python30 will insist to use PYthon25 if installed. There must be a file association config file somewhere that screws this up.

I finally wrote a batch file (I use Windows Vista) and that solves the problem:

REM a batch file to force IDLE to use Pyhon30
REM saved as IDLE30.bat
C:\Python30\pythonw.exe -u C:\Python30\Lib\idlelib\idle.pyw

By the way, I really hate VISTA (their socalled security is childish, rather annoying and stupid)!

Ene Uran 638 Posting Virtuoso

There would be no changes using a list of vowels, the 'in' operator works the same way:

first = raw_input("Enter a sentence :\n")
second = ""
#vowels = 'aeiou'
vowels = ['a','e','i','o','u']
for i in first:
    if i in vowels:
        second = second+i.upper()
    else :
        second = second+i

print second

using vowels = 'aeiou' is much simpler.

Ene Uran 638 Posting Virtuoso

HTML code is easy to learn and you can format text using a simplified version of it, and show it in the wx.html.HtmlWindow() widget. Here is an example:
http://www.daniweb.com/forums/post803532-107.html

Ene Uran 638 Posting Virtuoso

The wx.html.HtmlWindow widget is also very useful to show text in changing size and colour:

# using wxPython's
# wx.html.HtmlWindow(parent, id, pos, size, style, name)
# to show colourful text using relatively simple html code

import wx
import wx.html

class MyFrame(wx.Frame):
    def __init__(self, parent, mytitle, mysize, html_code1, html_code2):
        wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle,
            size=mysize)

        # create an html label/window
        htmlwin1 = wx.html.HtmlWindow(self, wx.ID_ANY)
        htmlwin1.SetPage(html_code1)
        
        htmlwin2 = wx.html.HtmlWindow(self, wx.ID_ANY)
        htmlwin2.SetPage(html_code2)
        
        # position the labels with a box sizer
        sizer_v = wx.BoxSizer(wx.VERTICAL)
        sizer_v.Add(htmlwin1, proportion=1, flag=wx.EXPAND)
        sizer_v.Add(htmlwin2, proportion=2, flag=wx.EXPAND)
        self.SetSizer(sizer_v)


# simple HTML code ...
# text between <B> and </B> is bold
# <BR> inserts a line break (or new line)
# text between <FONT color="blue"> and </FONT> is that color
# add size to the FONT tag
html_code1 = """\
This shows you how to display text in color
<BR>
<FONT color="blue">like blue text</FONT>
<FONT color="red"> or red text</FONT>
<B> or maybe just bold ...</B>
<BR><BR>
<FONT color="green" size=5>
You are in extreme
<FONT color="red" size=5>danger</FONT>
standing so close!
</FONT>
"""

# a few more HTML tags ...
# use <BODY> tags to add a background colour
# text between <H3> and </H3> is header size
# etc. etc. just experiment with the <> tags
html_code2 = """\
<BODY bgcolor="#FFE47E">
look at the new background colour ...
<H3>large header size</H3><H2>larger header size</H2>
<BR>
<FONT size="+4">even larger font size</FONT>
<BR><BR>
<FONT color="red" size="+4">larger </FONT>
<FONT color="green" size="+4">size </FONT>
<FONT color="blue" size="+4">and </FONT>
<FONT color="magenta" size="+4">color</FONT>
<BR>
</BODY>
"""

app = wx.App()
mytitle …