예제 #1
0
    def __init__(self, fileName):
        self.fileName = "menu.csv"
        self.menuItemDrinkList =[] # drink list
        self.menuItemAppetizerList = [] # appetizer list
        self.menuItemEntreeList = [] # entree list
        self.menuItemDessertList = [] # dessert list

        # this block of code reads through the csv file and adds the items to the proper list
        fileIn = open(self.fileName, "r")
        for line in fileIn:
            line = line.split(',')
            if line[1] == "Drink":
                line = MenuItem(line[0], line[1], line[2], line[3])
                self.menuItemDrinkList.append(line)
            elif line[1] == "Appetizer":
                line = MenuItem(line[0], line[1], line[2], line[3])
                self.menuItemAppetizerList.append(line)
            elif line[1] == "Entree":
                line = MenuItem(line[0], line[1], line[2], line[3])
                self.menuItemEntreeList.append(line)
            elif line[1] == "Dessert":
                line = MenuItem(line[0], line[1], line[2], line[3])
                self.menuItemDessertList.append(line)

        fileIn.close() #close the file
예제 #2
0
class Trigger(SignalManager, TriggerManager):
    def __init__(self, editor):
        SignalManager.__init__(self)
        TriggerManager.__init__(self, editor)
        self.__init_attributes(editor)
        self.connect(self.__trigger, "activate", self.__show_cb)

    def __init_attributes(self, editor):
        self.__editor = editor
        from Manager import Manager
        self.__manager = Manager(editor)
        from MenuItem import MenuItem
        self.__menuitem = MenuItem(editor)
        self.__trigger = self.create_trigger("show-autoreplace-dialog")
        return

    def __show_cb(self, *args):
        self.__manager.show()
        return

    def destroy(self):
        self.disconnect()
        self.remove_triggers()
        self.__menuitem.destroy()
        self.__manager.destroy()
        del self
        return
예제 #3
0
class Trigger(SignalManager, TriggerManager):

	def __init__(self, editor):
		SignalManager.__init__(self)
		TriggerManager.__init__(self, editor)
		self.__init_attributes(editor)
		self.connect(self.__trigger, "activate", self.__show_window_cb)

	def __init_attributes(self, editor):
		self.__editor = editor
		self.__manager = None
		self.__trigger = self.create_trigger("show-advanced-configuration-window")
		from MenuItem import MenuItem
		self.__menuitem = MenuItem(editor)
		return

	def __show_window_cb(self, *args):
		try:
			self.__manager.show()
		except AttributeError:
			from Manager import Manager
			self.__manager = Manager(self.__editor)
			self.__manager.show()
		return

	def destroy(self):
		if self.__manager: self.__manager.destroy()
		if self.__menuitem: self.__menuitem.destroy()
		self.remove_triggers()
		self.disconnect()
		del self
		return
예제 #4
0
파일: Menu.py 프로젝트: fxia22/ASM_xf
  def ShowOff(self,arg1, arg2,arg3):
    MenuHeight = len(self.items)
    MenuWidth  = self.maxLength
    X = self.X
    Y = self.Y + 1
    Parent = self.PARENT
    Screen = Parent.SCREEN
    self.myscreen = Screen.CaptureScreen( Y, X, Y + MenuHeight ,
      X + MenuWidth )
    MenuWin = Dialog(Parent, Y, X, Y + MenuHeight, X + MenuWidth )
    MenuWin.SetColor(Screen.colors.C_MENUBAR)
    count = 1
    self.EXITFORM = 0
    for i in range(len(self.items)):
      text = ''
      if self.items[i][0] == -1:
        text = (self.maxLength - 2) * chr(tiHLINE)
      else:
        newTitle = self.items[i][1]
        text = self.__FixDisplay(newTitle)
      item = MenuItem(MenuWin,str(self.items[i][0]),count-1,0,text,
          self.items[i][2])
      item.ITEMID = self.items[i][0]
      count += 1
      item.SetMethod("CLICK",self.ItemSelected)
      item.SetMethod("GOTFOCUS",self.ItemFocused)
      MenuWin.AddControl(item)
      item.DeActivate(self.items[i][3])
##    MenuWin.INSET = 1
    MenuWin.DROPSHADOW=0
    r =MenuWin.RunDialog()
    Parent.Paint()
    Parent.Screen().Refresh()
예제 #5
0
    def create_task_through_ui(self):
        task_create_type: Type[Task] = Menu(
            [
                MenuItem('Transient Task', lambda: TransientTask),
                MenuItem('Recurring Task', lambda: RecurringTask),
                MenuItem('Cancellation', lambda: AntiTask)
            ],
            'What type of task would you like to create?',
        ).process()

        if Task not in type.mro(task_create_type):
            raise RuntimeError(
                'Invalid task type resulting from CreateTaskMenuItem.create_task_through_ui()'
            )

        fields = task_create_type.get_input_fields()
        CliController.populate_fields(fields)
        field_values = CliController.fields_as_dict(fields)

        task = task_create_type(field_values)
        try:
            self.model.add_task(task)
        except PSSValidationError as err:
            raise PSSInvalidOperationError(
                f'Could not complete operation: {err}')

        CliView.display_notification(f'Successfully added {task}')
예제 #6
0
class Trigger(SignalManager, TriggerManager):

	def __init__(self, editor):
		SignalManager.__init__(self)
		TriggerManager.__init__(self, editor)
		self.__init_attributes(editor)
		self.connect(self.__trigger, "activate", self.__show_cb)

	def __init_attributes(self, editor):
		self.__editor = editor
		from Manager import Manager
		self.__manager = Manager(editor)
		from MenuItem import MenuItem
		self.__menuitem = MenuItem(editor)
		self.__trigger = self.create_trigger("show-autoreplace-dialog")
		return

	def __show_cb(self, *args):
		self.__manager.show()
		return

	def destroy(self):
		self.disconnect()
		self.remove_triggers()
		self.__menuitem.destroy()
		self.__manager.destroy()
		del self
		return
예제 #7
0
class Trigger(SignalManager, TriggerManager):
    def __init__(self, editor):
        SignalManager.__init__(self)
        TriggerManager.__init__(self, editor)
        self.__init_attributes(editor)
        self.connect(self.__trigger, "activate", self.__show_window_cb)

    def __init_attributes(self, editor):
        self.__editor = editor
        self.__manager = None
        self.__trigger = self.create_trigger(
            "show-advanced-configuration-window")
        from MenuItem import MenuItem
        self.__menuitem = MenuItem(editor)
        return

    def __show_window_cb(self, *args):
        try:
            self.__manager.show()
        except AttributeError:
            from Manager import Manager
            self.__manager = Manager(self.__editor)
            self.__manager.show()
        return

    def destroy(self):
        if self.__manager: self.__manager.destroy()
        if self.__menuitem: self.__menuitem.destroy()
        self.remove_triggers()
        self.disconnect()
        del self
        return
예제 #8
0
    def view_schedule_through_ui(self):
        get_schedule_task_instances = Menu(
            [
                MenuItem(
                    'Daily Schedule', lambda: lambda start_date: self.model.
                    get_task_instances_for_date(start_date)),
                MenuItem(
                    'Weekly Schedule', lambda: lambda start_date: self.model.
                    get_task_instances_for_week_starting(start_date)),
                MenuItem(
                    'Monthly Schedule', lambda: lambda start_date: self.model.
                    get_task_instances_for_month(start_date))
            ],
            'What type of schedule would you like to view?',
        ).process()
        start_date_field = Field(
            'StartDate', 'Start Date', validate_date_string,
            "Must be a date in form YYYYMMDD",
            lambda start_date_string: datetime.strptime(
                start_date_string, '%Y%m%d').date())
        CliController.populate_field(start_date_field)

        task_instances = get_schedule_task_instances(start_date_field.value)
        view = ScheduleView(task_instances)
        view.display()
예제 #9
0
 def __init_attributes(self, editor):
     self.__editor = editor
     from Manager import Manager
     self.__manager = Manager(editor)
     from MenuItem import MenuItem
     self.__menuitem = MenuItem(editor)
     self.__trigger = self.create_trigger("show-autoreplace-dialog")
     return
예제 #10
0
 def __init_attributes(self, editor):
     self.__editor = editor
     self.__manager = None
     self.__trigger = self.create_trigger(
         "show-advanced-configuration-window")
     from MenuItem import MenuItem
     self.__menuitem = MenuItem(editor)
     return
