Ejemplo n.º 1
0
    def openFile(self, filename):
        self.searchCtrl.SetValue("")
        self.titleList.Clear()
        #self.previewCtrl.SetValue("")
        self.sourceCtrl.SetValue("")

        self._file = XelapediaFile(filename)
        self.searchCtrl.SetValue(unicode(self._file.mainPage()))
Ejemplo n.º 2
0
  def openFile(self, filename):
    self.searchCtrl.SetValue("")
    self.titleList.Clear()
    #self.previewCtrl.SetValue("")
    self.sourceCtrl.SetValue("")

    self._file = XelapediaFile(filename)
    self.searchCtrl.SetValue(unicode(self._file.mainPage()))
Ejemplo n.º 3
0
class MainFrame(MainFrameBase):
  _file = None
  _ids = []

  def __init__(self, parent, title):
    MainFrameBase.__init__(self, parent, -1, title)

  def openFile(self, filename):
    self.searchCtrl.SetValue("")
    self.titleList.Clear()
    #self.previewCtrl.SetValue("")
    self.sourceCtrl.SetValue("")

    self._file = XelapediaFile(filename)
    self.searchCtrl.SetValue(unicode(self._file.mainPage()))

  def searchCtrlTextHandler(self, evt):
    if self._file == None:
      return

    title=self.searchCtrl.GetValue().encode('utf-8')
    items=[]
    self._ids=[]

    titles=self._file.findTitlesFrom(title, 50)
    firstTitle=title
    if len(titles) > 0:
      firstId=titles[0][0]
      firstTitle=titles[0][1]
    for id, title in titles:
      items.append(unicode(title))
      self._ids.append(id)

    titlesBefore=self._file.findTitlesBefore(firstTitle, 50)
    for id, title in titlesBefore:
      items.insert(0, unicode(title))
      self._ids.insert(0, id)

    self.titleList.Set(items)
    self.titleList.Select(len(titlesBefore))


  def previewArticle(self, title, contents):
    self.SetTitle("Xelapedia Creator - %s" % title)
    converter=Converter(title, contents)
    self.previewCtrl.SetPage(converter.toHtml())


  def titleListHandler(self, evt):
    if evt.IsSelection():
      title=evt.GetString()
      id=self._ids[evt.GetSelection()]
      contents=unicode(self._file.readArticle(id))
      self.sourceCtrl.SetValue(contents)
      self.previewArticle(title, contents)
    else:
      self.sourceCtrl.SetValue('')
      self.previewCtrl.SetPage('')
      self.SetTitle('Xelapedia Creator')


  def menuOpenHandler(self, evt):
    dlg = wx.FileDialog(self, message='Choose a Xelapedia file',
      wildcard='*.xelapedia')
    if wx.ID_OK == dlg.ShowModal():
      self.openFile(dlg.GetPath())

  def menuQuitHandler(self, evt):
    self.Close()
    evt.Skip()

  def menuAboutHandler(self, evt):
    wx.AboutBox(createAboutDialogInfo())
Ejemplo n.º 4
0
class MainFrame(MainFrameBase):
    _file = None
    _ids = []

    def __init__(self, parent, title):
        MainFrameBase.__init__(self, parent, -1, title)

    def openFile(self, filename):
        self.searchCtrl.SetValue("")
        self.titleList.Clear()
        #self.previewCtrl.SetValue("")
        self.sourceCtrl.SetValue("")

        self._file = XelapediaFile(filename)
        self.searchCtrl.SetValue(unicode(self._file.mainPage()))

    def searchCtrlTextHandler(self, evt):
        if self._file == None:
            return

        title = self.searchCtrl.GetValue().encode('utf-8')
        items = []
        self._ids = []

        titles = self._file.findTitlesFrom(title, 50)
        firstTitle = title
        if len(titles) > 0:
            firstId = titles[0][0]
            firstTitle = titles[0][1]
        for id, title in titles:
            items.append(unicode(title))
            self._ids.append(id)

        titlesBefore = self._file.findTitlesBefore(firstTitle, 50)
        for id, title in titlesBefore:
            items.insert(0, unicode(title))
            self._ids.insert(0, id)

        self.titleList.Set(items)
        self.titleList.Select(len(titlesBefore))

    def previewArticle(self, title, contents):
        self.SetTitle("Xelapedia Creator - %s" % title)
        converter = Converter(title, contents)
        self.previewCtrl.SetPage(converter.toHtml())

    def titleListHandler(self, evt):
        if evt.IsSelection():
            title = evt.GetString()
            id = self._ids[evt.GetSelection()]
            contents = unicode(self._file.readArticle(id))
            self.sourceCtrl.SetValue(contents)
            self.previewArticle(title, contents)
        else:
            self.sourceCtrl.SetValue('')
            self.previewCtrl.SetPage('')
            self.SetTitle('Xelapedia Creator')

    def menuOpenHandler(self, evt):
        dlg = wx.FileDialog(self,
                            message='Choose a Xelapedia file',
                            wildcard='*.xelapedia')
        if wx.ID_OK == dlg.ShowModal():
            self.openFile(dlg.GetPath())

    def menuQuitHandler(self, evt):
        self.Close()
        evt.Skip()

    def menuAboutHandler(self, evt):
        wx.AboutBox(createAboutDialogInfo())