FAQ
I need to create a button and a text box follows the text box to enter a
number, and this number is expected to create the same screen text boxes, and
these text boxes need to be referenced, ie if I enter 30 in the first text
box and click the button to be created 30 text boxes so that I can then "
call" each of the boxes, eg box1, box2, box3, etc. .. .


This all-in Tkinter.


I thank you all for understanding and help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130401/dcb60f2b/attachment-0001.html>

Search Discussions

  • Demian Brecht at Apr 2, 2013 at 3:25 pm
    ...And your question is?...


    If you're looking for people to just do your work for you, you'll
    likely get little assistance and will instead project a negative image
    of yourself here. What have you tried? Where are you stuck? What,
    /specifically/, do you need help with or what do you not understand?


    Questions with that kind of information and showing that you've done
    /some/ work will likely get you helpful answers.
  • Jason Swails at Apr 2, 2013 at 3:29 pm

    On Mon, Apr 1, 2013 at 5:12 PM, Renato Barbosa Pim Pereira wrote:


    I need to create a button and a text box follows the text box to enter a
    number, and this number is expected to create the same screen text boxes, and
    these text boxes need to be referenced, ie if I enter 30 in the first
    text box and click the button to be created 30 text boxes so that I can
    then "call" each of the boxes, eg box1, box2, box3, etc. .. .

    This all-in Tkinter.

    I thank you all for understanding and help.

    First, you have not asked a question. You have just said you need
    something.


    Second, we are not here to do your homework. If you want help with your
    programming, you have to at least demonstrate an initial effort.


    What have you programmed so far? What does it do? What errors are you
    getting when you run your code? Annotating your code with what you expect
    each segment to do is even better -- it lets us quickly correct
    misconceptions.


    The more information you can provide, the more targeted help we can give.
    Simply saying "I need a program to do X" is unlikely to get a response any
    more helpful than mine.


    Good luck,
    Jason
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://mail.python.org/pipermail/python-list/attachments/20130402/80bc5eea/attachment.html>
  • Jason Swails at Apr 2, 2013 at 4:11 pm
    Please keep response replies to the Python list (e.g., use 'reply all' or
    just send the email to python-list).


    Also, you should tell people what Python version you are using. I assume
    you are using Python 2 since Tkinter was renamed to tkinter in Python 3.


    Finally, do not top-post. Type your responses inside the body of the email
    you are responding to. That gives people context for your responses.


    On Tue, Apr 2, 2013 at 11:48 AM, Renato Barbosa Pim Pereira wrote:

    Sorry for my inconsistence:

    I need a textbox to get one number and pass for variable called numero
    with one click of button. Thanks .

    I have this:

    import numpy as np
    import matplotlib.pyplot as plt
    from Tkinter import *
    import tkMessageBox

    prefixo = "vetor"
    numero = 10
    numeroVetores = 0

    def makeWidgets(numero):
    global entries
    window = Tk()
    window.title('Vetores')
    form = Frame(window)
    form.pack()
    entries = {}
    for ix in range(numero):
    label = "%s %s" % (prefixo , ix + 1)
    lab = Label(form, text=label)
    ent = Entry(form)
    lab.grid(row=ix, column=0)
    ent.grid(row=ix, column=1)
    entries[label] = ent





    Button(window, text="Calcular", command=calcular).pack(side=LEFT)
    Button(window, text="Media", command=media).pack(side=LEFT)



    return window



    def pegavalores():
    valores = []
    for chave, entrada in sorted(entries.items()):
    valores.append(entrada.get())

    return valores


    def calcular():
    calcular = pegavalores()
    plt.plot(calcular)
    plt.show()

    def media():
    media = pegavalores()
    elementos = len(media)
    media = np.asarray(media, dtype=np.float64)
    valormedio = np.sum(media)/elementos
    tkMessageBox.showinfo("Media", valormedio)


    window = makeWidgets(numero)
    window.mainloop()

    I'm not sure exactly what you are trying to do. My guess is that you want
    to get "numero" from user input. Luckily, the tkSimpleDialog module
    contains a handy function that does just this: askinteger. So add a call:


    numero = tkSimpleDialog.askinteger('Window Title', 'Please insert the
    number of input values you want')
    window = makeWidgets(numero)
    window.mainloop()


    I leave to you the task of bringing tkSimpleDialog into your namespace.


    Good luck,
    Jason


    --
    Jason M. Swails
    Quantum Theory Project,
    University of Florida
    Ph.D. Candidate
    352-392-4032
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://mail.python.org/pipermail/python-list/attachments/20130402/3442dc56/attachment-0001.html>
  • Renato Barbosa Pim Pereira at Apr 3, 2013 at 2:04 am
    Thanks for the advices, I need now one scrollbar to roll under screen, I
    created the scrollbar but cant roll, please help me on this.


    http://pastebin.com/L6XWY6cm




    2013/4/2 Jason Swails <jason.swails@gmail.com>

    Please keep response replies to the Python list (e.g., use 'reply all' or
    just send the email to python-list).

    Also, you should tell people what Python version you are using. I assume
    you are using Python 2 since Tkinter was renamed to tkinter in Python 3.

    Finally, do not top-post. Type your responses inside the body of the
    email you are responding to. That gives people context for your responses.

    On Tue, Apr 2, 2013 at 11:48 AM, Renato Barbosa Pim Pereira <
    renato.barbosa.pim.pereira at gmail.com> wrote:
    Sorry for my inconsistence:

    I need a textbox to get one number and pass for variable called numero
    with one click of button. Thanks .

    I have this:

    import numpy as np
    import matplotlib.pyplot as plt
    from Tkinter import *
    import tkMessageBox

    prefixo = "vetor"
    numero = 10
    numeroVetores = 0

    def makeWidgets(numero):
    global entries
    window = Tk()
    window.title('Vetores')
    form = Frame(window)
    form.pack()
    entries = {}
    for ix in range(numero):
    label = "%s %s" % (prefixo , ix + 1)
    lab = Label(form, text=label)
    ent = Entry(form)
    lab.grid(row=ix, column=0)
    ent.grid(row=ix, column=1)
    entries[label] = ent





    Button(window, text="Calcular", command=calcular).pack(side=LEFT)
    Button(window, text="Media", command=media).pack(side=LEFT)



    return window



    def pegavalores():
    valores = []
    for chave, entrada in sorted(entries.items()):
    valores.append(entrada.get())

    return valores


    def calcular():
    calcular = pegavalores()
    plt.plot(calcular)
    plt.show()

    def media():
    media = pegavalores()
    elementos = len(media)
    media = np.asarray(media, dtype=np.float64)
    valormedio = np.sum(media)/elementos
    tkMessageBox.showinfo("Media", valormedio)


    window = makeWidgets(numero)
    window.mainloop()
    I'm not sure exactly what you are trying to do. My guess is that you want
    to get "numero" from user input. Luckily, the tkSimpleDialog module
    contains a handy function that does just this: askinteger. So add a call:

    numero = tkSimpleDialog.askinteger('Window Title', 'Please insert the
    number of input values you want')
    window = makeWidgets(numero)
    window.mainloop()

    I leave to you the task of bringing tkSimpleDialog into your namespace.

    Good luck,
    Jason
    --
    Jason M. Swails
    Quantum Theory Project,
    University of Florida
    Ph.D. Candidate
    352-392-4032
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://mail.python.org/pipermail/python-list/attachments/20130402/f61e204e/attachment.html>
  • Jason Swails at Apr 3, 2013 at 12:05 pm

    On Tue, Apr 2, 2013 at 10:04 PM, Renato Barbosa Pim Pereira wrote:


    Thanks for the advices, I need now one scrollbar to roll under screen, I
    created the scrollbar but cant roll, please help me on this.

    http://pastebin.com/L6XWY6cm



    You need to bind your scrollbar to a particular action. It does not roll
    because you never told it what 'rolling' should do. That said, you need to
    bind your scrollbar command to a widget that actually supports scrolling.
    According to [1], your options are the Listbox, Text, Canvas, and Entry
    widgets. What that means is that you will need to replace your Frame
    widget with a Canvas widget (or embed a Canvas in your Frame, although with
    your existing code that latter approach does not serve much purpose). Then
    bind your scrollbar command to the xview method of your Canvas instance (or
    the yview method of your Canvas instance if you want to scroll vertically).


    HTH,
    Jason


    [1] http://effbot.org/zone/tkinter-scrollbar-patterns.htm
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://mail.python.org/pipermail/python-list/attachments/20130403/7013c35e/attachment.html>

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedApr 1, '13 at 9:12p
activeApr 3, '13 at 12:05p
posts6
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase