I would like to know if there is any wway to change the Title of an input box( Left Upper Corner).

Lets say we have the input box:
x= input("blah blah blah")

if we run that the title of the input box would be like "Python input" or something, isnt in ?

So how can I change that to something else?

Thank you for your time

In Tkinter is would just be
top.title("New Title")

Or use a Label and Entry box if you have several entries and want a separate title/label for each one.

Ah, you are using input, i.e. the console

x= input("blah blah blah")

then you would just print a line to get something more than "blah blah blah" to print

print("Python Input")
x= input("blah blah blah")

What graphics module are you using? In Tkinter, there is nothing called an input box. Rather there is a widget called an "entry". It has no title, but you can fit it with a "label". Likewise, pyGTK, has a "text" and "label". In non-GUI python, "input" is a command indicating that the user is expected to type text. There's no box and no title. So, maybe I'm just not getting something obvious about your question but I'm not.

In wxPython you can do:

import wx
app = wx.PySimpleApp()
dlg = wx.TextEntryDialog(None, 'This is the text', 'This is the title', '')
if dlg.ShowModal() == wx.ID_OK:
    val = dlg.GetValue()
print "You entered %s" % val

Hello, thanks for your reply.
Actually in the Uni course they just teach us that way I mentioned before, so I cant use any other way in my project.
So there is no way using the input("") method isnt it?

Thank you

Why would you not describe the task you have, what have you done, your ideas how you plan to do the rest of it? For example the test cases you have prepared for your coding.

Then we can give some ideas to get you going.

Well, my task is something like that but with different dimensions, colours, and shapes

Lets say we have a list with colours. we asking the users for their prefered colours, if the colours are not in the list or the colour already existed in their selection, then the program askss the user for another colour, but on that input box I would like to change the Title of the inputbox from Python input to "Invalid Colour" and write something in the inputbox like "Colour not in the colour list or already existed in you selections"

Your input window is idle's shell window. There is an option to change the title of the shell window when you start idle. Start idle with

idle -t "Python input"

from a terminal.

You don't have an input box, you are using the command line so you would just print the error message. You should be able to modify the code you posted on the other forum

while True:
    first_colour = input("Please enter your first valid colour: ")
    if first_colour in list_colours:

    print("Some error message")        ##  added

although I would use a function and a loop to get the colors instead of the 4 separate input statements.

or already existed in you(r) selections

You do not test for this in the code you posted.

Hello, I made an attempt to create the colour part of my project, but when i give something wrong like pink that is not in the list or an already existed colour and the loop start running Im getting an error :

NameError: global name 'colour' is not defined

Whats going wrong with my code, maybe is something obvious but I cant see it.

Thank you

#This is the function in case of invalid colour or already existed colour
def invalidColour():
     colour = input('''Invalid Colour!
The colour you choose is invalid or already existed in you selection.
The colour must be red, blue, green or yellow, magenta, orange or cyan.
Please enter a valid colour: ''')
     return colour

def selection():
#We gonna ask the user to input 4 different colours, In case of invalid
#colour the window of input will be pop up again until it receive a valid one
    print("Enter four  colours of your choice (red, blue, green, yellow, magenta, orange and cyan")
    list_colours = ["red", "blue", "green", "yellow", "magenta", "orange", "cyan"]
    #colour 1
    while True:
        first_colour = input("Please enter your first valid colour: ")
        while first_colour not in list_colours:
         first_colour = invalidColour(colour)

    #colour 2
    while True:
        second_colour = input("Please enter your second valid colour: ")
        while (second_colour not in list_colours) or (second_colour == first_colour):
         second_colour = invalidColour(colour)

    #colour 3
    while True:
        third_colour = input("Please enter your third valid colour: ")
        while (third_colour not in list_colours) or (third_colour ==first_colour) or (third_colour==second_colour) :
         third_colour = invalidColour(colour)

    #colour 4
    while True:
        fourth_colour = input("Please enter your fourth valid colour: ")
        while (fourth_colour not in list_colours) or  \
                (fourth_colour ==first_colour) or \
                (fourth_colour==second_colour) or \
                (fourth_colour == third_colour) :
         fourth_colour = invalidColour(colour)

    return(first_colour, second_colour, third_colour, fourth_colour)

