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


Python Frame.bind方法代码示例

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


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

示例1: ScrollFrame

# 需要导入模块: from tkinter.ttk import Frame [as 别名]
# 或者: from tkinter.ttk.Frame import bind [as 别名]
class ScrollFrame(Frame):
	
	def __init__(self,parent):
		
		Frame.__init__(self, master=parent)

		canvas = tkinter.Canvas(self, highlightthickness=0)
		self.innerFrame = Frame(canvas)

		myscrollbar = Scrollbar(self, orient="vertical")
		myscrollbar.configure(command=canvas.yview)

		def scrollbarSet(top, bottom):
			# Hides and shows the scroll frame depending on need
			if float(top) > 0 or float(bottom) < 1:
				myscrollbar.grid(row=0, column=1, sticky="NS")
			else:
				pass
				myscrollbar.grid_remove()
			myscrollbar.set(top, bottom)
		canvas.configure(yscrollcommand = scrollbarSet)


		configureFunc = lambda _ :  canvas.configure(scrollregion=canvas.bbox("all"))
		frameID = canvas.create_window((0,0), window=self.innerFrame, anchor='nw')
		self.innerFrame.bind("<Configure>",configureFunc)

		canvas.grid(row=0, column=0, sticky="NSEW")
		myscrollbar.grid(row=0, column=1, sticky="NS")
		self.grid_rowconfigure(0, weight=1)
		self.grid_columnconfigure(0, weight=0)


		#canvas.bind("<Configure>", lambda e : canvas.itemconfig(frameID, width=e.width))
		canvas.bind("<Configure>", lambda e : canvas.configure(width=self.innerFrame.winfo_width()))
开发者ID:volcan01010,项目名称:AshCalc,代码行数:37,代码来源:custom_components.py

示例2: BibleReferenceCollectionWindow

