![]() ![]() Self.index_line = list(self.widget_dict.keys()).index(event.widget)ĭef create_new_line(self,event): # when user input enter,generate an entry and a label Self.check_func = (self.check)įirst_line = tkinter.Entry(self,font=("",16),relief="flat",validate="key",validatecommand=(self.check_func,'%W','%P'))įirst_underline = tkinter.Label(self,background="white",fg="red",font=("",4))įirst_line:first_underline # a dict which save the squiggly line widget(as a value) and entry widget(as a key)įirst_line.bind("",self.to_previous_line)ĭef focused(self,event): # when one entry widget is focused,change the index_line number When user type "Up" arrow,it will make previous entry widget focused. If user type "Backspace" and this entry is null,it will delete both this entry and label(squiggly line widget). When user input "Enter",it will generate a new entry and a new label(squiggly line widget). I customized a frame,its layout(just an idea,it needs improvement): Note that the height of the XBM image need to match the font size and spacing between lines. Textbox.insert("end", "\nthis is second line") Textbox.insert("end", "Python", "squiggly") # add squiggly line Textbox = tk.Text(root, width=30, height=10, font=('Courier New',12), spacing1=1) Textbox.insert("end", "hello", "squiggly") # add squiggly lineīelow is a sample code: import tkinter as tk and apply the tag to the portion of text inside Text widget:.Textbox.tag_config("squiggly", background='red') # config a tag with squiggly.xbm as bgstipple in red color then you can config a tag in Text widget using the above XBM image file as bgstipple in red color:.create a XBM image, for example squiggly.xbm, like below:.This is just an example of using user-defined XBM as the bgstipple of part of the text inside a Text widget to simulate the squiggly line effect: ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |