wiz_link.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_link.py
#Boa:FramePanel:pnl
# -*- coding: utf-8 -*-
#
# hylaPEx, an hylafax client written in python
#
# www.unipex.it/hylapex/
#
# License:
#         GNU General Public License (GPL)
#         For more info see LICENSE.txt and LICENSE-GPL.txt
#
# Copyright (C) 2004-2006  Unipex s.r.l.,  All Rights Reserved.
# Via Vittorio Veneto 83/A
# 33050 Gonars (UD) - Italy
# phone 0039 0432 931511 - fax 0039 0432 931378
# www.unipex.it - michele.petrazzo@unipex.it

import wx
import wx.grid
import string, wx_util
from library.ftp import read_conf

[wxID_PNL, wxID_PNLBT_LINK, wxID_PNLBT_SAVE, wxID_PNLBT_UNLINK,
 wxID_PNLGR_END, wxID_PNLLBL_END_FIELDS, wxID_PNLLBL_FIELD, wxID_PNLLST_FIELD,
] = [wx.NewId() for _init_ctrls in range(8)]

class pnl(wx.Panel):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Panel.__init__(self, id=wxID_PNL, name='pnl', parent=prnt,
              pos= wx.Point(10, 55), size= wx.Size(468, 277),
              style=wx.TAB_TRAVERSAL)
        self.SetClientSize(wx.Size(460, 250))
        self.SetToolTipString('')
        self.SetBackgroundColour(wx.Colour(245, 245, 245))

        self.lst_field = wx.ListBox(choices=[], id=wxID_PNLLST_FIELD,
              name='lst_field', parent=self, pos= wx.Point(24, 32),
              size= wx.Size(136, 184), style=0, validator=wx.DefaultValidator)
        self.lst_field.SetToolTipString('')

        self.gr_end =wx.grid.Grid(id=wxID_PNLGR_END, name='gr_end', parent=self,
              pos= wx.Point(240, 32), size= wx.Size(200, 184), style=0)
        self.gr_end.SetRowLabelSize(80)
        self.gr_end.SetDefaultRowSize(20)
        self.gr_end.SetDefaultCellFont(wx.Font(8,wx.SWISS,wx.NORMAL,wx.NORMAL,
              False, 'MS Shell Dlg'))
        self.gr_end.SetColLabelSize(22)
        self.gr_end.SetToolTipString('')

        self.bt_save = wx.Button(id=wxID_PNLBT_SAVE, label='Save',
              name='bt_save', parent=self, pos= wx.Point(396, 224),
              size= wx.Size(43, 23), style=0)
        self.bt_save.Bind(wx.EVT_BUTTON, self.OnBt_saveButton, id=wxID_PNLBT_SAVE)

        self.bt_link = wx.Button(id=wxID_PNLBT_LINK, label='Link ->',
              name='bt_link', parent=self, pos= wx.Point(176, 104),
              size= wx.Size(51, 23), style=0)
        self.bt_link.Bind(wx.EVT_BUTTON, self.OnBt_linkButton, id=wxID_PNLBT_LINK)

        self.bt_unlink = wx.Button(id=wxID_PNLBT_UNLINK, label='<- Unlink',
              name='bt_unlink', parent=self, pos= wx.Point(176, 136),
              size= wx.Size(51, 23), style=0)
        self.bt_unlink.Bind(wx.EVT_BUTTON, self.OnBt_unlinkButton, id=wxID_PNLBT_UNLINK)

        self.lbl_field = wx.StaticText(id=wxID_PNLLBL_FIELD,
              label='List of fields', name='lbl_field', parent=self,
              pos= wx.Point(24, 16), size= wx.Size(55, 13), style=0)

        self.lbl_end_fields = wx.StaticText(id=wxID_PNLLBL_END_FIELDS,
              label='List of end fields', name='lbl_end_fields', parent=self,
              pos= wx.Point(248, 16), size= wx.Size(76, 13), style=0)

    def __init__(self, parent, paths, db_inst, db4work):
        self._init_ctrls(parent)
        self.parent = parent
        self.paths = paths
        self.db_inst = db_inst
        self.db4work = db4work
        self.gr_end.CreateGrid(2,1)
        status, ret = self.db_inst.queryReturn('SELECT fb_fields FROM fb WHERE name = "%s"' % (self.db4work))
        print ret
        if ret:
            fields = string.split(ret[0][0], ',')
            for i in fields:
                self.lst_field.Append(i.strip())
        self.ren = wx_util.rename_ctrls(self, 'wiz_link', \
            lang = self.paths.language)
        self.ren.rename()
        self.ren.SetGridFieldNames('gr_end')
        field_list = self.ren.get_list('_field_to_link')
        for num, i in enumerate(field_list):
            self.gr_end.SetRowLabelValue(num, i)

    def OnBt_saveButton(self, event):
        conf = read_conf.conf_parser(self.paths.file_db_fb_link, self.db4work)
        conf.init_sections([self.db4work])
        #This list MUST be like p_fb
        self.fileds2link = ['company', 'fax number']
        for num, val in enumerate(self.fileds2link):
            val_cell = self.gr_end.GetCellValue(num,0)
            if not val_cell:
                wx.MessageBox(self.ren.get('_insert_values_into_table'),
                    self.ren.get('error', 1), wx.ICON_ERROR)
                return
            conf.set(val, val_cell)
        conf.exit()
        self.parent.fb_wizard_pag3_ok()

    def OnBt_linkButton(self, event):
        lst_sel =  self.lst_field.GetSelection()
        if lst_sel == -1:
            return
        if not self.gr_end.GetSelectedRows():
            return
        grd_sel = self.gr_end.GetSelectedRows()[0]
        if self.gr_end.GetCellValue(grd_sel,0) == '':
            self.gr_end.SetCellValue(grd_sel,0,self.lst_field.GetString(lst_sel))
            self.lst_field.Delete(lst_sel)

    def OnBt_unlinkButton(self, event):
        if not self.gr_end.GetSelectedRows() == -1:
            return
        grd_sel = self.gr_end.GetSelectedRows()[0]
        self.lst_field.Append(self.gr_end.GetCellValue(grd_sel,0))
        self.gr_end.SetCellValue(grd_sel,0,'')
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.