#!/usr/bin/python
"""
Module  : simplePyCrust.py
Version : 1.0
Author  : Patrick K O'Brien <pobrein@orbtech.com>
Date    : 22nd December, 2002
Purpose : Really simple example of how to embed PyCrust in a wxPython application.
"""

from wxPython import wx
from wxPython.lib.PyCrust import shell
from wxPython.lib.PyCrust.crust import CrustFrame


class myFrame(wx.wxFrame):
    def __init__(self, parent, ID, title, pos, size, parentApp):
        wx.wxFrame.__init__(self, parent, ID, title, pos, size)
        # A text field
        self.textFld = wx.wxTextCtrl(self, -1, size=(500,200), style=wx.wxTE_MULTILINE)
        # A slider
        self.slider = wx.wxSlider(self, -1, 0, 0, 100, point=(10,250), 
                                  size=(100, -1), 
                                  style= wx.wxSL_HORIZONTAL | wx.wxSL_AUTOTICKS | wx.wxSL_LABELS)
        self.slider.SetTickFreq(5, 1)
        # Finally, a toggle button
        self.button = wx.wxToggleButton(self, -1, "Toggle", pos=(250,250))
        # Add in the crust, hmm
        self.crustFrame = CrustFrame()
        self.crustFrame.SetSize((700, 500))
        self.crustFrame.Show(wx.TRUE)
        self.crustFrame.shell.interp.locals['pcapp'] = parentApp
        wx.EVT_CLOSE(self.crustFrame, self.onCloseCrustFrame)

    def onCloseCrustFrame(self, event): 
        self.crustFrame.Show(False) 

class myApp(wx.wxApp):
    def OnInit(self):
        wx.wxInitAllImageHandlers()
        self.frame = myFrame(None, -1, "My Basic Application", (20, 20), (500, 300), self)
        self.frame.Show(wx.TRUE)
        self.SetTopWindow(self.frame)
        return wx.TRUE

if __name__ == "__main__":
    app = myApp(0)
    app.MainLoop()
