[Tutor] two windows

EUGENE ASTLEY erastley at charter.net
Fri May 27 19:30:26 CEST 2005


I asked for help on my problem but unfortunately now help yet. I am
trying to put up instructions for a board game and then have the person
read and then proceed onto the game. The following is what I have that
displays the instructions just fine but will not let the game proceed on
to the board and the game.:
The instruction section works fine and the game part works fine but not
together. I guess I need the widget to have a button that allows the
reader to proceed.
Appreciate help as I am just learning. I am thinking that the widget
doesn't qualify as a screen.
Gene
 
 
import random, math
from livewires import games, color
from Tkinter import *
 
SCREEN_WIDTH = 1280
SCREEN_HEIGHT = 768
THE_SCREEN = games.Screen(SCREEN_WIDTH, SCREEN_HEIGHT)
 
class Application(Frame):
       def __init__(self, master):
        """ Initialize the frame. """
        Frame.__init__(self, master)
        self.grid()
        self.create_widgets()
 
    def create_widgets(self):
        """ Create button, text, and entry widgets. """
        # create instruction label
        self.inst_lbl = Label(self, text = "Enter your Name, please")
        self.inst_lbl.grid(row = 0, column = 0, columnspan = 2, sticky =
W)
 
        # create label for name input      
        self.pw_lbl = Label(self, text = "Name: ")
        self.pw_lbl.grid(row = 1, column = 0, sticky = W)
                # create entry widget to accept name      
        self.pw_ent = Entry(self)
        self.pw_ent.grid(row = 1, column = 1, sticky = W)
 
        # create submit button
        self.submit_bttn = Button(self, text = "Submit", command =
self.reveal)
        self.submit_bttn.grid(row = 2, column = 0, sticky = W)
 
        # create text widget to display message
        self.instruction_txt = Text(self, width = 65, height = 30, wrap
= WORD)
        self.instruction_txt.grid(row = 3, column = 0, columnspan = 3,
sticky = W)
 
    def reveal(self):
        """ Display message based on name. """
        contents = self.pw_ent.get()
        if contents == "Joe":
            message = """
                         The rules of the game are: etc. etc.       
                       """
        else:
            message = "That's not your first name, try again!" 
                      
        self.instruction_txt.delete(0.0, END)
        self.instruction_txt.insert(0.0, message)
        
            
          
# main
root = Tk()
root.title("Name")
root.geometry("1280x768")
app = Application(root)
 
my_screen = THE_SCREEN
wall_image = games.load_image("board.jpg", transparent = False)
my_screen.set_background(board_image)
etc. etc.
 
my_screen.mainloop()
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20050527/dc45b04c/attachment-0001.html


More information about the Tutor mailing list