示例#1
0
    def win_replace(self, event=None):
        """Method displays Replace window

        Args:
            event (obj): event

        Returns:
            void

        """

        tab = self.nb.get_current_tab()
        if (tab is not None):
            win = tk.Toplevel(self.root)
            win.title(self.trn.msg('htk_gui_editor_replace_title'))
            win.transient(self.root)
            win.resizable(False, False)
            win.geometry('+%d+%d' % (self.root.winfo_screenwidth() / 2,
                                     self.root.winfo_screenheight() / 2))
            win.tk.call('wm', 'iconphoto', win._w, self.root.images['logo'])

            tk.Label(win,
                     text=self.trn.msg('htk_gui_editor_replace_find')).grid(
                         row=0, column=0, sticky='e')
            find_entry = tk.Entry(win, width=50)
            find_entry.grid(row=0, column=1, padx=3, sticky='e')
            find_entry.focus_set()

            tk.Label(win,
                     text=self.trn.msg('htk_gui_editor_replace_replace')).grid(
                         row=1, column=0, pady=3, sticky='e')
            replace_entry = tk.Entry(win, width=50)
            replace_entry.grid(row=1, column=1, padx=3, sticky='e')

            replace_all = tk.BooleanVar(value=True)
            tk.Checkbutton(
                win,
                text=self.trn.msg('htk_gui_editor_replace_replace_all'),
                variable=replace_all).grid(row=2, column=1, pady=3, sticky='w')
            ignore_case = tk.BooleanVar(value=True)
            tk.Checkbutton(
                win,
                text=self.trn.msg('htk_gui_editor_replace_ignore_case'),
                variable=ignore_case).grid(row=3, column=1, sticky='w')
            regexp = tk.BooleanVar()
            tk.Checkbutton(win,
                           text=self.trn.msg('htk_gui_editor_replace_regexp'),
                           variable=regexp).grid(row=4, column=1, sticky='w')

            btn = tk.Button(
                win,
                text='OK',
                command=lambda: self._replace(find_entry.get(
                ), replace_entry.get(), replace_all.get(), ignore_case.get(),
                                              regexp.get(), win))
            btn.grid(row=0, column=2, padx=3, sticky='e')

            win.bind('<Escape>', lambda f: win.destroy())
示例#2
0
    def _win_clone(self):
        """Method displays clone window

        Args:
           none

        Returns:
           void

        """

        win = tk.Toplevel(self.root)
        win.title(self.trn.msg('htk_gitclient_clone_title'))
        win.transient(self.root)
        win.resizable(False, False)
        win.geometry('+%d+%d' % (self.root.winfo_screenwidth() / 3,
                                 self.root.winfo_screenheight() / 3))
        win.tk.call('wm', 'iconphoto', win._w, self.root.images['logo'])

        tk.Label(win,
                 text=self.trn.msg('htk_gitclient_clone_url')).grid(row=0,
                                                                    column=0,
                                                                    sticky='e')
        url = tk.Entry(win, width=70)
        url.grid(row=0, column=1, padx=3, pady=10, sticky='e')
        url.focus_set()

        tk.Label(win, text=self.trn.msg('htk_gitclient_clone_user')).grid(
            row=1, column=0, sticky='e')
        user = tk.Entry(win, width=20)
        user.grid(row=1, column=1, padx=3, pady=3, sticky='w')

        tk.Label(win, text=self.trn.msg('htk_gitclient_clone_password')).grid(
            row=2, column=0, sticky='e')
        passw = tk.Entry(win, width=20)
        passw.grid(row=2, column=1, padx=3, pady=3, sticky='w')

        tk.Label(win, text=self.trn.msg('htk_gitclient_clone_dirpath')).grid(
            row=3, column=0, sticky='e')
        dirpath = tk.Entry(win, width=70)
        dirpath.grid(row=3, column=1, padx=3, pady=3, sticky='w')
        tk.Button(win, text='...',
                  command=lambda: self._set_dirpath(dirpath)).grid(row=3,
                                                                   column=2,
                                                                   sticky='w')

        error = tk.Label(win, text='', foreground='#FF0000')
        error.grid(row=4, column=1, sticky='w')
        btn = tk.Button(
            win,
            text=self.trn.msg('htk_gitclient_clone_button'),
            command=lambda: self._clone_repo(url.get(), dirpath.get(
            ), user.get(), passw.get(), error, win))
        btn.grid(row=4, column=2, padx=3, pady=3, sticky='e')

        win.bind('<Escape>', lambda f: win.destroy())
示例#3
0
    def show_manager(self):
        """Method shows manager window

        Args:
            none

        Returns:
            void

        """

        win = tk.Toplevel(self.root)
        win.title(self.trn.msg('htk_gui_plugin_manager_title'))
        win.transient(self.root)
        win.resizable(False, False)
        win.geometry('+%d+%d' % (self.root.winfo_screenwidth() / 3,
                                 self.root.winfo_screenheight() / 3))
        win.tk.call('wm', 'iconphoto', win._w, self.root.images['logo'])
        win.focus_set()

        font = ('Arial', 10, 'bold')
        tk.Label(win,
                 text=self.trn.msg('htk_gui_plugin_manager_name'),
                 font=font,
                 width=25,
                 anchor='w',
                 padx=3,
                 pady=3).grid(row=0, column=0)
        tk.Label(win,
                 text=self.trn.msg('htk_gui_plugin_manager_enabled'),
                 font=font,
                 anchor='w',
                 padx=3,
                 pady=3).grid(row=0, column=1)
        i = 1
        states = {}
        for name, cfg in self.config.data['Plugins'].items():
            tk.Label(win, text=name, width=25, anchor='w',
                     padx=3).grid(row=i, column=0)
            state = True if ('enabled' in cfg
                             and cfg['enabled'] == 1) else False
            var = tk.IntVar(value=state)
            tk.Checkbutton(win, variable=var).grid(row=i,
                                                   column=1,
                                                   padx=3,
                                                   sticky='w')
            states[name] = var
            i += 1

        btn = tk.Button(win,
                        text=self.trn.msg('htk_gui_plugin_manager_save'),
                        command=lambda: self._update_state(states, win))
        btn.grid(row=i, column=2, padx=3, pady=3, sticky='e')

        win.bind('<Escape>', lambda f: win.destroy())
示例#4
0
    def _display(self, event=None):
        """Method displays tooltip

        Args:
            event (obj): event

        Returns:
            void

        """

        x, y, cx, cy = self._parent.bbox('insert')
        x += self._parent.winfo_rootx() + 25
        y += self._parent.winfo_rooty() + 20

        self._win = tk.Toplevel(self._parent)
        self._win.wm_overrideredirect(True)
        self._win.wm_geometry("+%d+%d" % (x, y))
        label = tk.Label(self._win,
                         text=self._text,
                         justify='left',
                         background='#FFFF00',
                         relief='solid',
                         borderwidth=1)
        label.pack(ipadx=1)
示例#5
0
    def win_goto(self, event=None):
        """Method displays Goto window

        Args:
            event (obj): event

        Returns:
            void

        """

        tab = self.nb.get_current_tab()
        if (tab is not None):
            win = tk.Toplevel(self.root)
            win.title(self.trn.msg('htk_gui_editor_goto_title'))
            win.transient(self.root)
            win.resizable(False, False)
            win.geometry('+%d+%d' % (self.root.winfo_screenwidth() / 2,
                                     self.root.winfo_screenheight() / 2))
            win.tk.call('wm', 'iconphoto', win._w, self.root.images['logo'])

            tk.Label(win, text=self.trn.msg('htk_gui_editor_goto_text')).pack(
                side=tk.LEFT, padx=3)
            entry = tk.Entry(win, width=15)
            entry.pack(side=tk.LEFT, padx=3)
            entry.focus_set()
            btn = tk.Button(win,
                            text='OK',
                            command=lambda: self._goto(entry.get(), win))
            btn.pack(side=tk.LEFT, padx=3)

            win.bind('<Escape>', lambda f: win.destroy())
