def login(self): _user = self.entry_user.get() _pwd = self.entry_pwd.get() users = self.db.login() # 校验用户名和密码 if len(users) > 0: for user in users: if _user == user[1] and _pwd == user[2]: # 销毁登录界面 self.window.destroy() # 加载主界面 GUI().start() self.flag = True break if not self.flag: tk.messagebox.showinfo(message='用户名或密码错误') else: tk.messagebox.showinfo(message='无法登录')
def test(player1, player2, session): env = Environment() optimizer = get_optimizer() player1 = get_new_agent(player1, session, optimizer) if not player2 == "Human": player2 = get_new_agent(player2, session, optimizer) saver = tf.train.Saver() _ = load_model(session, saver) done = False state = np.array(env.reset()) gui = GUI(state[np.newaxis, :][0]) while not done: current_state = state[np.newaxis, :] player1_action = player1.greedy_action(current_state, False) print("P1 move: " + str(player1_action)) next_state, player1_reward, done = env.step(player1_action, env.p1_marker) state = np.array(next_state) current_state = state[np.newaxis, :] gui.update(current_state[0], env.get_winning_combo(current_state[0]), done) if not done: if player2 == "Human": p2_action = int(input("Your Turn\n")) while not input_valid(p2_action, current_state[0]): p2_action = int(input("No cheating allowed\n")) else: p2_action = player2.greedy_action(current_state, False) next_state, player2_reward, done = env.step(p2_action, env.p2_marker) print("P2 move: " + str(p2_action)) state = np.array(next_state) current_state = state[np.newaxis, :] gui.update(current_state[0], env.get_winning_combo(current_state[0]), done) if player2_reward == REWARD_DRAW or player1_reward == REWARD_DRAW: print("Draw") elif player1_reward == REWARD_WIN: print("Player 1 Won") elif player2_reward == REWARD_WIN: print("Player 2 Won") else: print("Well played\nYou've beaten an ill-trained machine")
def __init__(self, game_mode=1, opening=0, show_move=True, show_search=False, show_gui=True, save_data=False, load_data=False): self.board = Board() self.player_turn = False self.game_mode = game_mode self.opening = opening self.show_move = show_move self.show_search = show_search self.show_gui = show_gui self.save_data = save_data self.load_data = load_data self.view = GUI(self) self.ai = AI()
def __init__(self): self.thread = None self.reload = False # Time variables self.time_cycle = 80 self.ideal_cycle = 80 self.iteration_counter = 0 self.real_time_factor = 0 self.frequency_message = {'brain': '', 'gui': '', 'rtf': ''} self.server = None self.client = None self.host = sys.argv[1] # Initialize the GUI, HAL and Console behind the scenes self.hal = HAL() self.mouse = Mouse() self.gui = GUI(self.host, self.hal, self.mouse)
def __init__(self): '''Initialisiert den Controller.''' self.__dba = DBAccess("ernaehrung.db") self.__gui = GUI() # Zutaten self.__data_zutaten = [] # Mahlzeiten self.__data_mahlzeiten = [] # Zutat mit Menge self.__data_zutaten_mahlzeit = {} # Zuletzt gewählte Zutat merken self.__hiddenName = None self.__hiddenAngelegt = None # Datenbank-Listener registieren, der uns bei # geaenderten daten informiert self.__dba.addListener(self) # Initialer Datenabruf self.__updateZutaten() self.__updateMahlzeiten() # View-Elemente der GUI mit Aktionen verbinden setCallbackListBox(self.__gui.lb_mahlzeiten, self.__zeigeMahlzeitDetails) setCallbackListBox(self.__gui.lb_zutaten, self.__zeigeZutatenDetails) setCallback(self.__gui.btn_mahlzeit_hinzu, self.__zutatZuMahlzeitHinzu) setCallback(self.__gui.btn_zutat_insert, self.__zutatHinzu) setCallback(self.__gui.btn_zutat_update, self.__zutatUpdate) setCallback(self.__gui.btn_zutat_delete, self.__zutatDelete) setCallback(self.__gui.btn_insert, self.__mahlzeitHinzu) setCallback(self.__gui.btn_update, self.__mahlzeitUpdate) setCallback(self.__gui.btn_delete, self.__mahlzeitDelete) setCallback(self.__gui.btn_neu, self.__neueMahlzeit) setCallback(self.__gui.btn_mahlzeit_als_zt, self.__mahlzeitAlsZutat) # Fuer immer in den Main loop gehen self.__gui.root.mainloop()
def __init__(self): self.thread = None self.reload = False # Time variables self.time_cycle = 80 self.ideal_cycle = 80 self.iteration_counter = 0 self.server = None self.client = None self.host = sys.argv[1] # Initialize the GUI, WEBRTC and Console behind the scenes self.console = console.Console() self.exercice = subprocess.Popen(["python", "consumer.py"], stdout=subprocess.PIPE, preexec_fn=os.setsid) self.gui = GUI(self.host, self.console)
def __init__(self, args, **kwargs): self.thread = Thread(target=self._polling_thread) self.register_lock = Lock() self.registers: [int] = [] self.available_registers: Dict[int, Register] = {} self.unit = args.unit self.client = ModbusTcpClient(args.address, port=args.port, timeout=10) self.polling_groups = [] self.daemon = args.daemon self.interval = args.interval if args.enablegui: self.gui = GUI() else: self.gui = None if args.verbose: self.logger = KeyValueLogger() else: self.logger = None
def main(): # configuration.load_config_file() # alg_map = Map() # data = EAlgorithm().run_multiple_times(alg_map, 1) # print("DONE") # [best_ratings, routes, time] = data # for element in range(len(best_ratings)): # print("Try", time[element], ":", best_ratings[element], routes[element]) # routes_len = [] # for route in routes: # routes_len.append(len(route)) # # Plotter().style_setup() # Plotter().histogram(best_ratings) # Plotter().scatter_plot(routes_len, best_ratings, x_axis_name="Długość genotypu", y_axis_name="Rating") # Plotter().scatter_and_histogram(routes_len, best_ratings) menu = GUI() menu.main_menu()
def main(): # flags reading params = read_flags() # tkinter init root = Tk() root.geometry("600x400") root.title('IoT Manager') # devices init devices = Devices(params) # data gen data = Data(devices) # gui start gui = GUI(root, data, devices) gui.draw_graph() # main tkinter loop root.mainloop()
def __init__(self): self.gui = GUI(True) self._initGui() self.win = self._initWindow() self.createWin() self.win.setFixedSize(self.win.size()) self.dataAll = [] self.dataPerson = [] self.findChildren() self.setModels() self.setActions() self.itemExample()
def main(): active = True size = width, height = 400, 400 screen = pygame.display.set_mode(size) font = pygame.font.Font(None, 30) textCoord = 10 gui = GUI() gui.add_element(Label((140, 0, 70, 60), "САПЁР")) gui.add_element(Label((130, 50, 90, 30), "ПРАВИЛА ИГРЫ")) gui.add_element(Label((20, 75, 90, 30), "Нужно открыть все ячейки без мин.")) gui.add_element(Label((20, 95, 90, 30), "Если вы попадаете на ячейку с миной,")) gui.add_element(Label((25, 115, 90, 30), "то вы проигрываете.")) gui.add_element(Label((20, 135, 90, 30), "Клетки открываются нажатием на ")) gui.add_element(Label((25, 155, 90, 30), "левую кнопку мыши.")) gui.add_element(Label((20, 175, 90, 30), "Возможное расположение мины отмечается ")) gui.add_element(Label((25, 195, 90, 30), "правой кнопкой мыши")) buttons = [Button((15, 340, 110, 40), "Новичок"), Button((140, 340, 130, 40), "Любитель"), Button((290, 340, 100, 40), "Профи")] fon2 = pygame.sprite.Sprite() fon2.image = load_image("start.png") fon2.rect = fon2.image.get_rect() fon.add(fon2) while active: fon.draw(screen) for event in pygame.event.get(): if event.type == pygame.QUIT: terminate() for i in buttons: if i.get_event(event): fon.empty() return buttons.index(i) gui.render(screen) for i in buttons: i.render(screen) pygame.display.flip()
def load(cls, file): """ Restore network from text file :param file: file name :return: Instance of this (Network) class """ gui = GUI() with open(f"datasets/{file}", "r") as f: lines = f.readlines() # Parse meta data of the network size = int(lines[0].replace("Size = ", "")) s = int(lines[1].replace("Source = ", "")) t = int(lines[2].replace("Sink = ", "")) # cls is reference to the currant class which is passed by python network = cls(s, t, gui) for line in lines[3:]: # Parse Every Edge of the network from the file line = line.replace("S", str(s)) line = line.replace("T", str(t)) line = line.replace(" -> ", ",") line = line.replace(" = ", ",") line = line.strip() source, destination, capacity = map(int, line.split(",")) if source == s: network.add_edge(source, destination, capacity, source_name="S") elif destination == t: network.add_edge(source, destination, capacity, destination_name="T") else: network.add_edge(source, destination, capacity) return network, gui
def main(): s = socket.socket() s.connect((SERVER_IP, SERVER_PORT)) print(s.recv(1024)) video_getter = VideoGet(remote=True).start() tracker = LocationTracker(address=('', 8801), remote=True, use_mockdata=False) camera = CameraController(CAMERA_POSITION, socket=s, remote=True) camera.init(REFPOINT_POSITION) detector = Yolov3_Detector(video_getter) detector_thread = threading.Thread(target=detector.Inference_Thread) servo_thread = threading.Thread(target=camera.CameraRotation_Thread) detector_thread.start() servo_thread.start() gui = GUI(camera, tracker, video_getter, detector, socket=s, remote=True) gui.root.mainloop() detector_thread.join() servo_thread.join() s.close()
def GUI_getPlayUntil(keyMapping): setupPromptOne = GUI() promptText = TextObject("prompt", "Play Until", 350, 25) elevenText = TextObject("eleven", "11", 200, 125, 100) twentyoneText = TextObject("twentyone", "21", 500, 125, 100) lshoulderText = TextObject("lshoulder", "-->", 500, 225, 125) rshoulderText = TextObject("rshoulder", "<--", 200, 225, 125) setupPromptOne.addGUIObject(promptText) setupPromptOne.addGUIObject(elevenText) setupPromptOne.addGUIObject(twentyoneText) setupPromptOne.addGUIObject(rshoulderText) setupPromptOne.addGUIObject(lshoulderText) setupPromptOne.setupGUI() running = True while running: for event in pygame.event.get(): if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE: running = False pygame.quit() break if event.type == pygame.JOYBUTTONDOWN: button = parseButton(event) if button in keyMapping and keyMapping[button] is not None: keyMapping[button](event) running = False break pygame.display.update() setupPromptOne.update() setupPromptOne.draw() setupPromptOne.clock.tick(30) setupPromptOne.objects = []
def showGUI(self): """ Load and show the GUI.""" self._gui = GUI(self) #If anything has been loaded in the plateImage object then update the #GUI accordingly rImage = self._plateImage.rawImage if not rImage is None: self._gui.setOriginalImage(rImage) #Start with controls enabled if there is an image loaded self._gui.changeEnabled(True, []) wImage = self._plateImage.image if not wImage is None: self._gui.setWorkingImage(wImage) if not self._plateImage.histogram is None: self._gui.setHistogram(self._plateImage.histogram) if not self._plateImage.statistics is None: self._gui.printStatistics(self._plateImage.statistics) #Show GUI and give control over to the main GUI loop self._gui.show()
def GUI_gameOver(keyMapping, winner, score): setupGUI = GUI() winPrompt = winner + " wins!" winnerText = TextObject("winner", winPrompt, 350, 0, 75) promptText = TextObject("prompt", "Play Again?", 350, 125) elevenText = TextObject("left", "Yes", 200, 200, 75) twentyoneText = TextObject("right", "No", 500, 200, 75) rshoulderText = TextObject("rshoulder", "-->", 500, 275, 100) lshoulderText = TextObject("lshoulder", "<--", 200, 275, 100) setupGUI.addGUIObject(winnerText) setupGUI.addGUIObject(promptText) setupGUI.addGUIObject(elevenText) setupGUI.addGUIObject(twentyoneText) setupGUI.addGUIObject(rshoulderText) setupGUI.addGUIObject(lshoulderText) setupGUI.setupGUI() running = True while running: for event in pygame.event.get(): if event.type == pygame.JOYBUTTONDOWN: button = parseButton(event) if button in keyMapping and keyMapping[button] is not None: keyMapping[button](event) running = False break pygame.display.update() setupGUI.update() setupGUI.draw() setupGUI.clock.tick(30) setupGUI.objects = []
from gui import GUI import os import sys sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..')) from board import Board if __name__ == "__main__": # Create new GUI gui = GUI(board=Board.from_fen( "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1")) # Run GUI gui.run()
#!/usr/bin/env python3 from gui import GUI master = GUI() master.root.mainloop()
P2 = "Player2" def check_args(argv): """ Check validity of received arguments :param argv: A list of arguments :return: True if the arguments are valid, False otherwise """ if len(argv) < NUM_ARGUMENTS or NUM_ARGUMENTS + 1 < len(argv) or \ MAX_PORT < int(argv[PORT_ARGUMENT]) or argv[PLAYER_ARGUMENT] not \ in VALID_PLAYERS: print(ILLEGAL_ARGS) return False return True if __name__ == '__main__': args = sys.argv if check_args(args): root = tk.Tk() args[PLAYER_ARGUMENT] = VALID_PLAYERS.index(args[PLAYER_ARGUMENT]) args[PORT_ARGUMENT] = int(args[PORT_ARGUMENT]) act_args = args[1:] if len(args) == NUM_ARGUMENTS: root.title(P1) else: root.title(P2) game = GUI(root, *act_args) root.mainloop()
def main(): """ PySweeper main() function. The main function is broken down into 3 sections. 1. Initialization: Initialize pygame and our own pysweeper objects. 2. Declare all the UI elements we need for the game. 3. Run a while loop and listen for events. The while loop is broken down into two subsections. a. Listen for events provided by pygame. event.type is continually populated by pygame. b. Draw our elements based on current state of game and button states. """ # 1. Initialization: Pygame objects pg.init() pg.font.init() pg.mixer.pre_init(44100, -16, 2, 512) pg.mixer.init() gameSound = Sound() pg.mixer.music.load("resources/newback.wav") pg.mixer.music.play() #These bools are used so that sounds don't play more than once per click. winBool = True lossBool = True helpBool = True cheatBool = False cheatIteration = False seconds = str(0) # PySweeper objects gameBoard = Board() screen = GUI(gameBoard) # 2. Declarations # Our text elements. toolbarRowsText = UIElement(BORDER + 6, BORDER + 8, 0, 0, screen, "Rows:") toolbarColumnsText = UIElement(BORDER + 6, BORDER + 33, 0, 0, screen, "Columns:") toolbarMinesText = UIElement(BORDER + 120, BORDER + 8, 0, 0, screen, "Mines:") toolbarSoundText = UIElement(BORDER + 180, BORDER + 45, 22, 18, screen, "Sound") # Help bar that is drawn when help is pushed. toolbarHelpLMB = UIElement(BORDER + 6, BORDER + 5, 0, 0, screen, "Left click to reveal space.") toolbarHelpRMB = UIElement(BORDER + 6, BORDER + 22, 0, 0, screen, "Right click to flag space.") toolbarHelpWin = UIElement(BORDER + 6, BORDER + 40, 0, 0, screen, "Flag all mines to win game.") inputHelpButton = InputButton(BORDER + 218, BORDER + 0, 45, 20, screen, "Help ") # Cheat Button that will call Cheat Mode #Open or close the background music inputCheatButton = InputButton(BORDER + 218, BORDER + 20, 45, 20, screen, "Cheat ") toolbarCheat = UIElement(BORDER + 6, BORDER + 5, 0, 0, screen, "You are currently in Cheat Mode.") toolbarCheat2 = UIElement(BORDER + 6, BORDER + 22, 0, 0, screen, "Click Cheat again to Return.") inputSoundonButton = InputButton(BORDER + 218, BORDER + 40, 22, 18, screen, "On") inputSoundoffButton = InputButton(BORDER + 240, BORDER + 40, 22, 18, screen, "Off") # Declare input UI elements. inputRowBox = InputBox(BORDER + 66, BORDER + 3, 40, 20, screen, 30, 2, str(gameBoard.rows)) inputColumnBox = InputBox(BORDER + 66, BORDER + 27, 40, 20, screen, 30, 2, str(gameBoard.columns)) inputMineBox = InputBox(BORDER + 163, BORDER + 3, 40, 20, screen, 10, 1, str(gameBoard.mines)) # Declare button UI elements. inputQuitButton = InputButton(BORDER + 60, BORDER + 25, 40, 20, screen, "Quit") inputRestartButton = InputButton(BORDER + 110, BORDER + 25, 55, 20, screen, "Restart") # Declare gameOver UI elements. toolbarGameOverLost = UIElement(BORDER + 75, BORDER + 10, 0, 0, screen, "GAME OVER!") toolbarGameOverWon = UIElement(BORDER + 85, BORDER + 10, 0, 0, screen, "WINNER!") #Timer element. timeBox = UIElement(BORDER + 120, BORDER + 48, 0, 0, screen, "Time: ") # Arrays of elements need to be grouped by rendering order. uiElements = [ toolbarRowsText, toolbarColumnsText, toolbarMinesText, toolbarSoundText, timeBox ] uiHelpElements = [toolbarHelpLMB, toolbarHelpRMB, toolbarHelpWin] uiCheatElements = [toolbarCheat, toolbarCheat2] input_boxes = [ inputRowBox, inputColumnBox, inputMineBox, inputHelpButton, inputCheatButton, inputSoundonButton, inputSoundoffButton ] input_buttons = [inputQuitButton, inputRestartButton] start_ticks = -10 done = False while not done: #Timer #timeUpdate = UIElement(BORDER + 120, BORDER + 48, 0, 0, screen, "Time: " + str(seconds)) #timeUpdate.draw() # Keep the game running until the user decides to quit the game. for event in pg.event.get(): if event.type == pg.QUIT: done = True elif event.type == pg.MOUSEBUTTONDOWN: screen.mouseClick(event) mousePosition = pg.mouse.get_pos() # Handle input boxes here. if event.button == 1 or 3: if mousePosition[1] >= 70: if start_ticks == -10: start_ticks = pg.time.get_ticks() if gameBoard.gameOver: for button in input_buttons: if button.rect.collidepoint(event.pos): button.active = True if not gameBoard.gameOver: for box in input_boxes: # If the user clicked on the input box, toggle state. if box.rect.collidepoint(event.pos): box.active = not box.active else: box.active = False helpBool = True # Listen for key presses. Input boxes that are active take all inputs. elif event.type == pg.KEYDOWN: for box in input_boxes: # Always check mine max value incase board size is decreased if box.active: if event.key == pg.K_RETURN: box.active = not box.active # Calling all 3 works for the time being. inputRowBox.update("rows", inputRowBox.text) inputColumnBox.update("columns", inputColumnBox.text) inputMineBox.maxValue = (screen.board.rows * screen.board.columns) - 1 inputMineBox.update("mines", inputMineBox.text) elif event.key == pg.K_BACKSPACE: box.text = box.text[:-1] else: if len(box.text) < 4: box.text += event.unicode # Pygame draws elements from back to front. Pygame is also double buffered. The surface #+you draw to is not shown to the user until the py.display.flip() flips the buffers. screen.window.fill(COLOR['BLACK']) # Only draw elements based on game state. if inputSoundonButton.active == True: pg.mixer.music.play() if inputSoundoffButton.active == True: pg.mixer.music.pause() if gameBoard.gameOver: # Gameover if gameBoard.wonGame: pg.draw.circle( screen.window, (153, 255, 153), (random.randrange(0, 500), random.randrange(0, 500)), random.randrange(30, 100)) pg.time.delay(200) toolbarGameOverWon.draw() if winBool: pg.mixer.music.pause() gameSound.wins() winBool = False else: pg.draw.circle( screen.window, (255, 12, 20), (random.randrange(0, 500), random.randrange(0, 500)), random.randrange(30, 100)) pg.time.delay(200) toolbarGameOverLost.draw() if lossBool: pg.mixer.music.pause() gameSound.loss() lossBool = False for button in input_buttons: button.draw() if inputQuitButton.active == True: done = True if inputRestartButton.active == True: inputRestartButton.restart(screen, gameBoard) start_ticks = -10 winBool = True lossBool = True elif inputHelpButton.active: # Help active for element in uiHelpElements: element.draw() inputHelpButton.draw() if helpBool: gameSound.helps() helpBool = False elif inputCheatButton.active: for element in uiCheatElements: element.draw() inputCheatButton.draw() if cheatIteration == False: gameBoard.generateCheatGrid() cheatBool = True cheatIteration = True else: # Default UI elements for element in uiElements: element.draw() #todo: These flags need to be updated dynamically. How do we do that? flagsRemaining = str(gameBoard.mines - gameBoard.flagsPlaced) toolbarFlagsText = UIElement(BORDER + 120, BORDER + 33, 0, 0, screen, "Flags: " + flagsRemaining) toolbarFlagsText.draw() for box in input_boxes: box.draw() inputHelpButton.draw() if cheatBool == True: gameBoard.removeCheatGrid() cheatBool = False cheatIteration = False if start_ticks == -10: pass else: #Timer element. if not gameBoard.gameOver: seconds = str( math.floor((pg.time.get_ticks() - start_ticks) / 1000)) timeUpdate = UIElement(BORDER + 120, BORDER + 48, 0, 0, screen, "Time: " + seconds + "s") timeUpdate.draw() screen.drawBoard() pg.display.flip() pg.quit()
''' Created on Mar 17, 2019 @author: aapolinjama ''' from gui import GUI import sys from PyQt5.QtWidgets import (QApplication) if __name__ == '__main__': app = QApplication(sys.argv) gui = GUI() sys.exit(app.exec_())
"玩家名", "faction": "阵营", "team": "队伍", "About": "关于作者", "More": "详细信息", "Author": "该工具作者是大爽歌.\n" "他的b站: https://space.bilibili.com/149259132\n" "他的GitHub: https://github.com/BigShuang" "他的CSDN: https://blog.csdn.net/python1639er\n", "Details": "详情请查看该工具的readme文档: \n" "https://github.com/BigShuang/Red-Alert-3-Battle-Flow-Chart", "map_name": "地图名: ", "factions": { "S": "苏联", "E": "帝国", "A": "盟军", "Rnd": "随机" } } win = Tk() win.title(TEXT["title"]) GUI(win, TEXT, width=700, height=400, bg="#ddd") win.mainloop()
Toto je konec experimentu. Děkujeme za vaši účast! Laboratoř CEBEX/PLESS """ ################################################################################ updates = ["block", "dice", "lottery_win", "attention1", "attention2", "bonus", "reward", "rounded_reward", "station"] Intro = (InstructionsFrame, {"text": intro, "keys": ["g", "G"], "proceed": False, "height": 28}) Ending = (InstructionsFrame, {"text": czechending, "keys": ["g", "G"], "proceed": False, "height": 30, "update": updates}) if __name__ == "__main__": os.chdir(os.path.dirname(os.getcwd())) GUI([Intro, Ending])
def main(): import sys app = QtWidgets.QApplication(sys.argv) gui = GUI() gui.show() sys.exit(app.exec_())
__author__ = 'Harley' import sys, pygame from constants import * from gui import GUI RESOLUTION = pygame.Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) pygame.init() # Main_bgui is an instance of the gui class. Initializes screen size main_gui = GUI(RESOLUTION, "media/art/back_new.jpg") main_gui.load_background() clock = pygame.time.Clock() # Set starting units: main_gui.activate_fortress(0) main_gui.activate_fortress(1) # The game loop while 1: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.display.quit() sys.exit() # End if q is pressed if (event.type == pygame.KEYDOWN and (event.key == pygame.K_q or event.key == pygame.K_ESCAPE)): pygame.display.quit() sys.exit() # a key spawns a melee unit on the left side if (event.type == pygame.KEYDOWN and event.key == pygame.K_a and main_gui.team_0_cash >= MELEE_PRICE):
import pygame as pg from gui import GUI #mostly a bunch of global variables in here print "db init" activeGUI = GUI() selected = None # def __init__(self): # self.activeGUI = GUI() # self.selected = None # selected node def clearSelected(): selected = None
import sys import PyQt5.QtCore as qtc import PyQt5.QtWidgets as qtw import PyQt5.QtGui as qtg from gui import GUI import settings if __name__ == '__main__': settings.init() app = qtw.QApplication(sys.argv) root = GUI() root.show() sys._excepthook = sys.excepthook sys.excepthook = settings.custom_excepthook try: sys.exit(app.exec_()) except: sys.excepthook(*sys.exc_info())
def answered(self): self.file.write("\t".join([ self.id, self.mode, self.measure1.answer.get(), self.measure2.answer.get(), conditions[self.order], "\t".join( re.findall(r'"(.*?)"', texts[self.order])), str(perf_counter() - self.t0) ]) + "\n") self.proceed() def enable(self): if self.measure1.answer.get() and self.measure2.answer.get(): self.next["state"] = "!disabled" def newItem(self): self.measure1.answer.set("") self.measure2.answer.set("") self.measure1.question["text"] = self.q1 + shorts[self.order].replace( "AAA", names[self.order]) + "?" self.measure2.question["text"] = self.q2.replace( "AAA", names[self.order]) Character1 = (Character, {"mode": "environment"}) Character2 = (Character, {"mode": "character"}) if __name__ == "__main__": os.chdir(os.path.dirname(os.getcwd())) GUI([CharacterIntro, Character1, CharacterIntro2, Character2])
import tkinter as tk from gui import GUI # if this is run as a program (versus being imported), # create a root window and an instance of our example, # then start the event loop if __name__ == "__main__": root = tk.Tk() root.title('Simplex homology calculator') GUI(root).pack(fill="both", expand=True) root.mainloop()
def main(): root = Tk() gui = GUI(root) root.mainloop()