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


Python Tk.__init__方法代码示例

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


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

示例1: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import __init__ [as 别名]
 def __init__(self, menu):
     Tk.__init__(self)
     
     self.title("Pick a level")
     
     icon = PhotoImage(file=os.getcwd() + '/res/logo/logo.gif')
     self.tk.call("wm", "iconphoto", self._w, icon)
     
     self.eval('tk::PlaceWindow %s center' % self.winfo_pathname(self.winfo_id()))
     
     self.levels = [file[:-4] for file in listdir("res/levels")]
     self.protocol("WM_DELETE_WINDOW", self.shutdownTTK)
     
     if not self.levels:  # No levels
         self.withdraw()
         tkMessageBox.showwarning("Error", 'There doesn\'t seem to be any levels saved. Create one pressing the "Design Level" button!')
         self.shutdownTTK()
         
     else:
         self.menu = menu
         
         self.value = StringVar()
         self.levels_list = Combobox(self, textvariable=self.value, state='readonly')
         
         self.levels_list['values'] = self.levels
         self.levels_list.current(0)
         self.levels_list.grid(column=0, row=0)
         
         self.button = Button(self, text="Begin Level", command=self.begin_level)
         self.button.grid(column=0, row=1)
         self.mainloop()
开发者ID:Vicyorus,项目名称:BattleTank,代码行数:33,代码来源:Menu.py

示例2: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import __init__ [as 别名]
 def __init__(self, clb=None):
     Tk.__init__(self)
     self.title('Калькулятор танков     ===build. 009===')
     self.minsize(320, 240)
     self.frmButton = clsFrmButton(root=self)
     self.frmLeft = clsFrmLeft(root=self, clb=clb)
     self.frmRight = clsFrmRight(root=self, clb=clb)
开发者ID:prospero78,项目名称:pyPC,代码行数:9,代码来源:modWinMain.py

示例3: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import __init__ [as 别名]
 def __init__(self):
     Tk.__init__(self)
     self.title("Speed Reader")
     main_frame = MainFrame(master=self)
     self.grid_columnconfigure(0, weight=1)
     self.grid_rowconfigure(0, weight=1)
     main_frame.grid(padx=50, pady=50, sticky=(N, S, E, W))
开发者ID:DeadlyApps,项目名称:SpeedReader,代码行数:9,代码来源:SpeedReaderController.py

示例4: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import __init__ [as 别名]
    def __init__(self, namespace):
        Tk.__init__(self, className="Koshka")

        self.dac = DAC()
        self.dac.start()

        self.score_path = namespace.score

        self.sequencer = None
        self.sequencer_frame = None
        self.mixer_window = None
        self.scale_window = None
        self._open_score(self.score_path)

        menu = Menu(self)
        self.config(menu=menu)
        filemenu = Menu(menu)
        menu.add_cascade(label="File", menu=filemenu)
        filemenu.add_command(label="Open...", command=self.open, accelerator="meta-o")
        filemenu.add_command(label="Save", command=self.save, accelerator="meta-s")
        filemenu.add_command(label="Save As...", command=self.save_as, accelerator="meta-shift-s")
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=self.quit)

        menu.add_cascade(label="Help", menu=filemenu)
        filemenu.add_command(label="Online Help...", command=lambda: webbrowser.open_new_tab(URL_HELP_DOC))

        # Note: This is only implemented and tested for Mac OS
        self.bind_all("<Command-o>", self.open)
        self.bind_all("<Command-s>", self.save)
        self.bind_all("<Command-Shift-s>", self.save_as)
        self.bind_all("<Meta-o>", self.open)
        self.bind_all("<Meta-s>", self.save)
        self.bind_all("<Meta-Shift-s>", self.save_as)
开发者ID:ladsmund,项目名称:msp_group_project,代码行数:36,代码来源:main_window.py

