zoukankan      html  css  js  c++  java
  • Python的TkinterButton做为父窗口

    #-*-coding:utf-8-*-
    import Tkinter,time,tkMessageBox,sys,BeBigModule
    class MainFrame:
        def __init__(self,father):
            self.frame=Tkinter.Frame(father)
            self.frame.pack()
            
            self.entryWorkWidget=Tkinter.Entry(self.frame)
            self.entryWorkWidget["width"]=35                 #这句话和下句话的先后顺序不会影响程序
            self.entryWorkWidget.pack(side='top')
            
            self.entryRelaxWidget=Tkinter.Entry(self.frame)
            self.entryRelaxWidget.config(width=35)
            self.entryRelaxWidget.pack(side='top')
            
            self.startButton=Tkinter.Button(self.frame,text="OK",command=self.start)
            self.startButton.pack(side='left')
            
            self.quitButton=Tkinter.Button(self.frame,text="Exit",command=self.quit)
            self.quitButton.pack(side='right')
    #         self.frame.mainloop()
        def start(self):
            workTime=self.entryWorkWidget.get().strip()
            workTimeNum=int(workTime)   
            self.frame.destroy()     
            beBigFrame=BeBigModule.BeBig(workTimeNum)
            print'success'
        def quit(self):
            pass
    # root=Tkinter.Tk()
    # root.title("CountDowm")
    # 
    # mainFrame=MainFrame(root)
    # root.mainloop()
    abutton=Tkinter.Button()
    abutton.pack()
    mainFrame=MainFrame(abutton)
    abutton.mainloop()

    好玩吧,Button成了Frame的父窗口。

  • 相关阅读:
    29. Divide Two Integers
    leetCode 17. Letter Combinations of a Phone Number
    查找
    快速排序
    希尔排序
    插入排序
    归并排序,还有非递归方式没写
    堆排序--还有递归法没有写
    c++实现字符串全排序
    归并排序
  • 原文地址:https://www.cnblogs.com/wangjiyuan/p/pythonbutton.html
Copyright © 2011-2022 走看看