예제 #11
0
 def __init__(self, title):
    MenuItem.__init__(self)
    
    self.id = title
    self.label = QLabel(title, self)
    self.baseStyle = self.label.styleSheet()
    self.selectedStyle = 'QLabel { background-color: blue; }'
    
    self.setMinimumHeight(25)
예제 #12
0
파일: Menu.py 프로젝트: chenmeister22/CAIS
 def __init__(self, menuFile):
     self.menuItemDictionary = {}
     fileIn = open(menuFile, "r")
     for line in fileIn:
         line = line.strip()
         line = line.split(",")
         if line[1] not in self.menuItemDictionary:
             self.menuItemDictionary[line[1]] = [
                 MenuItem(line[0], line[1], line[2], line[3])
             ]
         elif line[1] in self.menuItemDictionary:
             self.menuItemDictionary[line[1]].append(
                 MenuItem(line[0], line[1], line[2], line[3]))
     fileIn.close()
예제 #13
0
파일: Menu.py 프로젝트: noremac19/ITP-115
 def __init__(self, fileName="menu.csv"):
     # creates dictionary and makes the keys the types of foods
     self.menuItemDictionary = {
         Menu.MENU_ITEM_TYPES[0]: [],
         Menu.MENU_ITEM_TYPES[1]: [],
         Menu.MENU_ITEM_TYPES[2]: [],
         Menu.MENU_ITEM_TYPES[3]: []
     }
     self.file = fileName
     ifile = open(self.file, "r")
     # reads menu.csv file
     for line in ifile:
         # separates each line of the file into a list
         object = line.strip()
         object = object.split(",")
         # Comments for if-else statement chain:
         #   checks and matches the first index of the list with the MENU_ITEMS_TYPE list
         #   assigns rest of values in list
         #   appends MenuItem object to the menuItemDictionary
         #   using the corresponding key found by conditional if statement
         if object[1] == Menu.MENU_ITEM_TYPES[0]:
             namef = str(object[0])
             typef = str(object[1])
             pricef = float(object[2])
             descf = str(object[3])
             self.menuItemDictionary[object[1]].append(
                 MenuItem(namef, typef, pricef, descf))
         elif object[1] == Menu.MENU_ITEM_TYPES[1]:
             namef = str(object[0])
             typef = str(object[1])
             pricef = float(object[2])
             descf = str(object[3])
             self.menuItemDictionary[object[1]].append(
                 MenuItem(namef, typef, pricef, descf))
         elif object[1] == Menu.MENU_ITEM_TYPES[2]:
             namef = str(object[0])
             typef = str(object[1])
             pricef = float(object[2])
             descf = str(object[3])
             self.menuItemDictionary[object[1]].append(
                 MenuItem(namef, typef, pricef, descf))
         elif object[1] == Menu.MENU_ITEM_TYPES[3]:
             namef = str(object[0])
             typef = str(object[1])
             pricef = float(object[2])
             descf = str(object[3])
             self.menuItemDictionary[object[1]].append(
                 MenuItem(namef, typef, pricef, descf))
     ifile.close()
예제 #14
0
    def __initMenus(self):
        if self.root == None:
            self.root = MenuItem()
            self.root.menuItems = self.__createMenus()

        self.activeMenu = self.root.menuItems[0]
        self.selectedMenu = self.root
