![]() With this you can import module without letting Python to execute, when this script is imported, and also excute the imported module individually for testing without modifying(comment or uncomment) your code. If _name_ = '_main_': # condition computes to TRUE only when this script is run and not otherwise. from Tkinter import import Tkinter top Tkinter.Tk() B1 Tkinter.Button(top, text 'circle', reliefRAISED, cursor'circle') B2 Tkinter.Button(top, text. from Tkinter import def getinfo(): print e.index(INSERT) root Tk() e Entry(root) e.pack() Button(root, text'get info', commandgetinfo).pack() root. root Tk () Syntax: Tk (screenNameNone, baseNameNone, className’Tk’, useTk1) Parameter: In this example, Tk class is instantiated. I am going to modify script.py little bit, #script.py You can use the Entry.index() method to get the index of the current INSERT position. The code below demonstrates the creation of a read-only Entry widget using Tkinter. root tk.Tk() nfig(width300, height200) entry ttk.Entry() ace(x50, y50) This second textbox cannot take focus via the Tab key. There is also better method which is more useful. If we want to prevent our textbox from taking focus this way, we use the takefocus argument. But can you see, you have to uncomment function call when you want to individually test script.py. Has no effect if the text fits entirely within the entry. ![]() index (index) Shift the contents of the entry so that the character at the given index is the leftmost visible character. You can avoid this by simply commenting function call in script.py, which is an obvious and quick solution to avoid execution of the module which you import. .get () Returns the entry's current text as a string.icursor (index) Set the insertion cursor just before the character at the given index. .bind(sequenceNone, commandNone, addNone) Bind command function to event specified by lete(firstindex, lastindexNone) Deletes characters from the widget, starting with the one at index firstindex, up to but not including the character at position lastindex. ![]() extract the halves of text before and after cursor, but it'd be better. text before and after the insertion cursor. ![]() When you import a module, python will compiles that script and executes for you. actual coordinate numbers of the mark I need this because I want not just to insert string at, but to examine. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |