Python Forum
[Tkinter] help please, checking the user input and outputting the result
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] help please, checking the user input and outputting the result
#4
I quickly reviewed your code and have a couple observations:
Make a class and eliminate your globals
initiate Tk once not 3 times:
you have multiple ways to create other free standing widgets:
create a separate frames
use simpledialogs-
example:
from tkinter.simpledialog import *
from tkinter import *
if __name__ == '__main__':

    def test():
        root = Tk()
        def doit(root=root):
            d = SimpleDialog(root,
                         text="This is a test dialog.  "
                              "Would this have been an actual dialog, "
                              "the buttons below would have been glowing "
                              "in soft pink light.\n"
                              "Do you believe this?",
                         buttons=["Yes", "No", "Cancel"],
                         default=0,
                         cancel=2,
                         title="Test Dialog")
            print(d.go())
            print(askinteger("Spam", "Egg count", initialvalue=12*12))
            print(askfloat("Spam", "Egg weight\n(in tons)", minvalue=1,
                           maxvalue=100))
            print(askstring("Spam", "Egg label"))
        t = Button(root, text='Test', command=doit)
        t.pack()
        q = Button(root, text='Quit', command=t.quit)
        q.pack()
        t.mainloop()

    test()
this example is from the simpledialog module. you could-
guess= askinteger("your guess", "Number 1-10", initialvalue=1)

then compare guess to your random number...
Reply


Messages In This Thread
RE: help please - by woooee - Mar-05-2019, 12:58 AM
RE: help please, checking the user input and outputting the result - by joe_momma - Mar-05-2019, 08:58 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyGUI] [Solved]Help storing in user input from line edit Extra 2 1,943 May-12-2022, 07:46 PM
Last Post: Extra
  Convert combobox user input in to date with tkinter Ame 8 7,076 Jul-01-2020, 09:40 PM
Last Post: Yoriz
  Create an identification code from user input PeroPuri 1 1,988 Apr-11-2020, 11:56 AM
Last Post: Larz60+
  [PyQt] Python PyQt5 - Change label text dynamically based on user Input ppel123 1 14,024 Mar-20-2020, 07:21 AM
Last Post: deanhystad
  PyQt5: How do you set the user input of a line edit to a specific variable? YoshikageKira 17 12,332 Dec-26-2019, 03:18 PM
Last Post: Denni
  [Tkinter] Is there a way to sleep without stopping user input? GalaxyCoyote 2 2,241 Oct-23-2019, 06:23 PM
Last Post: Denni
  [PyGUI] Hi All, how to hide/mask user input in PySimpleGUI nmrt 1 15,197 Sep-21-2018, 09:59 AM
Last Post: nmrt

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020