示例5: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import __init__ [as 别名]
    def __init__(self):

        Tk.__init__(self)

        self.geometry('%dx%d+500+500' % (WIDTH,HEIGHT))
        self.title('GooMPy')

        self.canvas = Canvas(self, width=WIDTH, height=HEIGHT)

        self.canvas.pack()

        self.bind("<Key>", self.check_quit)
        self.bind('<B1-Motion>', self.drag)
        self.bind('<Button-1>', self.click)

        self.label = Label(self.canvas)

        self.radiogroup = Frame(self.canvas)
        self.radiovar = IntVar()
        self.maptypes = ['OSM', 'GoogleSatellite', 'Satellite']
        self.add_radio_button('OSM',  0)
        self.add_radio_button('GoogleSatellite', 1)
        self.add_radio_button('Satellite',    2)

        self.zoom_in_button  = self.add_zoom_button('+', +1)
        self.zoom_out_button = self.add_zoom_button('-', -1)

        self.zoomlevel = ZOOM

        maptype_index = 0
        self.radiovar.set(maptype_index)

        self.goompy = GooMPy(WIDTH, HEIGHT, LATITUDE, LONGITUDE, ZOOM, MAPTYPE)

        self.restart()
开发者ID:victorgau,项目名称:GooMPy-Modified,代码行数:37,代码来源:example.py

示例6: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import __init__ [as 别名]
    def __init__(self, *args, **kwargs):
        Tk.__init__(self, *args, **kwargs)
        self.geometry("550x550+450+150")
        # the container is where we'll stack a bunch of frames
        # on top of each other, then the one we want visible
        # will be raised above the others
        container = Frame(self)
        container.pack(side="top", fill="both", expand=True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)
        
        self.protocol('WM_DELETE_WINDOW', self.leaveCallback)  # root is your root window

        self.frames = {}
        for F in (StartPage, AboutPage, CreateServer, FindServer, ChooseType, GameWindow):
            page_name = F.__name__
            frame = F(container, self)
            self.frames[page_name] = frame

            # put all of the pages in the same location;
            # the one on the top of the stacking order
            # will be the one that is visible.
            frame.grid(row=0, column=0, sticky="nsew")

        self.show_frame("StartPage")
开发者ID:kristapsdreija,项目名称:Frogs-vs-Flies,代码行数:27,代码来源:tkinter_main.py

示例7: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import __init__ [as 别名]
    def __init__(self,filename=None,block=50,debug=True,delay=0.25,image=False,width=10,height=10):
#    def __init__(self,filename=None,block=50,debug=True,delay=0.25,image=True,width=10,height=10):
        Tk.__init__(self)
        self.title("")
        arg, self.width, self.height = block, width, height
#        self.photos = [PhotoImage(file=(k+".gif")) for k in ["east","north","west","south"]]
        self.beepers, self.ovals, self.numbers, self.robots, self.walls = {},{},{},{},{}
        self.m, self.n, self.t, self.delay = arg*(width+3), arg*(height+3), arg, delay
        self.debug, self.useImage = debug, image
        a, b, c = self.t+self.t/2, self.m-self.t-self.t/2, self.n-self.t-self.t/2
        self.canvas = Canvas(self, bg="white", width=self.m, height=self.n)
        self.canvas.pack()
        count = 1
        for k in range(2*self.t, max(self.m,self.n)-self.t, self.t):
            if k < b: 
                self.canvas.create_line(k, c, k, a, fill="red")
                self.canvas.create_text(k, c+self.t/2, text=str(count), font=("Times",max(-self.t*2/3,-15),""))
            if k < c: 
                self.canvas.create_line(b, k, a, k, fill="red")
                self.canvas.create_text(a-self.t/2, self.n-k, text=str(count), font=("Times",max(-self.t*2/3,-15),""))
            count += 1
        self.canvas.create_line(a, c, b, c, fill="black", width=3)
        self.canvas.create_line(a, a, a, c, fill="black", width=3)
        if filename is not None:
            self.readWorld(filename)
        self.refresh()
开发者ID:supercavitation,项目名称:Compsci,代码行数:28,代码来源:robotworld.py

