在checkmouse遇到麻烦

时间:2018-03-29 06:26:47

标签: python python-3.x

当在特定对象(矩形)内点击鼠标时,我无法弄清楚如何取出某些内容。我希望代码的工作方式是当我点击矩形时它会删除文本(因为我必须绘制其他东西)。

我的教授不喜欢我们导入一堆不同的库等,所以一个简单的方法是首选。 我们在Zelle中使用的图形库可以在这里找到: http://mcsp.wartburg.edu/zelle/python/graphics.py

这是我现在的代码。

#... is a game to celebrate the 150th anniversay of ...
#The aim of the game is for players to complete a maze , but only
#with the least number of moves possible, and crossing the least number of
#trip wires. BoilerMazer keeps track of the names, moves, and scores. Then
#will also display the top players and scores.

from graphics import *

#creating the game panel window
def panel():
    #grey window, with coordinates flipped, with banners etc
    win = GraphWin("Start Panel", 300,200)
    win.setCoords(0,0,300,200)
    win.setBackground("light grey")
    #drawing the BoilerMazer banner with text
    boilermazer = Rectangle(Point(0,200),Point(300,160))
    boilermazer.setFill("white")
    boilermazer.draw(win)
    #text inside
    banner1 = Text(Point(150,180),"BoilerMazer")
    banner1.setStyle("bold")
    banner1.setSize(20)
    banner1.draw(win)
    #initial game panel is going to have two buttons and a top scores object
    #top score "screen"
    toprec = Rectangle(Point(60,140),Point(240,50))
    toprec.setFill("white")
    toprec.draw(win)
    #text inside toprec
    topscores = Text(Point(150,130),"TOP SCORES")
    topscores.setSize(8)
    topscores.draw(win)
    border = Text(Point(150,120),"======")
    border.draw(win)
    bigmac = Text(Point(150,110),"Big Mac     21")
    bigmac.setSize(8)
    bigmac.draw(win)
    tt = Text(Point(150,90),"T.T     23")
    tt.setSize(8)
    tt.draw(win)
    cshell = Text(Point(150,75),"C-Shell     25")
    cshell.setSize(8)
    cshell.draw(win)
    macmac = Text(Point(150,55),"MacMac     27")
    macmac.setSize(8)
    macmac.draw(win)
    #new player button that will eventually be clicked
    new1 = Point(90,35)
    new2 = Point(210,0)
    newrec = Rectangle(new1,new2)
    newrec.setFill("chartreuse2")
    newrec.draw(win)
    #new player button text
    newplayer = Text(Point(150,18),"NEW PLAYER")
    newplayer.draw(win)
    #reset button
    resetrec = Rectangle(Point(240,35),Point(300,0))
    resetrec.setFill("red")
    resetrec.draw(win)
    #resettext
    reset = Text(Point(270,18),"RESET")
    reset.draw(win)
    #secondary panel window is the game panel after they click new player
    clicknew = win.checkMouse()




#defining the main function that will hold and call all other functions
def main():
    #calling the panel function that draws the window
    panel()


main()

0 个答案:

没有答案
相关问题