示例#1
0
 def _setup_main_properties_box(self):
     node = self._node
     box = wx.StaticBox(self, label = _('Main properties'))
     box_sizer = wx.StaticBoxSizer(box)
     grid_sizer = wx.FlexGridSizer(0, 2, 5, 5)
     uri_label = wx.StaticText(self, label = 'URI: ')
     uri_edit = wx.TextCtrl(self, size = (self.DEFAULT_TEXT_WIDTH, -1))
     if node is not None:
         uri_edit.SetValue(self._node.uri)
     target_label = wx.StaticText(self, label = _('Target frame') + ': ')
     target_edit = wx.ComboBox(self,
         size = (self.DEFAULT_TEXT_WIDTH, -1),
         style = wx.CB_DROPDOWN,
         choices = HTML_TARGETS
     )
     if node is not None:
         target_edit.SetValue(self._node.target or '')
     comment_label = wx.StaticText(self, label = _('Comment') + ': ')
     comment_edit = wx.TextCtrl(self, size = (self.DEFAULT_TEXT_WIDTH, -1))
     if node is not None:
         comment_edit.SetValue(self._node.comment)
     for widget in uri_label, uri_edit, target_label, target_edit, comment_label, comment_edit:
         grid_sizer.Add(widget)
     box_sizer.Add(grid_sizer, 0, wx.EXPAND | wx.ALL, 5)
     self._edit_uri = uri_edit
     self._edit_target = target_edit
     self._edit_comment = comment_edit
     return box_sizer
示例#2
0
 def getPagesForWork(self, entry, work):
     cursor = self._openDBWithCursor()
     if isinstance(work, unicode) and work == _("Work unknown"):
         if isinstance(entry, unicode) and entry == _("Entry unknown"):
             cursor.execute(
                 "select distinct page from fiches f, pages p where f.fiche = p.fiche and work is null and not exists (select * from actual_entries e where f.fiche = e.fiche) order by page"
             )
         else:
             cursor.execute(
                 "select distinct page from fiches f, pages p, actual_entries e where f.fiche = p.fiche and p.fiche = e.fiche and entry = %s and work is null order by page",
                 (entry))
     else:
         if isinstance(entry, unicode) and entry == _("Entry unknown"):
             cursor.execute(
                 "select distinct page from fiches f, pages p where f.fiche = p.fiche and work = %s and not exists (select * from actual_entries e where f.fiche = e.fiche) order by page",
                 (work))
         else:
             cursor.execute(
                 "select distinct page from fiches f, pages p, actual_entries e where f.fiche = p.fiche and p.fiche = e.fiche and entry = %s and work = %s order by page",
                 (entry, work))
     res = [_("Page unknown")]
     row = cursor.fetchone()
     while row != None:
         res.append(str(row[0]))
         row = cursor.fetchone()
     self._closeDBAndCursor(cursor)
     return res
示例#3
0
 def __init__(self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.LC_REPORT):
     wx.ListCtrl.__init__(self, parent, id, pos, size, style)
     self.InsertColumn(0, _('URI'))
     self.InsertColumn(1, _('Comment'))
     self._have_items = False
     self._data = {}
     self._data_map = {}
     self.page = None
     wx.lib.mixins.listctrl.ListCtrlAutoWidthMixin.__init__(self)
     wx.lib.mixins.listctrl.TextEditMixin.__init__(self)
     self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.on_selection_changed, self)
     self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.on_item_right_click, self)
     self.Bind(wx.EVT_CHAR, self.on_char, self)
示例#4
0
 def addFicheToPrefixesIndex(self, ficheId, entry):
     cursor = self._openDBWithCursor()
     try:
         cursor.execute("insert into entry_prefixes values (%s, %s, null)",
                        (ficheId, entry))
     except _mysql_exceptions.IntegrityError:
         self._closeDBAndCursor(cursor)
         return _('Fiche already indexed in entry prefix index')
     self._closeDBAndCursor(cursor)
     return None
