Module gui
[hide private]
[frames] | no frames]

Module gui

source code

PYBAG - Crossplatform files synchronization and backup portable tools.

GUI implementation.


License: Copyright (c) 2007 ... 2019, Mazhugin Aleksey All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Mazhugin Aleksey nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Classes [hide private]
  dlgTips_class
  dlgPrefs_class
  dlgAddRoot_class
  dlgInfo_class
  PyBAGListCtrl_class
  frmMain_class
  outstream
Output stream.
Functions [hide private]
 
start_gui(cmd)
Start GUI.
source code
 
FillColFromConfig()
Return list with columns.
source code
 
WriteCols2Config(cols)
Write columns to config cfg.Z_CP.
source code
 
LoadAppStateFromConfig() source code
 
SaveAppStateToConfig() source code
boolean
ask_yn(msg, title=u'')
Show msg and return Yes (True) or No (False) result.
source code
 
ask_ok(msg, title=u'')
Show msg with OK button.
source code
Variables [hide private]
  catalog = {}
Icons catalog.
  index = []
Icons index.
  SELSTATEALL = 1
  SELSTATEDEFAULT = 0
  SELSTATECLEAR = 2
  btnSelectRoots_state = 0
Current state of button.
  AppState = {'ff_bag': True, 'ff_ch': True, 'ff_conf': True, 'f...
Application state for GUI UI update.
  _filter = {u'ff_bag': u'filter_bag', u'ff_ch': u'filter_change...
  _outlock = threading.Lock()
Lock object for gui print.
  _outtxt = u''
Text printed from GUI.
  _column_choise_dict = {u'actionicon': (u'actionicon', u'Action...
  BACKUPDIR = 16
  COL_FORMAT = 4
  COL_HEADING = 1
  COL_NAME = 0
  COL_VISIBLE = 2
  COL_WIDTH = 3
  CRC32BUF = 1048575
  DBBACKUP = 27
  DBBACKUPNO = False
  DBBACKUPYES = True
  DBBAGCRC32 = 104
  DBBAGFLAG = 101
  DBBAGLINK = 107
  DBBAGMDATE = 103
  DBBAGPATH = 106
  DBBAGREAD = 105
  DBBAGSIZE = 102
  DBCOMPARE = 18
  DBDBCRC32 = 304
  DBDBFLAG = 301
  DBDBLINK = 307
  DBDBMDATE = 303
  DBDBPATH = 306
  DBDBREAD = 305
  DBDBSIZE = 302
  DBDESC = 20
  DBDESCMAN = 22
  DBDESCMANNONE = u''
  DBDESCNONE = u'Not compared.'
  DBDESCOK = u'Ok.'
  DBDESCREADED = 25
  DBDIR = 15
  DBDIRBAG = 1
  DBDIRCONFLICT = 64
  DBDIRCOPY = 8
  DBDIRDB = 4
  DBDIRDELETE = 16
  DBDIRDIFF = 4096
  DBDIRERROR = 128
  DBDIRFORCED = 1024
  DBDIRIGNORED = 2048
  DBDIRMAN = 21
  DBDIRNEW = 256
  DBDIRNONE = 0
  DBDIROK = 8192
  DBDIRORIG = 2
  DBDIRREADED = 24
  DBDIRRESTORE = 16384
  DBDIRTS = 32768
  DBDIRUNCHANGED = 512
  DBDIRWARNING = 32
  DBDUMPMAX = 500
  DBESCAPE = u' %'
  DBESCESC = u'#'
  DBFLAGDIR = u'd'
  DBFLAGFILE = u'f'
  DBFLAGNONE = u''
  DBFLAGSYMLINK = u's'
  DBFLAGUNKNOWN = u'u'
  DBFORCEDIRBAG = 1
  DBFORCEDIRBAGALL = 16
  DBFORCEDIRBAGCOPY = 128
  DBFORCEDIRNEWER = 8
  DBFORCEDIRNONE = 0
  DBFORCEDIROLDER = 4
  DBFORCEDIRORIGIN = 2
  DBFORCEDIRORIGINALL = 32
  DBFORCEDIRORIGINCOPY = 64
  DBITEMID = 23
  DBITEMNONE = None
  DBLINKNONE = u'-'
  DBMDATENONE = 0.0
  DBNONE = 0
  DBORIGCRC32 = 204
  DBORIGFLAG = 201
  DBORIGLINK = 207
  DBORIGMDATE = 203
  DBORIGPATH = 206
  DBORIGREAD = 205
  DBORIGSIZE = 202
  DBPATH = 0
  DBPATHNONE = u''
  DBREADNONE = False
  DBREADYES = True
  DBSEP = u'/'
  DBSYMEMULNONE = False
  DBSYMLINK = 19
  DBSYMLINKEMUL = 26
  DBSYNC = 17
  DBSYNCCOMPARE = 128
  DBSYNCCONFLICT = 512
  DBSYNCERRCOMPARE = 64
  DBSYNCERROR = 111
  DBSYNCERROTHER = 32
  DBSYNCERRREAD = 3
  DBSYNCERRREADBAG = 1
  DBSYNCERRREADSYNC = 2
  DBSYNCERRWRITE = 12
  DBSYNCERRWRITEBAG = 4
  DBSYNCERRWRITESYNC = 8
  DBSYNCIGNORED = 256
  DBSYNCNONE = 0
  DBSYNCOK = 16
  IBAG = 100
  ICRC32 = 4
  IDB = 300
  IFLAG = 1
  ILINK = 7
  IMDATE = 3
  IPATH = 6
  IREAD = 5
  ISIZE = 2
  ISYNC = 200
  LI_CANCEL = 0
  LI_DESC = 4
  LI_ERROR = 1
  LI_FILTERRUNNING = 9
  LI_FUN2 = 7
  LI_LENGTH = 11
  LI_PERCENT = 2
  LI_PERCENT100 = 3
  LI_PERCENTGLOBAL = 6
  LI_PERCENTPART = 5
  LI_THREAD = 10
  LI_UPDATEFILTER = 8
  LOOPN = 10000
  MDDELTA_DEFAULT = u'5.0'
  O_ACTION = [u'bag', u'origin', u'delete', u'skip', u'restore',...
  O_K_DICT = {u'c': u'copy', u'cn': u'copynoemul', u'copy': u'co...
  O_K_LIST = [u'c', u'i', u'copy', u'ignore', u'cn', u'in', u'co...
  O_REPORTFILTER = {u'b': 1, u'c': 64, u'd': 16, u'e': 128, u'f'...
  O_REPORTFORMAT = {u'l': u'%(forced)s %(dir)s %(err)s [%(path...
  O_REPORTTYPE = {u'1': u'f', u'2': u'd', u'3': u's', u'4': u'u'}
  O_S_DICT = {u'crc32': u'crc32', u'stat': u'stat'}
  O_S_LIST = [u'stat', u'crc32']
  PYBAG_COLORIZE_DEFAULT = u'1'
  PYBAG_DEBUG_DEFAULT = u'0'
  PYBAG_EMUL_DEFAULT = u'1'
  PYBAG_LOG_DEFAULT = u'1'
  P_BACKUP = u'backup'
  P_BACKUPNO = u'0'
  P_BACKUPYES = u'1'
  P_COLORIZE = u'colorize'
  P_COMPARE = u'compare'
  P_COMPARECRC32 = u'crc32'
  P_COMPARESTAT = u'stat'
  P_DEBUG = u'debug'
  P_DEFBACKUP = u'0'
  P_DEFCOMPARE = u'stat'
  P_DEFIGNORE = u''
  P_DEFSELECTDEFAULT = u'0'
  P_DEFSYMLINK = u'copy'
  P_EMUL = u'emulation'
  P_GUI = u'GUI'
  P_IGNORE = u'ignore'
  P_IGNORENONE = u''
  P_LOGGING = u'logging'
  P_MDDELTA = u'mddelta'
  P_OUTFILTER = u'outfilter'
  P_OUTPUT = u'output'
  P_SELECTDEFAULT = u'selectdefault'
  P_SELECTDEFAULTNO = u'0'
  P_SELECTDEFAULTYES = u'1'
  P_SHOWTIPS = u'showtips'
  P_SYMLINK = u'symlink'
  P_SYMLINKCOPY = u'copy'
  P_SYMLINKCOPYNOEMUL = u'copynoemul'
  P_SYMLINKIGNORE = u'ignore'
  P_SYMLINKIGNORENOEMUL = u'ignorenoemul'
  P_SYMLINK_EMUL = (u'ignore', u'copy')
  P_SYMLINK_IGNORE = (u'ignore', u'ignorenoemul')
  P_TIPSNUMBER = u'tipsnumber'
  P_VERB = u'verbosity'
  P_WRITECOLSATEXIT = u'writecolsatexit'
  REPORTDIR_DEFAULT = u'bonhdyfwce'
  REPORTFILTER_DEFAULT = u'sbonhdyfwce1234'
  REPORTFORMAT_DEFAULT = u's'
  REPORTPAGE_DEFAULT = u'0'
  REPORTPATT_DEFAULT = u'!.*'
  REPORTTYPE_DEFAULT = u'1234'
  TSDIRBAG = 1
  TSDIRNONE = 0
  TSDIRORIG = 2
  VERBOSE_DEFAULT = u'3'
  Z_DBFORCE = {u'bag': 1, u'bagall': 16, u'bagcopy': 128, u'newe...
  __package__ = None
  i = (u'timeshift', u'TS', 0, 16, 2)
  z_action_choise = [(u'No', 0), (u'To bag', 1), (u'To origin', ...
  z_backupmode = {u'0': 128, u'1': 16}
  z_compare_choice = [u'stat', u'crc32']
  z_db_formatlist = [(101, <type 'unicode'>, u'', u'DBBAGFLAG'),...
  z_db_marker = u'PYBAG DB version = '
  z_db_marker_len = 19
  z_db_version = u'0.2'
  z_pble = u':pybaglink end'
  z_pblmaxlen = 4096
  z_pbls = u'pybaglink start:'
  z_symlink_choice = [u'ignore', u'ignorenoemul', u'copy', u'cop...

Imports: re, webbrowser, time, threading, traceback, cfg, TermColors, _tips, __about__, _usage, command_class, f_add, cmd_dist, z_gp_class, cmd_remove, cmd_relocate, dbstartswith, getpathdirdb, f_stat, z_r, f_syncread, f_synccompare, f_syncsync, f_syncclear, dbsave, cmd_cleandb, wxversion, wx, codecs, dbg, init_encoding, locale, log, log_clear, log_init, log_writeln, log_writeln_0, log_writeln_1, os, prt, prt0, prt1, prt2, prt3, prt4, prt5, sys, z_u


Function Details [hide private]

FillColFromConfig()

source code 

Return list with columns. If no columns in config then use default.

ask_yn(msg, title=u'')

source code 

Show msg and return Yes (True) or No (False) result.

Parameters:
  • msg (string) - Message for show.
  • title (string) - Window title.
Returns: boolean
Yes or No result.

ask_ok(msg, title=u'')

source code 

Show msg with OK button. param msg: Message for show.

Parameters:
  • title (string) - Window title.
  • msg (string)

Variables Details [hide private]

AppState

Application state for GUI UI update.

Value:
{'ff_bag': True,
 'ff_ch': True,
 'ff_conf': True,
 'ff_del': True,
 'ff_dir': True,
 'ff_err': True,
 'ff_file': True,
 'ff_forced': True,
...

_filter

Value:
{u'ff_bag': u'filter_bag',
 u'ff_ch': u'filter_changed',
 u'ff_conf': u'filter_conflict',
 u'ff_del': u'filter_delete',
 u'ff_dir': u'filter_directory',
 u'ff_err': u'filter_error',
 u'ff_file': u'filter_file',
 u'ff_forced': u'filter_forced',
...

_column_choise_dict

Value:
{u'actionicon': (u'actionicon', u'Action', 1, 38, 2),
 u'crc32bag': (u'crc32bag', u'CRC32 bag', 0, 80, 1),
 u'crc32db': (u'crc32db', u'CRC32 DB', 0, 80, 1),
 u'crc32origin': (u'crc32origin', u'CRC32 origin', 0, 80, 1),
 u'desc': (u'desc', u'Description', 1, 350, 0),
 u'dir': (u'dir', u'Direction', 0, 32, 2),
 u'err': (u'err', u'Error', 0, 16, 2),
 u'forced': (u'forced', u'Forced', 0, 16, 2),
...

O_ACTION

Value:
[u'bag',
 u'origin',
 u'delete',
 u'skip',
 u'restore',
 u'tsbag',
 u'tsorigin',
 u'tsreset']

O_K_DICT

Value:
{u'c': u'copy',
 u'cn': u'copynoemul',
 u'copy': u'copy',
 u'copynoemul': u'copynoemul',
 u'i': u'ignore',
 u'ignore': u'ignore',
 u'ignorenoemul': u'ignorenoemul',
 u'in': u'ignorenoemul'}

O_K_LIST

Value:
[u'c',
 u'i',
 u'copy',
 u'ignore',
 u'cn',
 u'in',
 u'copynoemul',
 u'ignorenoemul']

O_REPORTFILTER

Value:
{u'b': 1,
 u'c': 64,
 u'd': 16,
 u'e': 128,
 u'f': 1024,
 u'h': 8,
 u'i': 2048,
 u'n': 256,
...

O_REPORTFORMAT

Value:
{u'l': u'''%(forced)s %(dir)s %(err)s [%(path)s]
	%(desc)s''',
 u'p': u'''	[%(path)s]-->
	  == "%(desc)s".''',
 u's': u'%(forced)s %(dir)s %(err)s [%(path)s]'}

Z_DBFORCE

Value:
{u'bag': 1,
 u'bagall': 16,
 u'bagcopy': 128,
 u'newer': 8,
 u'no': 0,
 u'older': 4,
 u'origin': 2,
 u'originall': 32,
...

z_action_choise

Value:
[(u'No', 0),
 (u'To bag', 1),
 (u'To origin', 2),
 (u'Newer', 8),
 (u'Older', 4),
 (u'Newer, to bag', 9),
 (u'Newer, to origin', 10),
 (u'Older, to bag', 5),
...

z_db_formatlist

Value:
[(101, <type 'unicode'>, u'', u'DBBAGFLAG'),
 (102, <type 'int'>, 0, u'DBBAGSIZE'),
 (103, <type 'float'>, 0.0, u'DBBAGMDATE'),
 (104, <type 'int'>, 0, u'DBBAGCRC32'),
 (105, <type 'bool'>, False, u'DBBAGREAD'),
 (106, <type 'unicode'>, u'', u'DBBAGPATH'),
 (107, <type 'unicode'>, u'-', u'DBBAGLINK'),
 (301, <type 'unicode'>, u'', u'DBDBFLAG'),
...

z_symlink_choice

Value:
[u'ignore', u'ignorenoemul', u'copy', u'copynoemul']