Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

TkInter: execute whole script at once problem

TkInter: execute whole script at once problem

TkInter: execute whole script at once problem


I'm having serious problems using tkInter. Everything went fine when I was still using the pack method. Now, after I have switched to the grid method, a problem has come up. No matter what I try, the whole script is executed at once. And I don't want that.

The idea is that you select some options in step one, click continue, and step two pops up. No matter what I try, step two immediatly pops up at startup.

Here's my script:


import random
from Tkinter import *

class Startup:

    def __init__(self, master):

        frame = Frame(master,bg="Gray")

        self.root = master
        self.master = master

        self.stepo = Label(frame,text="Step 1.",font=(15),bg="Gray",relief=RAISED,bd=3,fg="Red")

        self.setuplab = Label(frame,text="Setup players and games",font=(15),relief=GROOVE,bd=1,justify=LEFT,bg="Gray")

        self.playslide = Scale(frame, from_=2, to=10, orient=HORIZONTAL,bg="Gray",troughcolor="Gray")

        self.playlab = Label(frame,text="Players.",bg="Gray")

        self.egames = Entry(frame)

        self.gamelab = Label(frame,text="Games.",bg="Gray")

        self.setuplab = Label(frame,text="Setup profiles select type",font=(15),relief=GROOVE,bd=1,justify=LEFT,bg="Gray")

        profpick = 0
        self.rad1 = Radiobutton(frame, text="Randomly", variable=profpick, value=1,bg="Gray",highlightcolor="Gray")
        self.rad2 = Radiobutton(frame, text="Manual", variable=profpick, value=2,bg="Gray",highlightcolor="Gray")
        self.rad3 = Radiobutton(frame, text="Standard set", variable=profpick, value=3,bg="Gray",highlightcolor="Gray")

        self.steptwo = Button(frame,text="Go to step 2",command=self.cont(),bg="Gray")

    def cont(self):

        games = self.egames.get()
        players = self.playslide.get()

        app = StepT(root)

class StepT():

    def __init__ (self,master):

        frame = Frame(master,bg="Gray")

        self.stepi = Label(frame,text="Step 2.",font=(15),bg="Gray",relief=RAISED,bd=3,fg="Red")

root = Tk()
app = Startup(root)
app.master.title("Dis Astro's Poker Simulator")

What I have tried: pass the profpick int to the cont function, and check if it is not 0. However, no matter what I tried, nothing happened.

I hope somebody can help me!

RE: TkInter: execute whole script at once problem


try to run you script from command line console.
If you use windows, then click at Start/Run.., type in
then change to your directory where your script sits and type:

python your_script.py

Then you get such an error


  File "D:\Analyza\Python\pok.py", line 53
    class StepT():

This means that you typed by mistake the parentheses (). In the class definition the parentheses are only used, when the class is inherited and then in the parentheses the parrent class is placed

so correct


class StepT():

by deleting of ()to


class StepT:
and your script will be running.

RE: TkInter: execute whole script at once problem

Thanks for that, but it doesn't fix my problem. My script still runs in a faulty way. I don't want StepT to execute untill you press the "Go to Step 2" button. However, no matter what I do, StepT is executed immediatly on startup, or not at all. This behaivour remains unchanged, even after fixing the () on StepT.

I really hope someone call help me... ???

RE: TkInter: execute whole script at once problem

comand -function will be written without parentheses
so correct


self.steptwo =
Button(frame,text="Go to step 2",command=self.cont(),bg="Gray")


self.steptwo =
Button(frame,text="Go to step2",command=self.cont,bg="Gray")
Is this what you want?

RE: TkInter: execute whole script at once problem

That fixed it. Thank you very, very much!!!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close