wiz_fb.py :  » Business-Application » hylaPEx » hylapex » library » wizard » 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 » Business Application » hylaPEx 
hylaPEx » hylapex » library » wizard » wiz_fb.py
# -*- coding: utf-8 -*-

import wx
import wiz_type, wiz_local, wiz_mysql, wiz_odbc, wiz_link, wiz_file
import time
import wx_util

from library import i18n
_ = i18n.i18n()

def create(parent, db_inst, paths):
    return WizFrame(parent, db_inst, paths)

[wxID_WXFRAME1, wxID_WXFRAME1BT_NEXT, wxID_WXFRAME1BT_PREV,
 wxID_WXFRAME1LBL_TITLE, wxID_WXFRAME1STATICLINE1, wxID_WXFRAME1STATICLINE2,
] = [wx.NewId() for _init_ctrls in range(6)]

class WizFrame(wx.Frame):
    """
    """
    def __init__(self, parent, db_inst, paths):
        super(WizFrame, self).__init__(parent, title=_("wizard_title"))
        
        self.parent = parent
        self.paths = paths
        self.db_inst = db_inst
        self._init_ctrls(self)
        
        self.page = 1
        self.page_n = 4
        
        #Current page
        self._change_panel(wiz_type.pnl(self._p))
        self.close = False
        self.bt_prev.Enable(False)
        
        #Only for modify
        self.name = None
        self.local_db_name = ""
        
        self.Show()
        
    def _init_ctrls(self, parent):
        """
        """
        self._p = wx.Panel(parent)
        
        #bad hack for backwards compatibility
        self._p.update_parent = self.update_parent
        self._p.fb_wizard_pag3_ok = self.fb_wizard_pag3_ok
    
        lbl_title = wx.StaticText(self._p, label=_("widzard_lbl_title"))
        f = lbl_title.GetFont()
        f.SetPointSize(16)
        lbl_title.SetFont(f)
        
        null_panel = wx.Panel(self._p)
        
        l1 = wx.StaticLine(self._p)
        l2 = wx.StaticLine(self._p)
        
        self.bt_prev = wx.Button(self._p, label=_("bt_prev"))
        self.bt_next = wx.Button(self._p, label=_("bt_next"))
        
        sz = wx.BoxSizer(wx.VERTICAL)
        sz_buttons = wx.BoxSizer(wx.HORIZONTAL)
        
        sz_buttons.Add(self.bt_prev, 0, wx.ALIGN_CENTER | wx.RIGHT, 10)
        sz_buttons.Add(self.bt_next, 0, wx.ALIGN_CENTER | wx.LEFT, 10)
        
        flags = wx.ALIGN_CENTER | wx.ALL
        flags_line = wx.ALIGN_CENTER | wx.ALL | wx.EXPAND
        
        sz.Add(lbl_title, 0, flags, 5)
        sz.Add(l1, 0, flags_line, 5)
        sz.Add(null_panel, 1, flags, 5)
        sz.Add(l2, 0, flags_line, 5)
        sz.Add(sz_buttons, 0, flags, 5)
        
        #event bind
        self.bt_prev.Bind(wx.EVT_BUTTON, self.OnBt_prevButton)
        self.bt_next.Bind(wx.EVT_BUTTON, self.OnBt_nextButton)
        
        self._sz_all = sz
        self._p_midle = null_panel
        
        self._p.SetSizerAndFit(sz)
        self.SetClientSize(sz.GetSize())
    
    def _change_panel(self, panel):
        """ Change the panel into the midle of the frame
        """
        self._sz_all.Detach(self._p_midle)
        self._sz_all.Insert(2, panel, 1, wx.ALIGN_CENTER | wx.ALL | wx.EXPAND, 5)
        
        self._p_midle.Destroy()
        
        self._p_midle = panel
        self._sz_all.Layout()
        self._sz_all.Fit(self)
        
        #self.SetClientSize(self._sz_all.GetSize())
        
    def OnBt_prevButton(self, event):
        """
        """
        if self.page == 1:
            return
        
        elif self.page == 2:
            self._change_panel(wiz_type.pnl(self._p))
            self.bt_prev.Enable(False)
            self.bt_next.Enable(True)
        
        elif self.page == 3:
            
            if self.wid_type == 0:
                wi = wiz_local.pnl
            elif self.wid_type == 1:
                wi = wiz_file.pnl
            elif self.wid_type == 2:
                wi = wiz_mysql.pnl
            else:
                wi = wiz_odbc.pnl
            
            self._change_panel( wi( self._p, self.paths, self.db_inst, (1, self.local_db_name) ) )
            
        self.page -= 1

    def OnBt_nextButton(self, event):
        """
        """
        if self.close:
            self.Close()
        
        if self.page == 1:
            db_type =self._p_midle.GetDbType()
            self._createPanels(db_type)
        
        elif self.page == 2:
            self._change_panel( wiz_link.pnl(self._p, self.paths, self.db_inst, self.local_db_name) )
            self.page += 1
            self.bt_next.Enable(False)
            return
        
    def _createPanels(self, value=None, modify=0):
        """ Value is the type, modify is set when 
            I'm modifing the phonebook
        """
        if self.page_n == self.page:
            return
        
        if self.page == 1:
            
            self.wid_type = value

            if value == 0: pnl_wiz = wiz_local.pnl
            elif value == 1: pnl_wiz = wiz_file.pnl
            elif value == 2: pnl_wiz = wiz_mysql.pnl
            else: pnl_wiz = wiz_odbc.pnl
                
            self._change_panel( pnl_wiz(self._p, self.paths, self.db_inst, (modify, self.name)) )
                
            self.bt_next.Enable(False)
            self.bt_prev.Enable(True)
            self.page += 1
            return
            
        if self.page == 2:
            self._change_panel( wiz_link.pnl(self._p, self.paths, self.db_inst, self.local_db_name) )
            self.page += 1
            self.bt_next.Enable(False)
            
    def update_parent(self, db_name):
        """
        """
        self.local_db_name = db_name
        self.parent.my_init()
        self.fb_wizard_pag2_ok()

    def fb_wizard_pag2_ok(self):
        """
        """
        self.bt_next.Enable(True)

    def fb_wizard_pag3_ok(self):
        self.bt_next.SetLabel( _('bt_close') )
        self.bt_next.Enable(True)
        self.close = 1
        
    def goToPage(self, type, name):
        """ Need when I want to go to page xxx
        """
        if not self.IsShown(): self.Show(True)
        if type == 'local':
            val = 0   
        elif type == 'file':
            val = 1
        elif type == 'mysql':
            val = 2
        else:
            val = 3
        
        self.name = name
        self._createPanels(val, modify=1)
        
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.