示例#6
0
    def _set_config(self):
        """Method sets configuration gui

        Args:
           none

        Returns:
           void

        """

        row = 0
        font = ('Arial', 10, 'bold')
        tk.Label(self._frame_right,
                 text=self.trn.msg('htk_gitclient_repomanager_config_title'),
                 font=font).grid(row=row, column=0, sticky='w')
        tk.Label(
            self._frame_right,
            text=self.trn.msg('htk_gitclient_repomanager_config_url')).grid(
                row=row + 1, column=0, sticky='e')
        self._url = tk.Entry(self._frame_right, width=70)
        self._url.grid(row=row + 1, column=1, padx=3, pady=3, sticky='w')

        tk.Label(
            self._frame_right,
            text=self.trn.msg('htk_gitclient_repomanager_config_user')).grid(
                row=row + 2, column=0, sticky='e')
        self._user = tk.Entry(self._frame_right, width=20)
        self._user.grid(row=row + 2, column=1, padx=3, pady=3, sticky='w')

        tk.Label(self._frame_right,
                 text=self.trn.msg(
                     'htk_gitclient_repomanager_config_password')).grid(
                         row=row + 3, column=0, sticky='e')
        self._passw = tk.Entry(self._frame_right, width=20)
        self._passw.grid(row=row + 3, column=1, padx=3, pady=3, sticky='w')

        tk.Label(
            self._frame_right,
            text=self.trn.msg('htk_gitclient_repomanager_config_name')).grid(
                row=row + 4, column=0, sticky='e')
        self._name = tk.Entry(self._frame_right, width=40)
        self._name.grid(row=row + 4, column=1, padx=3, pady=3, sticky='w')

        tk.Label(
            self._frame_right,
            text=self.trn.msg('htk_gitclient_repomanager_config_email')).grid(
                row=row + 5, column=0, sticky='e')
        self._email = tk.Entry(self._frame_right, width=40)
        self._email.grid(row=row + 5, column=1, padx=3, pady=3, sticky='w')

        error = tk.Label(self._frame_right, text='', foreground='#FF0000')
        error.grid(row=row + 6, column=1, sticky='w')
        btn = tk.Button(
            self._frame_right,
            text=self.trn.msg('htk_gitclient_repomanager_config_save'),
            command=lambda: self._save_config(self._url.get(), self._user.get(
            ), self._passw.get(), self._name.get(), self._email.get(), error))
        btn.grid(row=row + 6, column=2, padx=3, pady=3, sticky='e')
示例#7
0
    def _set_commit(self):
        """Method sets commit gui

        Args:
           none

        Returns:
           void

        """

        row = 7
        font = ('Arial', 10, 'bold')
        tk.Label(self._frame_right,
                 text=self.trn.msg('htk_gitclient_repomanager_commit_title'),
                 font=font).grid(row=row, column=0, sticky='w')

        tk.Label(self._frame_right,
                 text=self.trn.msg(
                     'htk_gitclient_repomanager_commit_message')).grid(
                         row=row + 1, column=0, sticky='e')
        self._msg = tk.Text(self._frame_right,
                            background='#FFFFFF',
                            height=7,
                            width=50)
        self._msg.grid(row=row + 1, column=1, rowspan=2, sticky='w')
        row += 1

        tk.Label(
            self._frame_right,
            text=self.trn.msg('htk_gitclient_repomanager_commit_author')).grid(
                row=row + 3, column=0, sticky='e')
        self._author = tk.Entry(self._frame_right, width=40)
        self._author.grid(row=row + 3, column=1, padx=3, pady=3, sticky='w')

        push = tk.BooleanVar(value=True)
        tk.Checkbutton(
            self._frame_right,
            text=self.trn.msg('htk_gitclient_repomanager_commit_push'),
            variable=push).grid(row=row + 3, column=2, sticky='e')

        error = tk.Label(self._frame_right, text='', foreground='#FF0000')
        error.grid(row=row + 4, column=1, sticky='w')
        btn = tk.Button(
            self._frame_right,
            text=self.trn.msg('htk_gitclient_repomanager_commit_commit'),
            command=lambda: self._commit(self._msg.get(
                '1.0', 'end-1c'), self._author.get(), [], push.get(), error))
        btn.grid(row=row + 4, column=2, padx=3, pady=3, sticky='e')

        tk.Label(self._frame_right,
                 text=self.trn.msg('htk_gitclient_repomanager_commit_files'),
                 font=font).grid(row=row + 5, column=0, sticky='w')

        select_all = tk.BooleanVar(value=False)
        tk.Checkbutton(
            self._frame_right,
            text=self.trn.msg('htk_gitclient_repomanager_commit_select_all'),
            variable=select_all,
            command=lambda: self._select_all_files(select_all.get())).grid(
                row=row + 6, column=1, sticky='w')

        self._files_bar = ttk.Scrollbar(self._frame_right, orient=tk.VERTICAL)
        self._files = ttk.Treeview(self._frame_right,
                                   columns=('operation', 'file'),
                                   show='tree',
                                   displaycolumns=('operation', 'file'),
                                   height=10,
                                   selectmode='browse',
                                   yscrollcommand=self._files_bar.set)
        self._files_bar.configure(command=self._files.yview)
        self._files.grid(row=row + 7, column=1, sticky=tk.NSEW)
        self._files_bar.grid(row=row + 7, column=2, sticky='nsw')

        self._files.column('#0', stretch=False, width=40)
        self._files.column('operation', stretch=False, width=50)
        self._files.column('file', stretch=True, width=200)

        self._files.bind('<ButtonRelease-1>', self._select_file)
        self._files.bind('<Any-KeyRelease>', self._select_file)
