[Tutor] Problems with wx in Vista...

Trey Keown trey at opmstech.org
Wed Sep 5 02:49:49 CEST 2007


Although I should have expected at least a few problems, I have a question
about a glitch in vista using a wx-implemented script.
Here's the example script-
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#!/usr/bin/python

# togglebuttons.py

import wx

class ToggleButtons(wx.Dialog):
    def __init__(self, parent, id, title):
        wx.Dialog.__init__(self, parent, id, title, size=(300, 200))

        self.colour = wx.Colour(0, 0, 0)

        wx.ToggleButton(self, 1, 'red', (20, 25))
        wx.ToggleButton(self, 2, 'green', (20, 60))
        wx.ToggleButton(self, 3, 'blue', (20, 100))

        self.panel  = wx.Panel(self, -1, (150, 20), (110, 110),
style=wx.SUNKEN_BORDER)
        self.panel.SetBackgroundColour(self.colour)

        self.Bind(wx.EVT_TOGGLEBUTTON, self.ToggleRed, id=1)
        self.Bind(wx.EVT_TOGGLEBUTTON, self.ToggleGreen, id=2)
        self.Bind(wx.EVT_TOGGLEBUTTON, self.ToggleBlue, id=3)

        self.Centre()
        self.ShowModal()
        self.Destroy()

    def ToggleRed(self, event):
        green = self.colour.Green()
        blue = self.colour.Blue()
        if  self.colour.Red():
            self.colour.Set(0, green, blue)
        else:
            self.colour.Set(255, green, blue)
        self.panel.SetBackgroundColour(self.colour)

    def ToggleGreen(self, event):
        red = self.colour.Red()
        blue = self.colour.Blue()
        if  self.colour.Green():
            self.colour.Set(red, 0, blue)
        else:
            self.colour.Set(red, 255, blue)
        self.panel.SetBackgroundColour(self.colour)

    def ToggleBlue(self, event):
        red = self.colour.Red()
        green = self.colour.Green()
        if  self.colour.Blue():
            self.colour.Set(red, green, 0)
        else:
            self.colour.Set(red, green, 255)
        self.panel.SetBackgroundColour(self.colour)


app = wx.App(0)
ToggleButtons(None, -1, 'togglebuttons.py')
app.MainLoop()
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
This makes a window pop up with 3 buttons that changes the color of a box.
Now, my question is, is this a vista-specific problem, am I just doing
something wrong, or is the example messed up.
Note- the name I saved the program as is testwx.py
Thanks for any help



More information about the Tutor mailing list