DlgHelp.py :  » UML » Python-UML-Tool » pyut-1.4.0 » src » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » UML » Python UML Tool 
Python UML Tool » pyut 1.4.0 » src » DlgHelp.py
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
__version__ = "$Revision: 1.7 $"
__author__ = "EI5, eivd, Group Burgbacher - Waelti"
__date__ = "2001-11-14"
# C.Dutoit, 20020917, removed OnLoadFile / load file button... (why was it here?)

#from wxPython.wx import *
#from wxPython.html import *
import wx
from pyutUtils import assignID

[ID_LOAD_FILE, ID_BACK, ID_FORWARD, ID_PRINT, ID_VIEW_SOURCE] = assignID(5)

class DlgHelp(wx.Dialog):
    """
    Pyut help dialog frame. Used to show help and navigate through it.

    To use it from a wxFrame :
        dlg = DlgHelp(self, -1, "Pyut Help")
        dlg.Show()
        dlg.destroy()

    :version: $Revision: 1.7 $
    :author: C.Dutoit
    :contact: dutoitc@hotmail.com
    """

    #>------------------------------------------------------------------------

    def __init__(self, parent, ID, title):
        """
        Constructor.

        @since 1.0
        @author C.Dutoit
        """
        import os, wx
        #dialog box
        wx.Dialog.__init__(self, parent, ID, title, wx.DefaultPosition, 
                          wx.Size(720, 520))
        self.Center(wx.BOTH)

        #window
        import wx.html
        self.html = wx.html.HtmlWindow(self, -1, wx.DefaultPosition, wx.Size(720, 520))
        self.html.LoadPage(os.getcwd()+ os.sep + "help" + os.sep + "index.html")

        # Printer
        self.printer=wx.html.HtmlEasyPrinting()

        # Sizer
        self.box = wx.BoxSizer(wx.VERTICAL)
        self.box.Add(self.html, 1, wx.GROW)
        subbox = wx.BoxSizer(wx.HORIZONTAL)

        #buttons
        #btn = wx.Button(self, ID_LOAD_FILE, _("Load file"))
        #EVT_BUTTON(self, ID_LOAD_FILE, self.__OnLoadFile)
        #subbox.Add(btn, 1, wx.GROW | wx.ALL, 2)

        btn = wx.Button(self, ID_BACK, _("Back"))
        self.Bind(wx.EVT_BUTTON, self.__OnBack, id=ID_BACK)
        subbox.Add(btn, 1, wx.GROW | wx.ALL, 2)
        
        btn = wx.Button(self, ID_FORWARD, _("Forward"))
        self.Bind(wx.EVT_BUTTON, self.__OnForward, id=ID_FORWARD)
        subbox.Add(btn, 1, wx.GROW | wx.ALL, 2)

        btn = wx.Button(self, ID_PRINT, _("Print"))
        self.Bind(wx.EVT_BUTTON, self.__OnPrint, id=ID_PRINT)
        subbox.Add(btn, 1, wx.GROW | wx.ALL, 2)

        btn = wx.Button(self, ID_VIEW_SOURCE, _("View Source"))
        self.Bind(wx.EVT_BUTTON, self.__OnViewSource, id=ID_VIEW_SOURCE)
        subbox.Add(btn, 1, wx.GROW | wx.ALL, 2)

        btn = wx.Button(self, wx.ID_OK, _("Exit"))
        subbox.Add(btn, 1, wx.GROW | wx.ALL, 2)

        self.box.Add(subbox, 0, wx.GROW | wx.BOTTOM)
        self.SetSizer(self.box)
        self.SetAutoLayout(True)
        subbox.Fit(self)
        self.box.Fit(self)

        self.OnShowDefault(None)

        self.Show(True)



    #>------------------------------------------------------------------------

    def OnShowDefault(self, event):
        """
        Show default page

        @since 1.1
        @author C.Dutoit
        """
        import os
        name = os.path.join(os.getcwd(), 'help/index.html')
        self.html.LoadPage(name)

    #>------------------------------------------------------------------------

    #def __OnLoadFile(self, event):
        #"""
        #Load a html page
#
        #@since 1.1
        #@author C.Dutoit
        #"""
        #dlg = wx.FileDialog(self, wildcard = '*.htm*', style=wx.OPEN)
        #if dlg.ShowModal()==wx.OK:
            #path = dlg.GetPath()
            #self.html.LoadPage(path)
        #dlg.Destroy()


    #>------------------------------------------------------------------------

    def __OnBack(self, event):
        """
        go one level back; load last page

        @since 1.1
        @author C.Dutoit
        """
        if not self.html.HistoryBack():
            wx.MessageBox(_("No more items in history !"))

    #>------------------------------------------------------------------------

    def __OnForward(self, event):
        """
        go one level forward; load next page

        @since 1.1
        @author C.Dutoit
        """
        if not self.html.HistoryForward():
            wx.MessageBox(_("No more items in history !"))

    #>------------------------------------------------------------------------

    def __OnViewSource(self, event):
        """
        View document source

        @since 1.1
        @author C.Dutoit
        """
        from wx.Python.lib.dialogs import ScrolledMessageDialog
        source = self.html.GetParser().GetSource()
        dlg = wx.ScrolledMessageDialog(self, source, _('HTML Source'))
        dlg.ShowModal()
        dlg.Destroy()


    #>------------------------------------------------------------------------

    def __OnPrint(self, event):
        """
        print the current page

        @since 1.1
        @author C.Dutoit
        """
        self.printer.PrintFile(self.html.GetOpenedPage())



#Dialog box test
if __name__ == "__main__":
    class App(wx.App):
        def OnInit(self):
            frame = wx.Frame(None, -1, "Pyut Help test application")
            self.SetTopWindow(frame)
            self.dlg=DlgHelp(frame,  -1, "Pyut Help")
            return True
    app = App(0)
    app.MainLoop()
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.