예제 #15
0
 def __init__(self, fileName):
     # EXTRA CREDIT: a single dictionary is used instead of four lists.
     # a dictionary containing all of the menu items is defined.
     # 4 keys within the dictionary are defined as strings that represent the types of the menu items.
     self.menuItemDictionary = {"Drink": [], "Appetizer": [], "Entree": [], "Dessert": []}
     # the csv file is opened and read.
     fileIn = open(fileName, "r")
     # the csv file is iterated through using a for loop.
     for line in fileIn:
         # each line in the file is stripped of trailing white space and split using a comma to be made into a list.
         # each line represents a different menu item.
         # splitting line into a list allows for the different attributes of the menu item to be separated by index.
         aList = line.strip().split(",")
         # obj is the MenuItem object that contains the information from the indices of the list of each line.
         # index 0 is the name, index 1 is the type, index 2 is the price, and index 3 is the description.
         # the name, type, and description are set to strings. the price is set to a float.
         obj = MenuItem(str(aList[0]), str(aList[1]), float(aList[2]), str(aList[3]))
         # index 1 in aList represents the type of menu item it is.
         # if/elif statements determine what type of menu item each obj is by comparing to class variable's values.
         if aList[1] == Menu.MENU_ITEM_TYPES[0]:
             # if determined to be a drink, the obj is appended to the Drink key within the dictionary.
             self.menuItemDictionary["Drink"].append(obj)
         elif aList[1] == Menu.MENU_ITEM_TYPES[1]:
             # if determined to be an appetizer, the obj is appended to the Appetizer key within the dictionary.
             self.menuItemDictionary["Appetizer"].append(obj)
         elif aList[1] == Menu.MENU_ITEM_TYPES[2]:
             # if determined to be an entree, the obj is appended to the Entree key within the dictionary.
             self.menuItemDictionary["Entree"].append(obj)
         elif aList[1] == Menu.MENU_ITEM_TYPES[3]:
             # if determined to be a dessert, the obj is appended to the Dessert key within the dictionary.
             self.menuItemDictionary["Dessert"].append(obj)
     # the file is closed
     fileIn.close()
예제 #16
0
    def __init__(self, dict):
        self.__dict = dict
        self.__menuItemDictionary = {}
        self.__menuItemDictionary["Drink"] = []
        self.__menuItemDictionary["Appetizer"] = []
        self.__menuItemDictionary["Entree"] = []
        self.__menuItemDictionary["Dessert"] = []

        # Open and read the csv file and create a MenuItem object from each line in the file.
        fin = open(dict, "r")
        for line in fin:
            line = line.strip()
            dataList = line.split(",")

            name = dataList[0]
            t = dataList[1]
            price = dataList[2]
            description = dataList[3]
            item = MenuItem(name, t, price, description)

            # Add the new object to the dictionary by using its type as the key.
            if t == "Drink":
                self.__menuItemDictionary["Drink"].append(item)
            elif t == "Appetizer":
                self.__menuItemDictionary["Appetizer"].append(item)
            elif t =="Entree":
                self.__menuItemDictionary["Entree"].append(item)
            elif t == "Dessert":
                self.__menuItemDictionary["Dessert"].append(item)

        fin.close()
예제 #17
0
	def __init_attributes(self, editor):
		self.__editor = editor
		self.__manager = None
		self.__trigger = self.create_trigger("show-advanced-configuration-window")
		from MenuItem import MenuItem
		self.__menuitem = MenuItem(editor)
		return
예제 #18
0
	def __init_attributes(self, editor):
		self.__editor = editor
		from Manager import Manager
		self.__manager = Manager(editor)
		from MenuItem import MenuItem
		self.__menuitem = MenuItem(editor)
		self.__trigger = self.create_trigger("show-autoreplace-dialog")
		return
예제 #19
0
	def __init__(self, editor):
		SignalManager.__init__(self)
		TriggerManager.__init__(self, editor)
		self.__init_attributes(editor)
		self.connect(self.__trigger1, "activate", self.__activate_cb)
		self.connect(self.__trigger2, "activate", self.__activate_cb)
		from MenuItem import MenuItem
		MenuItem(editor)
예제 #20
0
 def __init__(self, filename):
     self.__menuItemDictionary = {}
     for t in self.MENU_ITEM_TYPES:
         self.__menuItemDictionary[t] = []
     with open(filename) as f:
         reader = list(csv.reader(f))
         for row in reader:
             menuItem = MenuItem(row[0], row[1], row[2], row[3], row[4])
             self.__menuItemDictionary[menuItem.type].append(menuItem)
예제 #21
0
 def add(self,
         number,
         name,
         price,
         ingredients,
         category,
         labels,
         availability=True):
     super().add(
         MenuItem(number, name, price, ingredients, category, labels,
                  availability))
예제 #22
0
 def __init__(self, fileName):
     self.menuItemDictionary = {}
     for item_type in Menu.MENU_ITEM_TYPES:
         self.menuItemDictionary[item_type] = []
     fileIn = open(fileName, "r")
     for line in fileIn:
         line = line.strip()
         item = line.split(",")
         menuItem = MenuItem(item[0], item[1], float(item[2]), item[3])
         self.menuItemDictionary[item[1]].append(menuItem)
     fileIn.close()
