Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 30th, 2012, 05:54 AM
noskiw noskiw is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 18 noskiw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 30 m 46 sec
Reputation Power: 0
"GraphWin Object is not callable"

When I a section of code into a new function, it comes up with "GraphWin Object is not callable"

This is my whole code

Code:
from graphics import *
import urllib.request, re

def LoginScreen():
    LoginScreen = GraphWin("Login",300,100)
    file = open("users.csv","r")
    readfile = file.read()
    UsernameLabel = Text(Point(45,25),"Username: ")
    UsernameLabel.draw(LoginScreen)
    UsernameText = Entry(Point(158,25),16)
    UsernameText.draw(LoginScreen)
    username = ''
    LoginScreen.getMouse()
    LoginScreen.close()

def RegisterScreen():
    RegisterScreen = GraphWin("Register",300,150)
    UsernameRegLabel = Text(Point(45,25),"Username: ")
    UsernameRegLabel.draw(RegisterScreen)
    UsernameRegText = Entry(Point(175,25),20)
    UsernameRegText.draw(RegisterScreen)
    PasswordRegLabel = Text(Point(45,50),"Password: ")
    PasswordRegLabel.draw(RegisterScreen)
    PasswordRegText = Entry(Point(175,50),20)
    PasswordRegText.draw(RegisterScreen)
    PasswordConfRegLabel = Text(Point(52,75),"Confirm: ")
    PasswordConfRegLabel.draw(RegisterScreen)
    PasswordConfRegText = Entry(Point(175,75),20)
    PasswordConfRegText.draw(RegisterScreen)
    EmailRegLabel = Text(Point(60,100),"Email: ")
    EmailRegLabel.draw(RegisterScreen)
    EmailRegText = Entry(Point(175,100),20)
    EmailRegText.draw(RegisterScreen)
    SubmitButton = Rectangle(Point(195,115),Point(265,140))
    SubmitButton.draw(RegisterScreen)
    SubmitButtonText = Text(Point(230,128),"Submit")
    SubmitButtonText.draw(RegisterScreen)
    CloseButton = Rectangle(Point(115,115),Point(185,140))
    CloseButton.draw(RegisterScreen)
    CloseButtonText = Text(Point(150,128),"Close")
    CloseButtonText.draw(RegisterScreen)

def GetMouseRegistration():
    MouseRegScreen = RegisterScreen.getMouse()
    RegScreenX = MouseRegScreen.getX()
    RegScreenY = MouseRegScreen.getY()

    if RegScreenX>=195 and RegScreenX<=265:
        if RegScreenY>=115 and RegScreenY<=140:
            ProcessRegister()
    elif RegScreenX>=115 and RegScreenX<=185:
        if RegScreenY>=115 and RegScreenY<=140:
            RegisterScreen.close()

def ValidateRegistration():
    return

def ProcessRegister():
    ValidateRegistration()

def GetMouse():
    MouseMainScreen = MainWin.getMouse()
    MainScreenX = MouseMainScreen.getX()
    MainScreenY = MouseMainScreen.getY()
    
    if MainScreenX>=197 and MainScreenX<=260:
        if MainScreenY>=230 and MainScreenY<=250:
            LoginScreen()
    if MainScreenX>=197 and MainScreenX<=297:
        if MainScreenY>=260 and MainScreenY<=285:
            RegisterScreen()
    
def DrawBackground():
    return
    
def DrawMenuItems():
    Main = Text(Point(300,200),"Main Menu")
    Main.setSize(32)
    Main.draw(MainWin)
    Login = Text(Point(228,240),"Login")
    Login.setSize(20)
    Login.draw(MainWin)
    Register = Text(Point(245,270),"Register")
    Register.setSize(20)
    Register.draw(MainWin)

MainWin = GraphWin("Fantasy Football",600,600)

DrawBackground()
DrawMenuItems()
while True:
    GetMouse()


This is the original code that I'm changing

