By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,640 Members | 1,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,640 IT Pros & Developers. It's quick & easy.

Creating gui in python using opengl. How can i make the text boxes which take values

P: 1
How can i create gui in python using pyopengl?
Or simply i want to create textbox in python using pyopengl which takes the value entered in text box and the calculation can be conducted. please help me to get through it (p.s. not using thread)
Feb 28 '13 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 2.5K+
P: 2,851
My understanding is PyOpenGL is interoperable with PyQt, PyGTK, Tkinter, wxPython and other GUI libraries. I know a little Tkinter and have an example of an entry dialog. It's more than you need, but shows how you can do it with Tkinter.
Expand|Select|Wrap|Line Numbers
  1. import Tkinter
  3. textFont1 = ("Arial", 20, "bold italic")
  5. class EntryWidget(Tkinter.Entry):
  6.     def __init__(self, master, initial=""):
  7.         Tkinter.Entry.__init__(self, master=master)
  8.         self.value = Tkinter.StringVar()
  9.         self.config(textvariable=self.value, width=40,
  10.                     relief="ridge", font=textFont1,
  11.                     bg="#ddd", fg="#e00",
  12.                     justify='center')
  13.         self.pack()
  14.         self.value.set(initial)
  16. class App(Tkinter.Tk):
  17.     def __init__(self, title="Case Insensitive Entry"):
  18.         Tkinter.Tk.__init__(self)
  19.         self.title(title)
  20.         self.w = EntryWidget(self, "Enter Text")
  21.         self.w.bind(sequence="<KeyRelease>", func=self.lower)
  22.         self.mainloop()
  23.         self.value = self.w.value.get()
  25.     def lower(self, event):
  26.         event.widget.value.set(event.widget.value.get().lower())
  28. if __name__ == "__main__":
  29.     app = App()
  30.     print app.value
Feb 28 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.