示例8: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import __init__ [as 别名]
    def __init__(self, input):
        Tk.__init__(self)
        self.input = input

        if sys.platform == "win32":
            self.iconbitmap(bitmap=settings.mainicon)
        else:
            img = ImageTk.PhotoImage(master=self, file=settings.mainicon)
            self.tk.call('wm', 'iconphoto', self._w, img)
        self.resizable(width=FALSE, height=FALSE)

        self.end = None
        self.serialized = dict()

        self.title('Download.am')

        self.ok_element = None
        self.cancel_element = None

        self.bind('<Return>', lambda event: self.unbound_ok())
        self.bind('<Escape>', lambda event: self.unbound_cancel())
        if input.close_aborts:
            self.protocol("WM_DELETE_WINDOW", self.unbound_cancel)
        else:
            self.protocol("WM_DELETE_WINDOW", self.destroy)

        ctx = Context(self, self, input.elements)
        ctx.frame.pack()

        self.wm_attributes("-topmost", 1)
        self.focus_force()
开发者ID:MoroGasper,项目名称:client,代码行数:33,代码来源:input.py

示例9: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import __init__ [as 别名]
    def __init__(self):
        Tk.__init__(self)
        self.geometry('400x400')
        self.resizable(0,0)

        # game screen
        self.canvas = Canvas(self, bg='black', width=400, height=400)
        self.canvas.pack(expand=1, fill=BOTH)

        # ball
        self._initiate_new_ball()

        # paddle
        self.canvas.create_rectangle(175,375,225,385, fill='black',
                                     outline='white', tags='paddle')
        self.bind('<Key>', self._move_paddle)

        # bricks
        self.bricks = {}
        brick_coords = [5,5,35,15]
        for i in range(39):
            self.canvas.create_rectangle(*brick_coords, outline='white',
                                         fill=('#{}'.format(randint(100000,999999))),
                                         tags='brick' + str(i))
            self.bricks['brick' + str(i)] = None
            brick_coords[0] += 30; brick_coords[2] += 30
            if brick_coords[2] > 395:
                brick_coords[0] = 5; brick_coords[2] = 35
                brick_coords[1] += 10; brick_coords[3] += 10
开发者ID:petemojeiko,项目名称:tkinter-breakout,代码行数:31,代码来源:tkbreakout.py

示例10: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import __init__ [as 别名]
 def __init__(self):
     #Creating main window. And initializing components
     Tk.__init__(self)
     f = Frame(self, width=400, height=200)
     f.pack(expand=True)
     #Blank labels are added to make window alignment  better
     Label(f,text="").grid(row=0)
     #Blank labels are added to make window alignment  better
     Label(f,text="  ").grid(row=1,column=0)
     #Add label fileName
     Label(f,text="File Name").grid(row=1,column=1)
     #Adding text box
     self.textbox1=Entry(f,width=20)
     self.textbox1.grid(row=1,column=2)
     #Adding file Browse button. Set its even handler as openFileBrowser()
     Button(f,text="Choose File",command=self.openFileBrowser).grid(row=1,column=3)
     #Blank labels are added to make window alignment  better
     Label(f,text="  ").grid(row=1,column=4)
     #Blank labels are added to make window alignment  better
     Label(f,text="").grid(row=2)
     #Adding Summarize button. Set its even handler as summarize()
     Button(f,text="Summarize",command=self.summarize).grid(row=3,column=2)
     #Adding frame to window
     f.pack_propagate(0)
     #Set window title
     self.title("Auto Text Summarizer")
     self.mainloop()
开发者ID:VivekProHacker,项目名称:AutoTextSummerizer,代码行数:29,代码来源:Window.py

