当前位置: 首页>>代码示例>>Python>>正文


Python Entry.select_range方法代码示例

本文整理汇总了Python中tkinter.Entry.select_range方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.select_range方法的具体用法?Python Entry.select_range怎么用?Python Entry.select_range使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tkinter.Entry的用法示例。


在下文中一共展示了Entry.select_range方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: mainGUI

# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import select_range [as 别名]

#.........这里部分代码省略.........
        def hover_off(widget):
            widget['fg'] = 'black'
            # widget['underline'] = False

        for individual_thread in self.MESSAGE_THREADS:  # Fetch Message List from model

            if individual_thread.is_valid_thread():
                self.bg_color = 'green'
            else:
                self.bg_color = 'red'

            self.individual_thread_frame = Frame(self.thread_list_frame,
                                                 bg=self.bg_color)  # Create frame for each thread

            rowToInsertAt = self.MESSAGE_THREADS.index(individual_thread)

            self.text_color = 'black'
            self.threadText = Label(self.individual_thread_frame, bg=self.bg_color, fg=self.text_color)
            self.threadText['text'] = "[ Thread #:  " + individual_thread.threadId + " ]"

            self.threadText.bind("<Enter>", lambda event, text=self.threadText: hover_on(text))
            self.threadText.bind("<Leave>", lambda event, text=self.threadText: hover_off(text))

            self.threadText.bind("<Button-1>",
                                 lambda event, thread_in=individual_thread: self.open_in_web_browser(thread_in))
            self.threadText.grid(column=0, row=0, sticky='w', padx=0)

            self.image_count_text = Label(self.individual_thread_frame, bg=self.bg_color)
            num_of_images = individual_thread.get_number_of_images()
            if 0 < int(num_of_images) < 10:  # Format padding
                num_of_images = '00' + num_of_images
            if 10 < int(num_of_images) < 100:  # Format padding
                num_of_images = '0' + num_of_images

            self.image_count_text['text'] = "  [ # Images: " + num_of_images + " ]"
            self.image_count_text.bind("<Enter>", lambda event, text=self.image_count_text: hover_on(text))
            self.image_count_text.bind("<Leave>", lambda event, text=self.image_count_text: hover_off(text))

            self.image_count_text.bind("<Button-1>",
                                       lambda event, thread_in=individual_thread: self.open_in_file_browser(thread_in))

            self.image_count_text.grid(column=1, row=0, sticky='e', padx=0)

            self.deleteButton = Button(self.individual_thread_frame)
            self.deleteButton['text'] = 'Delete'
            self.deleteButton['command'] = lambda thread_in=individual_thread: self.delete_thread_GUI(thread_in)
            self.deleteButton.grid(column=2, row=0, sticky='e', padx=0)

            self.individual_thread_frame.grid(row=rowToInsertAt, sticky='w', pady=2)

    @staticmethod
    def open_in_file_browser(individual_thread):
        logging.debug(os.getcwd() + os.sep + individual_thread.threadId)
        if os.name == "nt":
            subprocess.Popen('explorer "' + os.getcwd() + os.sep + individual_thread.threadId + '"')

    @staticmethod
    def open_in_web_browser(individual_thread):
        webbrowser.open(
            url="http://boards.4chan.org/" + individual_thread.board + "/thread/" + individual_thread.threadId, new=2)

    def add_thread_GUI(self):
        entry_box_text = str(self.thread_entry_box.get())
        if entry_box_text not in self.MESSAGE_THREADS and entry_box_text != self.DEFAULT_THREAD_TEXT \
                and entry_box_text.isnumeric():
            try:
                self.add_thread(entry_box_text.strip(' '))
            except ThreadNotFound:
                messagebox.showwarning(message="Thread Not Found")
        else:
            messagebox.showwarning(message="Please enter a valid new thread ID")
        self.thread_entry_box.select_range(start=0, end=99)
        # Selects the contents so the user can just type the next message
        self.refresh_GUI()

    def delete_thread_GUI(self, thread_in):
        self.delete_thread(thread_in)
        self.refresh_GUI()

    def refresh_GUI(self):
        """ Refreshes the message list AND GUI window (used by auto refresh)"""
        self.refresh_thread_list()
        self.refresh_GUI_Window()

    def refresh_GUI_Window(self):
        """ Refreshes just the GUI window"""
        self.thread_list_canvas.destroy()
        self.vsb.destroy()
        self.hsb.destroy()
        self.create_thread_frame()

    @staticmethod
    def program_about():
        message = settings.__desc__ + '\n' + settings.__version__
        messagebox.showinfo(title='About', message=message)

    @staticmethod
    def program_help():
        message = 'See readme.md'
        messagebox.showinfo(title='About', message=message)
开发者ID:Jelloeater,项目名称:chanThreadWatcher,代码行数:104,代码来源:view.py


注:本文中的tkinter.Entry.select_range方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。