{"id":4900,"date":"2025-04-30T11:29:37","date_gmt":"2025-04-30T10:29:37","guid":{"rendered":"https:\/\/ibex.tech\/python\/?p=4900"},"modified":"2025-12-09T15:35:06","modified_gmt":"2025-12-09T15:35:06","slug":"text-multiline","status":"publish","type":"post","link":"https:\/\/ibex.tech\/python\/gui\/tkinter-tk-gui-toolkit\/gui-objects\/text-multiline","title":{"rendered":"Text &#8211; multiline"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Multiline textbox<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>def gui_init():\n    global textbox_my_textbox\n\n    #----- LIVE PROCESSING BOX -----\n    MonospaceFont = font.Font(family=\"Courier\", size=10)\n    textbox_my_textbox = tk.Text(\n        root,\n        bg=\"white\",\n        font=MonospaceFont,\n        wrap = \"word\",\n        height=8,\n        width=50\n    )\n    textbox_my_textbox.pack(padx=10, pady=10)\n    textbox_my_textbox.place(x=10, y=310)\n    textbox_my_textbox.insert(tk.END, \"Loading...\\n\")<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Overwrite all text<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>    NewText = \"Hello\\nNew content\"\n    textbox_my_textbox.delete(\"1.0\", tk.END)\n    textbox_my_textbox.insert(\"1.0\", NewText)<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Multiline textbox that auto removes top line once full example<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>#*******************************************************\n#*******************************************************\n#********** ADD A LINE TO LIVE PROCESSING BOX **********\n#*******************************************************\n#*******************************************************\ndef textbox_my_textbox_add_line (new_line):\n    global textbox_my_textbox\n\n    #Get current line count\n    LineCount = int(textbox_my_textbox.index(\"end-1c\").split('.')&#91;0])\n\n    #Delete top line if we're over # lines\n    if LineCount &gt;= 7:\n        textbox_my_textbox.delete(\"1.0\", \"2.0\")        #Delete the first line (from line 1, char 0 to line 2, char 0)\n\n    #Add a timestamp to the start of the new line\n    #time_stamp = datetime.now().strftime(\"%H:%M:%S\")\n    #new_line = f\"{time_stamp} {new_line}\"\n\n    #Add the new line to the textbox\n    textbox_my_textbox.insert(tk.END, new_line + \"\\n\")\n\n    gui_update()<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Multiline textbox Overwrite all text Multiline textbox that auto removes top line once full example<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[372],"tags":[],"class_list":["post-4900","post","type-post","status-publish","format-standard","hentry","category-gui-objects"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/posts\/4900","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/comments?post=4900"}],"version-history":[{"count":12,"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/posts\/4900\/revisions"}],"predecessor-version":[{"id":4972,"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/posts\/4900\/revisions\/4972"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/media?parent=4900"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/categories?post=4900"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/tags?post=4900"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}