示例#1
0
 def _set_lists(self):
     f = '[MClient] logic.Order._set_lists'
     lists = Lists()
     self.blacklst = sh.Input (title = f
                              ,value = lists.get_blacklist()
                              ).get_list()
     self.priorlst = sh.Input (title = f
                              ,value = lists.get_priorities()
                              ).get_list()
示例#2
0
 def export_table_width(self):
     f = '[MClient] settings.controller.ExportSettingsUI.export_table_width'
     width = objs.get_settings_ui().ent_tab.get()
     width = sh.Input(f,width).get_integer()
     if not 60 <= width < 100:
         sub = _('{} ≤ value < {}').format(60,100)
         mes = _('A custom table width shall lie within the following range: {}')
         mes = mes.format(sub)
         sh.objs.get_mes(f,mes).show_warning()
         width = 97
         objs.settings_ui.ent_tab.reset()
         objs.settings_ui.ent_tab.insert(width)
     sh.lg.globs['int']['table_width'] = width
示例#3
0
 def __getitem__(self, key):
     ''' int and slice return coresponding words string key is used
         for reverse lookup.
     '''
     f = '[MClient] plugins.stardict.get.Stardict.__getitem__'
     if self.Success:
         if type(key) is int:
             return self.idx[key][0]
         if type(key) is slice:
             return [w[0] for w in self.idx[key]]
         if type(key) is str:
             return sh.Input(title=f, value=self.search(key)).get_integer()
     else:
         sh.com.cancel(f)
示例#4
0
 def set_meta(self):
     f = '[MClient] plugins.stardict.get.Stardict.set_meta'
     if self.Success:
         if self.ifo:
             if 'bookname' in self.ifo and 'wordcount' in self.ifo:
                 self.title = str(self.ifo['bookname'])
                 self.wcount = sh.Input(
                     f, self.ifo['wordcount']).get_integer()
             else:
                 self.Success = False
                 mes = _('File "{}" is incorrect!')
                 mes = mes.format(self.fname + '.ifo')
                 sh.objs.get_mes(f, mes).show_warning()
         else:
             sh.com.rep_empty(f)
     else:
         sh.com.cancel(f)
示例#5
0
 def fix_raw_htm(self):
     f = '[MClient] manager.Plugins.fix_raw_htm'
     code = ''
     if self.plugin:
         code = self.plugin.fix_raw_htm()
     else:
         sh.com.rep_empty(f)
     code = sh.Input(f, code).get_not_none()
     if not '</html>' in code.lower():
         search = self.get_search()
         # '.format' does not work properly for 'multitrandem'
         mes = '<!doctype html><title>'
         mes += search
         mes += '</title><body>'
         mes += code
         mes += '</body></html>'
         code = mes
     return code
示例#6
0
 def gen_poses(self):
     ''' We generate positions here according to the text produced by 
         TkinterHtml's 'widget.text()' command.
         Peculiarities of the retrieved text:
         - TkinterHtml adds some empty lines from the top and
           the bottom;
         - The number of these lines varies each time (and we don't
           know the rule according to which they are generated)
         - Each cell occupies a single line
         - Blocks within a cell are spaced with a single space
           (except for the blocks having such text as '(')
         - Each line is stripped
         - Pos2 of the previous cell and pos1 of the next cell are
           sometimes equal; this corresponds to the position system
           used by Tkinter
         - Duplicate spaces are removed
     '''
     f = '[MClient] cells.Pos.gen_poses'
     last = 0
     not_found = []
     for block in self.blocks:
         text = sh.Text(block.text.strip()).delete_duplicate_spaces()
         if text:
             search = sh.Search(text=self.rawtext, pattern=text)
             search.i = last
             result = sh.Input(f, search.get_next()).get_integer()
             if result >= last:
                 block.first = result
             else:
                 block.first = last
                 not_found.append(text)
         else:
             block.first = last
         block.last = block.first + len(text)
         last = block.last
     ''' This may be caused by the following:
         a) Missing types in db.DB.types
         b) Defective HTML generation algorithm
     '''
     if not_found:
         not_found = ['"' + item + '"' for item in not_found]
         not_found = '\n' + '\n'.join(not_found)
         mes = _('Unable to find: {}').format(not_found)
         sh.objs.get_mes(f, mes).show_error()
示例#7
0
文件: elems.py 项目: sklprogs/mclient
 def _get_pair(self, text):
     f = '[MClient] plugins.multitrandem.elems.Elems._get_pair'
     code = sh.Input(f, text).get_integer()
     return self.abbr.get_pair(code)