예제 #23
0
 def __init__(self,filename):
     fileIn=open(filename,'r')
     self.__menuItemDictionary={}
     input=fileIn.readlines()
     for x in input:
         temp=x.split(',')
         tempitem=MenuItem(temp[0],temp[1],temp[2],temp[3])
         if temp[1] in self.__menuItemDictionary.keys():
             self.__menuItemDictionary[temp[1]].append(tempitem)
         else:
             self.__menuItemDictionary[temp[1]]=[tempitem]
예제 #24
0
    def __init__(self, window):
        # positioning
        centerWidth = window.width / 2
        y = window.height - 40
        self.window = window
        self.titlePostition = (centerWidth, y)
        self.menuPosition = (centerWidth,
                             self.titlePostition[1] - (window.height / 3))
        self.fontSize = 32
        self.menuSpacing = (float(self.fontSize) * 1.33)**1.1

        # build menu hierarchy
        mainMenu = MenuNode(self.titlePostition, "game engine", self.fontSize)
        play = MenuItem(self.menuPosition, "play", self.fontSize)
        quit = MenuItem(self.menuPosition, "quit", self.fontSize)

        options = MenuNode(self.menuPosition, "options", self.fontSize)
        options.children.append(
            MenuItem(self.menuPosition, "volume", self.fontSize))
        options.children.append(
            MenuItem(self.menuPosition, "sfx", self.fontSize))
        options.children.append(
            MenuItem(self.menuPosition, "FoV", self.fontSize))

        self.rootNode = mainMenu
        self.rootNode.children.append(play)
        self.rootNode.children.append(options)
        self.rootNode.children.append(quit)

        # setup the node stack
        self.currentNode = self.rootNode
        self.previousNodes = []

        # layout children
        self.arrangeMenu(self.currentNode)

        # setup initial menu object focus
        self.focusFirstChild()

        # keyboard focus until mouse movement
        self.keyboardHighlight = True
예제 #25
0
 def __init__(self, fileName):
     self.__menuItemDictionary = {}
     fileIn = open(fileName, 'r')
     for line in fileIn:
         attr = line.strip().split(',')
         type = attr[1]
         item = MenuItem(attr[0], attr[1], float(attr[2]), attr[3])
         if type in self.__menuItemDictionary:
             self.__menuItemDictionary[type].append(item)
         else:
             itemList = [item]
             self.__menuItemDictionary[type] = itemList
예제 #26
0
	def __init_attributes(self, editor):
		self.__editor = editor
		name, shortcut, description, category = (
			"show-template-editor",
			"<alt>F12",
			_("Manage dynamic templates or snippets"),
			_("Miscellaneous Operations")
		)
		self.__trigger = self.create_trigger(name, shortcut, description, category)
		self.__manager = None
		from MenuItem import MenuItem
		self.__menuitem = MenuItem(editor)
		return
예제 #27
0
파일: Menu.py 프로젝트: varnie/snake
    def __init__(self, field_center_x, field_center_y, gameStartCallback, gameEndCallback, win):
        self._batch = pyglet.graphics.Batch()

        self._startGameMenuItem = MenuItem("start game", field_center_x, field_center_y - 80 , gameStartCallback, self._batch)
        self._exitGameMenuItem = MenuItem("exit game", field_center_x, field_center_y - 110, gameEndCallback, self._batch)
        self.win = win

        self._startGameMenuItem.is_selected = True
        self._selectedMenuItem = self._startGameMenuItem

        img = pyglet.resource.image('title.png')
        img.anchor_x = img.width/2
        img.anchor_y = img.height/2
        self._title = pyglet.sprite.Sprite(img, field_center_x, FIELD_HEIGHT-img.height, batch=self._batch)

        img = pyglet.resource.image('logo.png')
        img.anchor_x = img.width/2
        img.anchor_y = img.height/2
        self._logo = pyglet.sprite.Sprite(img, field_center_x, field_center_y + self._title.height, batch=self._batch)

        self._menuBackground = impl.MenuBackground.MenuBackground(0, 0, FIELD_WIDTH, FIELD_HEIGHT)
        self.start_bgrn_animation()
