RE: How do I place a preset into the text box?

2020-08-28 Thread Steve
Works like a charm, special thanks.
Steve

=

Footnote:
He called his wife to see if he should pick up Fish and Chips on the way
home.  She hung up on him.  She is still fuming over letting him name the
kids.

-Original Message-
From: Python-list  On
Behalf Of Cousin Stanley
Sent: Friday, August 28, 2020 7:47 AM
To: python-list@python.org
Subject: Re: How do I place a preset into the text box?

Steve wrote:

> The following program compiles but does not quite do what I would like 
> it to do. Line 19 is the preset information but I do not seem to be 
> able to get it into the form by code.  My purpose is to let the user 
> make changes without having to re-enter the entire code.
> 

You might consider moving the entry  get()  function into the  Submit()
call back 

def Submit() :

label.configure( text = 'The new code is : ' + NewCode.get() )

x = ( NewCode.get() )

print( "\n  The new code entered is :  " + x )



The following  insert  function will show the OldCode in the  entry  box

 
OldCode = ( "1234-abcd" )

# 

CodeEntered = ttk.Entry( window , width = 15 , textvariable = NewCode )

CodeEntered.grid( column = 2 , row = 3 , pady = 10 )

CodeEntered.insert( 0 , OldCode )


--
Stanley C. Kitching
Human Being
Phoenix, Arizona

--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: How do I place a preset into the text box?

2020-08-28 Thread Steve
Yes, the form/window now closes properly.

Removal of sys.exit() and inserting window.destroy() cleared up the exiting
problem.

 

Thanks.  

I saw several variations on that but I guess I just never twerked it enough.

 

 

Footnote:
"What rhymes with orange?"
"No it doesn't.."

 

From: Colin McPhail  
Sent: Friday, August 28, 2020 7:46 AM
To: Chris Narkiewicz via Python-list 
Cc: Steve 
Subject: Re: How do I place a preset into the text box?

 

Hi Steve,





On 28 Aug 2020, at 11:03, Steve mailto:Gronicus@SGA.Ninja> > wrote:

 


The following program compiles but does not quite do what I would like it to
do. Line 19 is the preset information but I do not seem to be able to get it
into the form by code.  My purpose is to let the user make changes without
having to re-enter the entire code.

 

I'm no Tk expert but does the following do what you want? (Strictly
speaking, the parentheses in ("1234-abcd") are not wrong just unnecessary.)

 

#===

import tkinter as tk

from tkinter import ttk

import sys

 

window = tk.Tk()

window.title("Python Tkinter Text Box")

window.minsize(600,400)

 

def Submit():

   label.configure(text= 'The new code is: ' + NewCode.get())

 

def ClickExit():

   #This exit closes the program but the form remains and is still active.

   # I want only to close the form.

   print("Exiting")

   #sys.exit()

   window.destroy()

 

#OldCode = ("1234-abcd")

OldCode = "1234-abcd"

 

label = ttk.Label(window, text = "Enter the new code")

label.grid(column = 1, row = 1)

 

#NewCode = tk.StringVar()

NewCode = tk.StringVar(value=OldCode)

 

CodeEntered = ttk.Entry(window, width = 15, textvariable = NewCode)

CodeEntered.grid(column = 2, row = 3)

 

button = ttk.Button(window, text = "Submit", command = Submit)

button.grid(column= 2, row = 5)

 

button = ttk.Button(window, text = "Quit", command = ClickExit)

button.grid(column= 2, row = 7)

 

window.mainloop()

 

x = (NewCode.get())

print("The new code entered is: " + x)

 

#=

 

Regards,

Colin

 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I place a preset into the text box?

2020-08-28 Thread Cousin Stanley
Steve wrote:

> The following program compiles but does not quite do what I would like it to
> do. Line 19 is the preset information but I do not seem to be able to get it
> into the form by code.  My purpose is to let the user make changes without
> having to re-enter the entire code.
> 

You might consider moving the entry  get()  function
into the  Submit()  call back 

def Submit() :

label.configure( text = 'The new code is : ' + NewCode.get() )

x = ( NewCode.get() )

print( "\n  The new code entered is :  " + x )



The following  insert  function will show the OldCode
in the  entry  box 
 
OldCode = ( "1234-abcd" )

# 

CodeEntered = ttk.Entry( window , width = 15 , textvariable = NewCode )

CodeEntered.grid( column = 2 , row = 3 , pady = 10 )

CodeEntered.insert( 0 , OldCode )


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I place a preset into the text box?

2020-08-28 Thread Colin McPhail via Python-list
Hi Steve,

> On 28 Aug 2020, at 11:03, Steve  wrote:
> 
> 
> The following program compiles but does not quite do what I would like it to
> do. Line 19 is the preset information but I do not seem to be able to get it
> into the form by code.  My purpose is to let the user make changes without
> having to re-enter the entire code.

I'm no Tk expert but does the following do what you want? (Strictly speaking, 
the parentheses in ("1234-abcd") are not wrong just unnecessary.)

#===
import tkinter as tk
from tkinter import ttk
import sys

window = tk.Tk()
window.title("Python Tkinter Text Box")
window.minsize(600,400)

def Submit():
   label.configure(text= 'The new code is: ' + NewCode.get())

def ClickExit():
   #This exit closes the program but the form remains and is still active.
   # I want only to close the form.
   print("Exiting")
   #sys.exit()
   window.destroy()

#OldCode = ("1234-abcd")
OldCode = "1234-abcd"

label = ttk.Label(window, text = "Enter the new code")
label.grid(column = 1, row = 1)

#NewCode = tk.StringVar()
NewCode = tk.StringVar(value=OldCode)

CodeEntered = ttk.Entry(window, width = 15, textvariable = NewCode)
CodeEntered.grid(column = 2, row = 3)

button = ttk.Button(window, text = "Submit", command = Submit)
button.grid(column= 2, row = 5)

button = ttk.Button(window, text = "Quit", command = ClickExit)
button.grid(column= 2, row = 7)

window.mainloop()

x = (NewCode.get())
print("The new code entered is: " + x)

#=

Regards,
Colin

-- 
https://mail.python.org/mailman/listinfo/python-list


How do I place a preset into the text box?

2020-08-28 Thread Steve


The following program compiles but does not quite do what I would like it to
do. Line 19 is the preset information but I do not seem to be able to get it
into the form by code.  My purpose is to let the user make changes without
having to re-enter the entire code.

Suggestions welcome.
Steve

#===
import tkinter as tk
from tkinter import ttk
import sys

window = tk.Tk()
window.title("Python Tkinter Text Box")
window.minsize(600,400)

def Submit():
label.configure(text= 'The new code is: ' + NewCode.get())

def ClickExit():
#This exit closes the program but the form remains and is still active.
# I want only to close the form.
print("Exiting")
sys.exit()

OldCode = ("1234-abcd")

label = ttk.Label(window, text = "Enter the new code")
label.grid(column = 1, row = 1)

NewCode = tk.StringVar()
CodeEntered = ttk.Entry(window, width = 15, textvariable = NewCode)
CodeEntered.grid(column = 2, row = 3)

button = ttk.Button(window, text = "Submit", command = Submit)
button.grid(column= 2, row = 5)

button = ttk.Button(window, text = "Quit", command = ClickExit)
button.grid(column= 2, row = 7)

window.mainloop()

x = (NewCode.get())
print("The new code entered is: " + x)
  
#=



Footnote: 
Mars is the only known planet in our solar system solely inhabited by
functioning robots.


-- 
https://mail.python.org/mailman/listinfo/python-list