示例#5
0
 def __init__(self, *args, **kwargs):
     wx.Panel.__init__(self, *args, **kwargs)
     Notifier.__init__(self)
     self.__sizer = wx.BoxSizer(wx.VERTICAL)
     self.__label = wx.StaticText(self, wx.ID_ANY)
     self.__bar = wx.Panel(self, wx.ID_ANY)
     self.__barSizer = wx.BoxSizer(wx.HORIZONTAL)
     self.__upButton = wx.BitmapButton(
         self.__bar, wx.ID_ANY, wx.Bitmap(__RESOURCES_PATH__ + "/up.png"))
     self.__upButton.SetToolTip(
         wx.ToolTip(_('Go to element parent in structure register')))
     self.__backButton = wx.BitmapButton(
         self.__bar, wx.ID_ANY, wx.Bitmap(__RESOURCES_PATH__ + "/back.png"))
     self.__backButton.SetToolTip(wx.ToolTip(
         _('Go back to previous fiche')))
     self.__leftButton = wx.BitmapButton(
         self.__bar, wx.ID_ANY, wx.Bitmap(__RESOURCES_PATH__ + "/prev.png"))
     self.__leftButton.SetToolTip(
         wx.ToolTip(_('Go to left in binary search')))
     self.__rightButton = wx.BitmapButton(
         self.__bar, wx.ID_ANY, wx.Bitmap(__RESOURCES_PATH__ + "/next.png"))
     self.__rightButton.SetToolTip(
         wx.ToolTip(_('Go to right in binary search')))
     self.__binaryButton = wx.BitmapButton(
         self.__bar, wx.ID_ANY,
         wx.Bitmap(__RESOURCES_PATH__ + "/binary.png"))
     self.__binaryButton.SetToolTip(
         wx.ToolTip(_('Start/stop binary search')))
     self.__chooseRegisterButton = wx.BitmapButton(
         self.__bar, wx.ID_ANY,
         wx.Bitmap(__RESOURCES_PATH__ + "/chreg.png"))
     self.__chooseRegisterButton.SetToolTip(
         wx.ToolTip(_('Load task register from file')))
     self.__defaultRegisterButton = wx.BitmapButton(
         self.__bar, wx.ID_ANY,
         wx.Bitmap(__RESOURCES_PATH__ + "/defreg.png"))
     self.__defaultRegisterButton.SetToolTip(
         wx.ToolTip(_('Show default task register')))
     self.__barSizer.Add(self.__upButton, 0, wx.ALIGN_LEFT)
     self.__barSizer.Add(self.__backButton, 0, wx.ALIGN_LEFT)
     self.__barSizer.Add(self.__leftButton, 0, wx.ALIGN_LEFT)
     self.__barSizer.Add(self.__rightButton, 0, wx.ALIGN_LEFT)
     self.__barSizer.Add(self.__binaryButton, 0, wx.ALIGN_LEFT)
     self.__barSizer.Add(self.__chooseRegisterButton, 0, wx.ALIGN_LEFT)
     self.__barSizer.Add(self.__defaultRegisterButton, 0, wx.ALIGN_LEFT)
     self.__bar.SetSizer(self.__barSizer)
     self.__sizer.Add(self.__label, 0, wx.ALIGN_LEFT | wx.ALIGN_TOP)
     self.__sizer.Add(self.__bar, 1, wx.ALIGN_LEFT | wx.ALIGN_TOP)
     self.SetSizer(self.__sizer)
     self.Bind(wx.EVT_BUTTON, self.__onUp, self.__upButton)
     self.Bind(wx.EVT_BUTTON, self.__onBack, self.__backButton)
     self.Bind(wx.EVT_BUTTON, self.__onLeft, self.__leftButton)
     self.Bind(wx.EVT_BUTTON, self.__onRight, self.__rightButton)
     self.Bind(wx.EVT_BUTTON, self.__onBinary, self.__binaryButton)
     self.Bind(wx.EVT_BUTTON, self.__onChooseRegister,
               self.__chooseRegisterButton)
     self.Bind(wx.EVT_BUTTON, self.__onDefaultRegister,
               self.__defaultRegisterButton)
示例#6
0
 def _create_root_item(self):
     node = self.document.outline.root
     if node:
         type = str(node.type)
         self._root_item = self.AddRoot(_(type))
         self.SetPyData(self._root_item, node)
         return True
     else:
         self._root_item = None
         return False
示例#7
0
 def getEntriesRegister(self):
     cursor = self._openDBWithCursor()
     cursor.execute(
         "select distinct entry from actual_entries order by entry")
     res = [_("Entry unknown")]
     row = cursor.fetchone()
     while row != None:
         res.append(str(row[0]))
         row = cursor.fetchone()
     self._closeDBAndCursor(cursor)
     return res
示例#8
0
def show_menu(parent, annotations, node, point, origin=None):
    menu = wx.Menu()
    try:
        menu_item = menu.Append(wx.ID_ANY, _(u'&New hyperlink…'))
        parent.Bind(
            wx.EVT_MENU, lambda event: on_new_annotation(
                event, parent, annotations, origin), menu_item)
        if node is not None:
            menu_item = menu.Append(wx.ID_ANY, _(u'&Properties…'))
            parent.Bind(wx.EVT_MENU,
                        lambda event: on_properties(event, parent, node),
                        menu_item)
            menu_item = menu.Append(wx.ID_ANY, _('&Remove') + '\tDel')
            parent.Bind(wx.EVT_MENU,
                        lambda event: on_delete(event, parent, node),
                        menu_item)
        del menu_item
        parent.PopupMenu(menu, point)
    finally:
        menu.Destroy()