示例#8
0
    def _set_gui(self, content=None):
        """Method sets graphical interface

        Args:
            content (str): file content

        Returns:
            void

        """

        self.rowconfigure(0, weight=1)
        self.columnconfigure(1, weight=1)

        self._vbar = ttk.Scrollbar(self, orient=tk.VERTICAL)
        self._hbar = ttk.Scrollbar(self, orient=tk.HORIZONTAL)

        # line number bar
        self._ln_bar = tk.Text(self, background='#FFFFFF', width=5, padx=3, takefocus=0, state=tk.DISABLED, yscrollcommand=self._vbar.set)
        self._ln_bar.grid(in_=self, row=0, column=0, sticky=tk.NSEW)

        # text area
        self._text = tk.Text(self, wrap=tk.NONE, background='#FFFFFF', xscrollcommand=self._hbar.set, yscrollcommand=self._vbar.set)
        self.set_font(self.editor.font['family'], self.editor.font['size'], self.editor.font['style'])
        self._text.grid(in_=self, row=0, column=1, sticky=tk.NSEW)

        # scrollbars
        self._vbar.configure(command=self._text.yview)
        self._vbar.grid(in_=self, row=0, column=2, sticky=tk.NS)
        self._hbar.configure(command=self._text.xview)
        self._hbar.grid(in_=self, row=1, column=1, sticky=tk.EW)

        # info bar
        info_text = '1 : 1' if (self.editor.var_show_info_bar.get()) else ''
        self._info_bar = tk.Label(self._text, text=info_text)
        self._info_bar.pack(side=tk.RIGHT, anchor=tk.SE)

        self._text.focus_set()

        # initial text content
        if (content != None):
            self._text.insert(tk.END, content)
            self._text.edit_modified(False)
            self._text.mark_set(tk.INSERT, 1.0)
            self.update_line_numbers()
            self.update_info_bar()
            self.colorize()

        # events
        self._text.configure(undo=True)
        self._text.bind('<Control-v>', self.editor.paste)
        self._text.bind('<Control-F4>', self.nb.close_tab)
        self._text.bind('<Any-KeyPress>', self._on_key_press)
        self._text.bind('<Any-KeyRelease>', self._on_key_release)
        self._text.bind('<ButtonRelease-1>', self._on_mouse_click)
        self._vbar.configure(command=self._on_vsb)

        if (c_os == 'Windows'):
            self._ln_bar.bind('<MouseWheel>', self._on_mouse_wheel)
            self._text.bind('<MouseWheel>', self._on_mouse_wheel)
            self._text.bind('<Control-MouseWheel>', self._change_font_size)
        else:
            self._ln_bar.bind('<Button-4>', self._on_mouse_wheel)
            self._ln_bar.bind('<Button-5>', self._on_mouse_wheel)
            self._text.bind('<Button-4>', self._on_mouse_wheel)
            self._text.bind('<Button-5>', self._on_mouse_wheel)
            self._text.bind('<Control-Button-4>', self._change_font_size)
            self._text.bind('<Control-Button-5>', self._change_font_size)

        self._text.bind('<F3>', self.find)
        self._text.bind('<Control-z>', self.editor.undo)
        self._text.bind('<Control-y>', self.editor.redo)
        self._text.bind('<Control-space>', self._show_autocomplete)

        self._set_menu()