示例11: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import __init__ [as 别名]
    def __init__(self):
        Tk.__init__(self)
        self.title('socket tools in *nix')

        #Frame setting
        top_mbar = self.winfo_toplevel()

        frame_left = Frame(self)
        frame_right_top = Frame(self)
        frame_right_center = Frame(self)
        frame_right_bottom = Frame(self, height=40)

        #menu
        mbFile = Menu(top_mbar)
        top_mbar['menu'] = mbFile
        mbFile.subMenu = Menu(mbFile)
        mbFile.add_cascade(label='File', menu=mbFile.subMenu)
        mbFile.subMenu.add_command(label='Open', command=self.open_file)
        mbFile.subMenu.add_command(label='Exit', command=top_mbar.quit)
        mbFile.subMenu.entryconfig(0, state=Tkinter.DISABLED)

        #Button and Text
        self.text_send = Text(frame_right_center)
        self.text_send.grid()
        self.text_recv = Text(frame_right_top)
        self.text_recv.grid()

        #set ip and port
        ipf = Frame(frame_left, padx=10, pady=15)
        Label(ipf, text='ip', relief=Tkinter.RAISED, borderwidth=2, width=8).pack(side='left')
        self.ip = Entry(ipf)
        self.ip.pack(side='left')
        ipf.pack()

        portf = Frame(frame_left, padx=10, pady=5)
        Label(portf, text='port', relief=Tkinter.RAISED, borderwidth=2, width=8).pack(side='left')
        self.port = Entry(portf)
        self.port.pack(side='left')
        portf.pack()
        #set short and long link
        linkf = Frame(frame_left, padx=10, pady=15, relief=Tkinter.SUNKEN, borderwidth=2)
        self.flag = IntVar()
        Radiobutton(linkf, text="短链接", 
                value=0, variable=self.flag, 
                relief=Tkinter.RAISED)\
                        .pack(side=Tkinter.LEFT)
        Radiobutton(linkf, text="长链接", 
                value=1, variable=self.flag, 
                relief=Tkinter.RAISED)\
                        .pack(side=Tkinter.LEFT)
        linkf.pack()

        button_senddata = Button(frame_right_bottom, text='send', command=self.send).grid(sticky=Tkinter.W)

        #Grid
        frame_left.pack(side='left', anchor=Tkinter.N)
        frame_right_top.pack(side='top')
        frame_right_center.pack(side='top')
        frame_right_bottom.pack(side='top', anchor=Tkinter.E)
开发者ID:wangxiaochuang,项目名称:socketTool,代码行数:61,代码来源:socketTool.py

示例12: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import __init__ [as 别名]
 def __init__(self, simulator, diameter = 300, margin = 50, parent = None):
   Tk.__init__(self, parent)
   self.simulator = simulator
   self.diameter = diameter
   self.margin = margin
   self.parent = parent
   self.text_labels = []
   self.initialize()
开发者ID:mikemeko,项目名称:18.821-projects,代码行数:10,代码来源:visualization.py

示例13: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import __init__ [as 别名]
 def __init__(self, master, *args, **kwargs):
     Tk.__init__(self, *args, **kwargs)
     self.attributes("-fullscreen", True)
     self.config(background="black", cursor="none")
     self.title("Jeopardy")
     Constants.SCREENW = self.winfo_screenwidth()
     Constants.SCREENH = self.winfo_screenheight()
     Fonts.construct()
开发者ID:FSI-HochschuleTrier,项目名称:hacker-jeopardy,代码行数:10,代码来源:MainWindow.py

示例14: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import __init__ [as 别名]
 def __init__(self):
     Tk.__init__(self)
     self.title(mainWindowTitle)
     self.resizable(width=0, height=0)
     self.__setStyles()
     self.__initializeComponents()
     self.__dataController = DataController();
     self.mainloop()
开发者ID:jsikorski,项目名称:HCC-tablet-data-presenter,代码行数:10,代码来源:interface.py

示例15: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import __init__ [as 别名]
 def __init__(self, my_tank=None, tank1=None, tank2=None):
     Tk.__init__(self)
     self.title('Калькулятор танков     ===build. 009===')
     self.minsize(320, 240)
     self.frmButton = ClsFrmButton(root=self)
     self.frmLeft = ClsFrmLeft(root=self, my_tank=my_tank)
     self.frmRight = ClsFrmRight(root=self, tank1=tank1, tank2=tank2)
     self.after(1000, self.update_sound)
     self.mainloop()
开发者ID:prospero78,项目名称:pyPC,代码行数:11,代码来源:comapre_tank.py


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