示例#9
0
 def _setup_shape_box(self):
     box = wx.RadioBox(self,
         label = _('Shape'),
         choices = [shape.label for shape in SHAPES]
     )
     for i, shape in enumerate(SHAPES):
         box.EnableItem(i, shape.enabled)
     self.Bind(wx.EVT_RADIOBOX, self.on_select_shape, box)
     self._edit_shape = box
     # It's too early to select proper shape. We'll do it later.
     return box
示例#10
0
 def getWorksForEntry(self, entry):
     cursor = self._openDBWithCursor()
     print entry, type(entry)
     if isinstance(entry, unicode) and entry == _(
             "Entry unknown"
     ):  # TODO: NOTE tu i w ponizszych metodach, bo _ zamienia na unicode
         cursor.execute(
             "select distinct work from fiches f where not exists (select * from actual_entries e where f.fiche = e.fiche) order by work"
         )
     else:
         cursor.execute(
             "select distinct work from fiches f, actual_entries e where f.fiche = e.fiche and entry = %s order by work",
             (entry))
     res = [_('Work unknown')]
     row = cursor.fetchone()
     while row != None:
         if row[0] != None:
             res.append(str(row[0]))
         row = cursor.fetchone()
     self._closeDBAndCursor(cursor)
     return res
示例#11
0
 def __init__(self, *args, **kwargs):
     wx.Dialog.__init__(self, *args, **kwargs)
     panel = wx.Panel(self)
     sizer = wx.FlexGridSizer(4, 2)
     sizer.AddGrowableCol(1, 1)
     self.__original = wx.TextCtrl(panel, wx.ID_ANY)
     self.__ficheActual = wx.TextCtrl(panel, wx.ID_ANY)
     self.__cloneActual = wx.TextCtrl(panel, wx.ID_ANY)
     sizer.Add(wx.StaticText(panel, label=_("Original entry")), 0)
     sizer.Add(self.__original, 1, wx.EXPAND)
     sizer.Add(
         wx.StaticText(panel, label=_("Actual entry of original fiche")), 0)
     sizer.Add(self.__ficheActual, 1, wx.EXPAND)
     sizer.Add(wx.StaticText(panel, label=_("Actual entry of clone")), 0)
     sizer.Add(self.__cloneActual, 1, wx.EXPAND)
     self.__OKButton = wx.Button(panel, label=_("OK"))
     self.__cancelButton = wx.Button(panel, label=_("Cancel"))
     sizer.Add(self.__OKButton)
     sizer.Add(self.__cancelButton)
     panel.SetSizerAndFit(sizer)
     self.__OKButton.Bind(wx.EVT_BUTTON, self.__onOK)
     self.__cancelButton.Bind(wx.EVT_BUTTON, self.__onCancel)
示例#12
0
	def __init__(self, *args, **kwargs):
		wx.Panel.__init__(self, *args, **kwargs)
		Notifier.__init__(self)
		sizer = wx.FlexGridSizer(3, 3)
		sizer.AddGrowableCol(1, 1)
		self.__hypothesisPanel = wx.TextCtrl(self, wx.ID_ANY)
		self.__editPanel = wx.TextCtrl(self, wx.ID_ANY)
		self.__hintPanel = wx.TextCtrl(self, wx.ID_ANY)
		self.__editPanelAcceptButton = wx.BitmapButton(self, wx.ID_ANY, wx.Bitmap(__RESOURCES_PATH__ + "/edins.png"))
		self.__editPanelAcceptButton.SetToolTip(wx.ToolTip(_('Accept edit panel content')))
		#self.__editPanelPrefixAcceptButton = wx.BitmapButton(self, wx.ID_ANY, wx.Bitmap(__RESOURCES_PATH__ + "/edpre.png"))
		#self.__editPanelPrefixAcceptButton.SetToolTip(wx.ToolTip(_('Accept edit panel content as prefix')))
		self.__hintPanelAcceptButton = wx.BitmapButton(self, wx.ID_ANY, wx.Bitmap(__RESOURCES_PATH__ + "/hins.png"))
		self.__hintPanelAcceptButton.SetToolTip(wx.ToolTip(_('Accept hint panel content')))
		sizer.Add(wx.Panel(self), 0)
		sizer.Add(self.__hypothesisPanel, 1, wx.EXPAND)
		sizer.Add(wx.Panel(self), 0)
		sizer.Add(self.__editPanelAcceptButton, 0)
		sizer.Add(self.__editPanel, 1, wx.EXPAND)
		sizer.Add(wx.Panel(self), 0)
		#sizer.Add(self.__editPanelPrefixAcceptButton, 0)
		sizer.Add(self.__hintPanelAcceptButton, 0)
		sizer.Add(self.__hintPanel, 1, wx.EXPAND)
		sizer.Add(wx.Panel(self), 0)
		self.SetSizerAndFit(sizer)
		self.__editPanel.Bind(wx.EVT_TEXT, self.editPanelChanged)
		self.__editPanel.Bind(wx.EVT_KEY_DOWN, self.__onEditAcceptEnter, self.__editPanel)
		self.__editPanel.Bind(wx.EVT_KEY_UP, self.__onKeyUp, self.__editPanel)
		self.__hintPanel.Bind(wx.EVT_TEXT, self.__hintPanelChanged)
		self.__hintPanel.Bind(wx.EVT_KEY_UP, self.__onKeyUp, self.__hintPanel)
		self.Bind(wx.EVT_BUTTON, self.__onEditAccept, self.__editPanelAcceptButton)
		#self.Bind(wx.EVT_BUTTON, self.__onEditPrefixAccept, self.__editPanelPrefixAcceptButton)
		self.Bind(wx.EVT_BUTTON, self.__onHintAccept, self.__hintPanelAcceptButton)
		self.__hintRegister = None
		self.__hint = None
		self.__browsingHistory = False
		self.__skipOneKeyUp = False
		self.__keyEventFromTopPanel = False
