当前位置: 首页>>代码示例>>Python>>正文


Python Tk.winfo_pointerx方法代码示例

本文整理汇总了Python中Tkinter.Tk.winfo_pointerx方法的典型用法代码示例。如果您正苦于以下问题:Python Tk.winfo_pointerx方法的具体用法?Python Tk.winfo_pointerx怎么用?Python Tk.winfo_pointerx使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tkinter.Tk的用法示例。


在下文中一共展示了Tk.winfo_pointerx方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import winfo_pointerx [as 别名]
class GUIHandler:

    screenwidth = 0
    screenheight = 0
    windowwidth = 0
    windowheight = 0

    ## Initializes the GUI setup of the program.
    #
    def __init__(self,game):

        assert type(game) is Game
        self.root = Tk()
        self.root.title('SET')
        self.root.resizable(0,0)
        self.root.withdraw()
        GUIHandler.screenwidth = self.root.winfo_screenwidth()
        GUIHandler.screenheight = self.root.winfo_screenheight()
        if GUIHandler.screenwidth < 1024 or GUIHandler.screenheight < 768:
            showerror("Resolution Error","Your screen's resolution is likely not the best choice to run this game. Minimum resolution for this game is at least 1024x768.")
            raise ResolutionError(GUIHandler.screenwidth,GUIHandler.screenheight)
        GUIHandler.windowwidth = GUIHandler.screenwidth // 3
        GUIHandler.windowheight = GUIHandler.screenheight // 1.5
        self.buttonField = None
        self.checkButtonField = None
        self.Game = game
        self.Field = game.field
        assert self.Game
        assert self.Field

        self.root.geometry('%dx%d+%d+%d' % (GUIHandler.windowwidth,
                                          GUIHandler.windowheight,
                                          self.root.winfo_screenwidth()/8,
                                          self.root.winfo_screenheight()/8))

        menu = Menu(self.root)

        gamemenu = Menu(menu,tearoff=0)
        gamemenu.add_command(label='New Game',command=lambda:self.startNewGame(),accelerator="F2")
        gamemenu.add_command(label='Leaderboards',command=lambda:showinfo("Not implemented","Feature not implemented...yet."))
        gamemenu.add_command(label='Exit',command=lambda:self.root.destroy(),accelerator="Alt-F4")

        menu.add_cascade(label='Game',menu=gamemenu)

        settingmenu = Menu(menu,tearoff=0)

        gamedifficulty = Menu(settingmenu,tearoff=0)
        gamedifficulty.add_radiobutton(label='Beginner',command=lambda :self.changeGameDifficulty(Difficulty.BEGINNER),accelerator="B")
        gamedifficulty.add_radiobutton(label='Novice',command=lambda :self.changeGameDifficulty(Difficulty.NOVICE),accelerator="N")
        gamedifficulty.add_radiobutton(label='Advanced',command=lambda :self.changeGameDifficulty(Difficulty.ADVANCED),accelerator="A")

        settingmenu.add_cascade(label='Game Difficulty',menu=gamedifficulty)

        timedmode = Menu(settingmenu,tearoff=0)
        timedmode.add_radiobutton(label='On',command=lambda:showinfo("Not implemented","Feature not implemented...yet."))
        timedmode.add_radiobutton(label='Off',command=lambda:showinfo("Not implemented","Feature not implemented...yet."))
        
        settingmenu.add_cascade(label='Timed Mode',menu=timedmode)

        timeddifficulty = Menu(settingmenu,tearoff=0)
        timeddifficulty.add_radiobutton(label='Easy',accelerator="E")
        timeddifficulty.add_radiobutton(label='Medium',accelerator="M")
        timeddifficulty.add_radiobutton(label='Hard',accelerator="H")

        settingmenu.add_cascade(label='Timed Difficulty',menu=timeddifficulty)
        menu.add_cascade(label='Settings',menu=settingmenu)

        helpmenu = Menu(menu,tearoff=0)
        helpmenu.add_command(label='About SET',command=lambda:showinfo("Not implemented","Feature not implemented...yet."))

        menu.add_cascade(label='Help',menu=helpmenu)

        self.root.config(menu=menu)

        self.root.bind('<F2>',lambda e:gamemenu.invoke(0))
        self.root.bind('L',lambda e:gamemenu.invoke(1))
        self.root.bind('<Alt-F4>',lambda e:gamemenu.invoke(2))
        self.root.bind('b',lambda e:gamedifficulty.invoke(Difficulty.BEGINNER))
        self.root.bind('n',lambda e:gamedifficulty.invoke(Difficulty.NOVICE))
        self.root.bind('a',lambda e:gamedifficulty.invoke(Difficulty.ADVANCED))

        self.remainderLabel = Label(self.root,text="There are %d set(s) remaining on the board." % self.Game.numSetsRemaining(),bg="white",relief=Tkinter.RAISED,font=('Helvetica',12))
        self.remainderLabel.place(x=(GUIHandler.windowwidth-self.remainderLabel.winfo_reqwidth())//2,y=3*GUIHandler.windowheight//4)

        timer = Label(self.root,text="Untimed Mode",bg="green",relief=Tkinter.RAISED,font=('Helvetica',12))
        timer.place(x=(GUIHandler.windowwidth-timer.winfo_reqwidth())//2,y=3*GUIHandler.windowheight//4.5)

        hintbutton = Button(text="Hint, please!",font=("Helvetica",12),command=lambda :self.getHint())
        hintbutton.place(x=(GUIHandler.windowwidth-hintbutton.winfo_reqwidth())//2,y=3*GUIHandler.windowheight//3.5)

        self.userSetsCreated = Toplevel(self.root)
        self.userSetsHeight = 0
        self.userSetsCreated.title("Sets Created")
        self.userSetsCreated.geometry("%dx%d+%d+%d" % (Card.pixelWidth*3,
                                               self.userSetsCreated.winfo_screenheight(),
                                               self.root.winfo_pointerx()+self.userSetsCreated.winfo_reqwidth(),0))
        self.userSetsCreated.protocol("WM_DELETE_WINDOW",0)
        self.userSetsCreated.resizable(0,0)
        self.root.focus_set()

#.........这里部分代码省略.........
开发者ID:rishidewan33,项目名称:SET,代码行数:103,代码来源:GUIHandler.py


注:本文中的Tkinter.Tk.winfo_pointerx方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。