예제 #28
0
    def __init__(self, fileName):
        menuItemDictionary = {}
        for foodType in Menu.MENU_ITEM_TYPES:
            menuItemDictionary[foodType] = []
        fileIn = open(fileName, "r")
        for line in fileIn:
            line = line.strip()
            dataList = line.split(",")
            menuItem = MenuItem(dataList[0], dataList[1], dataList[2], dataList[3])
            menuItemDictionary[dataList[1]].append(menuItem)
        fileIn.close()

        self.menuItemDictionary = menuItemDictionary
    def write_schedule_through_ui(self):
        get_schedule_task_instances = Menu(
            [
                MenuItem(
                    'Daily Schedule', lambda: lambda start_date: self.model.
                    get_task_instances_for_date(start_date)),
                MenuItem(
                    'Weekly Schedule', lambda: lambda start_date: self.model.
                    get_task_instances_for_week_starting(start_date)),
                MenuItem(
                    'Monthly Schedule', lambda: lambda start_date: self.model.
                    get_task_instances_for_month(start_date))
            ],
            'What type of schedule would you like to write?',
        ).process()

        start_date_field = Field(
            'StartDate', 'Start Date', validate_date_string,
            "Must be a date in form YYYYMMDD",
            lambda start_date_string: datetime.strptime(
                start_date_string, '%Y%m%d').date())

        filename_field = Field(
            'Filename',
            'filename',
            validate_data_filename,
        )

        try:
            CliController.populate_fields([start_date_field, filename_field])
            task_instances = get_schedule_task_instances(
                start_date_field.value)
            self.model.write_task_instances_to_file(
                filename=filename_field.value, task_instances=task_instances)
            CliView.display_notification(
                f'Exported schedule to "{filename_field.value}"')
        except Exception as err:
            raise PSSInvalidOperationError(f'Failed to export schedule: {err}')
예제 #30
0
    def Refresh(self,
                Items,
                Funcs,
                BackgroundColor=BLACK,
                Font=None,
                FontSize=30,
                FontColor=WHITE):
        self.BackgroundColor = BackgroundColor
        self.Funcs = Funcs
        self.Items = []
        self.CurrentItem = None
        for Index, Item in enumerate(Items):
            MI = MenuItem(Item, Font, FontSize, FontColor)
            TotalHeight = len(Items) * MI.Height
            PosX = (self.ScreenWidth / 2) - (MI.Width / 2)

            #Formular to place all items in the center of the screen,
            # but according to the item order in the MenuItem array given
            PosY = (self.ScreenHeight / 2) - (TotalHeight / 2) + (
                (Index * 2) + Index * MI.Height)

            MI.SetPosition(PosX, PosY)
            self.Items.append(MI)
class MenuItemTest(unittest.TestCase):    
    #MenuItem1=MenuItem();  #java = Private Static variable
    
    def setUp(self):
        self.menuitem1 = MenuItem("Chicken",1.55)

    def tearDown(self):
        pass

    def testName(self):
        pass
    
    def test__str__(self):
        StringTest="Chicken\t1.55"
        self.assertEqual(StringTest,str(self.menuitem1))
        
    def testgetName(self):
        StringTest="Chicken"
        self.assertEqual(StringTest, self.menuitem1.getName())
    
    def testgetPrice(self):
        FloatNumber=1.55;
        self.assertEqual(FloatNumber,self.menuitem1.getPrice())
예제 #32
0
파일: cursed.py 프로젝트: nckbrzg/cursed
def main(stdscr):
    default_colors = CursedColorScheme()

    stored_session_file = "./saved_sessions.json"
    session_storage = SessionStorage(stored_session_file)

    top_menu = SessionMenu(default_colors, session_storage)
    top_win = CursedWindow(True, default_colors, top_menu, "Actionables", True)

    bottom_menu = CursedMenu(default_colors)
    bottom_win = CursedWindow(True, default_colors, bottom_menu, "Values")

    window_group = CursedWindowGroup()

    window_group.add_sub_window(stdscr, bottom_win, CursedWindowGroup.Position.BOTTOM_HORIZONTAL_THIRD)
    window_group.add_sub_window(stdscr, top_win, CursedWindowGroup.Position.TOP_TWO_THIRDS)

    try:
        sessions = session_storage.load_sessions()
        for sess in sessions:
            item = ScreenItem(sess["session_id"], sess["windows"], sess)
            top_menu.add_menu_item(item)
    except FileNotFoundError:
        print("No stored sessions found")

    for num in range(40):
        bottom_menu.add_menu_item(MenuItem("Thing {0}".format(num)))
    # turn off cursor blinking
    curses.curs_set(0)

    stdscr.refresh()
    window_group.update_all()

    try:
        keep_going = True
        while keep_going:
            key = stdscr.getch()
            if key == ord('q'):
                keep_going = False
            else:
                window_group.handle_key_event(key)

            if key == curses.KEY_ENTER or key == 10:
                # If a screen session as entered, we will need the keypad mode back on
                stdscr.keypad(1)

            window_group.update_all()
    finally:
        top_menu.save()