示例#13
0
 def __init__(self, parent, models, known_keys):
     wx.Dialog.__init__(self, parent, title=_('Edit metadata'), style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
     sizer = wx.BoxSizer(wx.VERTICAL)
     tabs = wx.Notebook(self, -1)
     for model in models:
         grid = MetadataGrid(tabs, model, known_keys)
         tabs.AddPage(grid, model.title)
     sizer.Add(tabs, 1, wx.EXPAND | wx.ALL, 5)
     line = wx.StaticLine(self, -1, style = wx.LI_HORIZONTAL)
     sizer.Add(line, 0, wx.EXPAND | wx.BOTTOM | wx.TOP, 5)
     button_sizer = wx.StdDialogButtonSizer()
     button = wx.Button(self, wx.ID_OK)
     button.SetDefault()
     button_sizer.AddButton(button)
     button = wx.Button(self, wx.ID_CANCEL)
     button_sizer.AddButton(button)
     button_sizer.Realize()
     sizer.Add(button_sizer, 0, wx.EXPAND | wx.ALL, 5)
     self.SetSizerAndFit(sizer)
示例#14
0
 def __init__(self, parent, node=None, origin=None):
     wx.Dialog.__init__(self, parent, title = _('Overprinted annotation (hyperlink) properties'))
     self._node = node
     if origin is None:
         self._origin = None
     else:
         self._origin = tuple(origin)
         if len(self._origin) != 2:
             raise ValueError
     sizer = wx.BoxSizer(wx.VERTICAL)
     main_properties_box_sizer = self._setup_main_properties_box()
     shape_box_sizer = self._setup_shape_box()
     border_box_sizer = self._setup_border_box()
     extra_sizers = self._setup_extra_boxes()
     for box_sizer in [main_properties_box_sizer, shape_box_sizer, border_box_sizer] + extra_sizers:
         sizer.Add(box_sizer, 0, wx.EXPAND | wx.ALL, 5)
     line = wx.StaticLine(self, -1, style = wx.LI_HORIZONTAL)
     sizer.Add(line, 0, wx.EXPAND | wx.BOTTOM | wx.TOP, 5)
     button_sizer = wx.StdDialogButtonSizer()
     button = wx.Button(self, wx.ID_OK)
     button.SetDefault()
     button_sizer.AddButton(button)
     button = wx.Button(self, wx.ID_CANCEL)
     button_sizer.AddButton(button)
     button_sizer.Realize()
     sizer.Add(button_sizer, 0, wx.EXPAND | wx.ALL, 5)
     self.SetSizer(sizer)
     self.Fit()
     self._sizer = sizer
     if self._node is None:
         i, shape = 0, SHAPE_RECTANGLE
     else:
         for i, shape in enumerate(SHAPES):
             if isinstance(node, shape.model_class):
                 break
         else:
             raise TypeError
     self._edit_shape.SetSelection(i)
     self.do_select_shape(shape)
示例#15
0
def get_label_for_node(node):
    zone_type = str(node.type)
    if node.is_inner():
        return _(zone_type)
    else:
        return _(zone_type) + ': ' + replace_control_characters(' ', node.text)
示例#16
0
 def _setup_extra_boxes(self):
     node = self._node
     extra_boxes = \
     [
         wx.StaticBox(self, label = label)
         for label in (_('Highlight color and opacity'), _('Line-specific properties'), _('Text-specific properties'))
     ]
     extra_sizers = map(wx.StaticBoxSizer, extra_boxes)
     highlight_specific_sizer, line_specific_sizer, text_specific_sizer = extra_sizers
     self._specific_sizers = {
         SHAPE_RECTANGLE: [highlight_specific_sizer],
         SHAPE_LINE: [line_specific_sizer],
         SHAPE_TEXT: [text_specific_sizer]
     }
     extra_grid_sizers = [wx.FlexGridSizer(0, 2, 5, 5) for i in extra_sizers]
     for extra_sizer, extra_grid_sizer in zip(extra_sizers, extra_grid_sizers):
         extra_sizer.Add(extra_grid_sizer, 0, wx.EXPAND | wx.ALL, 5)
     highlight_specific_sizer, line_specific_sizer, text_specific_sizer = extra_grid_sizers
     highlight_color_label = wx.CheckBox(self, label = _('Highlight color') + ': ')
     highlight_color_selector = wx.lib.colourselect.ColourSelect(self, wx.ID_ANY)
     highlight_color_selector.SetColour(wx.BLUE)
     highlight_color_selector.Enable(False)
     def on_switch_highlight_color(event):
         highlight_color_selector.Enable(event.IsChecked())
     self.Bind(wx.EVT_CHECKBOX, on_switch_highlight_color, highlight_color_label)
     opacity_label = wx.StaticText(self, label = _('Opacity') + ': ')
     opacity_slider = wx.Slider(self,
         value = djvu.const.MAPAREA_OPACITY_DEFAULT,
         size = (self.DEFAULT_TEXT_WIDTH, -1),
         style = wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | wx.SL_LABELS
     )
     for widget in highlight_color_label, highlight_color_selector, opacity_label, opacity_slider:
         highlight_specific_sizer.Add(widget, 0, wx.ALIGN_CENTER_VERTICAL)
     if isinstance(node, models.annotations.RectangleMapArea):
         if node.highlight_color is None:
             highlight_color_label.SetValue(False)
             highlight_color_selector.Enable(False)
         else:
             highlight_color_label.SetValue(True)
             highlight_color_selector.Enable(True)
             highlight_color_selector.SetColour(node.highlight_color)
         opacity_slider.SetValue(node.opacity)
     line_width_label = wx.StaticText(self, label = _('Line width') + ': ')
     line_width_edit = wx.SpinCtrl(self, size = (self.DEFAULT_SPIN_WIDTH, -1))
     line_width_edit.SetRange(djvu.const.MAPAREA_LINE_MIN_WIDTH, 99)
     line_width_edit.SetValue(djvu.const.MAPAREA_LINE_MIN_WIDTH)
     line_color_label = wx.StaticText(self, label = _('Line color') + ': ')
     line_color_selector = wx.lib.colourselect.ColourSelect(self, wx.ID_ANY)
     line_arrow_checkbox = wx.CheckBox(self, label = _('Arrow'))
     dummy = (0, 0)
     for widget in line_arrow_checkbox, dummy, line_width_label, line_width_edit, line_color_label, line_color_selector:
         line_specific_sizer.Add(widget, 0, wx.ALIGN_CENTER_VERTICAL)
     if isinstance(node, models.annotations.LineMapArea):
         line_width_edit.SetValue(node.line_width)
         line_color_selector.SetColour(node.line_color)
         line_arrow_checkbox.SetValue(node.line_arrow)
     else:
         line_color_selector.SetColour(djvu.const.MAPAREA_LINE_COLOR_DEFAULT)
     text_background_color_label = wx.CheckBox(self, label = _('Background color') + ': ')
     text_background_color_selector = wx.lib.colourselect.ColourSelect(self, wx.ID_ANY)
     text_background_color_selector.SetColour(wx.WHITE)
     text_background_color_selector.Enable(False)
     def on_switch_text_background_color(event):
         text_background_color_selector.Enable(event.IsChecked())
     self.Bind(wx.EVT_CHECKBOX, on_switch_text_background_color, text_background_color_label)
     text_color_label = wx.StaticText(self, label = _('Text color') + ': ')
     text_color_selector = wx.lib.colourselect.ColourSelect(self, wx.ID_ANY)
     text_pushpin = wx.CheckBox(self, label = _('Pushpin'))
     for widget in text_background_color_label, text_background_color_selector, text_color_label, text_color_selector, text_pushpin:
         text_specific_sizer.Add(widget, 0, wx.ALIGN_CENTER_VERTICAL)
     if isinstance(node, models.annotations.TextMapArea):
         if node.background_color is not None:
             text_background_color_label.SetValue(True)
             text_background_color_selector.Enable(True)
             text_background_color_selector.SetColour(node.background_color)
         else:
             text_background_color_label.SetValue(False)
             text_background_color_selector.Enable(False)
         text_color_selector.SetColour(node.text_color)
         text_pushpin.SetValue(node.pushpin)
     else:
         text_color_selector.SetColour(djvu.const.MAPAREA_LINE_COLOR_DEFAULT)
     self._edit_have_highlight = highlight_color_label
     self._edit_highlight_color = highlight_color_selector
     self._edit_opacity = opacity_slider
     self._edit_line_width = line_width_edit
     self._edit_line_color = line_color_selector
     self._edit_arrow = line_arrow_checkbox
     self._edit_background_nontrasparent = text_background_color_label
     self._edit_background_color = text_background_color_selector
     self._edit_text_color = text_color_selector
     self._edit_pushpin = text_pushpin
     return extra_sizers
示例#17
0
 def wrongOrder(self, entry):
     log.log("wrongOrder", [entry], 0)
     msg = ustr(entry) + u": " + _('corrupted alphabetic order')
     self.showMessage(msg)
     log.log("wrongOrder return", [], 1)
示例#18
0
 def wrongFiche(self, entry):
     log.log("wrongFiche", [entry], 0)
     msg = ustr(entry) + u": " + _('fiche not in order')
     self.showMessage(msg)
     log.log("wrongFiche return", [], 1)
示例#19
0
 def binaryStopped(self, steps):
     log.log("binaryStopped", [steps], 0)
     msg = _('Binary search') + u" " + _('finished') + u". " + _(
         'Steps:') + u" " + unicode(steps)
     self.showMessage(msg)
     log.log("binaryStopped return", [], 1)
示例#20
0
 def automaticBinaryStopped(self, target, steps):
     log.log("automaticBinaryStopped", [target, steps], 0)
     msg = _('Search for') + u" \"" + ustr(target) + u"\" " + _(
         'finished') + u". " + _('Steps:') + u" " + unicode(steps)
     self.showMessage(msg)
     log.log("automaticBinaryStopped return", [], 1)
示例#21
0
 def error(self, ficheId, entry):
     msg = _('Fiche') + u' ' + ustr(ficheId) + u' ' + _(
         'not accepted with entry') + u' ' + ustr(entry)
     self.showMessage(msg)
示例#22
0
 def submit(self, ficheId, entry):
     msg = _('Fiche') + u' ' + ustr(ficheId) + u' ' + _(
         'submitted for acceptation with entry') + u' ' + ustr(entry)
     self.showMessage(msg)
示例#23
0
 def _setup_border_box(self):
     node = self._node
     try:
         border = node.border
     except AttributeError:
         border = None
     box = wx.StaticBox(self, label = _('Border'))
     box_sizer = wx.StaticBoxSizer(box, orient = wx.VERTICAL)
     box_grid_sizer = wx.FlexGridSizer(0, 3, 5, 10)
     border_width_sizer = wx.BoxSizer(wx.HORIZONTAL)
     border_width_label = wx.StaticText(self, label = _('Width') + ': ')
     border_width_edit = wx.SpinCtrl(self, size = (self.DEFAULT_SPIN_WIDTH, -1))
     border_width_edit.SetRange(djvu.const.MAPAREA_SHADOW_BORDER_MIN_WIDTH, djvu.const.MAPAREA_SHADOW_BORDER_MAX_WIDTH)
     border_width_edit.SetValue(djvu.const.MAPAREA_SHADOW_BORDER_MIN_WIDTH)
     border_width_sizer.Add(border_width_label, 0, wx.ALIGN_CENTER_VERTICAL)
     border_width_sizer.Add(border_width_edit, 0, wx.ALIGN_CENTER_VERTICAL)
     radio_none = wx.RadioButton(self, label = _('None'))
     radio_xor = wx.RadioButton(self, label = _('XOR'))
     if isinstance(border, models.annotations.XorBorder):
         radio_xor.SetValue(True)
     radio_solid = wx.RadioButton(self, label = _('Solid color') + ': ')
     solid_color_selector = wx.lib.colourselect.ColourSelect(self, wx.ID_ANY)
     if isinstance(border, models.annotations.SolidBorder):
         radio_solid.SetValue(True)
         solid_color_selector.Enable(True)
         solid_color_selector.SetColour(border.color)
     else:
         solid_color_selector.Enable(False)
     solid_sizer = wx.BoxSizer(wx.HORIZONTAL)
     solid_sizer.Add(radio_solid, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT)
     solid_sizer.Add(solid_color_selector, 0, wx.ALIGN_CENTER_VERTICAL)
     for widget in radio_none, radio_xor, solid_sizer:
         box_grid_sizer.Add(widget, 0, wx.ALIGN_CENTER_VERTICAL)
     shadow_widgets = []
     have_shadow_border = False
     for i, shadow_border in enumerate(SHADOW_BORDERS):
         if i == 2:
             box_grid_sizer.Add(border_width_sizer, 0, wx.ALIGN_CENTER_VERTICAL)
         widget = wx.RadioButton(self, label = shadow_border.label)
         if isinstance(border, shadow_border.model_class):
             widget.SetValue(True)
             have_shadow_border = True
         widget.model_class = shadow_border.model_class
         box_grid_sizer.Add(widget, 0, wx.ALIGN_CENTER_VERTICAL)
         shadow_widgets += widget,
     for widget in shadow_widgets:
         self.Bind(wx.EVT_RADIOBUTTON, self.on_select_shadow_border, widget)
     self.Bind(wx.EVT_RADIOBUTTON, self.on_select_nonshadow_border, radio_xor)
     self.Bind(wx.EVT_RADIOBUTTON, self.on_select_no_border, radio_none)
     self.Bind(wx.EVT_RADIOBUTTON, self.on_select_solid_border, radio_solid)
     avis_checkbox = wx.CheckBox(self, label = _('Always visible')) # TODO: hide it for irrelevant shapes, i.e. `line` and maybe `text`
     if border is None or isinstance(border, models.annotations.NoBorder):
         avis_checkbox.Enable(False)
     elif node is not None and node.border_always_visible is True:
         avis_checkbox.SetValue(True)
     box_sizer.Add(box_grid_sizer, 0, wx.EXPAND | wx.ALL, 5)
     box_sizer.Add(avis_checkbox, 0, wx.ALL, 5)
     self._edit_border_none = radio_none
     self._edit_border_xor = radio_xor
     self._edit_border_solid = radio_solid
     self._edit_border_solid_color = solid_color_selector
     self._edit_border_shadows = shadow_widgets
     self._edit_border_always_visible = avis_checkbox
     self._edit_border_width = border_width_edit
     self._label_border_thickenss = border_width_label
     self.enable_border_width(have_shadow_border)
     if have_shadow_border:
         border_width_edit.SetValue(border.width)
     return box_sizer
示例#24
0
 def getFichesForLine(self, entry, work, page, line):
     cursor = self._openDBWithCursor()
     if isinstance(line, unicode) and line == _("Line unknown"):
         if isinstance(page, unicode) and page == _("Page unknown"):
             if isinstance(work, unicode) and work == _("Work unknown"):
                 if isinstance(entry,
                               unicode) and entry == _("Entry unknown"):
                     cursor.execute("select * from fiches where 1 = 2")
                 else:
                     cursor.execute(
                         "select f.fiche from fiches f, actual_entries e where f.fiche = e.fiche and entry = %s and work is null and not exists (select * from pages p where f.fiche = p.fiche) and not exists (select * from linesIndex l where l.fiche = f.fiche)",
                         (entry))
             else:
                 if isinstance(entry,
                               unicode) and entry == _("Entry unknown"):
                     cursor.execute(
                         "select f.fiche from fiches f where work = %s and not exists (select * from actual_entries e where f.fiche = e.fiche) and not exists (select * from pages p where f.fiche = p.fiche) and not exists (select * from linesIndex l where l.fiche = f.fiche)",
                         (work))
                 else:
                     cursor.execute(
                         "select f.fiche from fiches f, actual_entries e where f.fiche = e.fiche and entry = %s and work = %s and not exists (select * from pages p where f.fiche = p.fiche) and not exists (select * from linesIndex l where l.fiche = f.fiche)",
                         (entry, work))
         else:
             if isinstance(work, unicode) and work == _("Work unknown"):
                 if isinstance(entry,
                               unicode) and entry == _("Entry unknown"):
                     cursor.execute(
                         "select f.fiche from fiches f, pages p where f.fiche = p.fiche and page = %s and work is null and not exists (select * from actual_entries e where f.fiche = e.fiche) and not exists (select * from linesIndex l where l.fiche = f.fiche)",
                         (page))
                 else:
                     cursor.execute(
                         "select f.fiche from fiches f, pages p, actual_entries e where f.fiche = p.fiche and p.fiche = e.fiche and page = %s and entry = %s and work is null and not exists (select * from linesIndex l where l.fiche = f.fiche)",
                         (page, entry))
             else:
                 if isinstance(entry,
                               unicode) and entry == _("Entry unknown"):
                     cursor.execute(
                         "select f.fiche from fiches f, pages p where f.fiche = p.fiche and page = %s and work = %s and not exists (select * from actual_entries e where f.fiche = e.fiche) and not exists (select * from linesIndex l where l.fiche = f.fiche)",
                         (page, work))
                 else:
                     cursor.execute(
                         "select f.fiche from fiches f, pages p, actual_entries e where f.fiche = p.fiche and p.fiche = e.fiche and page = %s and entry = %s and work = %s and not exists (select * from linesIndex l where l.fiche = f.fiche)",
                         (page, entry, work))
     else:
         if isinstance(page, unicode) and page == _("Page unknown"):
             if isinstance(work, unicode) and work == _("Work unknown"):
                 if isinstance(entry,
                               unicode) and entry == _("Entry unknown"):
                     cursor.execute(
                         "select l.fiche from fiches f, linesIndex l where f.fiche = l.fiche and work is null and not exists (select * from actual_entries e where f.fiche = e.fiche) and not exists (select * from pages p where l.fiche = p.fiche) and line = %s",
                         (line))
                 else:
                     cursor.execute(
                         "select l.fiche from fiches f, linesIndex l, actual_entries e where f.fiche = l.fiche and f.fiche = e.fiche and entry = %s and work is null and not exists (select * from pages p where l.fiche = p.fiche) and line = %s",
                         (entry, line))
             else:
                 if isinstance(entry,
                               unicode) and entry == _("Entry unknown"):
                     cursor.execute(
                         "select l.fiche from fiches f, linesIndex l where f.fiche = l.fiche and work = %s and not exists (select * from actual_entries e where f.fiche = e.fiche) and not exists (select * from pages p where l.fiche = p.fiche) and line = %s",
                         (work, line))
                 else:
                     cursor.execute(
                         "select l.fiche from fiches f, linesIndex l, actual_entries e where f.fiche = l.fiche and f.fiche = e.fiche and entry = %s and work = %s and not exists (select * from pages p where l.fiche = p.fiche) and line = %s",
                         (entry, work, line))
         else:
             if isinstance(work, unicode) and work == _("Work unknown"):
                 if isinstance(entry,
                               unicode) and entry == _("Entry unknown"):
                     cursor.execute(
                         "select l.fiche from fiches f, linesIndex l, pages p where f.fiche = p.fiche and p.fiche = l.fiche and page = %s and work is null and not exists (select * from actual_entries e where f.fiche = e.fiche) and line = %s",
                         (page, line))
                 else:
                     cursor.execute(
                         "select l.fiche from fiches f, linesIndex l, pages p, actual_entries e where f.fiche = p.fiche and p.fiche = l.fiche and p.fiche = e.fiche and page = %s and entry = %s and work is null and line = %s",
                         (page, entry, line))
             else:
                 if isinstance(entry,
                               unicode) and entry == _("Entry unknown"):
                     cursor.execute(
                         "select l.fiche from fiches f, linesIndex l, pages p where f.fiche = p.fiche and p.fiche = l.fiche and page = %s and work = %s and not exists (select * from actual_entries e where f.fiche = e.fiche) and line = %s",
                         (page, work, line))
                 else:
                     cursor.execute(
                         "select l.fiche from fiches f, linesIndex l, pages p, actual_entries e where f.fiche = p.fiche and p.fiche = l.fiche and p.fiche = e.fiche and page = %s and entry = %s and work = %s and line = %s",
                         (page, entry, work, line))
     res = []
     row = cursor.fetchone()
     while row != None:
         res.append(row[0])
         row = cursor.fetchone()
     self._closeDBAndCursor(cursor)
     return res
示例#25
0
# the Free Software Foundation; version 2 dated June, 1991.
#
# This package is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.

import wx
import wx.grid
import wx.lib.mixins.grid

import djvu.sexpr

from maleks.i18n import _

LABELS = [_('key'), _('value')]

class MetadataTable(wx.grid.PyGridTableBase):
    def __init__(self, model, known_keys):
        wx.grid.PyGridTableBase.__init__(self)
        self._model = model
        self._keys = sorted(model)
        self._keys.append(None)
        attr_normal = wx.grid.GridCellAttr()
        attr_known = wx.grid.GridCellAttr()
        font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
        font.SetWeight(wx.FONTWEIGHT_BOLD)
        attr_known.SetFont(font)
        self._attrs = attr_normal, attr_known
        self._known_keys = known_keys
示例#26
0
from maleks.varietes import idict
from maleks.i18n import _

# See:
# <http://www.w3.org/TR/html4/present/frames.html#target-info>,
# <http://www.w3.org/TR/html4/types.html#type-frame-target>
# for details.

HTML_TARGETS = '_blank _self _parent _top'.split()

class Shape(idict):
    def __init__(self, **kwargs):
        kwargs.setdefault('enabled', True)
        idict.__init__(self, **kwargs)

SHAPE_TEXT = Shape(label = _('Text'), model_class = models.annotations.TextMapArea)
SHAPE_LINE = Shape(label = _('Line'), model_class = models.annotations.LineMapArea, enabled=False)
SHAPE_RECTANGLE = Shape(label = _('Rectangle'), model_class = models.annotations.RectangleMapArea)
SHAPES = (
    SHAPE_RECTANGLE,
    Shape(label = _('Oval'), model_class = models.annotations.OvalMapArea),
    Shape(label = _('Polygon'), model_class = models.annotations.PolygonMapArea, enabled=False),
    SHAPE_LINE,
    SHAPE_TEXT,
)

SHADOW_BORDERS = (
    idict(model_class = models.annotations.BorderShadowIn,  label = _('Shadow in')),
    idict(model_class = models.annotations.BorderShadowOut, label = _('Shadow out')),
    idict(model_class = models.annotations.BorderEtchedIn,  label = _('Etched in')),
    idict(model_class = models.annotations.BorderEtchedOut, label = _('Etched out'))