def __init__(self): # init pygame and set screen self.pygame = pygame self.pygame.init() self.pygame.display.set_caption('Ball Game') self.screenSize = self.width, self.height = 1200, 850 self.screen = pygame.Surface(self.screenSize) self.display = self.pygame.display.set_mode(self.screenSize) # Defining variables self.highScore = 0 self.level = 1 self.score = 0 self.shake = 0 self.paused = False self.startNewLevel = False # Autopilot self.auto = False # Initialize animations Ball.setFrames() BombCrate.setFrames() self.background = Background() # Initialize UI class self.ui = UI(self) # Set up game clock self.clock = pygame.time.Clock() # finish setting up game setUp(1, self)
def meniu_modifica_film(self): id = input("ID-ul filmului pe care vrei sa il modifici: ") titlu = input("Titlu nou: ") descriere = input("Descriere noua: ") gen = input("Gen nou: ") film = self.__dict_list[self.__user_input](id, titlu, descriere, gen) UI.display_film_updated(film)
def updateFilmInList(self, newFilm, ui=True): #Functie care actualizeaza un film din repo cu date noi #Date de intrare: newFilm Film #Date de iesire: - for index, film in enumerate(self.__listaFilme): if film.getId() == newFilm.getId(): self.__listaFilme[index] = newFilm if ui: UI.display_film_updated(newFilm)
def run(): repo = ContactRepository() repo.addContact(Contact("Popescu", "+40-711-111999", "work")) repo.addContact(Contact("Mom", "+40-733-333444", "personal")) repo.addContact(Contact("Dana", "+40-744-444999", "personal")) controller = ContactController(repo) ui = UI(controller) ui.run()
def deleteFilmFromList(self, filmToDelete, ui=True) -> None: #Functie care sterge un film din repo #Date de intrare: filmToDelete Film #Date de iesire: - idx = 0 for index, film in enumerate(self.__listaFilme): if film.getId() == filmToDelete.getId(): idx = index break del(self.__listaFilme[idx]) if ui: UI.display_film_deleted_notification()
def deleteClientFromList(self, clientToDelete, ui=True) -> None: #Functie care sterge un client din repo #Date de intrare: clientToDelete Client #Date de iesire: - idx = 0 for index, client in enumerate(self.__listaClienti): if client.getId() == clientToDelete.getId(): idx = index break del(self.__listaClienti[idx]) if ui: UI.display_client_deleted_notification()
def start(): repo = VectorRepository() repo.addVector(MyVector("abc", "r", 1, [1, 2, 3, 4])) repo.addVector(MyVector("aaa", "g", 3, [2, 2, 3, 4, 7, 8])) repo.addVector(MyVector("test", "b", 3, [4, 5])) repo.addVector(MyVector("1", 'r', 2, [10, 3, 9])) repo.addVector(MyVector("2", 'y', 4, [1, 3, 6, 9])) controller = VectorController(repo) ui = UI(controller) ui.run()
def run(self): ''' Metoda princiapala a consolei; Tine loop-ul in viata ''' self.greet_user() self.show_input_options_select() while self.__user_input != 'out': self.__user_input = self.get_user_input() if not self.options_valid(self.__user_input): UI.bad_option_selected() continue self.choose_menu(self.__user_input)
def __init__(self): # repositories self.repo_clients, self.repo_movies, self.repo_rentals = self.read_properties_file() # services self.services_clients = ServicesClients(self.repo_clients) self.services_movies = ServicesMovies(self.repo_movies) self.services_rentals = ServicesRentals(self.repo_rentals) # ui self.ui = UI(self.services_clients, self.services_movies, self.services_rentals) self.repository_type = None # loads data to persistent reposoitory when user exits application atexit.register(self.write_data_to_persistent_repository)
class Application(): def __init__(self): self.bus = EventBus() self.simulator = Simulator(self.bus) self.ui = UI(self.bus) def Update(self, deltaTime): self.ui.Update(deltaTime) self.simulator.Update(deltaTime) self.bus.NotifyListeners()
def main(): """ Main method :return: None """ ui = UI() ui.change_panel(MainMenuPanel) ui.mainloop()
from Repository.Repoitory import * from Service.Service import * from Service.Service_Taxe import * from UI.UI import UI repo_client = Repository_Generic('Clienti') repo_taxe = Repository_Generic('Taxe') serv_client = Service_Client(repo_client) serv_taxe = Service_Taxe(repo_taxe) console = UI(serv_client, serv_taxe) console.console()
grade_validator, undo_service) # we add random data if we use the inmemory storing method if repoSetUp.get_mode == "inmemory": number = generateRandom(student_service, assignment_service, grade_service) number.generate_random_student() number.generate_random_assignment() number.generate_random_grades() if repoSetUp.get_uimode == "gui": gui = GUI(student_service, assignment_service, grade_service, undo_service) gui.start() elif repoSetUp.get_uimode == "menu": ui = UI(student_service, assignment_service, grade_service, undo_service) ui.start() """ repository = inmemory students = "" assignments = "" grades = "" ui = "gui" repository = binaryfiles students = "TextFiles/students.bin" assignments = "TextFiles/assignments.bin" grades = "TextFiles/grades.bin" ui = "gui" repository = jsonfiles
def __init__(self, args): args.append("--disable-web-security") self.app = QApplication(args) self.ui = UI()
from PyQt5.QtWidgets import * from UI.UI import UI import sys # main function if __name__ == '__main__': app = QApplication(sys.argv) ex = UI() sys.exit(app.exec_())
class MainApp(object): ''' A class that incorporates the whole app and its basic data structures Attributes ---------- :param: repo_clients, repo_movies, repo_rentals : Repo() Repositories in which clients, movies, rentals are stored, respectively :param: services_clients, services_movies, services_rentals : ServicesClients(), ServicesMovies(), ServicesRentals() Services corresponding to each domain. For clients and movies, operations are: add, remove, update and list entities :param: ui : UI() Main app user interface ''' def __init__(self): # repositories self.repo_clients, self.repo_movies, self.repo_rentals = self.read_properties_file() # services self.services_clients = ServicesClients(self.repo_clients) self.services_movies = ServicesMovies(self.repo_movies) self.services_rentals = ServicesRentals(self.repo_rentals) # ui self.ui = UI(self.services_clients, self.services_movies, self.services_rentals) self.repository_type = None # loads data to persistent reposoitory when user exits application atexit.register(self.write_data_to_persistent_repository) def init_clients(self): ''' Initializes the repository of clients with 5 default entities. ''' self.repo_clients.add_new_entity(Client(1, "Joshua")) self.repo_clients.add_new_entity(Client(2, "Sue")) self.repo_clients.add_new_entity(Client(3, "Philip")) self.repo_clients.add_new_entity(Client(4, "Josh")) self.repo_clients.add_new_entity(Client(5, "Ralph")) def init_movies(self): ''' Initializes the repository of movies with 5 default entities ''' self.repo_movies.add_new_entity(Movie(1, "Once Upon a Time In Hollywood", "The end of a Hollywood movies era", "comedy")) self.repo_movies.add_new_entity(Movie(2, "The Sixth Sense", "A startling twist", "thriller")) self.repo_movies.add_new_entity(Movie(3, "Ice Age", "Humor at another level", "comedy")) self.repo_movies.add_new_entity(Movie(4, "The Dark Knight", "Absolutely revolutionary for its genre", "action")) self.repo_movies.add_new_entity(Movie(5, "Godfather", "Masterpiece illustrating what gangsters look like", "drama")) def init_rentals(self): ''' Initializes the repository of rentals with 3 default entities ''' self.repo_rentals.add_new_entity(Rental(1, 3, 2, datetime.date(2019, 5, 23), datetime.date(2019, 10, 2), datetime.date(2019, 11, 20))) self.repo_rentals.add_new_entity(Rental(2, 4, 1, datetime.date(2019, 7, 14), datetime.date(2019, 10, 14), datetime.date(2000, 1, 1))) self.repo_rentals.add_new_entity(Rental(3, 3, 5, datetime.date(2019, 5, 30), datetime.date(2019, 12, 30), datetime.date(2000, 1, 1))) def init_everything(self): ''' Initializes the repositories with default elements ''' self.init_clients() self.init_movies() self.init_rentals() def read_properties_file(self): config = ConfigParser() config.read('settings.properties') self.repository_type = config.get('repo_type', 'repository') file_client = config.get('repo_type', 'clients') file_movie = config.get('repo_type', 'movies') file_rentals = config.get('repo_type', 'rentals') repo_clients = None repo_movies = None repo_rentals = None if self.repository_type == "memory_based": repo_clients = MemoryBasedRepository() repo_movies = MemoryBasedRepository() repo_rentals = MemoryBasedRepository() elif self.repository_type == "file_based": repo_clients = FileBasedRepository(file_client) repo_movies = FileBasedRepository(file_movie) repo_rentals = FileBasedRepository(file_rentals) elif self.repository_type == "binary_file_based": repo_clients = BinaryFileBasedRepository(file_client) repo_movies = BinaryFileBasedRepository(file_movie) repo_rentals = BinaryFileBasedRepository(file_rentals) elif self.repository_type == "JSON_based": repo_clients = JSONBasedRepository(file_client) repo_movies = JSONBasedRepository(file_movie) repo_rentals = JSONBasedRepository(file_rentals) elif self.repository_type == "XML_based": repo_clients = XMLBasedRepository() repo_movies = XMLBasedRepository() repo_rentals = XMLBasedRepository() elif self.repository_type == "SQL_based": repo_clients = SQLBasedRepository(file_client) repo_movies = SQLBasedRepository(file_movie) repo_rentals = SQLBasedRepository(file_rentals) else: raise InvalidRepositoryTypeError return repo_clients, repo_movies, repo_rentals #def convert_str def write_data_to_persistent_repository(self): if self.repository_type == "memory_based": return if self.repository_type == "file_based": self.repo_clients.write_data_to_file() self.repo_movies.write_data_to_file() self.repo_rentals.write_data_to_file() elif self.repository_type == "binary_file_based": self.repo_clients.write_to_binary_file() self.repo_movies.write_to_binary_file() self.repo_rentals.write_to_binary_file() elif self.repository_type == "JSON_based": self.repo_clients.write_data_to_json("clients") self.repo_movies.write_data_to_json("movies") self.repo_rentals.write_data_to_json("rentals") elif self.repository_type == "SQL_based": self.repo_clients.write_data_to_mysql() self.repo_movies.write_data_to_mysql() self.repo_rentals.write_data_to_mysql() def read_data_from_repository(self): if self.repository_type == "file_based": clients = self.repo_clients.read_data_from_file() for c in clients: c = c.strip() c = c.split(";") print(c) self.repo_clients.add_new_entity(Client(int(c[0]), c[1])) movies = self.repo_movies.read_data_from_file() for m in movies: m = m.strip() m = m.split(";") self.repo_movies.add_new_entity(Movie(int(m[0]), m[1], m[2], m[3])) rentals = self.repo_rentals.read_data_from_file() for r in rentals: r = r.strip() r = r.split(";") rented_date = parse(r[3]) due_date = parse(r[4]) return_date = parse(r[5]) self.repo_rentals.add_new_entity(Rental(int(r[0]), int(r[1]), int(r[2]), rented_date.date(), due_date.date(), return_date.date())) if self.repository_type == "binary_file_based": self.repo_clients.repo = self.repo_clients.read_from_binary_file() self.repo_movies.repo = self.repo_movies.read_from_binary_file() self.repo_rentals.repo = self.repo_rentals.read_from_binary_file() if self.repository_type == "JSON_based": clients = self.repo_clients.read_data_from_json() for c in clients["clients"]: self.repo_clients.add_new_entity(Client(int(c["id"]), c["name"])) movies = self.repo_movies.read_data_from_json() for m in movies["movies"]: self.repo_movies.add_new_entity(Movie(int(m["id"]), m["title"], m["description"], m["genre"])) print("adasdasd") rentals = self.repo_rentals.read_data_from_json() for r in rentals["rentals"]: rented_date = parse(r["rented_date"]) due_date = parse(r["due_date"]) return_date = parse(r["return_date"]) self.repo_rentals.add_new_entity(Rental(int(r["id"]), int(r["client_id"]), int(r["movie_id"]), rented_date.date(), due_date.date(), return_date.date())) if self.repository_type == "SQL_based": clients = self.repo_clients.read_data_from_mysql() for c in clients: self.repo_clients.add_new_entity(Client(int(c[0]), c[1])) movies = self.repo_movies.read_data_from_mysql() for m in movies: self.repo_movies.add_new_entity(Movie(int(m[0]), m[1], m[2], m[3])) rentals = self.repo_rentals.read_data_from_mysql() for r in rentals: # rented_date = parse(r[3]) # due_date = parse(r[4]) # return_date = parse(r[5]) self.repo_rentals.add_new_entity(Rental(int(r[0]), int(r[1]), int(r[2]), r[3], r[4], r[5])) def run(self): """ Runs the application, that is, carries out all prerequisites(initializations and tests) and starts the menu loop """ # prerequisites self.read_properties_file() if self.repository_type == "memory_based": self.init_everything() else: self.read_data_from_repository() # start the menu loop, handled in the UI class self.ui.start_menu_loop()
from Repository.repository_generic import * from Service.service_tranzactie import Service_Tranzactie from Service.service_card import Service_Card from Service.service_medicament import Service_Medicament from UI.UI import UI repo_medicament = Repository_generic('MEDICAMENT') repo_tranzactie = Repository_generic('TRANZACTIE') repo_card = Repository_generic('CARDURI') serv_medicament = Service_Medicament(repo_medicament) serv_tranzactie = Service_Tranzactie(repo_tranzactie, repo_medicament, repo_card) serv_card = Service_Card(repo_card) console = UI(serv_medicament, serv_card, serv_tranzactie) console.run_console()
def adauga_client(self, client, ui=True): #Functie care adauga un client nou in repo #Date de intrare: client Client #Date de iesire: - self.__listaClienti.append(client) if ui: UI.display_client_added(client)
def __init__(self): self.bus = EventBus() self.simulator = Simulator(self.bus) self.ui = UI(self.bus)
''' Created on 19 dec. 2017 @author: Catalin ''' from op.controller import controller from repo.repo import busRepo, routeRepo from UI.UI import UI from domain.entities import route, bus rRepo = routeRepo() bRepo = busRepo() rRepo.add(route(1, 20)) rRepo.add(route(2, 20)) rRepo.add(route(3, 20)) rRepo.add(route(4, 20)) bRepo.add(bus(1, 2, "Merc", 5)) bRepo.add(bus(2, 3, "Volv", 6)) ctr = controller(rRepo, bRepo) ui = UI(ctr) ui.main()
from UI.UI import UI from Game.Game import Game g = Game() ui = UI(g) ui.Start()
class Game(): def __init__(self): # init pygame and set screen self.pygame = pygame self.pygame.init() self.pygame.display.set_caption('Ball Game') self.screenSize = self.width, self.height = 1200, 850 self.screen = pygame.Surface(self.screenSize) self.display = self.pygame.display.set_mode(self.screenSize) # Defining variables self.highScore = 0 self.level = 1 self.score = 0 self.shake = 0 self.paused = False self.startNewLevel = False # Autopilot self.auto = False # Initialize animations Ball.setFrames() BombCrate.setFrames() self.background = Background() # Initialize UI class self.ui = UI(self) # Set up game clock self.clock = pygame.time.Clock() # finish setting up game setUp(1, self) def iteration(self): if self.startNewLevel: setUp(self.level, self) self.startNewLevel = False self.inputAndEvents() if not self.paused: Ball.update(self) def inputAndEvents(self): # Handle pressed keys self.keys = pygame.key.get_pressed() events = pygame.event.get() mous_pos = pygame.mouse.get_pos() if not self.finished and not self.paused: self.bar.move(self.keys, self.width) # Handle game events for event in events: if event.type == pygame.QUIT: sys.exit() elif event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: self.paused = not self.paused elif event.key == pygame.K_p: self.auto = not self.auto elif event.key == pygame.K_o: print("Crate Info: ") print(Crate.Crates) for crate in Crate.Crates: print( f"Crate pos -- x: {str(crate.rect.x)}, y: {str(crate.rect.y)}" ) self.ui.listenForInput(self.keys, self, events, mous_pos) def draw(self): if not self.finished: self.screen.fill(green) self.background.draw(self) # Render entities for ball in Ball.Balls: self.screen.blit(ball.image, ball.rect) self.bar.draw(self.screen) Crate.drawCrates(self.screen) else: # If game is finished self.screen.fill(green) if self.keys[self.pygame.K_RETURN]: self.level = 1 self.score = 0 setUp(1, self) # Draw user interface self.ui.draw(self) self.render_offset = [0, 0] if self.shake: self.shake -= 1 self.render_offset[0] = random.randint(0, 8) - 4 self.render_offset[1] = random.randint(0, 8) - 4 self.display.blit(self.screen, self.render_offset) self.pygame.display.flip() def loop(self): while True: self.iteration() self.draw() self.clock.tick(60)
import config from UI.UI import UI config.init() user_interface = UI() user_interface.exec() print("Exit") user_interface.disconnect() config.save()
''' Created on 31 ian. 2015 @author: Darius ''' from repository.repo import FileRepo from controller.ctr_tranducere import CtrTraducere from UI.UI import UI from domain.val_tr import ValTraducere rep = FileRepo("Alandala.txt") val = ValTraducere() ctr = CtrTraducere(rep, val) ui = UI(ctr) ui.run() #merge
def adauga_film(self, film, ui=True): #Functie care adauga un film nou in repo #Date de intrare: film Film #Date de iesire: - self.__listaFilme.append(film) if ui: UI.display_film_added(film)
def choose_menu(self, input): input = int(input) try: if input == 1: self.meniu_adauga_client() elif input == 2: self.meniu_sterge_client() elif input == 3: self.meniu_adauga_film() elif input == 4: self.meniu_modifica_film() elif input == 5: UI.show_all_films(self.__dict_list[self.__user_input]()) elif input == 6: self.meniu_sterge_film() elif input == 7: self.meniu_inchiriaza_film() elif input == 8: self.meniu_modifica_client() elif input == 9: UI.display_all_clients(self.__dict_list[self.__user_input]()) elif input == 10: UI.display_all_inchirieri( self.__dict_list[self.__user_input]()) elif input == 11: self.meniu_returneaza_inchiriere() elif input == 12: self.meniu_cauta_film() elif input == 13: self.meniu_cauta_client() elif input == 14: self.meniu_genereaza_clienti() elif input == 15: self.meniu_genereaza_filme() elif input == 16: self.meniu_inchirieri_ordonate_dupa_nume() elif input == 17: self.meniu_cele_mai_inchiriate_filme() elif input == 18: self.meniu_clienti_cele_mai_inchiriate() elif input == 19: self.meniu_get_primii_30perc_clienti() elif input == 20: self.meniu_clienti_intre_medii() except (CnpNotValid, CnpNotNumber, CnpAlreadyExists) as exc: UI.CnpNotValid(exc) except FilmNotFound as exc: UI.display_missing_film_error(exc) except ClientNotFound as exc: UI.display_missing_client_error(exc) except FilmAlreadyExists as exc: UI.FilmAlreadyExists(exc) except (FilmTitleTooShort, FilmDescriptionTooShort, FilmGenreTooShort) as exc: UI.display_generic_error(exc) except IdIsNotNumber as exc: UI.display_generic_error(exc) except FilmDejaInchiriat as exc: UI.display_generic_error(exc) except FilmNuEsteInchiriat as exc: UI.display_generic_error(exc) except ValueError as exc: UI.display_generic_error("Numarul trebuie sa fie antreg")
from Infastructure.PlantRepository import PlantRepository from UI.UI import UI from Domain.Plant import Plant repo = PlantRepository() repo.add_plant(Plant("abc", 1, 2)) repo.add_plant(Plant("bcd", 10, 0)) repo.add_plant(Plant("basda", 20, 30)) repo.add_plant(Plant("ddd", 10, 15)) repo.add_plant(Plant("abcdef", 3, 0)) ui = UI(repo) ui.run()
# repoGrade.addGrade(Grade(9, 7, 3.79), repoStudent, repoDiscipline) # repoGrade.addGrade(Grade(4, 22, 5.88), repoStudent, repoDiscipline) # repoGrade.addGrade(Grade(10, 18, 9.59), repoStudent, repoDiscipline) # repoGrade.addGrade(Grade(5, 3, 1.63), repoStudent, repoDiscipline) # repoGrade.addGrade(Grade(2, 24, 4.64), repoStudent, repoDiscipline) # repoGrade.addGrade(Grade(2, 10, 4.97), repoStudent, repoDiscipline) ctrlUndo = UndoController() ctrlDiscipline = DisciplineController(repoDiscipline, repoGrade, repoStudent, ctrlUndo) ctrlStudent = StudentController(repoStudent, repoGrade, repoDiscipline, ctrlUndo) ctrlGrade = GradeController(repoGrade, repoDiscipline, repoStudent, ctrlUndo) ctrlStatistics = StatisticsController(repoStudent, repoDiscipline, repoGrade) ui = UI(ctrlDiscipline, ctrlStudent, ctrlGrade, ctrlStatistics, ctrlUndo) ui.MainMenu() if reads[0] == "textfiles": repoDiscipline.writeAlltoFile() repoStudent.writeAlltoFile() repoGrade.writeAlltoFile() if reads[0] == "binaryfiles": repoDiscipline.writeAlltoFile() repoStudent.writeAlltoFile() repoGrade.writeAlltoFile()
from Board.Board import Board from Game.Game import Game from UI.UI import UI board = Board() game = Game(board) ui = UI(game, board) ui.startUI()
# @Time : 2019/11/3 22:08 # @Author : Just # @Email : [email protected] # @File : main.py import tkinter from UI.UI import UI from UI.Cmdexe import Cmdexe from Utiliy.Utiliy import Utiliy from config import Config import sys if __name__ == '__main__': print(len(sys.argv)) print(str(sys.argv)) if len(sys.argv) == 1: root = tkinter.Tk() root.title(Config.main_win_title) root.update_idletasks() root.withdraw() root.geometry('%dx%d+%d+%d' % (Utiliy.getMsize(root))) root.deiconify() root.update() UI(root).pack() root.mainloop() else: blcheckno = sys.argv[1] file_path = sys.argv[2] print("病理号为:"+blcheckno) print("玻片路径为:"+file_path) cmd = Cmdexe(blcheckno, file_path) cmd.tran()
def display_all_films(self): #Functie care display-uieste toate filmele din repo #Date de intrare: - #Date de iesire: - for film in self.get_lista_filme(): UI.display_film(film)