How can I use a loop, lets say we using a for loop and we have the varibles first_colour, second_colour, third_colour, fourth_colour, how can I change the varibale each time? beacuse the coulrs should be added each time to different variable. Sorry if my explanations are not clear, I know my writting its a bit messy as my mind is the same right now.
I need to take some brakes.

You should use a list of colors instead.

As Tony said, use a list. This can be run as is as a test.

def selection(number, list_colours, choices):
    while True:
        print("\nValid choices are %s" % (", ".join(list_colours)))
        colour = input("Please enter your %s valid colour: " % (number))

        if (colour in list_colours) and (colour not in choices):
            return colour, list_colours

            if colour not in list_colours:
                print("That is not a valid colour")
            if colour in choices:
                print("You have already chosen that colour")
            ## always prints
            print("Please make your selection again")

list_colours = ["red", "blue", "green", "yellow", "magenta", "orange", "cyan"]
choices = []
for number in ["first", "second", "third", "fourth"]:
    choice, list_colours = selection(number, list_colours, choices)

print ("Choices made list =", choices)

Hello again and thank you for your reply.
@woooee your code is really helpful and with some edits it can do the work on my project.

def main():
    # calls the getCoords() and get the width and height

    list_colours = ["red", "blue", "green", "yellow", "magenta", "orange", "cyan"]
    choices = []*25
    for number in ["first", "second", "third", "fourth"]:
        choice, list_colours = selection(number, list_colours, choices)
    print ("Choices made list =", choices)

    start = Point(100, 0)
    colourNumber = 1
    win = GraphWin("Patchwork Sample", (width) * 100, (height) * 100)
    for border in range(height):
        middle = 0 #Center
        colourNumber = colourNumber + 2
        start = Point(0, border * 100)
        shape1(win, choices[colourNumber], start)
        for middle in range(width ):
            colourNumber = colourNumber + 1
            start = Point(middle*100, start.getY())
            if border == 0 or middle == width - 2 or border == height - 1:
            #Here the program getting an error
                shape1(win, choices[colourNumber], start)
                shape2(win, choices[colourNumber], start)

Hello , Im calling the selector function (the function that woooee wrote). the shape 1 above the shape1 that I marked you is running fine but there Im getting error. and code is the same shape1(win, choices[colourNumber], start).
Whats going wrong? I have marked you the point tha Im getting error. Thank you

I found the solution guys thanks for your help. I will let you know if I need something else (for sure :) )

Hello guys,
I would like to ask your help again,

well i have that piece of code that draw a patch of boats:

def shape2(win, colour, start):
    s1 = -35
    s2 = -15
    s3 = -10
    s4 = -5
    for j in range(3):
        b1 = 12
        b2 = 0
        b3 = 25
        b4 = 5
        b5 = 20
        s1 = s1 + 35
        s2 = s2 + 35
        s3 = s3 + 35
        s4 = s4 + 35
        for i in range(4):
            triangle = Polygon(Point(start.getX()+b1,start.getY()+s1),\
            line = Line(Point(start.getX()+b1,start.getY()+s2),\
            boat = Polygon(Point(start.getX()+b2,start.getY()+s3),\
            b1 = b1 + 25
            b2 = b2 + 25
            b3 = b3 + 25
            b4 = b4 + 25
            b5 = b5 + 25

I would like to rewrite it but with less variables. I cant think any other way. Is like my mind stuck with that way. I asked my teacher but he told me that If I use that Im gonna lose marks. Ι'm in a real cleft stick!

I'm guessing the problem is the redundant calls to getX() and getY(). You do the exact same things 10 times for each boat drawn. That means 120 calls for the 12 boats. Move the call outside the for loops and store the values in variables. Also, the relationship between the "b" variables is constant so you only need one, i.e. instead of b2 you can use b1-12. And similar for the "s" variables. I originally though that perhaps you were supposed to use clone and move, but that wouldn't save anything and may even consume more computer resources.

Thanks for you reply, I will try that with variables b and s. But I didn't get that:

Move the call outside the for loops and store the values in variables

What you mean by that?
Thank you

Solved, Thank you woooee!

I don't know how to answer your question without knowing what you have tried so far.

Doesnt matter any more, I read your reply again curfully and I understand you ment. I think my project is done. I just sent it to my teacher for a review and give me his reccomendations.
If I get positive feedback, I'll submit it.
Thank you guys for your help, especially you woooee!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.