本文整理汇总了Python中Stack.clear方法的典型用法代码示例。如果您正苦于以下问题:Python Stack.clear方法的具体用法?Python Stack.clear怎么用?Python Stack.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stack
的用法示例。
在下文中一共展示了Stack.clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Calculator
# 需要导入模块: import Stack [as 别名]
# 或者: from Stack import clear [as 别名]
class Calculator( Tk ) :
# Width of @[email protected] in pixels.
__IO_PANEL_WIDTH = 200
# Height of @[email protected] in pixels.
__IO_PANEL_HEIGHT = 50
# Row number of @[email protected] in grid layout of the calculator.
__IO_PANEL_ROW = 0
# Column number of @[email protected] in grid layout of the calculator.
__IO_PANEL_COL = 0
# Span of @[email protected] in widgets in the grid layout of the calculator.
__IO_PANEL_SPAN = 3
# The default base of the calculator.
__BASE = 10
# The title of this calculator's window.
__TITLE = "Calculator"
#The title of the Base selection menu
__BASE_MENU_TITLE = 'Base'
#The title of the Help menu
__HELP_MENU_TITLE = 'Help'
#The title of the Options Menu
__OPTIONS_MENU_TITLE = "Options"
# Row number of the first digit row in grid layout of the calculator.
__DIGIT_ROW = 1
# Column number of the first digit row in grid layout of the calculator.
__DIGIT_COL = 0
# Number of digit buttons per row in grid layout of the calculator.
__DIGITS_PER_ROW = 3
# Text on the clear button.
__CLEAR_TITLE = "C"
# Text on the push button.
__PUSH_TITLE = "P"
#The operator for Clear Everything button
__CLEAR_EVERYTHING_TITLE = 'CE'
#Sticky for the stack panel
__STACK_STICKY = 'NS'
#String for recognising errors from operations
__ERROR_TAG = 'Error'
# Main constructor.
# @[email protected]: The master widget of this @[email protected] or @[email protected]
# @[email protected]: The number base for this @[email protected]
def __init__( self, master, title=__TITLE, base=__BASE) :
self.__base = base
#INITIALIZE THE STACK
self.__stack = Stack()
#Initialise the Operation class
self.__operation = Operation(self.__stack)
# Initialise main calculator window.
Tk.__init__( self, master )
# Set title.
self.title( title )
#Set not resizable
self.resizable(0,0)
# Save @[email protected] Not used...
self.__master = master
# Finish rest of initialisation.
self.__initialise( base=base)
# Utility method for initialising this @[email protected]'s components.
# @[email protected]: the number base of this @[email protected]'s operations.
def __initialise( self, base,clearOption=CLEAR_STACK_DEFAULT,
displayOption=DISPLAY_STACK_DEFAULT) :
self.__clearStack = clearOption
self.__displayStack = displayOption
# Initialise the IO panel component.
self.__initialiseIOPanel( )
# Initialise the digit panel component.
self.__initialiseDigitPanel( base=base)
#Initialise the operand panel component
self.__initialiseOperandPanel()
#Initialise the menu bar
self.__initialiseMenu()
#Add the Base Change dropdown
self.__initialiseBaseMenu(base)
#Add the Options dropdown
self.__initialiseOptionsMenu()
#Add the Help dropdown
self.__initialiseHelpMenu()
#Initialise the stack display panel, if the option is selected
if self.__displayStack:
self.__initialiseStackPanel()
# Initialise the digit panel widget of this @[email protected]
# @[email protected]: the number base of this @[email protected]'s operations.
# @[email protected]: row number in grid layout of this @[email protected]
# @[email protected]: column number in grid layout of this @[email protected]
# @[email protected]: digits per row in grid layout of this @[email protected]
def __initialiseDigitPanel( self,
base,
row=__DIGIT_ROW,
col=__DIGIT_COL,
digitsPerRow=__DIGITS_PER_ROW ) :
appendee = self.__iopanel
self.__base = base
self.__positioner = GridPositioner( row=row, col=col,
columns=digitsPerRow )
#.........这里部分代码省略.........