Python Forum

Full Version: Best Method for simple GUI?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've made a number guessing game, and I want to build a GUI so it can be played outside of a command prompt window so that I can eventually export it as an .exe that I can share.

What is the best module and/or method to use? PyGame seems absurdly complicated for me just wanting to display text and simple typed inputs so I haven't tried that yet. Tkinter seems to want to always close a window and open a new one rather than just update a single, consistent existing window. Is there another way that I can create a single window to display a single changeable line of text and a small input window for typed inputs that are max 3 characters long?
You can create in tkinter a text that can change. You can use a StringVar and set that as a label's or other text of widget and change it on the fly
http://effbot.org/tkinterbook/label.htm


pygame doesnt come with a UI toolkit, so yeah it would make it more complicated than what you are looking for. Unless your end result is gaming, then i would learn it and use it.
That... is brilliant. Thank you.
Have you considered using tkinter to set up an entry box, and having the entry display in a text box upon click of a button ? For example:
   
    def __init__(self, master):
        Frame.__init__(self, master)
        self.grid()
        self.create_widgets()
    def create_widgets(self):
        self.text = Text(self, width = 35, height =5, wrap = WORD)###this is where you'd put entry.
        self.text.grid(row =1, column=1, sticky = W)

        self.submit_button = Button(self, text = "Submit", command = self.reveal)###this is the button you'd hit to perform your function
        self.submit_button.grid(row = 2, column = 0, sticky =W)

        self.text1 = Text(self, width = 35, height =5, wrap = WORD) ###this places a second text box in grid.
        self.text1.grid(row = 3, column =0, columnspan = 2, sticky=W)
    def reveal(self): # this reveals w/e you wrote in first textbox, or you can configure to reveal whatever you want 
        content = self.text.get("1.0","end-1c") 
        self.text1.insert(3.0, content)
I'm new to the game myself, but hopefully this can provide you a glint of guidance :-D