# 需要导入模块: from tkinter.ttk import Frame [as 别名]
# 或者: from tkinter.ttk.Frame import bind [as 别名]
class BibleReferenceCollectionWindow( BibleResourceWindow ):
#class BibleReferenceCollectionWindow( ChildWindow ):
    def __init__( self, parentApp, internalBible ):
        """
        Given a collection name, try to open an empty Bible resource collection window.
        """
        if BibleOrgSysGlobals.debugFlag: print( "BibleReferenceCollectionWindow.__init__( {}, {} )".format( parentApp, internalBible.name ) )
        self.parentApp, self.internalBible = parentApp, internalBible
        BibleResourceWindow.__init__( self, self.parentApp, 'BibleReferenceCollectionWindow', internalBible.name )
        #ChildWindow.__init__( self, self.parentApp, 'BibleResource' )
        #self.winType = 'InternalBibleReferenceBox'

        self.geometry( INITIAL_REFERENCE_COLLECTION_SIZE )
        self.minimumSize, self.maximumSize = MINIMUM_REFERENCE_COLLECTION_SIZE, MAXIMUM_REFERENCE_COLLECTION_SIZE
        self.minsize( *parseWindowSize( self.minimumSize ) )
        self.maxsize( *parseWindowSize( self.maximumSize ) )

        # Get rid of the default widgets
        self.vScrollbar.destroy()
        self.textBox.destroy()

        # Make a frame inside a canvas inside our window (in order to get a scrollbar)
        self.canvas = tk.Canvas( self, borderwidth=0, background="#ffffff" )
        self.frame = Frame( self.canvas ) #, background="#ffffff" )
        self.vsb = Scrollbar( self, orient="vertical", command=self.canvas.yview )
        self.canvas.configure( yscrollcommand=self.vsb.set )
        self.vsb.pack( side="right", fill="y" )
        self.canvas.pack( side=tk.LEFT, fill=tk.BOTH, expand=True )
        self.canvas.create_window( (4,4), window=self.frame, anchor="nw", tags="self.frame" )
        self.frame.bind( "<Configure>", self.OnFrameConfigure )

        #self.BCVUpdateType = 'ReferencesMode' # Leave as default
        self.folderPath = self.filename = self.filepath = None
        self.referenceBoxes = BibleReferenceBoxes( self )
    # end of BibleReferenceCollectionWindow.__init__


    def OnFrameConfigure(self, event):
        '''Reset the scroll region to encompass the inner frame'''
        self.canvas.configure( scrollregion=self.canvas.bbox("all") )


    def setFolderPath( self, newFolderPath ):
        """
        Store the folder path for where our internal Bible files will be.

        We're still waiting for the filename.
        """
        if BibleOrgSysGlobals.debugFlag and debuggingThisModule:
            print( exp("BibleReferenceCollectionWindow.setFolderPath( {} )").format( repr(newFolderPath) ) )
            assert( self.filename is None )
            assert( self.filepath is None )
        self.folderPath = newFolderPath
    # end of BibleReferenceCollectionWindow.setFolderPath


    def createMenuBar( self ):
        """
        """
        if BibleOrgSysGlobals.debugFlag and debuggingThisModule: print( exp("BibleReferenceBox.createMenuBar()") )
        self.menubar = tk.Menu( self )
        #self['menu'] = self.menubar
        self.config( menu=self.menubar ) # alternative

        fileMenu = tk.Menu( self.menubar, tearoff=False )
        self.menubar.add_cascade( menu=fileMenu, label='File', underline=0 )
        #fileMenu.add_command( label='Info...', underline=0, command=self.doShowInfo, accelerator=self.parentApp.keyBindingDict['Info'][0] )
        #fileMenu.add_separator()
        #fileMenu.add_command( label='Rename', underline=0, command=self.doRename )
        #fileMenu.add_separator()
        fileMenu.add_command( label='Close', underline=0, command=self.doClose, accelerator=self.parentApp.keyBindingDict['Close'][0] ) # close this window

        if 0:
            editMenu = tk.Menu( self.menubar )
            self.menubar.add_cascade( menu=editMenu, label='Edit', underline=0 )
            editMenu.add_command( label='Copy', underline=0, command=self.doCopy, accelerator=self.parentApp.keyBindingDict['Copy'][0] )
            editMenu.add_separator()
            editMenu.add_command( label='Select all', underline=0, command=self.doSelectAll, accelerator=self.parentApp.keyBindingDict['SelectAll'][0] )

            searchMenu = tk.Menu( self.menubar )
            self.menubar.add_cascade( menu=searchMenu, label='Search', underline=0 )
            searchMenu.add_command( label='Goto line...', underline=0, command=self.doGotoLine, accelerator=self.parentApp.keyBindingDict['Line'][0] )
            searchMenu.add_separator()
            searchMenu.add_command( label='Find...', underline=0, command=self.doFind, accelerator=self.parentApp.keyBindingDict['Find'][0] )
            searchMenu.add_command( label='Find again', underline=5, command=self.doRefind, accelerator=self.parentApp.keyBindingDict['Refind'][0] )

        gotoMenu = tk.Menu( self.menubar )
        self.menubar.add_cascade( menu=gotoMenu, label='Goto', underline=0 )
        #gotoMenu.add_command( label='Previous book', underline=-1, command=self.doGotoPreviousBook )
        #gotoMenu.add_command( label='Next book', underline=-1, command=self.doGotoNextBook )
        #gotoMenu.add_command( label='Previous chapter', underline=-1, command=self.doGotoPreviousChapter )
        #gotoMenu.add_command( label='Next chapter', underline=-1, command=self.doGotoNextChapter )
        #gotoMenu.add_command( label='Previous section', underline=-1, command=self.notWrittenYet )
        #gotoMenu.add_command( label='Next section', underline=-1, command=self.notWrittenYet )
        #gotoMenu.add_command( label='Previous verse', underline=-1, command=self.doGotoPreviousVerse )
        #gotoMenu.add_command( label='Next verse', underline=-1, command=self.doGotoNextVerse )
        #gotoMenu.add_separator()
        #gotoMenu.add_command( label='Forward', underline=0, command=self.doGoForward )
        #gotoMenu.add_command( label='Backward', underline=0, command=self.doGoBackward )
        #gotoMenu.add_separator()
#.........这里部分代码省略.........
开发者ID:alerque,项目名称:Biblelator,代码行数:103,代码来源:BibleReferenceCollection.py


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