# Written by: QuantumPhyiscs
# Date Written: 10/03/12
# includes wxWidgets module
import wx
# includes web browser module to access internet
import webbrowser
# Copyright (c) ~ QuantumPhyiscs
class MyFrame(wx.Frame):
def __init__(self):
# Sets name of the frame
wx.Frame.__init__(self, None, wx.ID_ANY, 'Open IE WP',
pos=(300, 150), size=(207, 175))
# Sets background color of the frame
self.SetBackgroundColour("red")
# Creates a button(1 - 4) at x-x pos, x-y size
self.button1 = wx.Button(self, id=-1, label='Open Google',
pos=(8, 8), size=(175, 28))
self.button1.Bind(wx.EVT_BUTTON, self.button1Click)
self.button2 = wx.Button(self, id=-1, label='Open Facebook',
pos=(8, 38), size=(175, 28))
self.button2.Bind(wx.EVT_BUTTON, self.button2Click)
self.button3 = wx.Button(self, id=-1, label='Open Moodle',
pos=(8, 68), size=(175, 28))
self.button3.Bind(wx.EVT_BUTTON, self.button3Click)
self.button4 = wx.Button(self, id=-1, label='Open Youtube',
pos=(8, 98), size=(175, 28))
self.button4.Bind(wx.EVT_BUTTON, self.button4Click)
# Makes button visible on frame
self.Show(True)
# Tackle events if button is clicked
def button1Click(self,event):
# Sets title or super's the frame once button is clicked
self.SetTitle("Google is open.")
# Opens default web browser and redirects to google.com
# Sets new = 1, which means thats a new window will open
webbrowser.open("www.google.com",new = 1, autoraise = True)
# Makes button visible on frame
self.button2.Show()
# repeats for the rest
def button2Click(self,event):
self.SetTitle("Facebook is open.")
webbrowser.open("http://facebook.com",new = 1, autoraise = True)
self.button1.Show()
def button3Click(self,event):
self.SetTitle("Moodle is open.")
webbrowser.open("http://moodle2.yrdsb.ca/login/index.php",new = 1, autoraise = True)
self.button4.Enable()
def button4Click(self,event):
self.SetTitle("Youtube is open.")
webbrowser.open("www.youtube.com",new = 1, autoraise = True)
self.button3.Enable()
application = wx.PySimpleApp()
window = MyFrame()
# While loop for application, continues untill window is closed to DESTROY app
application.MainLoop()
|