We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,376 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion
Page 9 of Article: Starting wxPython (GUI code)
The idea of this thread is to help the beginning wxPython GUI programmer with hints and helpful code. Please feel free to contribute! If you have any questions start your own thread! For info on wxPython modules see: http://www.wxpython.org/docs/api/wx-module.html

Is it true that the development of wxPython is dead?

ZZucker
Master Poster
780 posts since Jan 2008
Reputation Points: 342
Solved Threads: 60
Skill Endorsements: 1
sneekula
Nearly a Posting Maven
2,483 posts since Oct 2006
Reputation Points: 1,000
Solved Threads: 231
Skill Endorsements: 2

Yes, project Phoenix does rewrite all the wxPython code to make it work with Python2 and Python3.

For old time sake, some fun with colors:

# color a wxPython panel every 2.5 seconds with a random color

import wx
import random
from wx.lib.colourdb import *

class MyFrame(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(600, 450))

        self.panel = wx.Panel(self, -1)
        # create a list of wx colors (from wx.lib.colourdb)
        self.colors = getColourList()
        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
        # milliseconds
        self.timer.Start(2500)
        self.Center()

    def OnTimer(self, event):
        self.panel.SetBackgroundColour(wx.RED)
        # pick a random color from the list
        color = random.choice(self.colors)
        self.panel.SetBackgroundColour(color)
        self.panel.Refresh()
        self.SetTitle(color)


app = wx.App(0)
# contains all the wx color names (from wx.lib.colourdb)
updateColourDB()
# create the frame instance
frame = MyFrame(None, -1, 'randomcolours.py')
frame.Show(True)
app.SetTopWindow(frame)
app.MainLoop()
Lardmeister
Posting Virtuoso
1,939 posts since Mar 2007
Reputation Points: 465
Solved Threads: 72
Skill Endorsements: 5

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0624 seconds using 2.74MB