Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Best Method for simple GUI?
#1
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?
"Nobody really knows how to program, the pros Google too." -A Google Engineer
Reply
#2
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.
Recommended Tutorials:
Reply
#3
That... is brilliant. Thank you.
"Nobody really knows how to program, the pros Google too." -A Google Engineer
Reply
#4
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
Reply
#5
See https://python-forum.io/Thread-Tkinter-N...I-graphics
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Simple URL Example – Get Method whois1230 7 9,197 Nov-19-2020, 07:57 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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