예제 #33
0
 def __init__(self, menuitemfile):
     self.menuItemDictionary = {}
     filein = open(menuitemfile, "r")
     #taking info from csv file and inputting it in dictionary with key as type and value as list of menuitem objects
     for line in filein:
         line = line.strip()
         datalist = line.split(",")
         Fooditem = MenuItem(datalist[0], datalist[1], float(datalist[2]),
                             datalist[3])
         if datalist[1] not in self.menuItemDictionary:
             MenuItemlist = [Fooditem]
             self.menuItemDictionary[datalist[1]] = MenuItemlist
         else:
             self.menuItemDictionary[datalist[1]].append(Fooditem)
     filein.close()
예제 #34
0
파일: Menu.py 프로젝트: mikeshi1998/Python
 def __init__(self, menu):  # set the constructor
     self.__menuItemDictionary = {}
     fileIn = open(menu, "r")  # read from the file
     for line in fileIn:
         line = line.strip()
         lineList = line.split(",")  # split every line into a list
         item = MenuItem(lineList[0], lineList[1], float(lineList[2]),
                         lineList[3])  # create the menu item
         if lineList[1] not in self.__menuItemDictionary.keys(
         ):  # if we have don't have this category yet, create a key value pair, and set the value to be a list of items
             self.__menuItemDictionary[lineList[1]] = [item]
         else:
             self.__menuItemDictionary[lineList[1]].append(
                 item
             )  # if we have this category already, append the item to the list
     fileIn.close()  # close the file
예제 #35
0
 def __init__(self, menufile):
     self.menufile = menufile # menufile from the variable
     self.fileIn = open(self.menufile, "r") # opens file
     self.items = {} # sets up empty dict
     for line in self.fileIn:  # goes through the line
         line = line.strip()  # strips the line
         data_list = line.split(",")  # splits the lines
         cat = data_list[1]  # category will be the first column
         price = data_list[2] # price is second column
         name = data_list[0] # name is the 0 column
         desc = data_list[3] # desc is third column
         menuentry = MenuItem(name, cat, price, desc) # menuentry combines the entries from the columns
         if cat in self.items: # if the category is already in the dictionary adds another entry from the menu to the key
             self.items[cat].append(menuentry)
         else: # if it is not already a key will add a new key and entry
             self.items[cat] = [menuentry]
     self.fileIn.close() # clsoes file
예제 #36
0
    def addItem(self, item, asHTML=None, popup=None):
        if not hasattr(item, "setSubMenu"):
            item = MenuItem(item, asHTML, popup)

        if self.vertical:
            tr = DOM.createTR()
            DOM.appendChild(self.body, tr)
        else:
            tr = DOM.getChild(self.body, 0)

        DOM.appendChild(tr, item.getElement())

        item.setParentMenu(self)
        item.setSelectionStyle(False)
        self.items.append(item)
        return item
예제 #37
0
    def __init__(self, menu):
        menuItemDictionary = {}
        self.menuItemDictionary = menuItemDictionary
        fileIn = open(menu, "r")
        for line in fileIn:  # one LINE of the file
            line = line.strip()
            wordList = line.split(",")  # words of a SINGLE in a list
            itemObject = MenuItem(wordList[0], wordList[1], wordList[2],
                                  wordList[3])
            #extra credit
            if wordList[
                    1] not in menuItemDictionary:  # we have NOT SEEN this word before
                menuItemDictionary[wordList[1]] = [itemObject]
            else:  # word is ALREADY in disctionary
                menuItemDictionary[wordList[1]].append(itemObject)

            #item += 1

        keys = list(menuItemDictionary.keys())
        keys.sort()