Code:
def RegisterScreen():
    RegisterScreen = GraphWin("Register",300,150)
    UsernameRegLabel = Text(Point(45,25),"Username: ")
    UsernameRegLabel.draw(RegisterScreen)
    UsernameRegText = Entry(Point(175,25),20)
    UsernameRegText.draw(RegisterScreen)
    PasswordRegLabel = Text(Point(45,50),"Password: ")
    PasswordRegLabel.draw(RegisterScreen)
    PasswordRegText = Entry(Point(175,50),20)
    PasswordRegText.draw(RegisterScreen)
    PasswordConfRegLabel = Text(Point(52,75),"Confirm: ")
    PasswordConfRegLabel.draw(RegisterScreen)
    PasswordConfRegText = Entry(Point(175,75),20)
    PasswordConfRegText.draw(RegisterScreen)
    EmailRegLabel = Text(Point(60,100),"Email: ")
    EmailRegLabel.draw(RegisterScreen)
    EmailRegText = Entry(Point(175,100),20)
    EmailRegText.draw(RegisterScreen)
    SubmitButton = Rectangle(Point(195,115),Point(265,140))
    SubmitButton.draw(RegisterScreen)
    SubmitButtonText = Text(Point(230,128),"Submit")
    SubmitButtonText.draw(RegisterScreen)
    CloseButton = Rectangle(Point(115,115),Point(185,140))
    CloseButton.draw(RegisterScreen)
    CloseButtonText = Text(Point(150,128),"Close")
    CloseButtonText.draw(RegisterScreen)

    MouseRegScreen = RegisterScreen.getMouse()
    RegScreenX = MouseRegScreen.getX()
    RegScreenY = MouseRegScreen.getY()

    if RegScreenX>=195 and RegScreenX<=265:
        if RegScreenY>=115 and RegScreenY<=140:
            ProcessRegister()
    elif RegScreenX>=115 and RegScreenX<=185:
        if RegScreenY>=115 and RegScreenY<=140:
            RegisterScreen.close()


The last section I want to take out and put in another function like this.

Code:
def GetMouseRegistration():
    MouseRegScreen = RegisterScreen.getMouse()
    RegScreenX = MouseRegScreen.getX()
    RegScreenY = MouseRegScreen.getY()

    if RegScreenX>=195 and RegScreenX<=265:
        if RegScreenY>=115 and RegScreenY<=140:
            ProcessRegister()
    elif RegScreenX>=115 and RegScreenX<=185:
        if RegScreenY>=115 and RegScreenY<=140:
            RegisterScreen.close()


I've tried making the RegisterScreen Window a global variable, but that's when it says it isn't callable.

I'm also having a problem when the user clicks on the x in the top right corner to close it, is there any way to stop the error from crashing the program?

Reply With Quote
  #2  
Old November 30th, 2012, 06:49 AM
Marcurion Marcurion is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 3 Marcurion User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 5 m 41 sec
Reputation Power: 0
You should use inheritance to create two classes(LoginScreenC, RegisterScreenC) that are derived from GraphWin, in these classes you can overwrite the GetMouse function.
Then you can create:

MainWin = LoginScreenC("Fantasy Football",600,600)

and in your RegisterScreen() function change:

RegisterScreen = RegisterScreenC("Register",300,150)

and append to the end of this function:

RegisterScreen.getMouse()
RegisterScreen.close()

Obviously you have to overwrite the getMouse functions in the two classes to fit your buttonsizes and needs

But why do you want to put this in a extra function anyway, this seems to work just fine:

Code:
def RegisterScreen():
    RegisterScreen = GraphWin("Register",300,150)
    UsernameRegLabel = Text(Point(45,25),"Username: ")
    UsernameRegLabel.draw(RegisterScreen)
    UsernameRegText = Entry(Point(175,25),20)
    UsernameRegText.draw(RegisterScreen)
    PasswordRegLabel = Text(Point(45,50),"Password: ")
    PasswordRegLabel.draw(RegisterScreen)
    PasswordRegText = Entry(Point(175,50),20)
    PasswordRegText.draw(RegisterScreen)
    PasswordConfRegLabel = Text(Point(52,75),"Confirm: ")
    PasswordConfRegLabel.draw(RegisterScreen)
    PasswordConfRegText = Entry(Point(175,75),20)
    PasswordConfRegText.draw(RegisterScreen)
    EmailRegLabel = Text(Point(60,100),"Email: ")
    EmailRegLabel.draw(RegisterScreen)
    EmailRegText = Entry(Point(175,100),20)
    EmailRegText.draw(RegisterScreen)
    SubmitButton = Rectangle(Point(195,115),Point(265,140))
    SubmitButton.draw(RegisterScreen)
    SubmitButtonText = Text(Point(230,128),"Submit")
    SubmitButtonText.draw(RegisterScreen)
    CloseButton = Rectangle(Point(115,115),Point(185,140))
    CloseButton.draw(RegisterScreen)
    CloseButtonText = Text(Point(150,128),"Close")
    CloseButtonText.draw(RegisterScreen)
    MouseRegScreen = RegisterScreen.getMouse()
    RegScreenX = MouseRegScreen.getX()
    RegScreenY = MouseRegScreen.getY()

    if RegScreenX>=195 and RegScreenX<=265:
        if RegScreenY>=115 and RegScreenY<=140:
            ProcessRegister()
    elif RegScreenX>=115 and RegScreenX<=185:
        if RegScreenY>=115 and RegScreenY<=140:
            RegisterScreen.close()


Regards,
Marcurion

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > "GraphWin Object is not callable"

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap