Exemplo n.º 1
0
    def __init__(self, parent):
        super().__init__(parent)

        self.SetFieldsCount(3)
        self.SetStatusWidths([-1, 70, 100])

        self.size_changed = False
        self.Bind(wx.EVT_SIZE, self.on_size)
        self.Bind(wx.EVT_IDLE, self.on_idle)

        self.SetStatusText("", 0)
        self.btn_todo_status = wx.Button(self, style=wx.NO_BORDER, size=(70, -1))
        self.btn_todo_status.SetLabelMarkup(self._get_todo_status_text(0,0))

        self.todo_progress = PyGauge(self, size=(100,-1), style=wx.GA_HORIZONTAL|wx.NO_BORDER)
        self.todo_progress.SetValue(0)
        self.todo_progress.SetBackgroundColour(wx.Colour(config.get('UI', 'todo_progress_bg_color')))
        self.todo_progress.SetBarGradient(
            (wx.Colour(config.get("UI","todo_progress_bg_start")), wx.Colour(config.get("UI", "todo_progress_bg_end")))
        )
        self.todo_progress.SetRange(1)

        self.do_position()
        self.Bind(wx.EVT_BUTTON, self.on_click_todo_status, self.btn_todo_status)
        pub.subscribe(self.on_note_show, 'on.note.show')
        pub.subscribe(self.on_todo_change, 'on.todo.change')
        pub.subscribe(self.on_note_hide, 'on.note.hide')
Exemplo n.º 2
0
def setup_translation():
    locales_dir = os.path.join(ApplicationUtil.bundle_dir(), 'assets',
                               'locales')
    i18n.load_path.append(locales_dir)
    i18n.set("filename_format", "{locale}.{format}")
    i18n.set("locale", config.get("APP", "language"))
    i18n.set("enable_memoization", True)
Exemplo n.º 3
0
def setup_locale():
    config_language = config.get("APP", "language")
    if config_language == "en":
        wx.Locale(language=wx.LANGUAGE_ENGLISH_US)
    elif config_language == "cn":
        wx.Locale(language=wx.LANGUAGE_CHINESE_SIMPLIFIED)

    if wx.Platform == "__WXMSW__":
        import locale
        if config_language == "en":
            locale.setlocale(locale.LC_ALL, 'en-US.UTF-8')
        elif config_language == "cn":
            locale.setlocale(locale.LC_ALL, 'zh-CN.UTF-8')
Exemplo n.º 4
0
def setup_db():
    db_file_existed = os.path.exists(config.get('PATH', 'db_file'))

    conn = sqlite3.connect(config.get("PATH", "db_file"))
    cursor = conn.cursor()

    if not db_file_existed:
        with open(os.path.join(ApplicationUtil.bundle_dir(), 'assets',
                               'sqlite_schema.sql'),
                  'r',
                  encoding='utf-8') as f:
            schema_content = f.read()
        cursor.executescript(schema_content)
        conn.commit()

    notebook_count = cursor.execute(
        "SELECT count(*) FROM notebooks").fetchone()[0]
    if not notebook_count:
        cursor.execute(
            "insert into notebooks(name, description) values(?,?)",
            (_("notebook.initial_name"), _("notebook.initial_desc")))
        conn.commit()
    conn.close()
Exemplo n.º 5
0
    def __init__(self):
        super().__init__(None,
                         title=config.get("APP.window_title"),
                         size=(800, 600))
        self.aui_manager = aui.AuiManager(self,
                                          wx.aui.AUI_MGR_TRANSPARENT_HINT)

        self.nav_panel = NavPanel(self)
        self.list_panel = ListPanel(self)
        self.detail_panel = TextEditor(self)
        self.todo_panel = TodoPanel(self)

        self.status_bar = StatusBar(self)
        self.SetStatusBar(self.status_bar)

        self.aui_manager.AddPane(
            self.nav_panel,
            self.get_default_pane_info().Left().Row(0).BestSize(300, -1))
        self.aui_manager.AddPane(
            self.list_panel,
            self.get_default_pane_info().Left().Row(1).BestSize(250,
                                                                -1).MinSize(
                                                                    150, -1))
        self.aui_manager.AddPane(
            self.detail_panel,
            self.get_default_pane_info().CenterPane().Position(0).BestSize(
                400, -1).MinSize(500, -1))
        self.aui_manager.AddPane(
            self.todo_panel,
            self.get_default_pane_info().CenterPane().Position(1).BestSize(
                400, -1).MinSize(500, -1))

        self.aui_manager.GetPane(self.todo_panel).Hide()
        self.aui_manager.GetArtProvider().SetMetric(
            wx.aui.AUI_DOCKART_SASH_SIZE, 1)
        self.aui_manager.Update()

        self.Maximize(True)
        self.register_listeners()

        self.build_menu_bar()

        self.current_note = None
        self.note_searcher = NoteSearchService()
        # tree root node is selected by default
        wx.CallAfter(self.detail_panel.Hide)
Exemplo n.º 6
0
 class Meta:
     database = SqliteDatabase(config.get("PATH.db_file"), pragmas={'foreign_keys': 1})
Exemplo n.º 7
0
 def __init__(self):
     self.schema = Schema(note_id=NUMERIC(stored=True, unique=True), notebook_id=NUMERIC(stored=True), title=TEXT(stored=True, analyzer=ChineseAnalyzer()), snippet=TEXT(analyzer=ChineseAnalyzer()))
     try:
         self.index = FileStorage(config.get("PATH", "notes_index_dir")).open_index()
     except:
         self.index = FileStorage(config.get("PATH", "notes_index_dir")).create_index(self.schema)
Exemplo n.º 8
0
from .base_model import BaseModel
from peewee import CharField, ForeignKeyField
from .notebook import Notebook
from .todo import Todo
import uuid
import os
import re
import shutil
from config_manager import config
from pubsub import pub

NOTE_DIR = config.get("PATH.notes_dir")


def generate_uuid():
    dir_uuid = str(uuid.uuid4())
    note_dir = os.path.join(NOTE_DIR, dir_uuid)
    os.makedirs(note_dir, exist_ok=True)
    open(os.path.join(note_dir, 'content.html'), 'w').close()
    open(os.path.join(note_dir, 'snippet.txt'), 'w').close()
    return dir_uuid


class Note(BaseModel):
    notebook = ForeignKeyField(Notebook, on_delete='cascade', backref='notes')
    local_uuid = CharField(default=generate_uuid)
    title = CharField(default="")

    @property
    def note_dir(self):
        return os.path.join(NOTE_DIR, self.local_uuid)