def __init__( self, track, pathToImage, trainName, trainId, trainType, velocity=constants.BASE_VELOCITY, screen=None, ): super().__init__(track, pathToImage, trainName, velocity) self.screen = screen self.trainInfoBox = textbox.TextBox(pygame.math.Vector2(0, 0), self.screen, 30, 25, color=(0, 0, 0)) self.trainNameBox = textbox.TextBox(pygame.math.Vector2(0, 0), self.screen, 16, 0, color=(0, 0, 0)) self.trainNameBox.showText(self.trainName) self.trainId = trainId self.trainType = trainType
def __init__(self, screen): self.screen = screen self.trainList = pygame.sprite.Group() self.track = None self.lastPressedKey = {} self.textbox = textbox.TextBox(constants.TEXTBOX_POS, self.screen) self.trainIdIdx = 0
def create_widgets(self): self.commentbox = tb.TextBox(self.master) self.commentbox.get_textbox().grid(row=2, column=0) #self.quit = Button(self.master, text="QUIT", fg="red", # command=self.master.destroy) # self.quit.grid(row=3, column=0) self.test = Button(self.master, command=lambda: self.commentbox.write_textbox( self.behavior.get(), "male", "Steve")) self.test.grid(row=2, column=1)
def main(): # メッセージボックスの作成 global box box = textbox.TextBox() # サブスレッド動作フラグ running = True # NFCリーダの設定と読み取り動作 def read_nfc(): try: with nfc.ContactlessFrontend('usb') as clf: while 1: try: while clf.connect(rdwr={ 'on-connect': on_connect, 'on-release': on_release, }): if (running == False): # GUIが終了していた場合にread_nfc()をとめる return except nfc.tag.tt3.Type3TagCommandError: # NFCが触れる時間が短かった際に発生するエラー error_thread = threading.Thread( target=box.changeMsg, args=("【Error】", "Touch it Again!")) error_thread.start() except IOError: print("NFCが接続されていません") box.quit() return # 画面を表示したのちにNFCリーダをサブスレッドとして動かす thread = threading.Thread(target=read_nfc) thread.setDaemon(True) box.start(thread.start) # サブスレッド終了処理 running = False thread.join()
def __init__(self): self.surface = pygame.display.set_mode((DISPLAY_X, DISPLAY_Y)) # menu vars self.menu_running = True self.button_selected = 0 self.button_play = entity.Button(button, button2, (DISPLAY_X/2 - 256/2, DISPLAY_Y/2 - 64, 256, 64), "Play") self.button_options = entity.Button(button, button2, (DISPLAY_X/2 - 256/2, DISPLAY_Y/2 + 64, 256, 64), "Fullscreen") self.menu_elements = pygame.sprite.Group(self.button_play, self.button_options) self.end = False # game_loop vars self.running = True self.controls_enabled = True self.player = player.Player(playerimg, (96, 514, 52, 30), (-6, -48 - 15)) self.rooms = [] for i in range(6): temproom = room.Room("resources/room"+str(i)+".txt") self.rooms.append(temproom) self.current_room = 0 self.action = False self.textbox = textbox.TextBox(None) self.player_group = pygame.sprite.Group() self.tile_group = pygame.sprite.Group() self.screen_elements = pygame.sprite.Group(self.textbox) self.player_group.add(self.player.sprite) self.time_old = 0 self.time_current = 0 self.time_diff = 0 self.frame_length = 1/FPS self.delta_t = 0
def main(stdscr): curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_WHITE) curses.curs_set(False) curses.cbreak() running = True legal_chars = set("abcdefghijklmnopqrstuvwxyz ") screen_height, screen_width = stdscr.getmaxyx() search_bar = curses.newpad(3, screen_width - 2) search_bar.keypad(True) result_space = curses.newwin(screen_height - 5, screen_width - 2, 4, 1) search_bar_text_box = textbox.TextBox() splash_text = ("Made by Aaron Li 2019", "Enter to start") for i, v in enumerate(splash_text): stdscr.addstr(screen_height // 2 - 2 + i, screen_width // 2 - len(v) // 2, v) stdscr.refresh() while running: search_bar_height, search_bar_width = search_bar.getmaxyx() search_bar.clear() stdscr.clear() result_space.clear() stdscr.border() search_bar.border() result_space.border() char = search_bar.getch() if char is not None: keycode_in = char if chr(char).lower() in legal_chars: search_bar_text_box.insert_letter(chr(char)) start_search(result_space, search_bar_text_box.get_string()) elif keycode_in == ENTER_KEYCODE: start_search(result_space, search_bar_text_box.get_string()) search_bar_text_box.clear_searchbar() elif keycode_in == CTRL_C_KEYCODE or keycode_in == ESCAPE_KEYCODE: running = False elif keycode_in == BACKSPACE_KEYCODE: search_bar_text_box.backspace() start_search(result_space, search_bar_text_box.get_string()) elif keycode_in == curses.KEY_DC: search_bar_text_box.delete() start_search(result_space, search_bar_text_box.get_string()) elif keycode_in == curses.KEY_LEFT: search_bar_text_box.cursor_left() start_search(result_space, search_bar_text_box.get_string()) elif keycode_in == curses.KEY_RIGHT: search_bar_text_box.cursor_right() start_search(result_space, search_bar_text_box.get_string()) elif keycode_in == curses.KEY_RESIZE: curses.curs_set(False) screen_height, screen_width = stdscr.getmaxyx() search_bar.resize(3, screen_width - 2) result_space.resize(screen_height - 5, screen_width - 2) search_bar.clear() stdscr.clear() result_space.clear() stdscr.border() search_bar.border() result_space.border() start_search(result_space, search_bar_text_box.get_string()) elif keycode_in == curses.KEY_HOME: search_bar_text_box.home() start_search(result_space, search_bar_text_box.get_string()) elif keycode_in == curses.KEY_END: search_bar_text_box.end() start_search(result_space, search_bar_text_box.get_string()) search_bar.addstr(1, 1, search_bar_text_box.get_string_with_cursor()) stdscr.refresh() search_bar.refresh(0, 0, 1, 1, 3, screen_width - 2) result_space.refresh()
os.remove(map_file) return res image = get_image(zom, coords, "map") # Инициализируем pygame screen = pygame.display.set_mode((600, 450)) gui = gui.GUI() map_button = button.Button(pygame.Rect(10, 10, 100, 25), "карта") gui.add_element(map_button) sat_button = button.Button(pygame.Rect(10, 45, 100, 25), "спутник") gui.add_element(sat_button) gib_button = button.Button(pygame.Rect(10, 80, 100, 25), "гибрид") gui.add_element(gib_button) findbox = textbox.TextBox(pygame.Rect(300, 10, 300, 50), "") gui.add_element(findbox) find_button = button.Button(pygame.Rect(500, 70, 100, 25), "найти") gui.add_element(find_button) clear_button = button.Button(pygame.Rect(500, 105, 100, 25), "стереть") gui.add_element(clear_button) stat = label.Label(pygame.Rect(10, 425, 600, 25), "", pygame.Color("white"), pygame.Color("blue")) gui.add_element(stat) index_button = button.Button(pygame.Rect(500, 140, 100, 25), "индекс") gui.add_element(index_button) # Рисуем картинку, загружаемую из только что созданного файла. limit = [1, 19] # Переключаем экран и ждем закрытия окна. running = True walkx = 450
def __init__(self): self.textbox = textbox.TextBox('monospace', 18, colors.WHITE, 100, self.update, self.enter, '0.0.0.0') self.font = pygame.font.SysFont('monospace', 24)