473,320 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

raw_input into Tkinter ?

Is there any way to type into a Tkinter frame window?
I want to use raw_input() within a Tkinter frame.
Jun 30 '08 #1
5 7094
ja********@gmail.com <ja********@gmail.com>:
Is there any way to type into a Tkinter frame window?
Maybe using a proper text/line edit widget?
I want to use raw_input() within a Tkinter frame.
The builtin raw_input is for console input only. Of course, one could
implement a raw_input using a Tkinter dialog to query input, but its way
more easier and comfortable to just write a real GUI application.

--
Freedom is always the freedom of dissenters.
(Rosa Luxemburg)
Jun 30 '08 #2
On Jun 30, 9:55*am, jamitwi...@gmail.com wrote:
Is there any way to type into a Tkinter frame window?
I want to use raw_input() within a Tkinter frame.
`raw_input(prompt)` just calls `sys.stdout.write(prompt)` and returns
`sys.stdin.readline()`. So, you can just create file-like objects to
replace stdout and stdin that are aware of your Tkinter gui.
Alternatively, you could just replace __builtins__.raw_input with your
own version.

Actual implementation left as an exercise for the user.

Matt
Jun 30 '08 #3

On 30 jun 2008, at 18:55, ja********@gmail.com wrote:
Is there any way to type into a Tkinter frame window?
I want to use raw_input() within a Tkinter frame.
--
http://mail.python.org/mailman/listinfo/python-list

You could use the Tkinter.Entry option from dialog windows...

http://www.pythonware.com/library/tk...og-windows.htm

gr
Arno
Jul 1 '08 #4
Matimus <mc******@gmail.com>:
On Jun 30, 9:55Â*am, jamitwi...@gmail.com wrote:
>Is there any way to type into a Tkinter frame window?
I want to use raw_input() within a Tkinter frame.

`raw_input(prompt)` just calls `sys.stdout.write(prompt)` and returns
`sys.stdin.readline()`.
It does more like providing readline support, if readline is loaded.

--
Freedom is always the freedom of dissenters.
(Rosa Luxemburg)
Jul 1 '08 #5
On Jun 30, 11:55 am, jamitwi...@gmail.com wrote:
Is there any way to type into a Tkinter frame window?
I want to use raw_input() within a Tkinter frame.
import sys
import Tkinter
import cStringIO

class GUIInputMgr(Tkinter.Entry):

def __init__(self, parent):
Tkinter.Entry.__init__(self, parent)

sys.stdin = cStringIO.StringIO()
self.bind("<Key>", self.__UpdateBuffer)

def __UpdateBuffer(self, event):
sys.stdin.truncate(0)
sys.stdin.write(self.get())
entry = GUIInputMgr(top) # top is your Tk() instance
entry.pack()

raw_input() # should now get you user input :)

Sebastian
Jul 2 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: dale | last post by:
Python newbie disclaimer on I am running an app with Tkinter screen in one thread and command-line input in another thread using raw_input(). First question - is this legal, should it run...
3
by: Terry Carroll | last post by:
I've got a small batch image-processing program (it adds the time a digital photo was taken to the lower right of the image), and as a feature, I wanted to show a thumbnail of each image it was...
1
by: cm012b5105 | last post by:
Hello i am fairly new to python, I have written an interactive programme a small example of it is here. s = raw_input ("Do you have any children? ") if s== 'yes': print "Thats great" elif...
21
by: planetthoughtful | last post by:
Hi All, As always, my posts come with a 'Warning: Newbie lies ahead!' disclaimer... I'm wondering if it's possible, using raw_input(), to provide a 'default' value with the prompt? I would...
4
by: BartlebyScrivener | last post by:
Using Python on Debian Etch. What is the best way to paste a block of text in at the command prompt. I'm trying something like: Quote = raw_input("Paste quote here: ") Which works great...
1
by: alivip | last post by:
I integrat program to be GUI using Tkinter I try browser direction as you can see # a look at the Tkinter Text widget # use ctrl+c to copy, ctrl+x to cut selected text, # ctrl+v to...
2
by: alivip | last post by:
when I wont to inser (anyting I print) to the textbox it will not inser it just print then hanging # a look at the Tkinter Text widget # use ctrl+c to copy, ctrl+x to cut selected text, #...
2
by: skanemupp | last post by:
why is the first program not working? when i click the screen the map is not appearing. the second program works. from Tkinter import * master = Tk()
2
by: Doran, Harold | last post by:
I am currently reading An Intro to Tkinter (1999) by F. Lundh. This doc was published in 1999 and I wonder if there is a more recent version. I've googled a bit and this version is the one I keep...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.