예제 #38
0
def handleEntry():
    global item
    if (e1.get() == 'report'):
        l1.config(text="")
        keys = list(resources.keys())
        e1.delete(0, 'end')
        mb.showinfo(
            "Resources",
            f"{keys[0]} : {resources[keys[0]]}ml\n{keys[1]} : {resources[keys[1]]}ml\n{keys[2]} : {resources[keys[2]]}gm\nMoney : ${money}"
        )
    elif (e1.get() == 'latte' or e1.get() == "cappuccino"
          or e1.get() == "espresso"):
        txt = e1.get()
        item = MenuItem(txt)
        enough = check_resources(item)
        if enough == True:
            get_coins()

    else:
        e1.delete(0, 'end')
        l1.config(text="please enter a valid drink")
예제 #39
0
    def addItem(self, item, asHTML=None, popup=None):
        if not hasattr(item, "setSubMenu"):
            item = MenuItem(item, asHTML, popup)

        if self.vertical:
            tr = DOM.createTR()
            DOM.appendChild(self.body, tr)
        else:
            tr = DOM.getChild(self.body, 0)

        DOM.appendChild(tr, item.getElement())

        item.setParentMenu(self)
        item.setSelectionStyle(False)
        self.items.append(item)
        return item
 def setUp(self):
     self.menuitem1 = MenuItem("Chicken",1.55)
예제 #41
0
파일: Menu.py 프로젝트: varnie/snake
class Menu(object):
    def __init__(self, field_center_x, field_center_y, gameStartCallback, gameEndCallback, win):
        self._batch = pyglet.graphics.Batch()

        self._startGameMenuItem = MenuItem("start game", field_center_x, field_center_y - 80 , gameStartCallback, self._batch)
        self._exitGameMenuItem = MenuItem("exit game", field_center_x, field_center_y - 110, gameEndCallback, self._batch)
        self.win = win

        self._startGameMenuItem.is_selected = True
        self._selectedMenuItem = self._startGameMenuItem

        img = pyglet.resource.image('title.png')
        img.anchor_x = img.width/2
        img.anchor_y = img.height/2
        self._title = pyglet.sprite.Sprite(img, field_center_x, FIELD_HEIGHT-img.height, batch=self._batch)

        img = pyglet.resource.image('logo.png')
        img.anchor_x = img.width/2
        img.anchor_y = img.height/2
        self._logo = pyglet.sprite.Sprite(img, field_center_x, field_center_y + self._title.height, batch=self._batch)

        self._menuBackground = impl.MenuBackground.MenuBackground(0, 0, FIELD_WIDTH, FIELD_HEIGHT)
        self.start_bgrn_animation()

    def start_bgrn_animation(self):
        schedule_interval(func=self._menuBackground.update,interval=MENU_BACKGROUND_ANIMATION_INTERVAL)

    def stop_bgrn_animation(self):
        unschedule(func=self._menuBackground.update)

    def on_draw(self):
        self.win.clear()
        self._menuBackground.draw()
        self._batch.draw()
        
    def on_key_press(self, symbol, modifiers):
        if symbol == key.UP:
            if self._selectedMenuItem is self._startGameMenuItem:
                pass
            else:
                self._startGameMenuItem.is_selected = True
                self._exitGameMenuItem.is_selected = False

                self._selectedMenuItem = self._startGameMenuItem
        elif symbol == key.DOWN:
            if self._selectedMenuItem is self._exitGameMenuItem:
                pass
            else:
                self._startGameMenuItem.is_selected = False
                self._exitGameMenuItem.is_selected = True

                self._selectedMenuItem = self._exitGameMenuItem
        elif  symbol == key.ESCAPE:
                pyglet.clock.unschedule(func=self._menuBackground.update)
                self.win.close()

        if symbol == key.ENTER:
            self.stop_bgrn_animation()
            self._selectedMenuItem.on_key_press(symbol, modifiers)

    def on_mouse_press(self, x, y, button, modifiers):
        if self._startGameMenuItem.on_mouse_press(x, y) or self._exitGameMenuItem.on_mouse_press(x, y):
            self.stop_bgrn_animation()